Added gst-plugins-base-subtitles0.10-0.10.34 for Meego Harmattan 1.2
[mafwsubrenderer] / gst-plugins-base-subtitles0.10 / gst-libs / gst / rtsp / gstrtspextension.c
1 /* GStreamer RTSP extension
2  * Copyright (C) 2007 Wim Taymans <wim.taymans@gmail.com>
3  *
4  * gstrtspextension.c: RTSP extension mechanism
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the
18  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  */
21
22 /**
23  * SECTION:gstrtspextension
24  * @short_description: Interface for extending RTSP protocols
25  *
26  * <refsect2>
27  * <para>
28  *  This interface is implemented e.g. by the Windows Media Streaming RTSP
29  *  exentension (rtspwms) and the RealMedia RTSP extension (rtspreal).
30  * </para>
31  * </refsect2>
32  *
33  * Last reviewed on 2007-07-25 (0.10.14)
34  */
35
36 #ifdef HAVE_CONFIG_H
37 #include "config.h"
38 #endif
39
40 #include "gstrtsp-marshal.h"
41 #include "gstrtsp-enumtypes.h"
42 #include "gstrtspextension.h"
43
44 static void gst_rtsp_extension_iface_init (GstRTSPExtension * iface);
45
46 enum
47 {
48   SIGNAL_SEND,
49   LAST_SIGNAL
50 };
51
52 static guint gst_rtsp_extension_signals[LAST_SIGNAL] = { 0 };
53
54 GType
55 gst_rtsp_extension_get_type (void)
56 {
57   static volatile gsize gst_rtsp_extension_type = 0;
58   static const GTypeInfo gst_rtsp_extension_info = {
59     sizeof (GstRTSPExtensionInterface),
60     (GBaseInitFunc) gst_rtsp_extension_iface_init,
61     NULL,
62     NULL,
63     NULL,
64     NULL,
65     0,
66     0,
67     NULL,
68   };
69
70   if (g_once_init_enter (&gst_rtsp_extension_type)) {
71     GType tmp = g_type_register_static (G_TYPE_INTERFACE,
72         "GstRTSPExtension", &gst_rtsp_extension_info, 0);
73     g_once_init_leave (&gst_rtsp_extension_type, tmp);
74   }
75   return (GType) gst_rtsp_extension_type;
76 }
77
78 static void
79 gst_rtsp_extension_iface_init (GstRTSPExtension * iface)
80 {
81   static gboolean initialized = FALSE;
82
83   if (!initialized) {
84     gst_rtsp_extension_signals[SIGNAL_SEND] =
85         g_signal_new ("send", G_TYPE_FROM_CLASS (iface),
86         G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstRTSPExtensionInterface,
87             send), NULL, NULL, __gst_rtsp_marshal_ENUM__POINTER_POINTER,
88         GST_TYPE_RTSP_RESULT, 2, G_TYPE_POINTER, G_TYPE_POINTER);
89     initialized = TRUE;
90   }
91 }
92
93 gboolean
94 gst_rtsp_extension_detect_server (GstRTSPExtension * ext, GstRTSPMessage * resp)
95 {
96   GstRTSPExtensionInterface *iface;
97   gboolean res = TRUE;
98
99   iface = GST_RTSP_EXTENSION_GET_IFACE (ext);
100   if (iface->detect_server)
101     res = iface->detect_server (ext, resp);
102
103   return res;
104 }
105
106 GstRTSPResult
107 gst_rtsp_extension_before_send (GstRTSPExtension * ext, GstRTSPMessage * req)
108 {
109   GstRTSPExtensionInterface *iface;
110   GstRTSPResult res = GST_RTSP_OK;
111
112   iface = GST_RTSP_EXTENSION_GET_IFACE (ext);
113   if (iface->before_send)
114     res = iface->before_send (ext, req);
115
116   return res;
117 }
118
119 GstRTSPResult
120 gst_rtsp_extension_after_send (GstRTSPExtension * ext, GstRTSPMessage * req,
121     GstRTSPMessage * resp)
122 {
123   GstRTSPExtensionInterface *iface;
124   GstRTSPResult res = GST_RTSP_OK;
125
126   iface = GST_RTSP_EXTENSION_GET_IFACE (ext);
127   if (iface->after_send)
128     res = iface->after_send (ext, req, resp);
129
130   return res;
131 }
132
133 GstRTSPResult
134 gst_rtsp_extension_parse_sdp (GstRTSPExtension * ext, GstSDPMessage * sdp,
135     GstStructure * s)
136 {
137   GstRTSPExtensionInterface *iface;
138   GstRTSPResult res = GST_RTSP_OK;
139
140   iface = GST_RTSP_EXTENSION_GET_IFACE (ext);
141   if (iface->parse_sdp)
142     res = iface->parse_sdp (ext, sdp, s);
143
144   return res;
145 }
146
147 GstRTSPResult
148 gst_rtsp_extension_setup_media (GstRTSPExtension * ext, GstSDPMedia * media)
149 {
150   GstRTSPExtensionInterface *iface;
151   GstRTSPResult res = GST_RTSP_OK;
152
153   iface = GST_RTSP_EXTENSION_GET_IFACE (ext);
154   if (iface->setup_media)
155     res = iface->setup_media (ext, media);
156
157   return res;
158 }
159
160 gboolean
161 gst_rtsp_extension_configure_stream (GstRTSPExtension * ext, GstCaps * caps)
162 {
163   GstRTSPExtensionInterface *iface;
164   gboolean res = TRUE;
165
166   iface = GST_RTSP_EXTENSION_GET_IFACE (ext);
167   if (iface->configure_stream)
168     res = iface->configure_stream (ext, caps);
169
170   return res;
171 }
172
173 GstRTSPResult
174 gst_rtsp_extension_get_transports (GstRTSPExtension * ext,
175     GstRTSPLowerTrans protocols, gchar ** transport)
176 {
177   GstRTSPExtensionInterface *iface;
178   GstRTSPResult res = GST_RTSP_OK;
179
180   iface = GST_RTSP_EXTENSION_GET_IFACE (ext);
181   if (iface->get_transports)
182     res = iface->get_transports (ext, protocols, transport);
183
184   return res;
185 }
186
187 GstRTSPResult
188 gst_rtsp_extension_stream_select (GstRTSPExtension * ext, GstRTSPUrl * url)
189 {
190   GstRTSPExtensionInterface *iface;
191   GstRTSPResult res = GST_RTSP_OK;
192
193   iface = GST_RTSP_EXTENSION_GET_IFACE (ext);
194   if (iface->stream_select)
195     res = iface->stream_select (ext, url);
196
197   return res;
198 }
199
200 GstRTSPResult
201 gst_rtsp_extension_receive_request (GstRTSPExtension * ext,
202     GstRTSPMessage * msg)
203 {
204   GstRTSPExtensionInterface *iface;
205   GstRTSPResult res = GST_RTSP_ENOTIMPL;
206
207   iface = GST_RTSP_EXTENSION_GET_IFACE (ext);
208   if (iface->receive_request)
209     res = iface->receive_request (ext, msg);
210
211   return res;
212 }
213
214 GstRTSPResult
215 gst_rtsp_extension_send (GstRTSPExtension * ext, GstRTSPMessage * req,
216     GstRTSPMessage * resp)
217 {
218   GstRTSPResult res = GST_RTSP_OK;
219
220   g_signal_emit (ext, gst_rtsp_extension_signals[SIGNAL_SEND], 0,
221       req, resp, &res);
222
223   return res;
224 }