gst_plugins_base/gst-libs/gst/rtsp/gstrtspextension.c
changeset 0 0e761a78d257
child 8 4a7fac7dd34a
equal deleted inserted replaced
-1:000000000000 0:0e761a78d257
       
     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  * </para>
       
    29  * </refsect2>
       
    30  *
       
    31  * Last reviewed on 2007-07-25 (0.10.14)
       
    32  */
       
    33 
       
    34 #ifdef HAVE_CONFIG_H
       
    35 #include "config.h"
       
    36 #endif
       
    37 
       
    38 #include "rtsp-marshal.h"
       
    39 #include "gstrtsp-enumtypes.h"
       
    40 #include "gstrtspextension.h"
       
    41 
       
    42 static void gst_rtsp_extension_iface_init (GstRTSPExtension * iface);
       
    43 
       
    44 enum
       
    45 {
       
    46   SIGNAL_SEND,
       
    47   LAST_SIGNAL
       
    48 };
       
    49 
       
    50 static guint gst_rtsp_extension_signals[LAST_SIGNAL] = { 0 };
       
    51 
       
    52 GType
       
    53 gst_rtsp_extension_get_type (void)
       
    54 {
       
    55   static GType gst_rtsp_extension_type = 0;
       
    56 
       
    57   if (!gst_rtsp_extension_type) {
       
    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     gst_rtsp_extension_type = g_type_register_static (G_TYPE_INTERFACE,
       
    71         "GstRTSPExtension", &gst_rtsp_extension_info, 0);
       
    72   }
       
    73   return gst_rtsp_extension_type;
       
    74 }
       
    75 
       
    76 static void
       
    77 gst_rtsp_extension_iface_init (GstRTSPExtension * iface)
       
    78 {
       
    79   static gboolean initialized = FALSE;
       
    80 
       
    81   if (!initialized) {
       
    82     gst_rtsp_extension_signals[SIGNAL_SEND] =
       
    83         g_signal_new ("send", G_TYPE_FROM_CLASS (iface),
       
    84         G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstRTSPExtensionInterface,
       
    85             send), NULL, NULL, gst_rtsp_marshal_ENUM__POINTER_POINTER,
       
    86         GST_TYPE_RTSP_RESULT, 2, G_TYPE_POINTER, G_TYPE_POINTER);
       
    87     initialized = TRUE;
       
    88   }
       
    89 }
       
    90 
       
    91 gboolean
       
    92 gst_rtsp_extension_detect_server (GstRTSPExtension * ext, GstRTSPMessage * resp)
       
    93 {
       
    94   GstRTSPExtensionInterface *iface;
       
    95   gboolean res = TRUE;
       
    96 
       
    97   iface = GST_RTSP_EXTENSION_GET_IFACE (ext);
       
    98   if (iface->detect_server)
       
    99     res = iface->detect_server (ext, resp);
       
   100 
       
   101   return res;
       
   102 }
       
   103 
       
   104 GstRTSPResult
       
   105 gst_rtsp_extension_before_send (GstRTSPExtension * ext, GstRTSPMessage * req)
       
   106 {
       
   107   GstRTSPExtensionInterface *iface;
       
   108   GstRTSPResult res = GST_RTSP_OK;
       
   109 
       
   110   iface = GST_RTSP_EXTENSION_GET_IFACE (ext);
       
   111   if (iface->before_send)
       
   112     res = iface->before_send (ext, req);
       
   113 
       
   114   return res;
       
   115 }
       
   116 
       
   117 GstRTSPResult
       
   118 gst_rtsp_extension_after_send (GstRTSPExtension * ext, GstRTSPMessage * req,
       
   119     GstRTSPMessage * resp)
       
   120 {
       
   121   GstRTSPExtensionInterface *iface;
       
   122   GstRTSPResult res = GST_RTSP_OK;
       
   123 
       
   124   iface = GST_RTSP_EXTENSION_GET_IFACE (ext);
       
   125   if (iface->after_send)
       
   126     res = iface->after_send (ext, req, resp);
       
   127 
       
   128   return res;
       
   129 }
       
   130 
       
   131 GstRTSPResult
       
   132 gst_rtsp_extension_parse_sdp (GstRTSPExtension * ext, GstSDPMessage * sdp,
       
   133     GstStructure * s)
       
   134 {
       
   135   GstRTSPExtensionInterface *iface;
       
   136   GstRTSPResult res = GST_RTSP_OK;
       
   137 
       
   138   iface = GST_RTSP_EXTENSION_GET_IFACE (ext);
       
   139   if (iface->parse_sdp)
       
   140     res = iface->parse_sdp (ext, sdp, s);
       
   141 
       
   142   return res;
       
   143 }
       
   144 
       
   145 GstRTSPResult
       
   146 gst_rtsp_extension_setup_media (GstRTSPExtension * ext, GstSDPMedia * media)
       
   147 {
       
   148   GstRTSPExtensionInterface *iface;
       
   149   GstRTSPResult res = GST_RTSP_OK;
       
   150 
       
   151   iface = GST_RTSP_EXTENSION_GET_IFACE (ext);
       
   152   if (iface->setup_media)
       
   153     res = iface->setup_media (ext, media);
       
   154 
       
   155   return res;
       
   156 }
       
   157 
       
   158 gboolean
       
   159 gst_rtsp_extension_configure_stream (GstRTSPExtension * ext, GstCaps * caps)
       
   160 {
       
   161   GstRTSPExtensionInterface *iface;
       
   162   gboolean res = TRUE;
       
   163 
       
   164   iface = GST_RTSP_EXTENSION_GET_IFACE (ext);
       
   165   if (iface->configure_stream)
       
   166     res = iface->configure_stream (ext, caps);
       
   167 
       
   168   return res;
       
   169 }
       
   170 
       
   171 GstRTSPResult
       
   172 gst_rtsp_extension_get_transports (GstRTSPExtension * ext,
       
   173     GstRTSPLowerTrans protocols, gchar ** transport)
       
   174 {
       
   175   GstRTSPExtensionInterface *iface;
       
   176   GstRTSPResult res = GST_RTSP_OK;
       
   177 
       
   178   iface = GST_RTSP_EXTENSION_GET_IFACE (ext);
       
   179   if (iface->get_transports)
       
   180     res = iface->get_transports (ext, protocols, transport);
       
   181 
       
   182   return res;
       
   183 }
       
   184 
       
   185 GstRTSPResult
       
   186 gst_rtsp_extension_stream_select (GstRTSPExtension * ext, GstRTSPUrl * url)
       
   187 {
       
   188   GstRTSPExtensionInterface *iface;
       
   189   GstRTSPResult res = GST_RTSP_OK;
       
   190 
       
   191   iface = GST_RTSP_EXTENSION_GET_IFACE (ext);
       
   192   if (iface->stream_select)
       
   193     res = iface->stream_select (ext, url);
       
   194 
       
   195   return res;
       
   196 }
       
   197 
       
   198 GstRTSPResult
       
   199 gst_rtsp_extension_send (GstRTSPExtension * ext, GstRTSPMessage * req,
       
   200     GstRTSPMessage * resp)
       
   201 {
       
   202   GstRTSPResult res = GST_RTSP_OK;
       
   203 
       
   204   g_signal_emit (ext, gst_rtsp_extension_signals[SIGNAL_SEND], 0,
       
   205       req, resp, &res);
       
   206 
       
   207   return res;
       
   208 }