mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-19 13:55:41 +00:00
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:
parent
adfb090b59
commit
5572e63858
2 changed files with 15 additions and 0 deletions
|
@ -242,6 +242,8 @@ gst_hls_demux_init (GstHLSDemux * demux, GstHLSDemuxClass * klass)
|
||||||
g_static_rec_mutex_init (&demux->task_lock);
|
g_static_rec_mutex_init (&demux->task_lock);
|
||||||
demux->task = gst_task_create ((GstTaskFunction) gst_hls_demux_loop, demux);
|
demux->task = gst_task_create ((GstTaskFunction) gst_hls_demux_loop, demux);
|
||||||
gst_task_set_lock (demux->task, &demux->task_lock);
|
gst_task_set_lock (demux->task, &demux->task_lock);
|
||||||
|
|
||||||
|
demux->position = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -379,6 +381,10 @@ gst_hls_demux_sink_event (GstPad * pad, GstEvent * event)
|
||||||
gst_event_unref (event);
|
gst_event_unref (event);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
case GST_EVENT_NEWSEGMENT:
|
||||||
|
/* Swallow newsegments, we'll push our own */
|
||||||
|
gst_event_unref (event);
|
||||||
|
return TRUE;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -615,8 +621,15 @@ gst_hls_demux_loop (GstHLSDemux * demux)
|
||||||
if (G_UNLIKELY (!demux->srcpad
|
if (G_UNLIKELY (!demux->srcpad
|
||||||
|| GST_BUFFER_CAPS (buf) != GST_PAD_CAPS (demux->srcpad))) {
|
|| GST_BUFFER_CAPS (buf) != GST_PAD_CAPS (demux->srcpad))) {
|
||||||
switch_pads (demux, GST_BUFFER_CAPS (buf));
|
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);
|
ret = gst_pad_push (demux->srcpad, buf);
|
||||||
if (ret != GST_FLOW_OK)
|
if (ret != GST_FLOW_OK)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
|
@ -87,6 +87,8 @@ struct _GstHLSDemux
|
||||||
gboolean cancelled;
|
gboolean cancelled;
|
||||||
GstAdapter *download;
|
GstAdapter *download;
|
||||||
|
|
||||||
|
/* Position in the stream */
|
||||||
|
GstClockTime position;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstHLSDemuxClass
|
struct _GstHLSDemuxClass
|
||||||
|
|
Loading…
Reference in a new issue