rtspsrc: send GstRTSPSrcTimeout message on timeout
authorPatrick Radizi <patrickr@axis.com>
Thu, 29 Nov 2018 15:07:08 +0000 (16:07 +0100)
committerSebastian Dröge <slomo@coaxion.net>
Mon, 14 Jan 2019 08:15:23 +0000 (08:15 +0000)
The GstRTSPSrcTimeout message is sent by the rtspsrc when it receives
the on-timeout signal from rtpsession. This can be used by an
application for error handling.

https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/issues/499

gst/rtsp/gstrtspsrc.c
gst/rtsp/gstrtspsrc.h

index 9ecf014..1c450f5 100644 (file)
@@ -42,6 +42,7 @@
  */
 /**
  * SECTION:element-rtspsrc
+ * @title: rtspsrc
  *
  * Makes a connection to an RTSP server and read the data.
  * rtspsrc strictly follows RFC 2326 and therefore does not (yet) support
  * rtspsrc acts like a live source and will therefore only generate data in the
  * PLAYING state.
  *
- * <refsect2>
- * <title>Example launch line</title>
+ * If a RTP session times out then the rtspsrc will generate an element message
+ * named "GstRTSPSrcTimeout". Currently this is only supported for timeouts
+ * triggered by RTCP.
+ *
+ * The message's structure contains three fields:
+ *
+ *   #GstRTSPSrcTimeoutCause `cause`: the cause of the timeout.
+ *
+ *   #gint `stream-number`: an internal identifier of the stream that timed out.
+ *
+ *   #guint `ssrc`: the SSRC of the stream that timed out.
+ *
+ * ## Example launch line
  * |[
  * gst-launch-1.0 rtspsrc location=rtsp://some.server/url ! fakesink
  * ]| Establish a connection to an RTSP server and send the raw RTP packets to a
  * fakesink.
- * </refsect2>
+ *
  */
 
 #ifdef HAVE_CONFIG_H
@@ -3410,7 +3422,7 @@ on_bye_ssrc (GObject * session, GObject * source, GstRTSPStream * stream)
 }
 
 static void
-on_timeout (GObject * session, GObject * source, GstRTSPStream * stream)
+on_timeout_common (GObject * session, GObject * source, GstRTSPStream * stream)
 {
   GstRTSPSrc *src = stream->parent;
   guint ssrc;
@@ -3425,6 +3437,22 @@ on_timeout (GObject * session, GObject * source, GstRTSPStream * stream)
 }
 
 static void
+on_timeout (GObject * session, GObject * source, GstRTSPStream * stream)
+{
+  GstRTSPSrc *src = stream->parent;
+
+  /* timeout, post element message */
+  gst_element_post_message (GST_ELEMENT_CAST (src),
+      gst_message_new_element (GST_OBJECT_CAST (src),
+          gst_structure_new ("GstRTSPSrcTimeout",
+              "cause", G_TYPE_ENUM, GST_RTSP_SRC_TIMEOUT_CAUSE_RTCP,
+              "stream-number", G_TYPE_INT, stream->id, "ssrc", G_TYPE_UINT,
+              stream->ssrc, NULL)));
+
+  on_timeout_common (session, source, stream);
+}
+
+static void
 on_npt_stop (GstElement * rtpbin, guint session, guint ssrc, GstRTSPSrc * src)
 {
   GstRTSPStream *stream;
@@ -3941,8 +3969,8 @@ gst_rtspsrc_stream_configure_manager (GstRTSPSrc * src, GstRTSPStream * stream,
 
         g_signal_connect (rtpsession, "on-bye-ssrc", (GCallback) on_bye_ssrc,
             stream);
-        g_signal_connect (rtpsession, "on-bye-timeout", (GCallback) on_timeout,
-            stream);
+        g_signal_connect (rtpsession, "on-bye-timeout",
+            (GCallback) on_timeout_common, stream);
         g_signal_connect (rtpsession, "on-timeout", (GCallback) on_timeout,
             stream);
         g_signal_connect (rtpsession, "on-ssrc-active",
index b144469..e0b60a9 100644 (file)
@@ -170,6 +170,18 @@ struct _GstRTSPStream {
 };
 
 /**
+ * GstRTSPSrcTimeoutCause:
+ * @GST_RTSP_SRC_TIMEOUT_CAUSE_RTCP: timeout triggered by RTCP
+ *
+ * Different causes to why the rtspsrc generated the GstRTSPSrcTimeout
+ * message.
+ */
+typedef enum
+{
+  GST_RTSP_SRC_TIMEOUT_CAUSE_RTCP
+} GstRTSPSrcTimeoutCause;
+
+/**
  * GstRTSPNatMethod:
  * @GST_RTSP_NAT_NONE: none
  * @GST_RTSP_NAT_DUMMY: send dummy packets
@@ -182,6 +194,7 @@ typedef enum
   GST_RTSP_NAT_DUMMY
 } GstRTSPNatMethod;
 
+
 struct _GstRTSPSrc {
   GstBin           parent;