hlsdemux: Fix clearing of decryption state

Don't clear decryption state immediately after
initialising it in the start_fragment. Don't clear
the state of all streams when we want to only clear
the current stream.

https://bugzilla.gnome.org//show_bug.cgi?id=768757
This commit is contained in:
Jan Schmidt 2016-07-19 02:11:54 +10:00
parent b3b764999a
commit 41644cfa70

View file

@ -236,19 +236,25 @@ gst_hls_demux_get_bitrate (GstHLSDemux * hlsdemux)
} }
static void static void
gst_hls_demux_clear_pending_data (GstHLSDemux * hlsdemux) gst_hls_demux_stream_clear_pending_data (GstHLSDemuxStream * hls_stream)
{
if (hls_stream->pending_encrypted_data)
gst_adapter_clear (hls_stream->pending_encrypted_data);
gst_buffer_replace (&hls_stream->pending_decrypted_buffer, NULL);
gst_buffer_replace (&hls_stream->pending_typefind_buffer, NULL);
hls_stream->current_offset = -1;
gst_hls_demux_stream_decrypt_end (hls_stream);
}
static void
gst_hls_demux_clear_all_pending_data (GstHLSDemux * hlsdemux)
{ {
GstAdaptiveDemux *demux = (GstAdaptiveDemux *) hlsdemux; GstAdaptiveDemux *demux = (GstAdaptiveDemux *) hlsdemux;
GList *walk; GList *walk;
for (walk = demux->streams; walk != NULL; walk = walk->next) { for (walk = demux->streams; walk != NULL; walk = walk->next) {
GstHLSDemuxStream *hls_stream = GST_HLS_DEMUX_STREAM_CAST (walk->data); GstHLSDemuxStream *hls_stream = GST_HLS_DEMUX_STREAM_CAST (walk->data);
if (hls_stream->pending_encrypted_data) gst_hls_demux_stream_clear_pending_data (hls_stream);
gst_adapter_clear (hls_stream->pending_encrypted_data);
gst_buffer_replace (&hls_stream->pending_decrypted_buffer, NULL);
gst_buffer_replace (&hls_stream->pending_typefind_buffer, NULL);
hls_stream->current_offset = -1;
gst_hls_demux_stream_decrypt_end (hls_stream);
} }
} }
@ -276,7 +282,7 @@ gst_hls_demux_seek (GstAdaptiveDemux * demux, GstEvent * seek)
/* properly cleanup pending decryption status */ /* properly cleanup pending decryption status */
if (flags & GST_SEEK_FLAG_FLUSH) { if (flags & GST_SEEK_FLAG_FLUSH) {
gst_hls_demux_clear_pending_data (hlsdemux); gst_hls_demux_clear_all_pending_data (hlsdemux);
} }
/* Use I-frame variants for trick modes */ /* Use I-frame variants for trick modes */
@ -406,7 +412,7 @@ gst_hls_demux_setup_streams (GstAdaptiveDemux * demux)
GstHLSDemuxStream *hlsdemux_stream; GstHLSDemuxStream *hlsdemux_stream;
/* only 1 output supported */ /* only 1 output supported */
gst_hls_demux_clear_pending_data (hlsdemux); gst_hls_demux_clear_all_pending_data (hlsdemux);
stream = gst_adaptive_demux_stream_new (demux, stream = gst_adaptive_demux_stream_new (demux,
gst_hls_demux_create_pad (hlsdemux)); gst_hls_demux_create_pad (hlsdemux));
@ -557,6 +563,8 @@ gst_hls_demux_start_fragment (GstAdaptiveDemux * demux,
GstHLSDemux *hlsdemux = GST_HLS_DEMUX_CAST (demux); GstHLSDemux *hlsdemux = GST_HLS_DEMUX_CAST (demux);
const GstHLSKey *key; const GstHLSKey *key;
gst_hls_demux_stream_clear_pending_data (hls_stream);
/* If no decryption is needed, there's nothing to be done here */ /* If no decryption is needed, there's nothing to be done here */
if (hls_stream->current_key == NULL) if (hls_stream->current_key == NULL)
return TRUE; return TRUE;
@ -571,8 +579,6 @@ gst_hls_demux_start_fragment (GstAdaptiveDemux * demux,
gst_hls_demux_stream_decrypt_start (hls_stream, key->data, gst_hls_demux_stream_decrypt_start (hls_stream, key->data,
hls_stream->current_iv); hls_stream->current_iv);
gst_hls_demux_clear_pending_data (hlsdemux);
return TRUE; return TRUE;
key_failed: key_failed:
@ -653,7 +659,6 @@ static GstFlowReturn
gst_hls_demux_finish_fragment (GstAdaptiveDemux * demux, gst_hls_demux_finish_fragment (GstAdaptiveDemux * demux,
GstAdaptiveDemuxStream * stream) GstAdaptiveDemuxStream * stream)
{ {
GstHLSDemux *hlsdemux = GST_HLS_DEMUX_CAST (demux);
GstHLSDemuxStream *hls_stream = GST_HLS_DEMUX_STREAM_CAST (stream); // FIXME: pass HlsStream into function GstHLSDemuxStream *hls_stream = GST_HLS_DEMUX_STREAM_CAST (stream); // FIXME: pass HlsStream into function
GstFlowReturn ret = GST_FLOW_OK; GstFlowReturn ret = GST_FLOW_OK;
@ -682,7 +687,7 @@ gst_hls_demux_finish_fragment (GstAdaptiveDemux * demux,
hls_stream->pending_decrypted_buffer = NULL; hls_stream->pending_decrypted_buffer = NULL;
} }
} }
gst_hls_demux_clear_pending_data (hlsdemux); gst_hls_demux_stream_clear_pending_data (hls_stream);
if (ret == GST_FLOW_OK || ret == GST_FLOW_NOT_LINKED) if (ret == GST_FLOW_OK || ret == GST_FLOW_NOT_LINKED)
return gst_adaptive_demux_stream_advance_fragment (demux, stream, return gst_adaptive_demux_stream_advance_fragment (demux, stream,
@ -868,7 +873,7 @@ gst_hls_demux_reset (GstAdaptiveDemux * ademux)
demux->srcpad_counter = 0; demux->srcpad_counter = 0;
gst_hls_demux_clear_pending_data (demux); gst_hls_demux_clear_all_pending_data (demux);
} }
static gchar * static gchar *