mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-18 21:35:44 +00:00
hls: Add a way to get best playlist for a specific bitrate in M3U8Client
Make use of it in hlsdemux
This commit is contained in:
parent
594d983ff9
commit
a8afa9755e
3 changed files with 33 additions and 20 deletions
|
@ -982,27 +982,12 @@ gst_hls_demux_update_playlist (GstHLSDemux * demux, gboolean update)
|
|||
static gboolean
|
||||
gst_hls_demux_change_playlist (GstHLSDemux * demux, guint max_bitrate)
|
||||
{
|
||||
GList *list, *previous_variant, *current_variant;
|
||||
GList *previous_variant, *current_variant;
|
||||
gint old_bandwidth, new_bandwidth;
|
||||
|
||||
GST_M3U8_CLIENT_LOCK (demux->client);
|
||||
current_variant = demux->client->main->current_variant;
|
||||
previous_variant = current_variant;
|
||||
|
||||
/* Go to the highest possible bandwidth allowed */
|
||||
while (GST_M3U8 (current_variant->data)->bandwidth < max_bitrate) {
|
||||
list = g_list_next (current_variant);
|
||||
if (!list)
|
||||
break;
|
||||
current_variant = list;
|
||||
}
|
||||
|
||||
while (GST_M3U8 (current_variant->data)->bandwidth > max_bitrate) {
|
||||
list = g_list_previous (current_variant);
|
||||
if (!list)
|
||||
break;
|
||||
current_variant = list;
|
||||
}
|
||||
previous_variant = demux->client->main->current_variant;
|
||||
current_variant = gst_m3u8_client_get_playlist_for_bitrate (demux->client,
|
||||
max_bitrate);
|
||||
|
||||
retry_failover_protection:
|
||||
old_bandwidth = GST_M3U8 (previous_variant->data)->bandwidth;
|
||||
|
@ -1010,7 +995,6 @@ retry_failover_protection:
|
|||
|
||||
/* Don't do anything else if the playlist is the same */
|
||||
if (new_bandwidth == old_bandwidth) {
|
||||
GST_M3U8_CLIENT_UNLOCK (demux->client);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -647,3 +647,30 @@ gst_m3u8_client_is_live (GstM3U8Client * client)
|
|||
GST_M3U8_CLIENT_UNLOCK (client);
|
||||
return ret;
|
||||
}
|
||||
|
||||
GList *
|
||||
gst_m3u8_client_get_playlist_for_bitrate (GstM3U8Client * client, guint bitrate)
|
||||
{
|
||||
GList *list, *current_variant;
|
||||
|
||||
GST_M3U8_CLIENT_LOCK (client);
|
||||
current_variant = client->main->current_variant;
|
||||
|
||||
/* Go to the highest possible bandwidth allowed */
|
||||
while (GST_M3U8 (current_variant->data)->bandwidth < bitrate) {
|
||||
list = g_list_next (current_variant);
|
||||
if (!list)
|
||||
break;
|
||||
current_variant = list;
|
||||
}
|
||||
|
||||
while (GST_M3U8 (current_variant->data)->bandwidth > bitrate) {
|
||||
list = g_list_previous (current_variant);
|
||||
if (!list)
|
||||
break;
|
||||
current_variant = list;
|
||||
}
|
||||
GST_M3U8_CLIENT_UNLOCK (client);
|
||||
|
||||
return current_variant;
|
||||
}
|
||||
|
|
|
@ -92,6 +92,8 @@ const gchar *gst_m3u8_client_get_uri(GstM3U8Client * client);
|
|||
const gchar *gst_m3u8_client_get_current_uri(GstM3U8Client * client);
|
||||
gboolean gst_m3u8_client_has_variant_playlist(GstM3U8Client * client);
|
||||
gboolean gst_m3u8_client_is_live(GstM3U8Client * client);
|
||||
GList * gst_m3u8_client_get_playlist_for_bitrate (GstM3U8Client * client,
|
||||
guint bitrate);
|
||||
|
||||
G_END_DECLS
|
||||
#endif /* __M3U8_H__ */
|
||||
|
|
Loading…
Reference in a new issue