summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYouness Alaoui <youness.alaoui@collabora.co.uk>2012-05-08 13:27:15 -0400
committerThibault Saunier <thibault.saunier@collabora.com>2012-05-10 14:07:54 -0400
commit594d983ff9dabcda5272bef353ab084ed4a098fc (patch)
tree0df6ebff1d6234ea33e0551c7c8a98aeeb22734b
parent705a52a1ac523913d2ad75f818a89af6650f99b6 (diff)
downloadgstreamer-plugins-bad-594d983ff9dabcda5272bef353ab084ed4a098fc.tar.gz
hlsdemux: Add failover protection.
Multiple streams with same bandwidth get retried
-rw-r--r--gst/hls/gsthlsdemux.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/gst/hls/gsthlsdemux.c b/gst/hls/gsthlsdemux.c
index 99ab1bd81..8d6975913 100644
--- a/gst/hls/gsthlsdemux.c
+++ b/gst/hls/gsthlsdemux.c
@@ -1004,14 +1004,16 @@ gst_hls_demux_change_playlist (GstHLSDemux * demux, guint max_bitrate)
current_variant = list;
}
+retry_failover_protection:
+ old_bandwidth = GST_M3U8 (previous_variant->data)->bandwidth;
+ new_bandwidth = GST_M3U8 (current_variant->data)->bandwidth;
+
/* Don't do anything else if the playlist is the same */
- if (current_variant == previous_variant) {
+ if (new_bandwidth == old_bandwidth) {
GST_M3U8_CLIENT_UNLOCK (demux->client);
return TRUE;
}
- old_bandwidth = GST_M3U8 (previous_variant->data)->bandwidth;
- new_bandwidth = GST_M3U8 (current_variant->data)->bandwidth;
demux->client->main->current_variant = current_variant;
GST_M3U8_CLIENT_UNLOCK (demux->client);
@@ -1029,8 +1031,17 @@ gst_hls_demux_change_playlist (GstHLSDemux * demux, guint max_bitrate)
gst_element_post_message (GST_ELEMENT_CAST (demux),
gst_message_new_element (GST_OBJECT_CAST (demux), s));
} else {
+ GList *failover = NULL;
+
GST_INFO_OBJECT (demux, "Unable to update playlist. Switching back");
GST_M3U8_CLIENT_LOCK (demux->client);
+
+ failover = g_list_previous (current_variant);
+ if (failover && new_bandwidth == GST_M3U8 (failover->data)->bandwidth) {
+ current_variant = failover;
+ goto retry_failover_protection;
+ }
+
demux->client->main->current_variant = previous_variant;
GST_M3U8_CLIENT_UNLOCK (demux->client);
gst_m3u8_client_set_current (demux->client, previous_variant->data);