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
This commit is contained in:
Sebastian Dröge 2016-03-31 13:39:59 +03:00
parent 3469104a47
commit 8344854c4c
2 changed files with 13 additions and 2 deletions

View file

@ -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;

View file

@ -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;
};