hlsdemux: set duration in outgoing buffers

Currently we push each fragment as a single buffer.
This commit is contained in:
Andoni Morales Alastruey 2011-04-14 13:34:53 +02:00 committed by Tim-Philipp Müller
parent 7ec71fb446
commit 851e9b1f8d
3 changed files with 15 additions and 13 deletions

View file

@ -1015,12 +1015,11 @@ gst_hls_demux_get_next_fragment (GstHLSDemux * demux, gboolean retry)
GstBuffer *buf;
guint avail;
const gchar *next_fragment_uri;
GstClockTime duration;
gboolean discont;
next_fragment_uri =
gst_m3u8_client_get_next_fragment (demux->client, &discont);
if (!next_fragment_uri) {
if (!gst_m3u8_client_get_next_fragment (demux->client, &discont,
&next_fragment_uri, &duration)) {
GST_INFO_OBJECT (demux, "This playlist doesn't contain more fragments");
demux->end_of_playlist = TRUE;
GST_TASK_SIGNAL (demux->task);
@ -1034,6 +1033,7 @@ gst_hls_demux_get_next_fragment (GstHLSDemux * demux, gboolean retry)
avail = gst_adapter_available (demux->download);
buf = gst_adapter_take_buffer (demux->download, avail);
GST_BUFFER_DURATION (buf) = duration;
if (G_UNLIKELY (demux->input_caps == NULL)) {
demux->input_caps = gst_type_find_helper_for_buffer (NULL, buf, NULL);

View file

@ -432,29 +432,31 @@ _find_next (GstM3U8MediaFile * file, GstM3U8Client * client)
return TRUE;
}
const gchar *
gboolean
gst_m3u8_client_get_next_fragment (GstM3U8Client * client,
gboolean * discontinuity)
gboolean * discontinuity, const gchar ** uri, GstClockTime * duration)
{
GList *l;
GstM3U8MediaFile *file;
g_return_val_if_fail (client != NULL, NULL);
g_return_val_if_fail (client->current != NULL, NULL);
g_return_val_if_fail (discontinuity != NULL, NULL);
g_return_val_if_fail (client != NULL, FALSE);
g_return_val_if_fail (client->current != NULL, FALSE);
g_return_val_if_fail (discontinuity != NULL, FALSE);
GST_DEBUG ("Looking for fragment %d", client->sequence);
l = g_list_find_custom (client->current->files, client,
(GCompareFunc) _find_next);
if (l == NULL)
return NULL;
return FALSE;
file = GST_M3U8_MEDIA_FILE (l->data);
*discontinuity = client->sequence != file->sequence;
client->sequence = file->sequence + 1;
return file->uri;
*uri = file->uri;
*duration = file->duration * GST_SECOND;
return TRUE;
}
static void

View file

@ -75,8 +75,8 @@ GstM3U8Client *gst_m3u8_client_new (const gchar * uri);
void gst_m3u8_client_free (GstM3U8Client * client);
gboolean gst_m3u8_client_update (GstM3U8Client * client, gchar * data);
void gst_m3u8_client_set_current (GstM3U8Client * client, GstM3U8 * m3u8);
const gchar *gst_m3u8_client_get_next_fragment (GstM3U8Client * client,
gboolean * discontinuity);
gboolean gst_m3u8_client_get_next_fragment (GstM3U8Client * client,
gboolean * discontinuity, const gchar ** uri, GstClockTime * duration);
GstClockTime gst_m3u8_client_get_duration (GstM3U8Client * client);
const gchar *gst_m3u8_client_get_uri(GstM3U8Client * client);
gboolean gst_m3u8_client_has_variant_playlist(GstM3U8Client * client);