rtspsrc: add signal to notify of the SDP
authorWim Taymans <wim.taymans@collabora.co.uk>
Mon, 1 Jul 2013 15:28:55 +0000 (17:28 +0200)
committerWim Taymans <wim.taymans@collabora.co.uk>
Mon, 1 Jul 2013 15:31:30 +0000 (17:31 +0200)
This way, the app can look and modify the SDP.

gst/rtsp/gstrtspsrc.c

index e8b00c1..911069f 100644 (file)
@@ -121,6 +121,7 @@ GST_STATIC_PAD_TEMPLATE ("internalsink_%u",
 enum
 {
   SIGNAL_HANDLE_REQUEST,
+  SIGNAL_ON_SDP,
   LAST_SIGNAL
 };
 
@@ -573,6 +574,27 @@ gst_rtspsrc_class_init (GstRTSPSrcClass * klass)
       0, NULL, NULL, g_cclosure_marshal_generic, G_TYPE_NONE, 2,
       G_TYPE_POINTER, G_TYPE_POINTER);
 
+  /**
+   * GstRTSPSrc::on-sdp:
+   * @rtspsrc: a #GstRTSPSrc
+   * @sdp: a #GstSDPMessage
+   *
+   * Emited when the client has retrieved the SDP and before it configures the
+   * streams in the SDP. @sdp can be inspected and modified.
+   *
+   * This signal is called from the streaming thread, you should therefore not
+   * do any state changes on @rtspsrc because this might deadlock. If you want
+   * to modify the state as a result of this signal, post a
+   * #GST_MESSAGE_REQUEST_STATE message on the bus or signal the main thread
+   * in some other way.
+   *
+   * Since: 1.2
+   */
+  gst_rtspsrc_signals[SIGNAL_ON_SDP] =
+      g_signal_new ("on-sdp", G_TYPE_FROM_CLASS (klass), 0,
+      0, NULL, NULL, g_cclosure_marshal_generic, G_TYPE_NONE, 1,
+      GST_TYPE_SDP_MESSAGE | G_SIGNAL_TYPE_STATIC_SCOPE);
+
   gstelement_class->send_event = gst_rtspsrc_send_event;
   gstelement_class->provide_clock = gst_rtspsrc_provide_clock;
   gstelement_class->change_state = gst_rtspsrc_change_state;
@@ -5816,6 +5838,9 @@ gst_rtspsrc_open_from_sdp (GstRTSPSrc * src, GstSDPMessage * sdp,
 
   gst_rtsp_ext_list_parse_sdp (src->extensions, sdp, src->props);
 
+  /* let the app inspect and change the SDP */
+  g_signal_emit (src, gst_rtspsrc_signals[SIGNAL_ON_SDP], 0, sdp);
+
   gst_segment_init (&src->segment, GST_FORMAT_TIME);
 
   /* parse range for duration reporting. */