Bug 1274626 part 3 - export NullDecoderModule via PDMFactory; r?jya
MozReview-Commit-ID: LiXOAzvVb1K
--- a/dom/media/platforms/PDMFactory.cpp
+++ b/dom/media/platforms/PDMFactory.cpp
@@ -45,16 +45,17 @@
#include "DecoderDoctorDiagnostics.h"
namespace mozilla {
extern already_AddRefed<PlatformDecoderModule> CreateAgnosticDecoderModule();
extern already_AddRefed<PlatformDecoderModule> CreateBlankDecoderModule();
+extern already_AddRefed<PlatformDecoderModule> CreateNullDecoderModule();
class PDMFactoryImpl final {
public:
PDMFactoryImpl()
{
#ifdef XP_WIN
WMFDecoderModule::Init();
#endif
@@ -98,16 +99,20 @@ PDMFactory::EnsureInit() const
NS_DispatchToMainThread(runnable);
}
}
}
already_AddRefed<MediaDataDecoder>
PDMFactory::CreateDecoder(const CreateDecoderParams& aParams)
{
+ if (mNullPDM && aParams.mUseNullDecoder == UseNullDecoder::USE_NULL_DECODER) {
+ return CreateDecoderWithPDM(mNullPDM, aParams);
+ }
+
const TrackInfo& config = aParams.mConfig;
bool isEncrypted = mEMEPDM && config.mCrypto.mValid;
if (isEncrypted) {
return CreateDecoderWithPDM(mEMEPDM, aParams);
}
DecoderDoctorDiagnostics* diagnostics = aParams.mDiagnostics;
@@ -312,9 +317,15 @@ PDMFactory::GetDecoder(const nsACString&
void
PDMFactory::SetCDMProxy(CDMProxy* aProxy)
{
RefPtr<PDMFactory> m = new PDMFactory();
mEMEPDM = new EMEDecoderModule(aProxy, m);
}
#endif
+void
+PDMFactory::SetNullDecode()
+{
+ mNullPDM = CreateNullDecoderModule();
+}
+
} // namespace mozilla
--- a/dom/media/platforms/PDMFactory.h
+++ b/dom/media/platforms/PDMFactory.h
@@ -39,32 +39,35 @@ public:
// 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
+ void SetNullDecode();
+
private:
virtual ~PDMFactory();
void CreatePDMs();
// 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> mNullPDM;
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
@@ -28,16 +28,21 @@ class ImageContainer;
class MediaDataDecoder;
class MediaDataDecoderCallback;
class TaskQueue;
class CDMProxy;
static LazyLogModule sPDMLog("PlatformDecoderModule");
+enum class UseNullDecoder {
+ USE_NULL_DECODER,
+ NOT_USE_NULL_DECODER
+};
+
struct CreateDecoderParams {
explicit CreateDecoderParams(const TrackInfo& aConfig)
: mConfig(aConfig)
{}
template <typename T1, typename... Ts>
CreateDecoderParams(const TrackInfo& aConfig, T1 a1, Ts... as)
: mConfig(aConfig)
@@ -59,24 +64,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;
+ UseNullDecoder mUseNullDecoder = UseNullDecoder::NOT_USE_NULL_DECODER;
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(UseNullDecoder aUseNullDecoder) { mUseNullDecoder = aUseNullDecoder; }
template <typename T1, typename T2, typename... Ts>
void Set(T1 a1, T2 a2, Ts... as)
{
// Parameter pack expansion trick, to call Set() on each argument.
using expander = int[];
(void)expander {
(Set(a1), 0), (Set(a2), 0), (Set(as), 0)...
};