2 * Copyright (C) <2006> Wim Taymans <wim@fluendo.com>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
20 * Unless otherwise indicated, Source Code is licensed under MIT license.
21 * See further explanation attached in License Statement (distributed in the file
24 * Permission is hereby granted, free of charge, to any person obtaining a copy of
25 * this software and associated documentation files (the "Software"), to deal in
26 * the Software without restriction, including without limitation the rights to
27 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
28 * of the Software, and to permit persons to whom the Software is furnished to do
29 * so, subject to the following conditions:
31 * The above copyright notice and this permission notice shall be included in all
32 * copies or substantial portions of the Software.
34 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
35 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
36 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
37 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
38 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
39 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
43 #include "gstrtspext.h"
45 GST_DEBUG_CATEGORY_STATIC (rtspext_debug);
46 #define GST_CAT_DEFAULT (rtspext_debug)
48 static GList *extensions;
51 gst_rtsp_ext_list_filter (GstPluginFeature * feature, gpointer user_data)
53 GstElementFactory *factory;
56 /* we only care about element factories */
57 if (!GST_IS_ELEMENT_FACTORY (feature))
60 factory = GST_ELEMENT_FACTORY (feature);
62 if (!gst_element_factory_has_interface (factory, "GstRTSPExtension"))
65 /* only select elements with autoplugging rank */
66 rank = gst_plugin_feature_get_rank (feature);
67 if (rank < GST_RANK_MARGINAL)
74 gst_rtsp_ext_list_init (void)
76 GST_DEBUG_CATEGORY_INIT (rtspext_debug, "rtspext", 0, "RTSP extension");
78 /* get a list of all extensions */
79 extensions = gst_registry_feature_filter (gst_registry_get_default (),
80 (GstPluginFeatureFilter) gst_rtsp_ext_list_filter, FALSE, NULL);
83 GstRTSPExtensionList *
84 gst_rtsp_ext_list_get (void)
86 GstRTSPExtensionList *result;
89 result = g_new0 (GstRTSPExtensionList, 1);
91 for (walk = extensions; walk; walk = g_list_next (walk)) {
92 GstElementFactory *factory = GST_ELEMENT_FACTORY (walk->data);
95 element = gst_element_factory_create (factory, NULL);
97 GST_ERROR ("could not create extension instance");
101 GST_DEBUG ("added extension interface for '%s'",
102 GST_ELEMENT_NAME (element));
103 result->extensions = g_list_prepend (result->extensions, element);
109 gst_rtsp_ext_list_free (GstRTSPExtensionList * ext)
113 for (walk = ext->extensions; walk; walk = g_list_next (walk)) {
114 GstRTSPExtension *elem = (GstRTSPExtension *) walk->data;
116 gst_object_unref (GST_OBJECT_CAST (elem));
118 g_list_free (ext->extensions);
123 gst_rtsp_ext_list_detect_server (GstRTSPExtensionList * ext,
124 GstRTSPMessage * resp)
129 for (walk = ext->extensions; walk; walk = g_list_next (walk)) {
130 GstRTSPExtension *elem = (GstRTSPExtension *) walk->data;
132 res = gst_rtsp_extension_detect_server (elem, resp);
138 gst_rtsp_ext_list_before_send (GstRTSPExtensionList * ext, GstRTSPMessage * req)
141 GstRTSPResult res = GST_RTSP_OK;
143 for (walk = ext->extensions; walk; walk = g_list_next (walk)) {
144 GstRTSPExtension *elem = (GstRTSPExtension *) walk->data;
146 res = gst_rtsp_extension_before_send (elem, req);
152 gst_rtsp_ext_list_after_send (GstRTSPExtensionList * ext, GstRTSPMessage * req,
153 GstRTSPMessage * resp)
156 GstRTSPResult res = GST_RTSP_OK;
158 for (walk = ext->extensions; walk; walk = g_list_next (walk)) {
159 GstRTSPExtension *elem = (GstRTSPExtension *) walk->data;
161 res = gst_rtsp_extension_after_send (elem, req, resp);
167 gst_rtsp_ext_list_parse_sdp (GstRTSPExtensionList * ext, GstSDPMessage * sdp,
171 GstRTSPResult res = GST_RTSP_OK;
173 for (walk = ext->extensions; walk; walk = g_list_next (walk)) {
174 GstRTSPExtension *elem = (GstRTSPExtension *) walk->data;
176 res = gst_rtsp_extension_parse_sdp (elem, sdp, s);
182 gst_rtsp_ext_list_setup_media (GstRTSPExtensionList * ext, GstSDPMedia * media)
185 GstRTSPResult res = GST_RTSP_OK;
187 for (walk = ext->extensions; walk; walk = g_list_next (walk)) {
188 GstRTSPExtension *elem = (GstRTSPExtension *) walk->data;
190 res = gst_rtsp_extension_setup_media (elem, media);
196 gst_rtsp_ext_list_configure_stream (GstRTSPExtensionList * ext, GstCaps * caps)
201 for (walk = ext->extensions; walk; walk = g_list_next (walk)) {
202 GstRTSPExtension *elem = (GstRTSPExtension *) walk->data;
204 res = gst_rtsp_extension_configure_stream (elem, caps);
212 gst_rtsp_ext_list_get_transports (GstRTSPExtensionList * ext,
213 GstRTSPLowerTrans protocols, gchar ** transport)
216 GstRTSPResult res = GST_RTSP_OK;
218 for (walk = ext->extensions; walk; walk = g_list_next (walk)) {
219 GstRTSPExtension *elem = (GstRTSPExtension *) walk->data;
221 res = gst_rtsp_extension_get_transports (elem, protocols, transport);
227 gst_rtsp_ext_list_stream_select (GstRTSPExtensionList * ext, GstRTSPUrl * url)
230 GstRTSPResult res = GST_RTSP_OK;
232 for (walk = ext->extensions; walk; walk = g_list_next (walk)) {
233 GstRTSPExtension *elem = (GstRTSPExtension *) walk->data;
235 res = gst_rtsp_extension_stream_select (elem, url);
241 gst_rtsp_ext_list_connect (GstRTSPExtensionList * ext,
242 const gchar * detailed_signal, GCallback c_handler, gpointer data)
246 for (walk = ext->extensions; walk; walk = g_list_next (walk)) {
247 GstRTSPExtension *elem = (GstRTSPExtension *) walk->data;
249 g_signal_connect (elem, detailed_signal, c_handler, data);
254 gst_rtsp_ext_list_receive_request (GstRTSPExtensionList * ext,
255 GstRTSPMessage * req)
258 GstRTSPResult res = GST_RTSP_ENOTIMPL;
260 for (walk = ext->extensions; walk; walk = g_list_next (walk)) {
261 GstRTSPExtension *elem = (GstRTSPExtension *) walk->data;
263 res = gst_rtsp_extension_receive_request (elem, req);
264 if (res != GST_RTSP_ENOTIMPL)