if (gst_m3u8_client_has_variant_playlist (hlsdemux->client)) {
GstM3U8 *child = NULL;
GError *err = NULL;
+ GList *current_variant = NULL;
- /* TODO seems like something that could be simplified */
- if (demux->connection_speed == 0) {
- GST_M3U8_CLIENT_LOCK (hlsdemux->client);
- child = hlsdemux->client->main->current_variant->data;
- GST_M3U8_CLIENT_UNLOCK (hlsdemux->client);
- } else {
- GList *tmp = gst_m3u8_client_get_playlist_for_bitrate (hlsdemux->client,
- demux->connection_speed);
-
- child = GST_M3U8 (tmp->data);
- }
+ current_variant =
+ gst_m3u8_client_get_playlist_for_bitrate (hlsdemux->client,
+ demux->connection_speed);
+ child = GST_M3U8 (current_variant->data);
gst_m3u8_client_set_current (hlsdemux->client, child);
if (!gst_hls_demux_update_playlist (hlsdemux, FALSE, &err)) {
GST_M3U8_CLIENT_LOCK (client);
current_variant = client->main->current_variant;
+ if (bitrate == 0) {
+ GST_M3U8_CLIENT_UNLOCK (client);
+ return current_variant;
+ }
+
/* Go to the highest possible bandwidth allowed */
while (GST_M3U8 (current_variant->data)->bandwidth <= bitrate) {
list = g_list_next (current_variant);