From: Sebastian Dröge Date: Thu, 31 Mar 2016 10:39:59 +0000 (+0300) Subject: hlsdemux: Properly keep track of current offset X-Git-Tag: 1.10.4~512 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8344854c4c62e13e23b073ecdee8d42ca9da4653;p=platform%2Fupstream%2Fgst-plugins-bad.git hlsdemux: Properly keep track of current offset GstAdapter does not guarantee to pass through all the offsets, we have to keep track of it ourselves. https://bugzilla.gnome.org/show_bug.cgi?id=764684 --- diff --git a/ext/hls/gsthlsdemux.c b/ext/hls/gsthlsdemux.c index 7afcfde..14e8819 100644 --- a/ext/hls/gsthlsdemux.c +++ b/ext/hls/gsthlsdemux.c @@ -236,6 +236,7 @@ gst_hls_demux_clear_pending_data (GstHLSDemux * hlsdemux) gst_adapter_clear (hlsdemux->pending_encrypted_data); gst_buffer_replace (&hlsdemux->pending_decrypted_buffer, NULL); gst_buffer_replace (&hlsdemux->pending_typefind_buffer, NULL); + hlsdemux->current_offset = -1; } static gboolean @@ -586,8 +587,13 @@ gst_hls_demux_handle_buffer (GstAdaptiveDemux * demux, g_assert (hlsdemux->pending_typefind_buffer == NULL); - if (buffer) + if (buffer) { + buffer = gst_buffer_make_writable (buffer); + GST_BUFFER_OFFSET (buffer) = hlsdemux->current_offset; + hlsdemux->current_offset += gst_buffer_get_size (buffer); + GST_BUFFER_OFFSET_END (buffer) = hlsdemux->current_offset; return gst_adaptive_demux_stream_push_buffer (stream, buffer); + } return GST_FLOW_OK; } @@ -637,6 +643,10 @@ gst_hls_demux_data_received (GstAdaptiveDemux * demux, { GstHLSDemux *hlsdemux = GST_HLS_DEMUX_CAST (demux); + if (hlsdemux->current_offset == -1) + hlsdemux->current_offset = + GST_BUFFER_OFFSET_IS_VALID (buffer) ? GST_BUFFER_OFFSET (buffer) : 0; + /* Is it encrypted? */ if (hlsdemux->current_key) { GError *err = NULL; diff --git a/ext/hls/gsthlsdemux.h b/ext/hls/gsthlsdemux.h index da84069..f0c530e 100644 --- a/ext/hls/gsthlsdemux.h +++ b/ext/hls/gsthlsdemux.h @@ -87,7 +87,8 @@ struct _GstHLSDemux GstAdapter *pending_encrypted_data; /* for chunking data into 16 byte multiples for decryption */ GstBuffer *pending_decrypted_buffer; /* last decrypted buffer for pkcs7 unpadding. We only know that it is the last at EOS */ - GstBuffer *pending_typefind_buffer; /* for collecting data until typefind succeeds */ + GstBuffer *pending_typefind_buffer; /* for collecting data until typefind succeeds */ + guint64 current_offset; /* offset we're currently at */ gboolean reset_pts; };