From 46ad1199deeaf6ba2db31fb3398d3eaa9abdbb2e Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Wed, 13 Dec 2017 12:07:12 +0100 Subject: Don't build EME-specific subroutines without EME. - Checks for restricted or encrypted content - Dispatching 'encrypted' events - Dispatching 'key needed' events - HTML Media Element media keys system - EME telemetry - HTML Media Element EME API This is the main bulk for #26, isolating EME-specific code. --- dom/media/MediaFormatReader.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'dom/media/MediaFormatReader.cpp') diff --git a/dom/media/MediaFormatReader.cpp b/dom/media/MediaFormatReader.cpp index 2093803ad..06e8b963b 100644 --- a/dom/media/MediaFormatReader.cpp +++ b/dom/media/MediaFormatReader.cpp @@ -346,8 +346,12 @@ MediaFormatReader::DecoderFactory::DoCreateDecoder(TrackType aTrack) if (!mOwner->mPlatform) { mOwner->mPlatform = new PDMFactory(); if (mOwner->IsEncrypted()) { +#ifdef MOZ_EME MOZ_ASSERT(mOwner->mCDMProxy); mOwner->mPlatform->SetCDMProxy(mOwner->mCDMProxy); +#else + return MediaResult(NS_ERROR_DOM_MEDIA_FATAL_ERR, "EME not supported"); +#endif } } @@ -577,6 +581,7 @@ MediaFormatReader::InitInternal() return NS_OK; } +#ifdef MOZ_EME class DispatchKeyNeededEvent : public Runnable { public: DispatchKeyNeededEvent(AbstractMediaDecoder* aDecoder, @@ -602,6 +607,7 @@ private: nsTArray mInitData; nsString mInitDataType; }; +#endif void MediaFormatReader::SetCDMProxy(CDMProxy* aProxy) @@ -618,7 +624,11 @@ MediaFormatReader::SetCDMProxy(CDMProxy* aProxy) bool MediaFormatReader::IsWaitingOnCDMResource() { MOZ_ASSERT(OnTaskQueue()); +#ifdef MOZ_EME return IsEncrypted() && !mCDMProxy; +#else + return false; +#endif } RefPtr @@ -725,11 +735,13 @@ MediaFormatReader::OnDemuxerInitDone(nsresult) UniquePtr crypto = mDemuxer->GetCrypto(); if (mDecoder && crypto && crypto->IsEncrypted()) { +#ifdef MOZ_EME // Try and dispatch 'encrypted'. Won't go if ready state still HAVE_NOTHING. for (uint32_t i = 0; i < crypto->mInitDatas.Length(); i++) { NS_DispatchToMainThread( new DispatchKeyNeededEvent(mDecoder, crypto->mInitDatas[i].mInitData, crypto->mInitDatas[i].mType)); } +#endif mInfo.mCrypto = *crypto; } -- cgit v1.2.3