summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSrimanta Panda <srimanta@axis.com>2014-09-08 09:26:23 +0200
committerSebastian Dröge <sebastian@centricular.com>2014-09-13 16:41:40 +0300
commit268bd127d247857137625ce7056c8aff485fd69d (patch)
tree604ccb8cee4eb652d7d21429d8f717acda69cd85
parentf62b4c4dfbb5bf22dcabde4084cfcf989600749c (diff)
rtsp-media: Make sure that sequence numbers are monotonic after pause1.4
The sequence number is not monotonic for RTP packets after pause. The reason is basepayloader generates a randon sequence number when the pipeline goes from ready to pause. With this fix generation of sequence number will be monotonic when going from pause to play request. https://bugzilla.gnome.org/show_bug.cgi?id=736017
-rw-r--r--gst/rtsp-server/rtsp-media.c14
-rw-r--r--gst/rtsp-server/rtsp-stream.c42
-rw-r--r--gst/rtsp-server/rtsp-stream.h3
3 files changed, 59 insertions, 0 deletions
diff --git a/gst/rtsp-server/rtsp-media.c b/gst/rtsp-server/rtsp-media.c
index 48868f5..6b81e25 100644
--- a/gst/rtsp-server/rtsp-media.c
+++ b/gst/rtsp-server/rtsp-media.c
@@ -2713,6 +2713,14 @@ no_setup_sdp:
}
}
+static void
+do_set_seqnum (GstRTSPStream * stream)
+{
+ guint16 seq_num;
+ seq_num = gst_rtsp_stream_get_current_seqnum (stream);
+ gst_rtsp_stream_set_seqnum_offset (stream, seq_num + 1);
+}
+
/* call with state_lock */
gboolean
default_suspend (GstRTSPMedia * media)
@@ -2735,6 +2743,12 @@ default_suspend (GstRTSPMedia * media)
ret = set_target_state (media, GST_STATE_NULL, TRUE);
if (ret == GST_STATE_CHANGE_FAILURE)
goto state_failed;
+ /* Because payloader needs to set the sequence number as
+ * monotonic, we need to preserve the sequence number
+ * after pause. (otherwise going from pause to play, which
+ * is actually from NULL to PLAY will create a new sequence
+ * number. */
+ g_ptr_array_foreach (priv->streams, (GFunc) do_set_seqnum, NULL);
break;
default:
break;
diff --git a/gst/rtsp-server/rtsp-stream.c b/gst/rtsp-server/rtsp-stream.c
index 6a79508..7e0d3c2 100644
--- a/gst/rtsp-server/rtsp-stream.c
+++ b/gst/rtsp-server/rtsp-stream.c
@@ -2468,6 +2468,48 @@ gst_rtsp_stream_get_rtcp_socket (GstRTSPStream * stream, GSocketFamily family)
}
/**
+ * gst_rtsp_stream_set_seqnum:
+ * @stream: a #GstRTSPStream
+ * @seqnum: a new sequence number
+ *
+ * Configure the sequence number in the payloader of @stream to @seqnum.
+ */
+void
+gst_rtsp_stream_set_seqnum_offset (GstRTSPStream * stream, guint16 seqnum)
+{
+ GstRTSPStreamPrivate *priv;
+
+ g_return_if_fail (GST_IS_RTSP_STREAM (stream));
+
+ priv = stream->priv;
+
+ g_object_set (G_OBJECT (priv->payloader), "seqnum-offset", seqnum, NULL);
+}
+
+/**
+ * gst_rtsp_stream_get_seqnum:
+ * @stream: a #GstRTSPStream
+ *
+ * Get the configured sequence number in the payloader of @stream.
+ *
+ * Returns: the sequence number of the payloader.
+ */
+guint16
+gst_rtsp_stream_get_current_seqnum (GstRTSPStream * stream)
+{
+ GstRTSPStreamPrivate *priv;
+ guint seqnum;
+
+ g_return_val_if_fail (GST_IS_RTSP_STREAM (stream), 0);
+
+ priv = stream->priv;
+
+ g_object_get (G_OBJECT (priv->payloader), "seqnum", &seqnum, NULL);
+
+ return seqnum;
+}
+
+/**
* gst_rtsp_stream_transport_filter:
* @stream: a #GstRTSPStream
* @func: (scope call) (allow-none): a callback
diff --git a/gst/rtsp-server/rtsp-stream.h b/gst/rtsp-server/rtsp-stream.h
index 1dbfdf3..135689e 100644
--- a/gst/rtsp-server/rtsp-stream.h
+++ b/gst/rtsp-server/rtsp-stream.h
@@ -153,6 +153,9 @@ gboolean gst_rtsp_stream_query_position (GstRTSPStream * stream,
gboolean gst_rtsp_stream_query_stop (GstRTSPStream * stream,
gint64 * stop);
+void gst_rtsp_stream_set_seqnum_offset (GstRTSPStream *stream, guint16 seqnum);
+guint16 gst_rtsp_stream_get_current_seqnum (GstRTSPStream *stream);
+
/**
* GstRTSPStreamTransportFilterFunc:
* @stream: a #GstRTSPStream object