From 5572e638589a10fd91bc6beff96585c2bb65d379 Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Mon, 1 Aug 2011 18:48:03 +0200 Subject: [PATCH] hlsdemux: Send NEWSEGMENT events Previously hlsdemux wasn't sending out any newsegment. Here we push a GST_FORMAT_TIME newsegment, and whenever possible we try to indicate the proper start time. This allows downstream elements to relay the start/time values properly to the sinks, allowing better stream switching. --- gst/hls/gsthlsdemux.c | 13 +++++++++++++ gst/hls/gsthlsdemux.h | 2 ++ 2 files changed, 15 insertions(+) diff --git a/gst/hls/gsthlsdemux.c b/gst/hls/gsthlsdemux.c index eed9d82d09..773d24986a 100644 --- a/gst/hls/gsthlsdemux.c +++ b/gst/hls/gsthlsdemux.c @@ -242,6 +242,8 @@ gst_hls_demux_init (GstHLSDemux * demux, GstHLSDemuxClass * klass) g_static_rec_mutex_init (&demux->task_lock); demux->task = gst_task_create ((GstTaskFunction) gst_hls_demux_loop, demux); gst_task_set_lock (demux->task, &demux->task_lock); + + demux->position = 0; } static void @@ -379,6 +381,10 @@ gst_hls_demux_sink_event (GstPad * pad, GstEvent * event) gst_event_unref (event); return TRUE; } + case GST_EVENT_NEWSEGMENT: + /* Swallow newsegments, we'll push our own */ + gst_event_unref (event); + return TRUE; default: break; } @@ -615,8 +621,15 @@ gst_hls_demux_loop (GstHLSDemux * demux) if (G_UNLIKELY (!demux->srcpad || GST_BUFFER_CAPS (buf) != GST_PAD_CAPS (demux->srcpad))) { switch_pads (demux, GST_BUFFER_CAPS (buf)); + /* And send a newsegment */ + gst_pad_push_event (demux->srcpad, + gst_event_new_new_segment (0, 1.0, GST_FORMAT_TIME, demux->position, + GST_CLOCK_TIME_NONE, demux->position)); } + if (GST_CLOCK_TIME_IS_VALID (GST_BUFFER_DURATION (buf))) + demux->position += GST_BUFFER_DURATION (buf); + ret = gst_pad_push (demux->srcpad, buf); if (ret != GST_FLOW_OK) goto error; diff --git a/gst/hls/gsthlsdemux.h b/gst/hls/gsthlsdemux.h index 5113b76df3..67574675d3 100644 --- a/gst/hls/gsthlsdemux.h +++ b/gst/hls/gsthlsdemux.h @@ -87,6 +87,8 @@ struct _GstHLSDemux gboolean cancelled; GstAdapter *download; + /* Position in the stream */ + GstClockTime position; }; struct _GstHLSDemuxClass