summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian@centricular.com>2018-06-22 13:59:13 +0300
committerSebastian Dröge <sebastian@centricular.com>2018-06-22 14:01:30 +0300
commit768eb1a913adf381fa021b28fb979fdbed723d3e (patch)
treedbed2794dd9c4124c34cba5f8e7b194ce59d905e
parentfd178617d0fc3bed781d566def792f90d7825d01 (diff)
tsdemux: Send instant-rate-change event if requested in the SEEK eventinstant-rate-change
-rw-r--r--gst/mpegtsdemux/mpegtsbase.c35
1 files changed, 33 insertions, 2 deletions
diff --git a/gst/mpegtsdemux/mpegtsbase.c b/gst/mpegtsdemux/mpegtsbase.c
index ee2460c28..fa0ccfacb 100644
--- a/gst/mpegtsdemux/mpegtsbase.c
+++ b/gst/mpegtsdemux/mpegtsbase.c
@@ -41,6 +41,8 @@
#include "mpegtsbase.h"
#include "gstmpegdesc.h"
+#include "tsdemux.h"
+
#define RUNNING_STATUS_RUNNING 4
GST_DEBUG_CATEGORY_STATIC (mpegts_base_debug);
@@ -1625,7 +1627,7 @@ mpegts_base_handle_seek_event (MpegTSBase * base, GstPad * pad,
MpegTSBaseClass *klass = GST_MPEGTS_BASE_GET_CLASS (base);
GstFlowReturn ret = GST_FLOW_ERROR;
gdouble rate;
- gboolean flush;
+ gboolean flush, instant_rate_change;
GstFormat format;
GstSeekFlags flags;
GstSeekType start_type, stop_type;
@@ -1691,7 +1693,36 @@ mpegts_base_handle_seek_event (MpegTSBase * base, GstPad * pad,
" stop: %" GST_TIME_FORMAT, rate, GST_TIME_ARGS (start),
GST_TIME_ARGS (stop));
- flush = flags & GST_SEEK_FLAG_FLUSH;
+ flush = ! !(flags & GST_SEEK_FLAG_FLUSH);
+ instant_rate_change = ! !(flags & GST_SEEK_FLAG_INSTANT_RATE_CHANGE);
+
+ /* Directly send the instant-rate-change event here before taking the
+ * stream-lock so that it can be applied as soon as possible */
+ // FIXME: Knowing the subclass in the baseclass is ugly but we
+ // need this as otherwise we can't access the actual segment here,
+ // and doing it later in the subclass seek handler is too late because
+ // the stream lock is already taken
+ if (base->mode != BASE_MODE_PUSHING && instant_rate_change &&
+ GST_IS_TS_DEMUX (base)) {
+ GstEvent *ev;
+
+ /* instant rate change only supported if direction does not change. All
+ * other requirements are already checked before creating the seek event
+ * but let's double-check here to be sure */
+ if ((rate > 0 && GST_TS_DEMUX (base)->segment.rate < 0) ||
+ (rate < 0 && GST_TS_DEMUX (base)->segment.rate > 0) ||
+ start_type != GST_SEEK_TYPE_NONE ||
+ stop_type != GST_SEEK_TYPE_NONE || flush) {
+ GST_ERROR_OBJECT (base,
+ "Instant rate change seeks only supported in the "
+ "same direction, without flushing and position change");
+ return FALSE;
+ }
+
+ ev = gst_event_new_instant_rate_change (rate);
+ gst_event_set_seqnum (ev, GST_EVENT_SEQNUM (event));
+ GST_MPEGTS_BASE_GET_CLASS (base)->push_event (base, ev);
+ }
/* stop streaming, either by flushing or by pausing the task */
base->mode = BASE_MODE_SEEKING;