diff --git a/dom/media/MediaDataDemuxer.h b/dom/media/MediaDataDemuxer.h index aa9bf6e674b9..79ef5f5f0a05 100644 --- a/dom/media/MediaDataDemuxer.h +++ b/dom/media/MediaDataDemuxer.h @@ -35,7 +35,7 @@ class MediaDataDemuxer : public DecoderDoctorLifeLogger { public: NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MediaDataDemuxer) - typedef MozPromise + typedef MozPromise InitPromise; // Initializes the demuxer. Other methods cannot be called unless diff --git a/dom/media/MediaDecoder.cpp b/dom/media/MediaDecoder.cpp index 7f2b2b0970b1..397854406cf2 100644 --- a/dom/media/MediaDecoder.cpp +++ b/dom/media/MediaDecoder.cpp @@ -436,12 +436,13 @@ void MediaDecoder::OnPlaybackErrorEvent(const MediaResult& aError) { return; } - // External engine can't play the resource, try to use our own state machine - // again. Here we will create a new state machine immediately and asynchrously - // shutdown the old one because we don't want to dispatch any task to the old - // state machine. Therefore, we will disconnect anything related with the old - // state machine, create a new state machine and setup events/mirror/etc, then - // shutdown the old one and release its reference once it finishes shutdown. + // External engine can't play the resource or we intentionally disable it, try + // to use our own state machine again. Here we will create a new state machine + // immediately and asynchrously shutdown the old one because we don't want to + // dispatch any task to the old state machine. Therefore, we will disconnect + // anything related with the old state machine, create a new state machine and + // setup events/mirror/etc, then shutdown the old one and release its + // reference once it finishes shutdown. MOZ_ASSERT(aError == NS_ERROR_DOM_MEDIA_EXTERNAL_ENGINE_NOT_SUPPORTED_ERR); RefPtr discardStateMachine = mDecoderStateMachine; @@ -1369,6 +1370,16 @@ bool MediaDecoder::CanPlayThrough() { RefPtr MediaDecoder::SetCDMProxy(CDMProxy* aProxy) { MOZ_ASSERT(NS_IsMainThread()); +#ifdef MOZ_WMF_MEDIA_ENGINE + // DRM playback via the media engine is disabled, switch back to the state + // machine using Gecko's media pipeline. + if (GetStateMachine()->IsExternalStateMachine() && + !StaticPrefs::media_wmf_media_engine_drm_playback()) { + LOG("Disable external state machine due to DRM playback not allowed"); + OnPlaybackErrorEvent( + MediaResult{NS_ERROR_DOM_MEDIA_EXTERNAL_ENGINE_NOT_SUPPORTED_ERR}); + } +#endif return GetStateMachine()->SetCDMProxy(aProxy); } diff --git a/modules/libpref/init/StaticPrefList.yaml b/modules/libpref/init/StaticPrefList.yaml index 411da168e1a6..5646f9de4bb6 100644 --- a/modules/libpref/init/StaticPrefList.yaml +++ b/modules/libpref/init/StaticPrefList.yaml @@ -10212,6 +10212,12 @@ value: false mirror: always +# This allows playing DRM video via the media engine pipeline. +- name: media.wmf.media-engine.drm-playback + type: RelaxedAtomicBool + value: false + mirror: always + # The amount of video raw data the engine stream will queue - name: media.wmf.media-engine.raw-data-threshold.video type: RelaxedAtomicInt32