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
--- 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