Bug 1274626 part 4 - provide APIs to create blank decoders; r=jya
MozReview-Commit-ID: LiXOAzvVb1K
--- a/dom/media/platforms/PDMFactory.cpp
+++ b/dom/media/platforms/PDMFactory.cpp
@@ -76,16 +76,17 @@ public:
StaticAutoPtr<PDMFactoryImpl> PDMFactory::sInstance;
StaticMutex PDMFactory::sMonitor;
PDMFactory::PDMFactory()
{
EnsureInit();
CreatePDMs();
+ CreateBlankPDM();
}
PDMFactory::~PDMFactory()
{
}
void
PDMFactory::EnsureInit() const
@@ -115,16 +116,21 @@ PDMFactory::EnsureInit() const
}
});
SyncRunnable::DispatchToThread(mainThread, runnable);
}
already_AddRefed<MediaDataDecoder>
PDMFactory::CreateDecoder(const CreateDecoderParams& aParams)
{
+ if (aParams.mUseBlankDecoder) {
+ MOZ_ASSERT(mBlankPDM);
+ return CreateDecoderWithPDM(mBlankPDM, aParams);
+ }
+
const TrackInfo& config = aParams.mConfig;
bool isEncrypted = mEMEPDM && config.mCrypto.mValid;
if (isEncrypted) {
return CreateDecoderWithPDM(mEMEPDM, aParams);
}
DecoderDoctorDiagnostics* diagnostics = aParams.mDiagnostics;
@@ -282,16 +288,23 @@ PDMFactory::CreatePDMs()
if (MediaPrefs::PDMGMPEnabled()) {
m = new GMPDecoderModule();
mGMPPDMFailedToStartup = !StartupPDM(m);
} else {
mGMPPDMFailedToStartup = false;
}
}
+void
+PDMFactory::CreateBlankPDM()
+{
+ mBlankPDM = CreateBlankDecoderModule();
+ MOZ_ASSERT(mBlankPDM && NS_SUCCEEDED(mBlankPDM->Startup()));
+}
+
bool
PDMFactory::StartupPDM(PlatformDecoderModule* aPDM)
{
if (aPDM && NS_SUCCEEDED(aPDM->Startup())) {
mCurrentPDMs.AppendElement(aPDM);
return true;
}
return false;
--- a/dom/media/platforms/PDMFactory.h
+++ b/dom/media/platforms/PDMFactory.h
@@ -42,29 +42,31 @@ public:
// that we use on on aTaskQueue to decode the decrypted stream.
// This is called on the decode task queue.
void SetCDMProxy(CDMProxy* aProxy);
#endif
private:
virtual ~PDMFactory();
void CreatePDMs();
+ void CreateBlankPDM();
// Startup the provided PDM and add it to our list if successful.
bool StartupPDM(PlatformDecoderModule* aPDM);
// Returns the first PDM in our list supporting the mimetype.
already_AddRefed<PlatformDecoderModule>
GetDecoder(const nsACString& aMimeType,
DecoderDoctorDiagnostics* aDiagnostics) const;
already_AddRefed<MediaDataDecoder>
CreateDecoderWithPDM(PlatformDecoderModule* aPDM,
const CreateDecoderParams& aParams);
nsTArray<RefPtr<PlatformDecoderModule>> mCurrentPDMs;
RefPtr<PlatformDecoderModule> mEMEPDM;
+ RefPtr<PlatformDecoderModule> mBlankPDM;
bool mWMFFailedToLoad = false;
bool mFFmpegFailedToLoad = false;
bool mGMPPDMFailedToStartup = false;
void EnsureInit() const;
template<class T> friend class StaticAutoPtr;
static StaticAutoPtr<PDMFactoryImpl> sInstance;
--- a/dom/media/platforms/PlatformDecoderModule.h
+++ b/dom/media/platforms/PlatformDecoderModule.h
@@ -59,24 +59,26 @@ struct CreateDecoderParams {
const TrackInfo& mConfig;
TaskQueue* mTaskQueue = nullptr;
MediaDataDecoderCallback* mCallback = nullptr;
DecoderDoctorDiagnostics* mDiagnostics = nullptr;
layers::ImageContainer* mImageContainer = nullptr;
layers::LayersBackend mLayersBackend = layers::LayersBackend::LAYERS_NONE;
RefPtr<GMPCrashHelper> mCrashHelper;
+ bool mUseBlankDecoder = false;
private:
void Set(TaskQueue* aTaskQueue) { mTaskQueue = aTaskQueue; }
void Set(MediaDataDecoderCallback* aCallback) { mCallback = aCallback; }
void Set(DecoderDoctorDiagnostics* aDiagnostics) { mDiagnostics = aDiagnostics; }
void Set(layers::ImageContainer* aImageContainer) { mImageContainer = aImageContainer; }
void Set(layers::LayersBackend aLayersBackend) { mLayersBackend = aLayersBackend; }
void Set(GMPCrashHelper* aCrashHelper) { mCrashHelper = aCrashHelper; }
+ void Set(bool aUseBlankDecoder) { mUseBlankDecoder = aUseBlankDecoder; }
template <typename T1, typename T2, typename... Ts>
void Set(T1&& a1, T2&& a2, Ts&&... args)
{
Set(mozilla::Forward<T1>(a1));
Set(mozilla::Forward<T2>(a2), mozilla::Forward<Ts>(args)...);
}
};