mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
hlsdemux: Fix forwards and backwards searching in the files list
This commit is contained in:
parent
6039734f3e
commit
8109ed8785
1 changed files with 24 additions and 19 deletions
|
@ -679,28 +679,32 @@ out:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gint
|
static gboolean
|
||||||
_find_current (GstM3U8MediaFile * file, GstM3U8Client * client)
|
_find_current (GstM3U8MediaFile * file, GstM3U8Client * client)
|
||||||
{
|
{
|
||||||
return file->sequence == client->sequence;
|
return file->sequence != client->sequence;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static GList *
|
||||||
_find_next (GstM3U8MediaFile * file, GstM3U8Client * client)
|
find_next_fragment (GstM3U8Client * client, GList * l, gboolean forward)
|
||||||
{
|
{
|
||||||
GST_DEBUG ("Found fragment %u", (guint) file->sequence);
|
GstM3U8MediaFile *file;
|
||||||
if (file->sequence >= client->sequence)
|
|
||||||
return FALSE;
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
if (!forward)
|
||||||
_find_previous (GstM3U8MediaFile * file, GstM3U8Client * client)
|
l = g_list_last (l);
|
||||||
{
|
|
||||||
GST_DEBUG ("Found fragment %u", (guint) file->sequence);
|
while (l) {
|
||||||
if (file->sequence <= client->sequence)
|
file = l->data;
|
||||||
return FALSE;
|
|
||||||
return TRUE;
|
if (forward && file->sequence >= client->sequence)
|
||||||
|
break;
|
||||||
|
else if (!forward && file->sequence <= client->sequence)
|
||||||
|
break;
|
||||||
|
|
||||||
|
l = (forward ? l->next : l->prev);
|
||||||
|
}
|
||||||
|
|
||||||
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
|
@ -721,9 +725,8 @@ gst_m3u8_client_get_next_fragment (GstM3U8Client * client,
|
||||||
GST_M3U8_CLIENT_UNLOCK (client);
|
GST_M3U8_CLIENT_UNLOCK (client);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
l = g_list_find_custom (client->current->files, client,
|
l = find_next_fragment (client, client->current->files, forward);
|
||||||
(GCompareFunc) (forward ? _find_next : _find_previous));
|
if (!l) {
|
||||||
if (l == NULL) {
|
|
||||||
GST_M3U8_CLIENT_UNLOCK (client);
|
GST_M3U8_CLIENT_UNLOCK (client);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -750,6 +753,8 @@ gst_m3u8_client_get_next_fragment (GstM3U8Client * client,
|
||||||
if (iv)
|
if (iv)
|
||||||
*iv = file->iv;
|
*iv = file->iv;
|
||||||
|
|
||||||
|
client->sequence = file->sequence;
|
||||||
|
|
||||||
GST_M3U8_CLIENT_UNLOCK (client);
|
GST_M3U8_CLIENT_UNLOCK (client);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue