tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 7dd78ad473f3d3c94a7c02cfec8d0bffa8d72e97
parent 2a1f1919071ce5dc161fc07db132a8b6de9c7912
Author: Andrew Osmond <aosmond@gmail.com>
Date:   Thu,  4 Dec 2025 02:35:00 +0000

Bug 2003943 - MediaDrmRemoteCDMParent::CreateCryptoInfo should use mConstantIV instead of IV for CBCS. r=media-playback-reviewers,jolin

Rather than explicitly failing, this manifested as buffering problems
from the ffmpeg perspective after a certain number of frames were
successfully decrypted/decoded.

Differential Revision: https://phabricator.services.mozilla.com/D275011

Diffstat:
Mdom/media/eme/mediadrm/MediaDrmRemoteCDMParent.cpp | 44++++++++++++++++++++++++--------------------
1 file changed, 24 insertions(+), 20 deletions(-)

diff --git a/dom/media/eme/mediadrm/MediaDrmRemoteCDMParent.cpp b/dom/media/eme/mediadrm/MediaDrmRemoteCDMParent.cpp @@ -808,10 +808,31 @@ already_AddRefed<MediaDrmCryptoInfo> MediaDrmRemoteCDMParent::CreateCryptoInfo( plainSizes[0] = newLeadingPlainSize.value(); } + const CopyableTArray<uint8_t>* srcIV; + cryptoinfo_mode_t mode; + switch (cryptoObj.mCryptoScheme) { + case CryptoScheme::None: + mode = AMEDIACODECRYPTOINFO_MODE_CLEAR; + srcIV = &cryptoObj.mIV; + break; + case CryptoScheme::Cenc: + mode = AMEDIACODECRYPTOINFO_MODE_AES_CTR; + srcIV = &cryptoObj.mIV; + break; + case CryptoScheme::Cbcs: + case CryptoScheme::Cbcs_1_9: + mode = AMEDIACODECRYPTOINFO_MODE_AES_CBC; + srcIV = &cryptoObj.mConstantIV; + break; + default: + MOZ_ASSERT_UNREACHABLE("Unhandled CryptoScheme!"); + return nullptr; + } + uint8_t key[16] = {}; uint8_t iv[16] = {}; - if (NS_WARN_IF(cryptoObj.mIV.Length() > sizeof(iv))) { + if (NS_WARN_IF(srcIV->Length() > sizeof(iv))) { MOZ_ASSERT_UNREACHABLE("IV too big for Android!"); return nullptr; } @@ -821,31 +842,14 @@ already_AddRefed<MediaDrmCryptoInfo> MediaDrmRemoteCDMParent::CreateCryptoInfo( return nullptr; } - if (!cryptoObj.mIV.IsEmpty()) { - memcpy(iv, cryptoObj.mIV.Elements(), cryptoObj.mIV.Length()); + if (!srcIV->IsEmpty()) { + memcpy(iv, srcIV->Elements(), srcIV->Length()); } if (!cryptoObj.mKeyId.IsEmpty()) { memcpy(key, cryptoObj.mKeyId.Elements(), cryptoObj.mKeyId.Length()); } - cryptoinfo_mode_t mode; - switch (cryptoObj.mCryptoScheme) { - case CryptoScheme::None: - mode = AMEDIACODECRYPTOINFO_MODE_CLEAR; - break; - case CryptoScheme::Cenc: - mode = AMEDIACODECRYPTOINFO_MODE_AES_CTR; - break; - case CryptoScheme::Cbcs: - case CryptoScheme::Cbcs_1_9: - mode = AMEDIACODECRYPTOINFO_MODE_AES_CBC; - break; - default: - MOZ_ASSERT_UNREACHABLE("Unhandled CryptoScheme!"); - return nullptr; - } - AMediaCodecCryptoInfo* cryptoInfo = AMediaCodecCryptoInfo_new( static_cast<int32_t>(numSubSamples), key, iv, mode, plainSizes.Elements(), encryptedSizes.Elements());