• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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., 51 Franklin St, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  */
21 
22 /**
23  * SECTION:gstrtspextension
24  * @title: GstRTSPExtension
25  * @short_description: Interface for extending RTSP protocols
26  *
27  *  This interface is implemented e.g. by the Windows Media Streaming RTSP
28  *  exentension (rtspwms) and the RealMedia RTSP extension (rtspreal).
29  *
30  */
31 
32 #ifdef HAVE_CONFIG_H
33 #include "config.h"
34 #endif
35 
36 #include "gstrtsp-enumtypes.h"
37 #include "gstrtspextension.h"
38 
39 static void gst_rtsp_extension_iface_init (GstRTSPExtension * iface);
40 
41 enum
42 {
43   SIGNAL_SEND,
44   LAST_SIGNAL
45 };
46 
47 static guint gst_rtsp_extension_signals[LAST_SIGNAL] = { 0 };
48 
49 GType
gst_rtsp_extension_get_type(void)50 gst_rtsp_extension_get_type (void)
51 {
52   static gsize gst_rtsp_extension_type = 0;
53   static const GTypeInfo gst_rtsp_extension_info = {
54     sizeof (GstRTSPExtensionInterface),
55     (GBaseInitFunc) gst_rtsp_extension_iface_init,
56     NULL,
57     NULL,
58     NULL,
59     NULL,
60     0,
61     0,
62     NULL,
63   };
64 
65   if (g_once_init_enter (&gst_rtsp_extension_type)) {
66     GType tmp = g_type_register_static (G_TYPE_INTERFACE,
67         "GstRTSPExtension", &gst_rtsp_extension_info, 0);
68     g_once_init_leave (&gst_rtsp_extension_type, tmp);
69   }
70   return (GType) gst_rtsp_extension_type;
71 }
72 
73 static void
gst_rtsp_extension_iface_init(GstRTSPExtension * iface)74 gst_rtsp_extension_iface_init (GstRTSPExtension * iface)
75 {
76   static gboolean initialized = FALSE;
77 
78   if (!initialized) {
79     gst_rtsp_extension_signals[SIGNAL_SEND] =
80         g_signal_new ("send", G_TYPE_FROM_CLASS (iface),
81         G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstRTSPExtensionInterface,
82             send), NULL, NULL, NULL, GST_TYPE_RTSP_RESULT, 2, G_TYPE_POINTER,
83         G_TYPE_POINTER);
84     initialized = TRUE;
85   }
86 }
87 
88 gboolean
gst_rtsp_extension_detect_server(GstRTSPExtension * ext,GstRTSPMessage * resp)89 gst_rtsp_extension_detect_server (GstRTSPExtension * ext, GstRTSPMessage * resp)
90 {
91   GstRTSPExtensionInterface *iface;
92   gboolean res = TRUE;
93 
94   iface = GST_RTSP_EXTENSION_GET_INTERFACE (ext);
95   if (iface->detect_server)
96     res = iface->detect_server (ext, resp);
97 
98   return res;
99 }
100 
101 GstRTSPResult
gst_rtsp_extension_before_send(GstRTSPExtension * ext,GstRTSPMessage * req)102 gst_rtsp_extension_before_send (GstRTSPExtension * ext, GstRTSPMessage * req)
103 {
104   GstRTSPExtensionInterface *iface;
105   GstRTSPResult res = GST_RTSP_OK;
106 
107   iface = GST_RTSP_EXTENSION_GET_INTERFACE (ext);
108   if (iface->before_send)
109     res = iface->before_send (ext, req);
110 
111   return res;
112 }
113 
114 GstRTSPResult
gst_rtsp_extension_after_send(GstRTSPExtension * ext,GstRTSPMessage * req,GstRTSPMessage * resp)115 gst_rtsp_extension_after_send (GstRTSPExtension * ext, GstRTSPMessage * req,
116     GstRTSPMessage * resp)
117 {
118   GstRTSPExtensionInterface *iface;
119   GstRTSPResult res = GST_RTSP_OK;
120 
121   iface = GST_RTSP_EXTENSION_GET_INTERFACE (ext);
122   if (iface->after_send)
123     res = iface->after_send (ext, req, resp);
124 
125   return res;
126 }
127 
128 GstRTSPResult
gst_rtsp_extension_parse_sdp(GstRTSPExtension * ext,GstSDPMessage * sdp,GstStructure * s)129 gst_rtsp_extension_parse_sdp (GstRTSPExtension * ext, GstSDPMessage * sdp,
130     GstStructure * s)
131 {
132   GstRTSPExtensionInterface *iface;
133   GstRTSPResult res = GST_RTSP_OK;
134 
135   iface = GST_RTSP_EXTENSION_GET_INTERFACE (ext);
136   if (iface->parse_sdp)
137     res = iface->parse_sdp (ext, sdp, s);
138 
139   return res;
140 }
141 
142 GstRTSPResult
gst_rtsp_extension_setup_media(GstRTSPExtension * ext,GstSDPMedia * media)143 gst_rtsp_extension_setup_media (GstRTSPExtension * ext, GstSDPMedia * media)
144 {
145   GstRTSPExtensionInterface *iface;
146   GstRTSPResult res = GST_RTSP_OK;
147 
148   iface = GST_RTSP_EXTENSION_GET_INTERFACE (ext);
149   if (iface->setup_media)
150     res = iface->setup_media (ext, media);
151 
152   return res;
153 }
154 
155 gboolean
gst_rtsp_extension_configure_stream(GstRTSPExtension * ext,GstCaps * caps)156 gst_rtsp_extension_configure_stream (GstRTSPExtension * ext, GstCaps * caps)
157 {
158   GstRTSPExtensionInterface *iface;
159   gboolean res = TRUE;
160 
161   iface = GST_RTSP_EXTENSION_GET_INTERFACE (ext);
162   if (iface->configure_stream)
163     res = iface->configure_stream (ext, caps);
164 
165   return res;
166 }
167 
168 GstRTSPResult
gst_rtsp_extension_get_transports(GstRTSPExtension * ext,GstRTSPLowerTrans protocols,gchar ** transport)169 gst_rtsp_extension_get_transports (GstRTSPExtension * ext,
170     GstRTSPLowerTrans protocols, gchar ** transport)
171 {
172   GstRTSPExtensionInterface *iface;
173   GstRTSPResult res = GST_RTSP_OK;
174 
175   iface = GST_RTSP_EXTENSION_GET_INTERFACE (ext);
176   if (iface->get_transports)
177     res = iface->get_transports (ext, protocols, transport);
178 
179   return res;
180 }
181 
182 GstRTSPResult
gst_rtsp_extension_stream_select(GstRTSPExtension * ext,GstRTSPUrl * url)183 gst_rtsp_extension_stream_select (GstRTSPExtension * ext, GstRTSPUrl * url)
184 {
185   GstRTSPExtensionInterface *iface;
186   GstRTSPResult res = GST_RTSP_OK;
187 
188   iface = GST_RTSP_EXTENSION_GET_INTERFACE (ext);
189   if (iface->stream_select)
190     res = iface->stream_select (ext, url);
191 
192   return res;
193 }
194 
195 GstRTSPResult
gst_rtsp_extension_receive_request(GstRTSPExtension * ext,GstRTSPMessage * msg)196 gst_rtsp_extension_receive_request (GstRTSPExtension * ext,
197     GstRTSPMessage * msg)
198 {
199   GstRTSPExtensionInterface *iface;
200   GstRTSPResult res = GST_RTSP_ENOTIMPL;
201 
202   iface = GST_RTSP_EXTENSION_GET_INTERFACE (ext);
203   if (iface->receive_request)
204     res = iface->receive_request (ext, msg);
205 
206   return res;
207 }
208 
209 GstRTSPResult
gst_rtsp_extension_send(GstRTSPExtension * ext,GstRTSPMessage * req,GstRTSPMessage * resp)210 gst_rtsp_extension_send (GstRTSPExtension * ext, GstRTSPMessage * req,
211     GstRTSPMessage * resp)
212 {
213   GstRTSPResult res = GST_RTSP_OK;
214 
215   g_signal_emit (ext, gst_rtsp_extension_signals[SIGNAL_SEND], 0,
216       req, resp, &res);
217 
218   return res;
219 }
220