Bug 1496501 - Do not mark CDM input as unencrypted even if it has no encrypted bytes. r=cpearce
authorBryce Van Dyk <bvandyk@mozilla.com>
Mon, 08 Oct 2018 22:34:32 +0000
changeset 495855 2cdf1848b6a7f7e006233a95ed78085d19d6ab6f
parent 495854 0c2d8b9fe4a7eb428be7cbb44757ce1b1558f0dc
child 495856 80f3e8b1d66fb5a9dbaba457ae2535a679ec49c5
push id9984
push userffxbld-merge
push dateMon, 15 Oct 2018 21:07:35 +0000
treeherdermozilla-beta@183d27ea8570 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1496501, 1494178
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1496501 - Do not mark CDM input as unencrypted even if it has no encrypted bytes. r=cpearce Bug 1494178 added code to mark samples with 0 encrypted ranges as unencrypted before they were fed to the CDM. This was to catch issues where we could mark such unencrypted samples as encrypted. However, the CDM expects certain samples that are clear to still be marked as encrypted. Specifically, WebM samples should be marked as encrypted if they are from an encrypted track and have the signal byte's encryption bit set (a marker for if the packet is encrypted), even if they have no encrypted ranges. The WebM demuxer is already doing this. Further inspection and testing of the mp4 demuxer shows it is behaving in line with Chromium's current mp4 parser, which we can expect prepares its data sensibly for Widevine. As the code removed here was added as a safety fallback, but is causing issues, and as the demuxers already appear to be doing the right thing, the fallback code can be removed. Differential Revision: https://phabricator.services.mozilla.com/D8024
--- a/dom/media/gmp/ChromiumCDMChild.cpp
+++ b/dom/media/gmp/ChromiumCDMChild.cpp
@@ -679,42 +679,16 @@ ConvertToCdmEncryptionScheme(const GMPEn
     case GMPEncryptionScheme::kGMPEncryptionCbcs:
       return cdm::EncryptionScheme::kCbcs;
       MOZ_ASSERT_UNREACHABLE("Cannot convert invalid encryption scheme!");
       return cdm::EncryptionScheme::kUnencrypted;
-static cdm::EncryptionScheme
-ConvertToCdmEncryptionScheme(const GMPEncryptionScheme& aEncryptionScheme,
-                             uint64_t aNumCipherBytes)
-  if (aNumCipherBytes == 0) {
-    // Starting at CDM10, if fed a sample marked as encrypted that has no
-    // encrypted bytes, the CDM will give a decryption error. So we mark these
-    // as unencrypted to attempt to avoid such errors -- though ideally our
-    // demuxers should not emit such data, so log it.
-    if (aEncryptionScheme != GMPEncryptionScheme::kGMPEncryptionNone) {
-      GMP_LOG(
-        "ChromiumCDMChild::ConvertToCdmEncryptionScheme() got scheme marked "
-        "as encrypted, but with no cipher bytes! This should be caught "
-        "earlier, preferably by the demuxer! Returning "
-        "cdm::EncryptionScheme::kUnencrypted");
-    }
-    return cdm::EncryptionScheme::kUnencrypted;
-  }
-  if (aEncryptionScheme == GMPEncryptionScheme::kGMPEncryptionNone) {
-    GMP_LOG("ChromiumCDMChild::ConvertToCdmEncryptionScheme() got scheme "
-            "marked as unecrypted but with > 0 cipher bytes! Something is "
-            "buggy to emit such data -- likey a demuxer");
-  }
-  return ConvertToCdmEncryptionScheme(aEncryptionScheme);
 static void
 InitInputBuffer(const CDMInputBuffer& aBuffer,
                 nsTArray<cdm::SubsampleEntry>& aSubSamples,
                 cdm::InputBuffer_2& aInputBuffer)
   aInputBuffer.data = aBuffer.mData().get<uint8_t>();
   aInputBuffer.data_size = aBuffer.mData().Size<uint8_t>();
@@ -724,27 +698,25 @@ InitInputBuffer(const CDMInputBuffer& aB
     MOZ_ASSERT(aBuffer.mEncryptionScheme() ==
     aInputBuffer.key_id = aBuffer.mKeyId().Elements();
     aInputBuffer.key_id_size = aBuffer.mKeyId().Length();
     aInputBuffer.iv = aBuffer.mIV().Elements();
     aInputBuffer.iv_size = aBuffer.mIV().Length();
-    uint64_t numCipherBytes = 0;
     for (size_t i = 0; i < aBuffer.mCipherBytes().Length(); i++) {
         aBuffer.mClearBytes()[i], aBuffer.mCipherBytes()[i] });
-      numCipherBytes += aBuffer.mCipherBytes()[i];
     aInputBuffer.subsamples = aSubSamples.Elements();
     aInputBuffer.num_subsamples = aSubSamples.Length();
     aInputBuffer.encryption_scheme =
-      ConvertToCdmEncryptionScheme(aBuffer.mEncryptionScheme(), numCipherBytes);
+      ConvertToCdmEncryptionScheme(aBuffer.mEncryptionScheme());
   aInputBuffer.timestamp = aBuffer.mTimestamp();
 ChromiumCDMChild::HasShmemOfSize(size_t aSize) const
   for (const ipc::Shmem& shmem : mBuffers) {