summaryrefslogtreecommitdiffstats
path: root/dom/media
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@gmail.com>2017-12-13 12:07:12 +0100
committerwolfbeast <mcwerewolf@gmail.com>2018-02-24 10:20:45 +0100
commit46ad1199deeaf6ba2db31fb3398d3eaa9abdbb2e (patch)
treebdb1316d0388f03c6b7e4171f56f5bac46c41d87 /dom/media
parent55d03738f9f79e30bab6294b023176d1a65ab5c3 (diff)
downloadUXP-46ad1199deeaf6ba2db31fb3398d3eaa9abdbb2e.tar
UXP-46ad1199deeaf6ba2db31fb3398d3eaa9abdbb2e.tar.gz
UXP-46ad1199deeaf6ba2db31fb3398d3eaa9abdbb2e.tar.lz
UXP-46ad1199deeaf6ba2db31fb3398d3eaa9abdbb2e.tar.xz
UXP-46ad1199deeaf6ba2db31fb3398d3eaa9abdbb2e.zip
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.
Diffstat (limited to 'dom/media')
-rw-r--r--dom/media/MediaDecoderOwner.h2
-rw-r--r--dom/media/MediaFormatReader.cpp12
-rw-r--r--dom/media/mediasource/TrackBuffersManager.cpp4
3 files changed, 18 insertions, 0 deletions
diff --git a/dom/media/MediaDecoderOwner.h b/dom/media/MediaDecoderOwner.h
index f884686fb..f993b4324 100644
--- a/dom/media/MediaDecoderOwner.h
+++ b/dom/media/MediaDecoderOwner.h
@@ -143,11 +143,13 @@ public:
// reference to the decoder to prevent further calls into the decoder.
virtual void NotifyXPCOMShutdown() = 0;
+#ifdef MOZ_EME
// Dispatches a "encrypted" event to the HTMLMediaElement, with the
// provided init data. Actual dispatch may be delayed until HAVE_METADATA.
// Main thread only.
virtual void DispatchEncrypted(const nsTArray<uint8_t>& aInitData,
const nsAString& aInitDataType) = 0;
+#endif
};
} // namespace mozilla
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<uint8_t> 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<MediaDecoderReader::MetadataPromise>
@@ -725,11 +735,13 @@ MediaFormatReader::OnDemuxerInitDone(nsresult)
UniquePtr<EncryptionInfo> 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;
}
diff --git a/dom/media/mediasource/TrackBuffersManager.cpp b/dom/media/mediasource/TrackBuffersManager.cpp
index 4265aed81..ac6d82411 100644
--- a/dom/media/mediasource/TrackBuffersManager.cpp
+++ b/dom/media/mediasource/TrackBuffersManager.cpp
@@ -58,6 +58,7 @@ AppendStateToStr(SourceBufferAttributes::AppendState aState)
static Atomic<uint32_t> sStreamSourceID(0u);
+#ifdef MOZ_EME
class DispatchKeyNeededEvent : public Runnable {
public:
DispatchKeyNeededEvent(AbstractMediaDecoder* aDecoder,
@@ -83,6 +84,7 @@ private:
nsTArray<uint8_t> mInitData;
nsString mInitDataType;
};
+#endif
TrackBuffersManager::TrackBuffersManager(MediaSourceDecoder* aParentDecoder,
const nsACString& aType)
@@ -1097,12 +1099,14 @@ TrackBuffersManager::OnDemuxerInitDone(nsresult)
UniquePtr<EncryptionInfo> crypto = mInputDemuxer->GetCrypto();
if (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(mParentDecoder, crypto->mInitDatas[i].mInitData,
crypto->mInitDatas[i].mType));
}
+#endif
info.mCrypto = *crypto;
// We clear our crypto init data array, so the MediaFormatReader will
// not emit an encrypted event for the same init data again.