mssdemux: use streams bitrate individually
connection setup times seem to matter when measuring the download rate of different streams. Streams with longer fragments have a *relatively* lower connection setup time and achieve higher bitrates. Using the average seems unfair here, so use each stream's measured bitrate to select its best quality option.
This commit is contained in:
parent
52c97834df
commit
255eb4b161
@ -954,27 +954,42 @@ gst_mss_demux_reconfigure (GstMssDemux * mssdemux)
|
|||||||
GSList *oldpads = NULL;
|
GSList *oldpads = NULL;
|
||||||
GSList *iter;
|
GSList *iter;
|
||||||
guint64 new_bitrate;
|
guint64 new_bitrate;
|
||||||
|
gboolean changed = FALSE;
|
||||||
|
|
||||||
/* TODO lock? */
|
/* TODO lock? */
|
||||||
|
|
||||||
if (!gst_mss_demux_all_streams_have_data (mssdemux))
|
if (!gst_mss_demux_all_streams_have_data (mssdemux))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
new_bitrate =
|
gst_mss_demux_stop_tasks (mssdemux, TRUE);
|
||||||
mssdemux->bitrate_limit * gst_mss_demux_get_download_bitrate (mssdemux);
|
for (iter = mssdemux->streams; iter; iter = g_slist_next (iter)) {
|
||||||
if (mssdemux->connection_speed) {
|
GstMssDemuxStream *stream;
|
||||||
new_bitrate = MIN (mssdemux->connection_speed, new_bitrate);
|
|
||||||
|
stream = iter->data;
|
||||||
|
|
||||||
|
new_bitrate =
|
||||||
|
mssdemux->bitrate_limit *
|
||||||
|
gst_download_rate_get_current_rate (&stream->download_rate);
|
||||||
|
if (mssdemux->connection_speed) {
|
||||||
|
new_bitrate = MIN (mssdemux->connection_speed, new_bitrate);
|
||||||
|
}
|
||||||
|
|
||||||
|
GST_DEBUG_OBJECT (mssdemux, "Current stream %s download bitrate %llu",
|
||||||
|
GST_PAD_NAME (stream->pad), new_bitrate);
|
||||||
|
|
||||||
|
if (gst_mss_stream_select_bitrate (stream->manifest_stream, new_bitrate)) {
|
||||||
|
changed = TRUE;
|
||||||
|
GST_INFO_OBJECT (mssdemux, "Stream %s changed bitrate to %llu",
|
||||||
|
GST_PAD_NAME (stream->pad),
|
||||||
|
gst_mss_stream_get_current_bitrate (stream->manifest_stream));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (mssdemux, "Current suggested bitrate: %llu", new_bitrate);
|
if (changed) {
|
||||||
|
|
||||||
gst_mss_demux_stop_tasks (mssdemux, TRUE);
|
|
||||||
if (gst_mss_manifest_change_bitrate (mssdemux->manifest, new_bitrate)) {
|
|
||||||
GstClockTime newseg_ts = GST_CLOCK_TIME_NONE;
|
GstClockTime newseg_ts = GST_CLOCK_TIME_NONE;
|
||||||
|
|
||||||
GST_INFO_OBJECT (mssdemux, "Switching to bitrate %llu", new_bitrate);
|
GST_DEBUG_OBJECT (mssdemux,
|
||||||
|
"Bitrates have changed, creating new pad group");
|
||||||
GST_DEBUG_OBJECT (mssdemux, "Creating new pad group");
|
|
||||||
/* if we changed the bitrate, we need to add new pads */
|
/* if we changed the bitrate, we need to add new pads */
|
||||||
for (iter = mssdemux->streams; iter; iter = g_slist_next (iter)) {
|
for (iter = mssdemux->streams; iter; iter = g_slist_next (iter)) {
|
||||||
GstMssDemuxStream *stream = iter->data;
|
GstMssDemuxStream *stream = iter->data;
|
||||||
|
@ -992,7 +992,7 @@ gst_mss_manifest_reload_fragments (GstMssManifest * manifest, GstBuffer * data)
|
|||||||
xmlFreeDoc (xml);
|
xmlFreeDoc (xml);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
gboolean
|
||||||
gst_mss_stream_select_bitrate (GstMssStream * stream, guint64 bitrate)
|
gst_mss_stream_select_bitrate (GstMssStream * stream, guint64 bitrate)
|
||||||
{
|
{
|
||||||
GList *iter = stream->current_quality;
|
GList *iter = stream->current_quality;
|
||||||
@ -1031,6 +1031,17 @@ gst_mss_stream_select_bitrate (GstMssStream * stream, guint64 bitrate)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
guint64
|
||||||
|
gst_mss_stream_get_current_bitrate (GstMssStream * stream)
|
||||||
|
{
|
||||||
|
GstMssStreamQuality *q;
|
||||||
|
if (stream->current_quality == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
q = stream->current_quality->data;
|
||||||
|
return q->bitrate;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_mss_manifest_change_bitrate:
|
* gst_mss_manifest_change_bitrate:
|
||||||
* @manifest: the manifest
|
* @manifest: the manifest
|
||||||
|
@ -52,6 +52,8 @@ void gst_mss_manifest_reload_fragments (GstMssManifest * manifest, GstBuffer * d
|
|||||||
|
|
||||||
GstMssStreamType gst_mss_stream_get_type (GstMssStream *stream);
|
GstMssStreamType gst_mss_stream_get_type (GstMssStream *stream);
|
||||||
GstCaps * gst_mss_stream_get_caps (GstMssStream * stream);
|
GstCaps * gst_mss_stream_get_caps (GstMssStream * stream);
|
||||||
|
gboolean gst_mss_stream_select_bitrate (GstMssStream * stream, guint64 bitrate);
|
||||||
|
guint64 gst_mss_stream_get_current_bitrate (GstMssStream * stream);
|
||||||
void gst_mss_stream_set_active (GstMssStream * stream, gboolean active);
|
void gst_mss_stream_set_active (GstMssStream * stream, gboolean active);
|
||||||
guint64 gst_mss_stream_get_timescale (GstMssStream * stream);
|
guint64 gst_mss_stream_get_timescale (GstMssStream * stream);
|
||||||
GstFlowReturn gst_mss_stream_get_fragment_url (GstMssStream * stream, gchar ** url);
|
GstFlowReturn gst_mss_stream_get_fragment_url (GstMssStream * stream, gchar ** url);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user