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 "gstrtmpsrc.h"
35 #include "gstrtmpsink.h"
36
37 #ifndef GST_DISABLE_GST_DEBUG
38 GST_DEBUG_CATEGORY_STATIC (rtmp_debug);
39
40 static void
gst_rtmp_log_callback(int level,const gchar * fmt,va_list vl)41 gst_rtmp_log_callback (int level, const gchar * fmt, va_list vl)
42 {
43 GstDebugLevel gst_level;
44
45 switch (level) {
46 case RTMP_LOGCRIT:
47 case RTMP_LOGERROR:
48 gst_level = GST_LEVEL_ERROR;
49 break;
50 case RTMP_LOGWARNING:
51 gst_level = GST_LEVEL_WARNING;
52 break;
53 case RTMP_LOGINFO:
54 gst_level = GST_LEVEL_INFO;
55 break;
56 case RTMP_LOGDEBUG:
57 gst_level = GST_LEVEL_DEBUG;
58 break;
59 case RTMP_LOGDEBUG2:
60 gst_level = GST_LEVEL_LOG;
61 break;
62 default:
63 gst_level = GST_LEVEL_TRACE;
64 break;
65 }
66
67 gst_debug_log_valist (rtmp_debug, gst_level, "", "", 0, NULL, fmt, vl);
68 }
69
70 static void
_set_debug_level(void)71 _set_debug_level (void)
72 {
73 GstDebugLevel gst_level;
74
75 RTMP_LogSetCallback (gst_rtmp_log_callback);
76 gst_level = gst_debug_category_get_threshold (rtmp_debug);
77
78 switch (gst_level) {
79 case GST_LEVEL_ERROR:
80 RTMP_LogSetLevel (RTMP_LOGERROR);
81 break;
82 case GST_LEVEL_WARNING:
83 case GST_LEVEL_FIXME:
84 RTMP_LogSetLevel (RTMP_LOGWARNING);
85 break;
86 case GST_LEVEL_INFO:
87 RTMP_LogSetLevel (RTMP_LOGINFO);
88 break;
89 case GST_LEVEL_DEBUG:
90 RTMP_LogSetLevel (RTMP_LOGDEBUG);
91 break;
92 case GST_LEVEL_LOG:
93 RTMP_LogSetLevel (RTMP_LOGDEBUG2);
94 break;
95 default: /* _TRACE and beyond */
96 RTMP_LogSetLevel (RTMP_LOGALL);
97 }
98 }
99 #endif
100
101 static gboolean
plugin_init(GstPlugin * plugin)102 plugin_init (GstPlugin * plugin)
103 {
104 gboolean ret;
105
106 #ifndef GST_DISABLE_GST_DEBUG
107 GST_DEBUG_CATEGORY_INIT (rtmp_debug, "rtmp", 0, "libRTMP logging");
108 _set_debug_level ();
109 #endif
110
111 ret = gst_element_register (plugin, "rtmpsrc", GST_RANK_PRIMARY,
112 GST_TYPE_RTMP_SRC);
113 ret &= gst_element_register (plugin, "rtmpsink", GST_RANK_PRIMARY,
114 GST_TYPE_RTMP_SINK);
115
116 return ret;
117 }
118
119 GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
120 GST_VERSION_MINOR,
121 rtmp,
122 "RTMP source and sink",
123 plugin_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN);
124