summaryrefslogtreecommitdiff
path: root/ext/hls
diff options
context:
space:
mode:
authorEdward Hervey <edward@centricular.com>2015-05-28 14:30:46 +0200
committerEdward Hervey <bilboed@bilboed.com>2015-05-28 14:56:36 +0200
commit04b010a883be722c3921661d381aa21071f12025 (patch)
treec4a2e8f0992b4f73d47dd74966feda1f0ce14b0d /ext/hls
parentb377112ee38912d316e77b4e2102041389dc0051 (diff)
downloadgstreamer-plugins-bad-04b010a883be722c3921661d381aa21071f12025.tar.gz
hlsdemux: Search more when advancing fragment
In live situations, it is not uncommon for the current fragment to end up out of the (updated) play range (lowest/highest sequence). But the next fragment to play *is* present in the play range. When advancing, if we can't find the current GstM3U8MediaFile, don't abort straight away. Instead, look if a GstM3U8MediaFile with the next sequence value is present, and if so switch to it. https://bugzilla.gnome.org/show_bug.cgi?id=750028
Diffstat (limited to 'ext/hls')
-rwxr-xr-xext/hls/m3u8.c38
1 files changed, 37 insertions, 1 deletions
diff --git a/ext/hls/m3u8.c b/ext/hls/m3u8.c
index bf33793b2..3f3c278e3 100755
--- a/ext/hls/m3u8.c
+++ b/ext/hls/m3u8.c
@@ -1085,6 +1085,40 @@ gst_m3u8_client_has_next_fragment (GstM3U8Client * client, gboolean forward)
return ret;
}
+static void
+alternate_advance (GstM3U8Client * client, gboolean forward)
+{
+ gint targetnum = client->sequence;
+ GList *tmp;
+ GstM3U8MediaFile *mf;
+
+ /* figure out the target seqnum */
+ if (forward)
+ targetnum += 1;
+ else
+ targetnum -= 1;
+
+ for (tmp = client->current->files; tmp; tmp = tmp->next) {
+ mf = (GstM3U8MediaFile *) tmp->data;
+ if (mf->sequence == targetnum)
+ break;
+ }
+ if (tmp == NULL) {
+ GST_ERROR ("Can't find next fragment");
+ return;
+ }
+ client->current_file = tmp;
+ client->sequence = targetnum;
+ if (forward)
+ client->sequence_position += mf->duration;
+ else {
+ if (client->sequence_position > mf->duration)
+ client->sequence_position -= mf->duration;
+ else
+ client->sequence_position = 0;
+ }
+}
+
void
gst_m3u8_client_advance_fragment (GstM3U8Client * client, gboolean forward)
{
@@ -1101,7 +1135,9 @@ gst_m3u8_client_advance_fragment (GstM3U8Client * client, gboolean forward)
l = g_list_find_custom (client->current->files, client,
(GCompareFunc) _find_current);
if (l == NULL) {
- GST_ERROR ("Could not find current fragment");
+ GST_DEBUG
+ ("Could not find current fragment, trying next fragment directly");
+ alternate_advance (client, forward);
GST_M3U8_CLIENT_UNLOCK (client);
return;
}