qtdemux: attach cbcs crypt info at the right moment

Before it was always added but that can cause issues when the stream begins
unencrypted.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5096>
This commit is contained in:
Xabier Rodriguez Calvar 2023-07-21 12:48:08 +02:00 committed by Tim-Philipp Müller
parent b4f137e2ba
commit 1a3deef85f

View file

@ -6092,13 +6092,22 @@ gst_qtdemux_push_buffer (GstQTDemux * qtdemux, QtDemuxStream * stream,
if (info->crypto_info == NULL) { if (info->crypto_info == NULL) {
if (stream->protection_scheme_type == FOURCC_cbcs) { if (stream->protection_scheme_type == FOURCC_cbcs) {
crypto_info = qtdemux_get_cenc_sample_properties (qtdemux, stream, 0); if (CUR_STREAM (stream)->fourcc == FOURCC_enca ||
if (!crypto_info || !gst_buffer_add_protection_meta (buf, crypto_info)) { CUR_STREAM (stream)->fourcc == FOURCC_encs ||
GST_ERROR_OBJECT (qtdemux, CUR_STREAM (stream)->fourcc == FOURCC_enct ||
"failed to attach cbcs metadata to buffer"); CUR_STREAM (stream)->fourcc == FOURCC_encv) {
qtdemux_gst_structure_free (crypto_info); crypto_info = qtdemux_get_cenc_sample_properties (qtdemux, stream, 0);
if (!crypto_info
|| !gst_buffer_add_protection_meta (buf, crypto_info)) {
GST_ERROR_OBJECT (qtdemux,
"failed to attach cbcs metadata to buffer");
qtdemux_gst_structure_free (crypto_info);
} else {
GST_TRACE_OBJECT (qtdemux, "added cbcs protection metadata");
}
} else { } else {
GST_TRACE_OBJECT (qtdemux, "added cbcs protection metadata"); GST_TRACE_OBJECT (qtdemux,
"cbcs stream is not encrypted yet, not adding protection metadata");
} }
} else { } else {
GST_DEBUG_OBJECT (qtdemux, GST_DEBUG_OBJECT (qtdemux,