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.
This commit is contained in:
Edward Hervey 2011-08-01 18:48:03 +02:00
parent adfb090b59
commit 5572e63858
2 changed files with 15 additions and 0 deletions

View file

@ -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;

View file

@ -87,6 +87,8 @@ struct _GstHLSDemux
gboolean cancelled;
GstAdapter *download;
/* Position in the stream */
GstClockTime position;
};
struct _GstHLSDemuxClass