Bug 1335295 - [EME] Add pref to override EME decrypt/decode with blank decoder. r?jya
This means we can isolate whether a playback failure is in
the audio or video stream.
MozReview-Commit-ID: G4broHPaAkX
--- a/dom/media/MediaPrefs.h
+++ b/dom/media/MediaPrefs.h
@@ -129,16 +129,18 @@ private:
#endif
DECL_MEDIA_PREF("media.decoder.fuzzing.enabled", PDMFuzzingEnabled, bool, false);
DECL_MEDIA_PREF("media.decoder.fuzzing.video-output-minimum-interval-ms", PDMFuzzingInterval, uint32_t, 0);
DECL_MEDIA_PREF("media.decoder.fuzzing.dont-delay-inputexhausted", PDMFuzzingDelayInputExhausted, bool, true);
DECL_MEDIA_PREF("media.decoder.recycle.enabled", MediaDecoderCheckRecycling, bool, false);
DECL_MEDIA_PREF("media.gmp.decoder.enabled", PDMGMPEnabled, bool, true);
DECL_MEDIA_PREF("media.gmp.decoder.aac", GMPAACPreferred, uint32_t, 0);
DECL_MEDIA_PREF("media.gmp.decoder.h264", GMPH264Preferred, uint32_t, 0);
+ DECL_MEDIA_PREF("media.eme.audio.blank", EMEBlankAudio, bool, false);
+ DECL_MEDIA_PREF("media.eme.video.blank", EMEBlankVideo, bool, false);
// MediaDecoderStateMachine
DECL_MEDIA_PREF("media.suspend-bkgnd-video.enabled", MDSMSuspendBackgroundVideoEnabled, bool, false);
DECL_MEDIA_PREF("media.suspend-bkgnd-video.delay-ms", MDSMSuspendBackgroundVideoDelay, AtomicUint32, SUSPEND_BACKGROUND_VIDEO_DELAY_MS);
DECL_MEDIA_PREF("media.dormant-on-pause-timeout-ms", DormantOnPauseTimeout, int32_t, 5000);
// WebSpeech
DECL_MEDIA_PREF("media.webspeech.synth.force_global_queue", WebSpeechForceGlobal, bool, false);
--- a/dom/media/platforms/PlatformDecoderModule.h
+++ b/dom/media/platforms/PlatformDecoderModule.h
@@ -145,16 +145,17 @@ public:
protected:
PlatformDecoderModule() {}
virtual ~PlatformDecoderModule() {}
friend class H264Converter;
friend class PDMFactory;
friend class dom::RemoteDecoderModule;
+ friend class EMEDecoderModule;
// Creates a Video decoder. The layers backend is passed in so that
// decoders can determine whether hardware accelerated decoding can be used.
// Asynchronous decoding of video should be done in runnables dispatched
// to aVideoTaskQueue. If the task queue isn't needed, the decoder should
// not hold a reference to it.
// Output and errors should be returned to the reader via aCallback.
// On Windows the task queue's threads in have MSCOM initialized with
--- a/dom/media/platforms/agnostic/eme/EMEDecoderModule.cpp
+++ b/dom/media/platforms/agnostic/eme/EMEDecoderModule.cpp
@@ -11,20 +11,23 @@
#include "mozilla/CDMProxy.h"
#include "mozilla/Unused.h"
#include "nsAutoPtr.h"
#include "nsServiceManagerUtils.h"
#include "MediaInfo.h"
#include "nsClassHashtable.h"
#include "GMPDecoderModule.h"
#include "MP4Decoder.h"
+#include "MediaPrefs.h"
+#include "mozilla/EMEUtils.h"
namespace mozilla {
typedef MozPromiseRequestHolder<CDMProxy::DecryptPromise> DecryptPromiseRequestHolder;
+extern already_AddRefed<PlatformDecoderModule> CreateBlankDecoderModule();
class EMEDecryptor : public MediaDataDecoder {
public:
EMEDecryptor(MediaDataDecoder* aDecoder,
MediaDataDecoderCallback* aCallback,
CDMProxy* aProxy,
@@ -227,16 +230,22 @@ CreateDecoderWrapper(MediaDataDecoderCal
return decoder.forget();
}
already_AddRefed<MediaDataDecoder>
EMEDecoderModule::CreateVideoDecoder(const CreateDecoderParams& aParams)
{
MOZ_ASSERT(aParams.mConfig.mCrypto.mValid);
+ if (MediaPrefs::EMEBlankVideo()) {
+ EME_LOG("EMEDecoderModule::CreateVideoDecoder() creating a blank decoder.");
+ RefPtr<PlatformDecoderModule> m(CreateBlankDecoderModule());
+ return m->CreateVideoDecoder(aParams);
+ }
+
if (SupportsMimeType(aParams.mConfig.mMimeType, nullptr)) {
// GMP decodes. Assume that means it can decrypt too.
RefPtr<MediaDataDecoderProxy> wrapper =
CreateDecoderWrapper(aParams.mCallback, mProxy, aParams.mTaskQueue);
auto params = GMPVideoDecoderParams(aParams).WithCallback(wrapper);
wrapper->SetProxyTarget(new EMEVideoDecoder(mProxy, params));
return wrapper.forget();
}
@@ -258,16 +267,22 @@ already_AddRefed<MediaDataDecoder>
EMEDecoderModule::CreateAudioDecoder(const CreateDecoderParams& aParams)
{
MOZ_ASSERT(aParams.mConfig.mCrypto.mValid);
// We don't support using the GMP to decode audio.
MOZ_ASSERT(!SupportsMimeType(aParams.mConfig.mMimeType, nullptr));
MOZ_ASSERT(mPDM);
+ if (MediaPrefs::EMEBlankAudio()) {
+ EME_LOG("EMEDecoderModule::CreateAudioDecoder() creating a blank decoder.");
+ RefPtr<PlatformDecoderModule> m(CreateBlankDecoderModule());
+ return m->CreateAudioDecoder(aParams);
+ }
+
RefPtr<MediaDataDecoder> decoder(mPDM->CreateDecoder(aParams));
if (!decoder) {
return nullptr;
}
RefPtr<MediaDataDecoder> emeDecoder(new EMEDecryptor(decoder,
aParams.mCallback,
mProxy,