rtspsrc: send GstRTSPSrcTimeout message on timeout

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
This commit is contained in:
Patrick Radizi 2018-11-29 16:07:08 +01:00 committed by Sebastian Dröge
parent ab8100e664
commit d3662bae00
2 changed files with 47 additions and 6 deletions

View file

@ -42,6 +42,7 @@
*/ */
/** /**
* SECTION:element-rtspsrc * SECTION:element-rtspsrc
* @title: rtspsrc
* *
* Makes a connection to an RTSP server and read the data. * Makes a connection to an RTSP server and read the data.
* rtspsrc strictly follows RFC 2326 and therefore does not (yet) support * rtspsrc strictly follows RFC 2326 and therefore does not (yet) support
@ -66,13 +67,24 @@
* rtspsrc acts like a live source and will therefore only generate data in the * rtspsrc acts like a live source and will therefore only generate data in the
* PLAYING state. * PLAYING state.
* *
* <refsect2> * If a RTP session times out then the rtspsrc will generate an element message
* <title>Example launch line</title> * 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 * 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 * ]| Establish a connection to an RTSP server and send the raw RTP packets to a
* fakesink. * fakesink.
* </refsect2> *
*/ */
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
@ -3410,7 +3422,7 @@ on_bye_ssrc (GObject * session, GObject * source, GstRTSPStream * stream)
} }
static void static void
on_timeout (GObject * session, GObject * source, GstRTSPStream * stream) on_timeout_common (GObject * session, GObject * source, GstRTSPStream * stream)
{ {
GstRTSPSrc *src = stream->parent; GstRTSPSrc *src = stream->parent;
guint ssrc; guint ssrc;
@ -3424,6 +3436,22 @@ on_timeout (GObject * session, GObject * source, GstRTSPStream * stream)
gst_rtspsrc_do_stream_eos (src, stream); gst_rtspsrc_do_stream_eos (src, 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 static void
on_npt_stop (GstElement * rtpbin, guint session, guint ssrc, GstRTSPSrc * src) on_npt_stop (GstElement * rtpbin, guint session, guint ssrc, GstRTSPSrc * src)
{ {
@ -3941,8 +3969,8 @@ gst_rtspsrc_stream_configure_manager (GstRTSPSrc * src, GstRTSPStream * stream,
g_signal_connect (rtpsession, "on-bye-ssrc", (GCallback) on_bye_ssrc, g_signal_connect (rtpsession, "on-bye-ssrc", (GCallback) on_bye_ssrc,
stream); stream);
g_signal_connect (rtpsession, "on-bye-timeout", (GCallback) on_timeout, g_signal_connect (rtpsession, "on-bye-timeout",
stream); (GCallback) on_timeout_common, stream);
g_signal_connect (rtpsession, "on-timeout", (GCallback) on_timeout, g_signal_connect (rtpsession, "on-timeout", (GCallback) on_timeout,
stream); stream);
g_signal_connect (rtpsession, "on-ssrc-active", g_signal_connect (rtpsession, "on-ssrc-active",

View file

@ -169,6 +169,18 @@ struct _GstRTSPStream {
GstStructure *rtx_pt_map; GstStructure *rtx_pt_map;
}; };
/**
* 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: * GstRTSPNatMethod:
* @GST_RTSP_NAT_NONE: none * @GST_RTSP_NAT_NONE: none
@ -182,6 +194,7 @@ typedef enum
GST_RTSP_NAT_DUMMY GST_RTSP_NAT_DUMMY
} GstRTSPNatMethod; } GstRTSPNatMethod;
struct _GstRTSPSrc { struct _GstRTSPSrc {
GstBin parent; GstBin parent;