• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* GStreamer
2  * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3  *                    2000 Wim Taymans <wtay@chello.be>
4  *                    2002 Kristian Rietveld <kris@gtk.org>
5  *                    2002,2003 Colin Walters <walters@gnu.org>
6  *                    2001,2010 Bastien Nocera <hadess@hadess.net>
7  *                    2010 Sebastian Dröge <sebastian.droege@collabora.co.uk>
8  *                    2010 Jan Schmidt <thaytan@noraisin.net>
9  *
10  * rtmpsrc.c:
11  *
12  * This library is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU Library General Public
14  * License as published by the Free Software Foundation; either
15  * version 2 of the License, or (at your option) any later version.
16  *
17  * This library is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20  * Library General Public License for more details.
21  *
22  * You should have received a copy of the GNU Library General Public
23  * License along with this library; if not, write to the
24  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
25  * Boston, MA 02110-1301, USA.
26  */
27 
28 #ifdef HAVE_CONFIG_H
29 #include "config.h"
30 #endif
31 
32 #include <gst/gst.h>
33 
34 #include "gstrtmpelements.h"
35 #include "gstrtmpsrc.h"
36 #include "gstrtmpsink.h"
37 
38 #ifndef GST_DISABLE_GST_DEBUG
39 GST_DEBUG_CATEGORY_STATIC (rtmp_debug);
40 
41 static void
gst_rtmp_log_callback(int level,const gchar * fmt,va_list vl)42 gst_rtmp_log_callback (int level, const gchar * fmt, va_list vl)
43 {
44   GstDebugLevel gst_level;
45 
46   switch (level) {
47     case RTMP_LOGCRIT:
48     case RTMP_LOGERROR:
49       gst_level = GST_LEVEL_ERROR;
50       break;
51     case RTMP_LOGWARNING:
52       gst_level = GST_LEVEL_WARNING;
53       break;
54     case RTMP_LOGINFO:
55       gst_level = GST_LEVEL_INFO;
56       break;
57     case RTMP_LOGDEBUG:
58       gst_level = GST_LEVEL_DEBUG;
59       break;
60     case RTMP_LOGDEBUG2:
61       gst_level = GST_LEVEL_LOG;
62       break;
63     default:
64       gst_level = GST_LEVEL_TRACE;
65       break;
66   }
67 
68   gst_debug_log_valist (rtmp_debug, gst_level, "", "", 0, NULL, fmt, vl);
69 }
70 
71 static void
_set_debug_level(void)72 _set_debug_level (void)
73 {
74   GstDebugLevel gst_level;
75 
76   RTMP_LogSetCallback (gst_rtmp_log_callback);
77   gst_level = gst_debug_category_get_threshold (rtmp_debug);
78 
79   switch (gst_level) {
80     case GST_LEVEL_ERROR:
81       RTMP_LogSetLevel (RTMP_LOGERROR);
82       break;
83     case GST_LEVEL_WARNING:
84     case GST_LEVEL_FIXME:
85       RTMP_LogSetLevel (RTMP_LOGWARNING);
86       break;
87     case GST_LEVEL_INFO:
88       RTMP_LogSetLevel (RTMP_LOGINFO);
89       break;
90     case GST_LEVEL_DEBUG:
91       RTMP_LogSetLevel (RTMP_LOGDEBUG);
92       break;
93     case GST_LEVEL_LOG:
94       RTMP_LogSetLevel (RTMP_LOGDEBUG2);
95       break;
96     default:                   /* _TRACE and beyond */
97       RTMP_LogSetLevel (RTMP_LOGALL);
98   }
99 }
100 #endif
101 
102 void
rtmp_element_init(GstPlugin * plugin)103 rtmp_element_init (GstPlugin * plugin)
104 {
105   static gsize res = FALSE;
106   if (g_once_init_enter (&res)) {
107 #ifndef GST_DISABLE_GST_DEBUG
108     GST_DEBUG_CATEGORY_INIT (rtmp_debug, "rtmp", 0, "libRTMP logging");
109     _set_debug_level ();
110 #endif
111     g_once_init_leave (&res, TRUE);
112   }
113 }
114