mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1206977: P8. Have PDMFactory directly manage the EMEDecoderModule. r=cpearce
This commit is contained in:
parent
00bc1ab395
commit
307d23c01c
@ -170,7 +170,7 @@ nsresult
|
||||
MediaFormatReader::Init(MediaDecoderReader* aCloneDonor)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread(), "Must be on main thread.");
|
||||
PlatformDecoderModule::Init();
|
||||
PDMFactory::Init();
|
||||
|
||||
InitLayersBackendType();
|
||||
|
||||
@ -380,29 +380,19 @@ MediaFormatReader::EnsureDecodersCreated()
|
||||
MOZ_ASSERT(OnTaskQueue());
|
||||
|
||||
if (!mPlatform) {
|
||||
mPlatform = new PDMFactory();
|
||||
NS_ENSURE_TRUE(mPlatform, false);
|
||||
if (IsEncrypted()) {
|
||||
#ifdef MOZ_EME
|
||||
// We have encrypted audio or video. We'll need a CDM to decrypt and
|
||||
// possibly decode this. Wait until we've received a CDM from the
|
||||
// JavaScript player app. Note: we still go through the motions here
|
||||
// even if EME is disabled, so that if script tries and fails to create
|
||||
// a CDM, we can detect that and notify chrome and show some UI
|
||||
// explaining that we failed due to EME being disabled.
|
||||
MOZ_ASSERT(mCDMProxy);
|
||||
mPlatform = PlatformDecoderModule::CreateCDMWrapper(mCDMProxy);
|
||||
NS_ENSURE_TRUE(mPlatform, false);
|
||||
mPlatform->SetCDMProxy(mCDMProxy);
|
||||
#else
|
||||
// EME not supported.
|
||||
return false;
|
||||
#endif
|
||||
} else {
|
||||
mPlatform = PlatformDecoderModule::Create();
|
||||
NS_ENSURE_TRUE(mPlatform, false);
|
||||
}
|
||||
}
|
||||
|
||||
MOZ_ASSERT(mPlatform);
|
||||
|
||||
if (HasAudio() && !mAudio.mDecoder) {
|
||||
NS_ENSURE_TRUE(IsSupportedAudioMimeType(mInfo.mAudio.mMimeType),
|
||||
false);
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
#include "MediaDataDemuxer.h"
|
||||
#include "MediaDecoderReader.h"
|
||||
#include "PlatformDecoderModule.h"
|
||||
#include "PDMFactory.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
@ -154,7 +154,7 @@ private:
|
||||
|
||||
size_t SizeOfQueue(TrackType aTrack);
|
||||
|
||||
nsRefPtr<PlatformDecoderModule> mPlatform;
|
||||
nsRefPtr<PDMFactory> mPlatform;
|
||||
|
||||
class DecoderCallback : public MediaDataDecoderCallback {
|
||||
public:
|
||||
|
@ -34,6 +34,11 @@
|
||||
|
||||
#include "AgnosticDecoderModule.h"
|
||||
|
||||
#ifdef MOZ_EME
|
||||
#include "EMEDecoderModule.h"
|
||||
#include "mozilla/CDMProxy.h"
|
||||
#endif
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
extern already_AddRefed<PlatformDecoderModule> CreateAgnosticDecoderModule();
|
||||
@ -109,7 +114,9 @@ PDMFactory::CreateDecoder(const TrackInfo& aConfig,
|
||||
layers::LayersBackend aLayersBackend,
|
||||
layers::ImageContainer* aImageContainer)
|
||||
{
|
||||
nsRefPtr<PlatformDecoderModule> current = GetDecoder(aConfig.mMimeType);
|
||||
nsRefPtr<PlatformDecoderModule> current = (mEMEPDM && aConfig.mCrypto.mValid)
|
||||
? mEMEPDM : GetDecoder(aConfig.mMimeType);
|
||||
|
||||
if (!current) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -117,8 +124,8 @@ PDMFactory::CreateDecoder(const TrackInfo& aConfig,
|
||||
|
||||
if (aConfig.GetAsAudioInfo()) {
|
||||
m = current->CreateAudioDecoder(*aConfig.GetAsAudioInfo(),
|
||||
aTaskQueue,
|
||||
aCallback);
|
||||
aTaskQueue,
|
||||
aCallback);
|
||||
return m.forget();
|
||||
}
|
||||
|
||||
@ -169,6 +176,9 @@ PDMFactory::CreateDecoder(const TrackInfo& aConfig,
|
||||
bool
|
||||
PDMFactory::SupportsMimeType(const nsACString& aMimeType)
|
||||
{
|
||||
if (mEMEPDM) {
|
||||
return mEMEPDM->SupportsMimeType(aMimeType);
|
||||
}
|
||||
nsRefPtr<PlatformDecoderModule> current = GetDecoder(aMimeType);
|
||||
return !!current;
|
||||
}
|
||||
@ -245,4 +255,21 @@ PDMFactory::GetDecoder(const nsACString& aMimeType)
|
||||
return pdm.forget();
|
||||
}
|
||||
|
||||
#ifdef MOZ_EME
|
||||
void
|
||||
PDMFactory::SetCDMProxy(CDMProxy* aProxy)
|
||||
{
|
||||
bool cdmDecodesAudio;
|
||||
bool cdmDecodesVideo;
|
||||
{
|
||||
CDMCaps::AutoLock caps(aProxy->Capabilites());
|
||||
cdmDecodesAudio = caps.CanDecryptAndDecodeAudio();
|
||||
cdmDecodesVideo = caps.CanDecryptAndDecodeVideo();
|
||||
}
|
||||
|
||||
nsRefPtr<PDMFactory> m = new PDMFactory();
|
||||
mEMEPDM = new EMEDecoderModule(aProxy, m, cdmDecodesAudio, cdmDecodesVideo);
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace mozilla
|
||||
|
@ -9,6 +9,8 @@
|
||||
|
||||
#include "PlatformDecoderModule.h"
|
||||
|
||||
class CDMProxy;
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class PDMFactory : public PlatformDecoderModule {
|
||||
@ -29,6 +31,15 @@ public:
|
||||
|
||||
bool SupportsMimeType(const nsACString& aMimeType) override;
|
||||
|
||||
#ifdef MOZ_EME
|
||||
// Creates a PlatformDecoderModule that uses a CDMProxy to decrypt or
|
||||
// decrypt-and-decode EME encrypted content. If the CDM only decrypts and
|
||||
// does not decode, we create a PDM and use that to create MediaDataDecoders
|
||||
// that we use on on aTaskQueue to decode the decrypted stream.
|
||||
// This is called on the decode task queue.
|
||||
void SetCDMProxy(CDMProxy* aProxy);
|
||||
#endif
|
||||
|
||||
ConversionRequired
|
||||
DecoderNeedsConversion(const TrackInfo& aConfig) const override
|
||||
{
|
||||
@ -77,6 +88,7 @@ private:
|
||||
static bool sDontDelayInputExhausted;
|
||||
|
||||
nsTArray<nsRefPtr<PlatformDecoderModule>> mCurrentPDMs;
|
||||
nsRefPtr<PlatformDecoderModule> mEMEPDM;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
@ -6,10 +6,6 @@
|
||||
|
||||
#include "PlatformDecoderModule.h"
|
||||
#include "PDMFactory.h"
|
||||
#ifdef MOZ_EME
|
||||
#include "EMEDecoderModule.h"
|
||||
#include "mozilla/CDMProxy.h"
|
||||
#endif
|
||||
|
||||
PRLogModuleInfo* GetPDMLog() {
|
||||
static PRLogModuleInfo* log = nullptr;
|
||||
@ -29,32 +25,6 @@ PlatformDecoderModule::Init()
|
||||
PDMFactory::Init();
|
||||
}
|
||||
|
||||
#ifdef MOZ_EME
|
||||
/* static */
|
||||
already_AddRefed<PlatformDecoderModule>
|
||||
PlatformDecoderModule::CreateCDMWrapper(CDMProxy* aProxy)
|
||||
{
|
||||
bool cdmDecodesAudio;
|
||||
bool cdmDecodesVideo;
|
||||
{
|
||||
CDMCaps::AutoLock caps(aProxy->Capabilites());
|
||||
cdmDecodesAudio = caps.CanDecryptAndDecodeAudio();
|
||||
cdmDecodesVideo = caps.CanDecryptAndDecodeVideo();
|
||||
}
|
||||
|
||||
// We always create a default PDM in order to decode
|
||||
// non-encrypted tracks.
|
||||
nsRefPtr<PlatformDecoderModule> pdm = Create();
|
||||
if (!pdm) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsRefPtr<PlatformDecoderModule> emepdm(
|
||||
new EMEDecoderModule(aProxy, pdm, cdmDecodesAudio, cdmDecodesVideo));
|
||||
return emepdm.forget();
|
||||
}
|
||||
#endif
|
||||
|
||||
/* static */
|
||||
already_AddRefed<PlatformDecoderModule>
|
||||
PlatformDecoderModule::Create()
|
||||
|
@ -63,16 +63,6 @@ public:
|
||||
// This is called on the decode task queue.
|
||||
virtual nsresult Startup() { return NS_OK; };
|
||||
|
||||
#ifdef MOZ_EME
|
||||
// Creates a PlatformDecoderModule that uses a CDMProxy to decrypt or
|
||||
// decrypt-and-decode EME encrypted content. If the CDM only decrypts and
|
||||
// does not decode, we create a PDM and use that to create MediaDataDecoders
|
||||
// that we use on on aTaskQueue to decode the decrypted stream.
|
||||
// This is called on the decode task queue.
|
||||
static already_AddRefed<PlatformDecoderModule>
|
||||
CreateCDMWrapper(CDMProxy* aProxy);
|
||||
#endif
|
||||
|
||||
// Creates a decoder.
|
||||
// See CreateVideoDecoder and CreateAudioDecoder for implementation details.
|
||||
virtual already_AddRefed<MediaDataDecoder>
|
||||
|
@ -191,7 +191,7 @@ EMEMediaDataDecoderProxy::Shutdown()
|
||||
}
|
||||
|
||||
EMEDecoderModule::EMEDecoderModule(CDMProxy* aProxy,
|
||||
PlatformDecoderModule* aPDM,
|
||||
PDMFactory* aPDM,
|
||||
bool aCDMDecodesAudio,
|
||||
bool aCDMDecodesVideo)
|
||||
: mProxy(aProxy)
|
||||
|
@ -8,6 +8,7 @@
|
||||
#define EMEDecoderModule_h_
|
||||
|
||||
#include "PlatformDecoderModule.h"
|
||||
#include "PDMFactory.h"
|
||||
#include "gmp-decryption.h"
|
||||
|
||||
namespace mozilla {
|
||||
@ -19,12 +20,13 @@ private:
|
||||
|
||||
public:
|
||||
EMEDecoderModule(CDMProxy* aProxy,
|
||||
PlatformDecoderModule* aPDM,
|
||||
PDMFactory* aPDM,
|
||||
bool aCDMDecodesAudio,
|
||||
bool aCDMDecodesVideo);
|
||||
|
||||
virtual ~EMEDecoderModule();
|
||||
|
||||
protected:
|
||||
// Decode thread.
|
||||
already_AddRefed<MediaDataDecoder>
|
||||
CreateVideoDecoder(const VideoInfo& aConfig,
|
||||
@ -54,12 +56,11 @@ public:
|
||||
private:
|
||||
nsRefPtr<CDMProxy> mProxy;
|
||||
// Will be null if CDM has decoding capability.
|
||||
nsRefPtr<PlatformDecoderModule> mPDM;
|
||||
nsRefPtr<PDMFactory> mPDM;
|
||||
// We run the PDM on its own task queue.
|
||||
nsRefPtr<TaskQueue> mTaskQueue;
|
||||
bool mCDMDecodesAudio;
|
||||
bool mCDMDecodesVideo;
|
||||
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
@ -9,6 +9,7 @@ EXPORTS += [
|
||||
'agnostic/OpusDecoder.h',
|
||||
'agnostic/VorbisDecoder.h',
|
||||
'agnostic/VPXDecoder.h',
|
||||
'PDMFactory.h',
|
||||
'PlatformDecoderModule.h',
|
||||
'wrappers/FuzzingWrapper.h',
|
||||
'wrappers/H264Converter.h'
|
||||
|
Loading…
Reference in New Issue
Block a user