mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-20 23:36:38 +00:00
hlsdemux: Switch playlists after pushing the fragment
Makes sure we properly set the discont flag for the next buffer, not the current one.
This commit is contained in:
parent
4da4dfc4bf
commit
5d5ca5139e
1 changed files with 8 additions and 7 deletions
|
@ -771,9 +771,6 @@ gst_hls_demux_stream_loop (GstHLSDemux * demux)
|
||||||
g_object_unref (fragment);
|
g_object_unref (fragment);
|
||||||
goto pause_task;
|
goto pause_task;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* try to switch to another bitrate if needed */
|
|
||||||
gst_hls_demux_switch_playlist (demux, fragment);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (demux->stop_updates_task) {
|
if (demux->stop_updates_task) {
|
||||||
|
@ -803,7 +800,6 @@ gst_hls_demux_stream_loop (GstHLSDemux * demux)
|
||||||
gst_caps_unref (bufcaps);
|
gst_caps_unref (bufcaps);
|
||||||
if (G_LIKELY (srccaps))
|
if (G_LIKELY (srccaps))
|
||||||
gst_caps_unref (srccaps);
|
gst_caps_unref (srccaps);
|
||||||
g_object_unref (fragment);
|
|
||||||
|
|
||||||
if (demux->need_segment) {
|
if (demux->need_segment) {
|
||||||
GstSegment segment;
|
GstSegment segment;
|
||||||
|
@ -828,6 +824,10 @@ gst_hls_demux_stream_loop (GstHLSDemux * demux)
|
||||||
if (ret != GST_FLOW_OK)
|
if (ret != GST_FLOW_OK)
|
||||||
goto error_pushing;
|
goto error_pushing;
|
||||||
|
|
||||||
|
/* try to switch to another bitrate if needed */
|
||||||
|
gst_hls_demux_switch_playlist (demux, fragment);
|
||||||
|
g_object_unref (fragment);
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (demux, "Pushed buffer");
|
GST_DEBUG_OBJECT (demux, "Pushed buffer");
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -850,6 +850,7 @@ type_not_found:
|
||||||
|
|
||||||
error_pushing:
|
error_pushing:
|
||||||
{
|
{
|
||||||
|
g_object_unref (fragment);
|
||||||
if (ret == GST_FLOW_NOT_LINKED || ret < GST_FLOW_EOS) {
|
if (ret == GST_FLOW_NOT_LINKED || ret < GST_FLOW_EOS) {
|
||||||
GST_ELEMENT_ERROR (demux, STREAM, FAILED, (NULL),
|
GST_ELEMENT_ERROR (demux, STREAM, FAILED, (NULL),
|
||||||
("stream stopped, reason %s", gst_flow_get_name (ret)));
|
("stream stopped, reason %s", gst_flow_get_name (ret)));
|
||||||
|
@ -1222,13 +1223,13 @@ gst_hls_demux_switch_playlist (GstHLSDemux * demux, GstFragment * fragment)
|
||||||
|
|
||||||
/* compare the time when the fragment was downloaded with the time when it was
|
/* compare the time when the fragment was downloaded with the time when it was
|
||||||
* scheduled */
|
* scheduled */
|
||||||
diff = g_get_monotonic_time () - demux->next_download;
|
diff = fragment->download_stop_time - fragment->download_start_time;
|
||||||
buffer = gst_fragment_get_buffer (fragment);
|
buffer = gst_fragment_get_buffer (fragment);
|
||||||
size = gst_buffer_get_size (buffer);
|
size = gst_buffer_get_size (buffer);
|
||||||
bitrate = (size * 8) / ((double) diff / G_USEC_PER_SEC);
|
bitrate = (size * 8) / ((double) diff / GST_SECOND);
|
||||||
|
|
||||||
GST_DEBUG ("Downloaded %d bytes in %" GST_TIME_FORMAT ". Bitrate is : %d",
|
GST_DEBUG ("Downloaded %d bytes in %" GST_TIME_FORMAT ". Bitrate is : %d",
|
||||||
(guint) size, GST_TIME_ARGS (diff * GST_USECOND), bitrate);
|
(guint) size, GST_TIME_ARGS (diff), bitrate);
|
||||||
|
|
||||||
gst_buffer_unref (buffer);
|
gst_buffer_unref (buffer);
|
||||||
return gst_hls_demux_change_playlist (demux, bitrate * demux->bitrate_limit);
|
return gst_hls_demux_change_playlist (demux, bitrate * demux->bitrate_limit);
|
||||||
|
|
Loading…
Reference in a new issue