Bug 1307019 - Ensure MDSM and MFR have consistent view of what counts as encrypted. r=jya draft
authorChris Pearce <cpearce@mozilla.com>
Mon, 03 Oct 2016 16:34:31 +1300
changeset 420248 85b303597a401a69f7e4ac63a267d8c8eb52ffa5
parent 419914 7c576fe3279d87543f0a03b844eba7bc215e17f1
child 420249 b03910c96c8f61622ce7bc9fb7b53adc209526a4
push id31145
push usercpearce@mozilla.com
push dateMon, 03 Oct 2016 20:16:28 +0000
reviewersjya
bugs1307019, 1300069
milestone52.0a1
Bug 1307019 - Ensure MDSM and MFR have consistent view of what counts as encrypted. r=jya The patch in bug 1300069 introduced an inconsistency between what the MediaDecoderStateMachine and the MediaFormatReader consider an encrypted stream. The MDSM considered a stream encrypted if mInfo.IsEncrypted() is true, and that only takes into account the PSSH. Whereas the MFR only considers the presence of a TENC box to indicate encryptedness. This would cause the MDSM to not wait for the CDM before trying to start decoding. So if you setup the MediaSource before setting the MediaKeys on the MediaElement, you'll end up trying to create an EME decoder without a CDMProxy, and that causes a null pointer deref and crash. This patch ensures that the MDSM and the MFR use the same logic to determine whether a stream is encrypted. MozReview-Commit-ID: KGuYTuP9XDL
dom/media/MediaInfo.h
--- a/dom/media/MediaInfo.h
+++ b/dom/media/MediaInfo.h
@@ -459,17 +459,18 @@ public:
     // Set dummy values so that HasAudio() will return true;
     // See AudioInfo::IsValid()
     mAudio.mChannels = 2;
     mAudio.mRate = 44100;
   }
 
   bool IsEncrypted() const
   {
-    return mCrypto.IsEncrypted();
+    return (HasAudio() && mAudio.mCrypto.mValid) ||
+           (HasVideo() && mVideo.mCrypto.mValid);
   }
 
   bool HasValidMedia() const
   {
     return HasVideo() || HasAudio();
   }
 
   void AssertValid() const