diff options
author | Edward Hervey <bilboed@bilboed.com> | 2015-05-28 14:01:25 +0200 |
---|---|---|
committer | Edward Hervey <bilboed@bilboed.com> | 2015-05-28 14:01:25 +0200 |
commit | e90392858948197f217215bccc1c58b765da593c (patch) | |
tree | 59e0c31f4eb5520fc94b954ef5cc13e2f036a241 | |
parent | e9f0d0fb51e8d92b566868f8fa5db10c2eccc22f (diff) |
WIP HLShls
-rwxr-xr-x | ext/hls/m3u8.c | 44 | ||||
-rw-r--r-- | gst-libs/gst/adaptivedemux/gstadaptivedemux.c | 8 |
2 files changed, 49 insertions, 3 deletions
diff --git a/ext/hls/m3u8.c b/ext/hls/m3u8.c index bf33793b2..8ac274e42 100755 --- a/ext/hls/m3u8.c +++ b/ext/hls/m3u8.c @@ -416,6 +416,8 @@ gst_m3u8_update (GstM3U8Client * client, GstM3U8 * self, gchar * data, return FALSE; } + GST_TRACE ("m3u8 contents:\n%s", data); + g_free (self->last_data); self->last_data = data; @@ -740,6 +742,7 @@ gst_m3u8_update (GstM3U8Client * client, GstM3U8 * self, gchar * data, for (walk = self->files; walk; walk = walk->next) { file = walk->data; + GST_DEBUG ("Added file (sequence:%" G_GINT64_FORMAT ")", file->sequence); duration += file->duration; if (file->sequence > client->highest_sequence_number) { if (client->highest_sequence_number >= 0) { @@ -961,6 +964,8 @@ gst_m3u8_client_update_variant_playlist (GstM3U8Client * self, gchar * data, static gboolean _find_current (GstM3U8MediaFile * file, GstM3U8Client * client) { + GST_DEBUG ("Comparing file->sequence:%" G_GINT64_FORMAT " client->sequence:%" + G_GINT64_FORMAT, file->sequence, client->sequence); return file->sequence != client->sequence; } @@ -969,10 +974,12 @@ find_next_fragment (GstM3U8Client * client, GList * l, gboolean forward) { GstM3U8MediaFile *file; + GST_DEBUG ("client->sequence:%" G_GINT64_FORMAT, client->sequence); + if (forward) { while (l) { file = l->data; - + GST_DEBUG ("Checking against %" G_GINT64_FORMAT, file->sequence); if (file->sequence >= client->sequence) break; @@ -1075,6 +1082,7 @@ gst_m3u8_client_has_next_fragment (GstM3U8Client * client, gboolean forward) GST_DEBUG ("Checking if has next fragment %" G_GINT64_FORMAT, client->sequence + (forward ? 1 : -1)); if (client->current_file) { + GST_DEBUG ("Using current_file"); ret = (forward ? client->current_file->next : client->current_file->prev) != NULL; @@ -1085,6 +1093,39 @@ 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) { @@ -1102,6 +1143,7 @@ gst_m3u8_client_advance_fragment (GstM3U8Client * client, gboolean forward) (GCompareFunc) _find_current); if (l == NULL) { GST_ERROR ("Could not find current fragment"); + alternate_advance (client, forward); GST_M3U8_CLIENT_UNLOCK (client); return; } diff --git a/gst-libs/gst/adaptivedemux/gstadaptivedemux.c b/gst-libs/gst/adaptivedemux/gstadaptivedemux.c index d2996557f..53730b077 100644 --- a/gst-libs/gst/adaptivedemux/gstadaptivedemux.c +++ b/gst-libs/gst/adaptivedemux/gstadaptivedemux.c @@ -2213,6 +2213,7 @@ static void gst_adaptive_demux_updates_loop (GstAdaptiveDemux * demux) { GstAdaptiveDemuxClass *klass = GST_ADAPTIVE_DEMUX_GET_CLASS (demux); + gint64 interv; /* Loop for updating of the playlist. This periodically checks if * the playlist is updated and does so, then signals the streaming @@ -2221,8 +2222,11 @@ gst_adaptive_demux_updates_loop (GstAdaptiveDemux * demux) /* block until the next scheduled update or the signal to quit this thread */ GST_DEBUG_OBJECT (demux, "Started updates task"); - demux->priv->next_update = - g_get_monotonic_time () + klass->get_manifest_update_interval (demux); + interv = klass->get_manifest_update_interval (demux); + GST_DEBUG_OBJECT (demux, + "subclass returned update interval of %" GST_TIME_FORMAT, + GST_TIME_ARGS (interv)); + demux->priv->next_update = g_get_monotonic_time () + interv; /* Updating playlist only needed for live playlists */ while (gst_adaptive_demux_is_live (demux)) { |