--- a/dom/media/Benchmark.cpp
+++ b/dom/media/Benchmark.cpp
@@ -202,18 +202,17 @@ BenchmarkPlayback::DemuxNextSample()
}
void
BenchmarkPlayback::InitDecoder(TrackInfo&& aInfo)
{
MOZ_ASSERT(OnThread());
RefPtr<PDMFactory> platform = new PDMFactory();
- mDecoder = platform->CreateDecoder(aInfo, mDecoderTaskQueue, this,
- /* DecoderDoctorDiagnostics* */ nullptr);
+ mDecoder = platform->CreateDecoder({ aInfo, mDecoderTaskQueue, reinterpret_cast<MediaDataDecoderCallback*>(this) });
if (!mDecoder) {
MainThreadShutdown();
return;
}
RefPtr<Benchmark> ref(mMainThreadState);
mDecoder->Init()->Then(
Thread(), __func__,
[this, ref](TrackInfo::TrackType aTrackType) {
--- a/dom/media/MediaFormatReader.cpp
+++ b/dom/media/MediaFormatReader.cpp
@@ -402,38 +402,37 @@ MediaFormatReader::EnsureDecoderCreated(
}
}
decoder.mDecoderInitialized = false;
MonitorAutoLock mon(decoder.mMonitor);
switch (aTrack) {
- case TrackType::kAudioTrack:
- decoder.mDecoder =
- mPlatform->CreateDecoder(decoder.mInfo ?
- *decoder.mInfo->GetAsAudioInfo() :
- mInfo.mAudio,
- decoder.mTaskQueue,
- decoder.mCallback,
- /* DecoderDoctorDiagnostics* */ nullptr);
+ case TrackType::kAudioTrack: {
+ decoder.mDecoder = mPlatform->CreateDecoder({
+ decoder.mInfo ? *decoder.mInfo->GetAsAudioInfo() : mInfo.mAudio,
+ decoder.mTaskQueue,
+ decoder.mCallback.get()
+ });
break;
- case TrackType::kVideoTrack:
+ }
+
+ case TrackType::kVideoTrack: {
// Decoders use the layers backend to decide if they can use hardware decoding,
// so specify LAYERS_NONE if we want to forcibly disable it.
- decoder.mDecoder =
- mPlatform->CreateDecoder(mVideo.mInfo ?
- *mVideo.mInfo->GetAsVideoInfo() :
- mInfo.mVideo,
- decoder.mTaskQueue,
- decoder.mCallback,
- /* DecoderDoctorDiagnostics* */ nullptr,
- mLayersBackendType,
- GetImageContainer());
+ decoder.mDecoder = mPlatform->CreateDecoder({
+ mVideo.mInfo ? *mVideo.mInfo->GetAsVideoInfo() : mInfo.mVideo,
+ decoder.mTaskQueue,
+ decoder.mCallback.get(),
+ mLayersBackendType,
+ GetImageContainer(),
+ });
break;
+ }
default:
break;
}
if (decoder.mDecoder ) {
decoder.mDescription = decoder.mDecoder->GetDescriptionName();
} else {
decoder.mDescription = "error creating decoder";
}
--- a/dom/media/fmp4/MP4Decoder.cpp
+++ b/dom/media/fmp4/MP4Decoder.cpp
@@ -217,20 +217,17 @@ CreateTestH264Decoder(layers::LayersBack
aConfig.mDuration = 40000;
aConfig.mMediaTime = 0;
aConfig.mImage = aConfig.mDisplay = nsIntSize(640, 360);
aConfig.mExtraData = new MediaByteBuffer();
aConfig.mExtraData->AppendElements(sTestH264ExtraData,
MOZ_ARRAY_LENGTH(sTestH264ExtraData));
RefPtr<PDMFactory> platform = new PDMFactory();
- RefPtr<MediaDataDecoder> decoder(
- platform->CreateDecoder(aConfig, aTaskQueue, nullptr,
- /* DecoderDoctorDiagnostics* */ nullptr,
- aBackend, nullptr));
+ RefPtr<MediaDataDecoder> decoder(platform->CreateDecoder({ aConfig, aTaskQueue, aBackend }));
return decoder.forget();
}
/* static */ already_AddRefed<dom::Promise>
MP4Decoder::IsVideoAccelerated(layers::LayersBackend aBackend, nsIGlobalObject* aParent)
{
MOZ_ASSERT(NS_IsMainThread());
--- a/dom/media/platforms/PDMFactory.cpp
+++ b/dom/media/platforms/PDMFactory.cpp
@@ -96,126 +96,94 @@ PDMFactory::EnsureInit() const
nsCOMPtr<nsIRunnable> runnable =
NS_NewRunnableFunction([]() { ClearOnShutdown(&sInstance); });
NS_DispatchToMainThread(runnable);
}
}
}
already_AddRefed<MediaDataDecoder>
-PDMFactory::CreateDecoder(const TrackInfo& aConfig,
- TaskQueue* aTaskQueue,
- MediaDataDecoderCallback* aCallback,
- DecoderDoctorDiagnostics* aDiagnostics,
- layers::LayersBackend aLayersBackend,
- layers::ImageContainer* aImageContainer) const
+PDMFactory::CreateDecoder(const CreateDecoderParams& aParams)
{
- bool isEncrypted = mEMEPDM && aConfig.mCrypto.mValid;
+ const TrackInfo& config = aParams.mConfig;
+ bool isEncrypted = mEMEPDM && config.mCrypto.mValid;
if (isEncrypted) {
- return CreateDecoderWithPDM(mEMEPDM,
- aConfig,
- aTaskQueue,
- aCallback,
- aDiagnostics,
- aLayersBackend,
- aImageContainer);
+ return CreateDecoderWithPDM(mEMEPDM, aParams);
}
- if (aDiagnostics) {
+ DecoderDoctorDiagnostics* diagnostics = aParams.mDiagnostics;
+ if (diagnostics) {
// If libraries failed to load, the following loop over mCurrentPDMs
// will not even try to use them. So we record failures now.
if (mWMFFailedToLoad) {
- aDiagnostics->SetWMFFailedToLoad();
+ diagnostics->SetWMFFailedToLoad();
}
if (mFFmpegFailedToLoad) {
- aDiagnostics->SetFFmpegFailedToLoad();
+ diagnostics->SetFFmpegFailedToLoad();
}
if (mGMPPDMFailedToStartup) {
- aDiagnostics->SetGMPPDMFailedToStartup();
+ diagnostics->SetGMPPDMFailedToStartup();
}
}
for (auto& current : mCurrentPDMs) {
- if (!current->SupportsMimeType(aConfig.mMimeType, aDiagnostics)) {
+ if (!current->SupportsMimeType(config.mMimeType, diagnostics)) {
continue;
}
- RefPtr<MediaDataDecoder> m =
- CreateDecoderWithPDM(current,
- aConfig,
- aTaskQueue,
- aCallback,
- aDiagnostics,
- aLayersBackend,
- aImageContainer);
+ RefPtr<MediaDataDecoder> m = CreateDecoderWithPDM(current, aParams);
if (m) {
return m.forget();
}
}
NS_WARNING("Unable to create a decoder, no platform found.");
return nullptr;
}
already_AddRefed<MediaDataDecoder>
PDMFactory::CreateDecoderWithPDM(PlatformDecoderModule* aPDM,
- const TrackInfo& aConfig,
- TaskQueue* aTaskQueue,
- MediaDataDecoderCallback* aCallback,
- DecoderDoctorDiagnostics* aDiagnostics,
- layers::LayersBackend aLayersBackend,
- layers::ImageContainer* aImageContainer) const
+ const CreateDecoderParams& aParams)
{
MOZ_ASSERT(aPDM);
RefPtr<MediaDataDecoder> m;
- if (aConfig.GetAsAudioInfo()) {
- m = aPDM->CreateAudioDecoder(*aConfig.GetAsAudioInfo(),
- aTaskQueue,
- aCallback,
- aDiagnostics);
+ const TrackInfo& config = aParams.mConfig;
+ if (config.IsAudio()) {
+ m = aPDM->CreateAudioDecoder(aParams);
return m.forget();
}
- if (!aConfig.GetAsVideoInfo()) {
+ if (!config.IsVideo()) {
return nullptr;
}
- MediaDataDecoderCallback* callback = aCallback;
+ MediaDataDecoderCallback* callback = aParams.mCallback;
RefPtr<DecoderCallbackFuzzingWrapper> callbackWrapper;
if (MediaPrefs::PDMFuzzingEnabled()) {
- callbackWrapper = new DecoderCallbackFuzzingWrapper(aCallback);
+ callbackWrapper = new DecoderCallbackFuzzingWrapper(callback);
callbackWrapper->SetVideoOutputMinimumInterval(
TimeDuration::FromMilliseconds(MediaPrefs::PDMFuzzingInterval()));
callbackWrapper->SetDontDelayInputExhausted(!MediaPrefs::PDMFuzzingDelayInputExhausted());
callback = callbackWrapper.get();
}
- if (H264Converter::IsH264(aConfig)) {
- RefPtr<H264Converter> h
- = new H264Converter(aPDM,
- *aConfig.GetAsVideoInfo(),
- aLayersBackend,
- aImageContainer,
- aTaskQueue,
- callback,
- aDiagnostics);
+ CreateDecoderParams params = aParams;
+ params.mCallback = callback;
+
+ if (H264Converter::IsH264(config)) {
+ RefPtr<H264Converter> h = new H264Converter(aPDM, params);
const nsresult rv = h->GetLastError();
if (NS_SUCCEEDED(rv) || rv == NS_ERROR_NOT_INITIALIZED) {
// The H264Converter either successfully created the wrapped decoder,
// or there wasn't enough AVCC data to do so. Otherwise, there was some
// problem, for example WMF DLLs were missing.
m = h.forget();
}
} else {
- m = aPDM->CreateVideoDecoder(*aConfig.GetAsVideoInfo(),
- aLayersBackend,
- aImageContainer,
- aTaskQueue,
- callback,
- aDiagnostics);
+ m = aPDM->CreateVideoDecoder(params);
}
if (callbackWrapper && m) {
m = new DecoderFuzzingWrapper(m.forget(), callbackWrapper.forget());
}
return m.forget();
}
--- a/dom/media/platforms/PDMFactory.h
+++ b/dom/media/platforms/PDMFactory.h
@@ -25,22 +25,17 @@ public:
PDMFactory();
// Factory method that creates the appropriate PlatformDecoderModule for
// the platform we're running on. Caller is responsible for deleting this
// instance. It's expected that there will be multiple
// PlatformDecoderModules alive at the same time.
// This is called on the decode task queue.
already_AddRefed<MediaDataDecoder>
- CreateDecoder(const TrackInfo& aConfig,
- TaskQueue* aTaskQueue,
- MediaDataDecoderCallback* aCallback,
- DecoderDoctorDiagnostics* aDiagnostics,
- layers::LayersBackend aLayersBackend = layers::LayersBackend::LAYERS_NONE,
- layers::ImageContainer* aImageContainer = nullptr) const;
+ CreateDecoder(const CreateDecoderParams& aParams);
bool SupportsMimeType(const nsACString& aMimeType,
DecoderDoctorDiagnostics* aDiagnostics) const;
#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
@@ -56,22 +51,17 @@ private:
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 TrackInfo& aConfig,
- TaskQueue* aTaskQueue,
- MediaDataDecoderCallback* aCallback,
- DecoderDoctorDiagnostics* aDiagnostics,
- layers::LayersBackend aLayersBackend,
- layers::ImageContainer* aImageContainer) const;
+ const CreateDecoderParams& aParams);
nsTArray<RefPtr<PlatformDecoderModule>> mCurrentPDMs;
RefPtr<PlatformDecoderModule> mEMEPDM;
bool mWMFFailedToLoad = false;
bool mFFmpegFailedToLoad = false;
bool mGMPPDMFailedToStartup = false;
--- a/dom/media/platforms/PlatformDecoderModule.h
+++ b/dom/media/platforms/PlatformDecoderModule.h
@@ -27,16 +27,64 @@ class ImageContainer;
class MediaDataDecoder;
class MediaDataDecoderCallback;
class TaskQueue;
class CDMProxy;
static LazyLogModule sPDMLog("PlatformDecoderModule");
+struct CreateDecoderParams {
+ explicit CreateDecoderParams(const TrackInfo& aConfig)
+ : mConfig(aConfig)
+ {}
+
+ template <typename T1, typename... Ts>
+ CreateDecoderParams(const TrackInfo& aConfig, T1 a1, Ts... as)
+ : mConfig(aConfig)
+ {
+ Set(a1, as...);
+ }
+
+ const VideoInfo& VideoConfig() const
+ {
+ MOZ_ASSERT(mConfig.IsVideo());
+ return *mConfig.GetAsVideoInfo();
+ }
+
+ const AudioInfo& AudioConfig() const
+ {
+ MOZ_ASSERT(mConfig.IsAudio());
+ return *mConfig.GetAsAudioInfo();
+ }
+
+ const TrackInfo& mConfig;
+ TaskQueue* mTaskQueue = nullptr;
+ MediaDataDecoderCallback* mCallback = nullptr;
+ DecoderDoctorDiagnostics* mDiagnostics = nullptr;
+ layers::ImageContainer* mImageContainer = nullptr;
+ layers::LayersBackend mLayersBackend = layers::LayersBackend::LAYERS_NONE;
+
+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; }
+ 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)...
+ };
+ }
+};
+
// The PlatformDecoderModule interface is used by the MediaFormatReader to
// abstract access to decoders provided by various
// platforms.
// Each platform (Windows, MacOSX, Linux, B2G etc) must implement a
// PlatformDecoderModule to provide access to its decoders in order to get
// decompressed H.264/AAC from the MediaFormatReader.
//
// Decoding is asynchronous, and should be performed on the task queue
@@ -83,38 +131,30 @@ protected:
// 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
// COINIT_MULTITHREADED.
// Returns nullptr if the decoder can't be created.
// It is safe to store a reference to aConfig.
// This is called on the decode task queue.
virtual already_AddRefed<MediaDataDecoder>
- CreateVideoDecoder(const VideoInfo& aConfig,
- layers::LayersBackend aLayersBackend,
- layers::ImageContainer* aImageContainer,
- TaskQueue* aTaskQueue,
- MediaDataDecoderCallback* aCallback,
- DecoderDoctorDiagnostics* aDiagnostics) = 0;
+ CreateVideoDecoder(const CreateDecoderParams& aParams) = 0;
// Creates an Audio decoder with the specified properties.
// Asynchronous decoding of audio should be done in runnables dispatched to
// aAudioTaskQueue. 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.
// Returns nullptr if the decoder can't be created.
// On Windows the task queue's threads in have MSCOM initialized with
// COINIT_MULTITHREADED.
// It is safe to store a reference to aConfig.
// This is called on the decode task queue.
virtual already_AddRefed<MediaDataDecoder>
- CreateAudioDecoder(const AudioInfo& aConfig,
- TaskQueue* aTaskQueue,
- MediaDataDecoderCallback* aCallback,
- DecoderDoctorDiagnostics* aDiagnostics) = 0;
+ CreateAudioDecoder(const CreateDecoderParams& aParams) = 0;
};
enum MediaDataDecoderError {
FATAL_ERROR,
DECODE_ERROR
};
// A callback used by MediaDataDecoder to return output/errors to the
--- a/dom/media/platforms/agnostic/AgnosticDecoderModule.cpp
+++ b/dom/media/platforms/agnostic/AgnosticDecoderModule.cpp
@@ -18,51 +18,37 @@ AgnosticDecoderModule::SupportsMimeType(
{
return VPXDecoder::IsVPX(aMimeType) ||
OpusDataDecoder::IsOpus(aMimeType) ||
VorbisDataDecoder::IsVorbis(aMimeType) ||
WaveDataDecoder::IsWave(aMimeType);
}
already_AddRefed<MediaDataDecoder>
-AgnosticDecoderModule::CreateVideoDecoder(const VideoInfo& aConfig,
- layers::LayersBackend aLayersBackend,
- layers::ImageContainer* aImageContainer,
- TaskQueue* aTaskQueue,
- MediaDataDecoderCallback* aCallback,
- DecoderDoctorDiagnostics* aDiagnostics)
+AgnosticDecoderModule::CreateVideoDecoder(const CreateDecoderParams& aParams)
{
RefPtr<MediaDataDecoder> m;
- if (VPXDecoder::IsVPX(aConfig.mMimeType)) {
- m = new VPXDecoder(*aConfig.GetAsVideoInfo(),
- aImageContainer,
- aTaskQueue,
- aCallback);
+ if (VPXDecoder::IsVPX(aParams.mConfig.mMimeType)) {
+ m = new VPXDecoder(aParams);
}
return m.forget();
}
already_AddRefed<MediaDataDecoder>
-AgnosticDecoderModule::CreateAudioDecoder(const AudioInfo& aConfig,
- TaskQueue* aTaskQueue,
- MediaDataDecoderCallback* aCallback,
- DecoderDoctorDiagnostics* aDiagnostics)
+AgnosticDecoderModule::CreateAudioDecoder(const CreateDecoderParams& aParams)
{
RefPtr<MediaDataDecoder> m;
- if (VorbisDataDecoder::IsVorbis(aConfig.mMimeType)) {
- m = new VorbisDataDecoder(*aConfig.GetAsAudioInfo(),
- aTaskQueue,
- aCallback);
- } else if (OpusDataDecoder::IsOpus(aConfig.mMimeType)) {
- m = new OpusDataDecoder(*aConfig.GetAsAudioInfo(),
- aTaskQueue,
- aCallback);
- } else if (WaveDataDecoder::IsWave(aConfig.mMimeType)) {
- m = new WaveDataDecoder(*aConfig.GetAsAudioInfo(), aCallback);
+ const TrackInfo& config = aParams.mConfig;
+ if (VorbisDataDecoder::IsVorbis(config.mMimeType)) {
+ m = new VorbisDataDecoder(aParams);
+ } else if (OpusDataDecoder::IsOpus(config.mMimeType)) {
+ m = new OpusDataDecoder(aParams);
+ } else if (WaveDataDecoder::IsWave(config.mMimeType)) {
+ m = new WaveDataDecoder(aParams);
}
return m.forget();
}
} // namespace mozilla
--- a/dom/media/platforms/agnostic/AgnosticDecoderModule.h
+++ b/dom/media/platforms/agnostic/AgnosticDecoderModule.h
@@ -17,26 +17,18 @@ public:
DecoderNeedsConversion(const TrackInfo& aConfig) const override
{
return ConversionRequired::kNeedNone;
}
protected:
// Decode thread.
already_AddRefed<MediaDataDecoder>
- CreateVideoDecoder(const VideoInfo& aConfig,
- layers::LayersBackend aLayersBackend,
- layers::ImageContainer* aImageContainer,
- TaskQueue* aTaskQueue,
- MediaDataDecoderCallback* aCallback,
- DecoderDoctorDiagnostics* aDiagnostics) override;
+ CreateVideoDecoder(const CreateDecoderParams& aParams) override;
// Decode thread.
already_AddRefed<MediaDataDecoder>
- CreateAudioDecoder(const AudioInfo& aConfig,
- TaskQueue* aTaskQueue,
- MediaDataDecoderCallback* aCallback,
- DecoderDoctorDiagnostics* aDiagnostics) override;
+ CreateAudioDecoder(const CreateDecoderParams& aParams) override;
};
} // namespace mozilla
#endif /* AgnosticDecoderModule_h_ */
--- a/dom/media/platforms/agnostic/BlankDecoderModule.cpp
+++ b/dom/media/platforms/agnostic/BlankDecoderModule.cpp
@@ -21,21 +21,20 @@ namespace mozilla {
// Decoder that uses a passed in object's Create function to create blank
// MediaData objects.
template<class BlankMediaDataCreator>
class BlankMediaDataDecoder : public MediaDataDecoder {
public:
BlankMediaDataDecoder(BlankMediaDataCreator* aCreator,
- MediaDataDecoderCallback* aCallback,
- TrackInfo::TrackType aType)
+ const CreateDecoderParams& aParams)
: mCreator(aCreator)
- , mCallback(aCallback)
- , mType(aType)
+ , mCallback(aParams.mCallback)
+ , mType(aParams.mConfig.GetType())
{
}
RefPtr<InitPromise> Init() override {
return InitPromise::CreateAndResolve(mType, __func__);
}
nsresult Shutdown() override {
@@ -194,44 +193,34 @@ private:
uint32_t mSampleRate;
};
class BlankDecoderModule : public PlatformDecoderModule {
public:
// Decode thread.
already_AddRefed<MediaDataDecoder>
- CreateVideoDecoder(const VideoInfo& aConfig,
- layers::LayersBackend aLayersBackend,
- layers::ImageContainer* aImageContainer,
- TaskQueue* aTaskQueue,
- MediaDataDecoderCallback* aCallback,
- DecoderDoctorDiagnostics* aDiagnostics) override {
+ CreateVideoDecoder(const CreateDecoderParams& aParams) override {
+ const VideoInfo& config = aParams.VideoConfig();
BlankVideoDataCreator* creator = new BlankVideoDataCreator(
- aConfig.mDisplay.width, aConfig.mDisplay.height, aImageContainer);
+ config.mDisplay.width, config.mDisplay.height, aParams.mImageContainer);
RefPtr<MediaDataDecoder> decoder =
- new BlankMediaDataDecoder<BlankVideoDataCreator>(creator,
- aCallback,
- TrackInfo::kVideoTrack);
+ new BlankMediaDataDecoder<BlankVideoDataCreator>(creator, aParams);
return decoder.forget();
}
// Decode thread.
already_AddRefed<MediaDataDecoder>
- CreateAudioDecoder(const AudioInfo& aConfig,
- TaskQueue* aTaskQueue,
- MediaDataDecoderCallback* aCallback,
- DecoderDoctorDiagnostics* aDiagnostics) override {
+ CreateAudioDecoder(const CreateDecoderParams& aParams) override {
+ const AudioInfo& config = aParams.AudioConfig();
BlankAudioDataCreator* creator = new BlankAudioDataCreator(
- aConfig.mChannels, aConfig.mRate);
+ config.mChannels, config.mRate);
RefPtr<MediaDataDecoder> decoder =
- new BlankMediaDataDecoder<BlankAudioDataCreator>(creator,
- aCallback,
- TrackInfo::kAudioTrack);
+ new BlankMediaDataDecoder<BlankAudioDataCreator>(creator, aParams);
return decoder.forget();
}
bool
SupportsMimeType(const nsACString& aMimeType,
DecoderDoctorDiagnostics* aDiagnostics) const override
{
return true;
--- a/dom/media/platforms/agnostic/OpusDecoder.cpp
+++ b/dom/media/platforms/agnostic/OpusDecoder.cpp
@@ -15,22 +15,20 @@
#include <stdint.h>
#include <inttypes.h> // For PRId64
#define OPUS_DEBUG(arg, ...) MOZ_LOG(sPDMLog, mozilla::LogLevel::Debug, \
("OpusDataDecoder(%p)::%s: " arg, this, __func__, ##__VA_ARGS__))
namespace mozilla {
-OpusDataDecoder::OpusDataDecoder(const AudioInfo& aConfig,
- TaskQueue* aTaskQueue,
- MediaDataDecoderCallback* aCallback)
- : mInfo(aConfig)
- , mTaskQueue(aTaskQueue)
- , mCallback(aCallback)
+OpusDataDecoder::OpusDataDecoder(const CreateDecoderParams& aParams)
+ : mInfo(aParams.AudioConfig())
+ , mTaskQueue(aParams.mTaskQueue)
+ , mCallback(aParams.mCallback)
, mOpusDecoder(nullptr)
, mSkip(0)
, mDecodedHeader(false)
, mPaddingDiscarded(false)
, mFrames(0)
, mIsFlushing(false)
{
}
--- a/dom/media/platforms/agnostic/OpusDecoder.h
+++ b/dom/media/platforms/agnostic/OpusDecoder.h
@@ -12,19 +12,17 @@
#include "mozilla/Maybe.h"
#include "nsAutoPtr.h"
namespace mozilla {
class OpusDataDecoder : public MediaDataDecoder
{
public:
- OpusDataDecoder(const AudioInfo& aConfig,
- TaskQueue* aTaskQueue,
- MediaDataDecoderCallback* aCallback);
+ explicit OpusDataDecoder(const CreateDecoderParams& aParams);
~OpusDataDecoder();
RefPtr<InitPromise> Init() override;
nsresult Input(MediaRawData* aSample) override;
nsresult Flush() override;
nsresult Drain() override;
nsresult Shutdown() override;
const char* GetDescriptionName() const override
--- a/dom/media/platforms/agnostic/VPXDecoder.cpp
+++ b/dom/media/platforms/agnostic/VPXDecoder.cpp
@@ -27,26 +27,23 @@ static int MimeTypeToCodec(const nsACStr
if (aMimeType.EqualsLiteral("video/webm; codecs=vp8")) {
return VPXDecoder::Codec::VP8;
} else if (aMimeType.EqualsLiteral("video/webm; codecs=vp9")) {
return VPXDecoder::Codec::VP9;
}
return -1;
}
-VPXDecoder::VPXDecoder(const VideoInfo& aConfig,
- ImageContainer* aImageContainer,
- TaskQueue* aTaskQueue,
- MediaDataDecoderCallback* aCallback)
- : mImageContainer(aImageContainer)
- , mTaskQueue(aTaskQueue)
- , mCallback(aCallback)
+VPXDecoder::VPXDecoder(const CreateDecoderParams& aParams)
+ : mImageContainer(aParams.mImageContainer)
+ , mTaskQueue(aParams.mTaskQueue)
+ , mCallback(aParams.mCallback)
, mIsFlushing(false)
- , mInfo(aConfig)
- , mCodec(MimeTypeToCodec(aConfig.mMimeType))
+ , mInfo(aParams.VideoConfig())
+ , mCodec(MimeTypeToCodec(aParams.VideoConfig().mMimeType))
{
MOZ_COUNT_CTOR(VPXDecoder);
PodZero(&mVPX);
}
VPXDecoder::~VPXDecoder()
{
MOZ_COUNT_DTOR(VPXDecoder);
--- a/dom/media/platforms/agnostic/VPXDecoder.h
+++ b/dom/media/platforms/agnostic/VPXDecoder.h
@@ -16,21 +16,17 @@
namespace mozilla {
using namespace layers;
class VPXDecoder : public MediaDataDecoder
{
public:
- VPXDecoder(const VideoInfo& aConfig,
- ImageContainer* aImageContainer,
- TaskQueue* aTaskQueue,
- MediaDataDecoderCallback* aCallback);
-
+ explicit VPXDecoder(const CreateDecoderParams& aParams);
~VPXDecoder();
RefPtr<InitPromise> Init() override;
nsresult Input(MediaRawData* aSample) override;
nsresult Flush() override;
nsresult Drain() override;
nsresult Shutdown() override;
const char* GetDescriptionName() const override
--- a/dom/media/platforms/agnostic/VorbisDecoder.cpp
+++ b/dom/media/platforms/agnostic/VorbisDecoder.cpp
@@ -25,22 +25,20 @@ ogg_packet InitVorbisPacket(const unsign
packet.bytes = aLength;
packet.b_o_s = aBOS;
packet.e_o_s = aEOS;
packet.granulepos = aGranulepos;
packet.packetno = aPacketNo;
return packet;
}
-VorbisDataDecoder::VorbisDataDecoder(const AudioInfo& aConfig,
- TaskQueue* aTaskQueue,
- MediaDataDecoderCallback* aCallback)
- : mInfo(aConfig)
- , mTaskQueue(aTaskQueue)
- , mCallback(aCallback)
+VorbisDataDecoder::VorbisDataDecoder(const CreateDecoderParams& aParams)
+ : mInfo(aParams.AudioConfig())
+ , mTaskQueue(aParams.mTaskQueue)
+ , mCallback(aParams.mCallback)
, mPacketCount(0)
, mFrames(0)
, mIsFlushing(false)
{
// Zero these member vars to avoid crashes in Vorbis clear functions when
// destructor is called before |Init|.
PodZero(&mVorbisBlock);
PodZero(&mVorbisDsp);
--- a/dom/media/platforms/agnostic/VorbisDecoder.h
+++ b/dom/media/platforms/agnostic/VorbisDecoder.h
@@ -16,19 +16,17 @@
#include "vorbis/codec.h"
#endif
namespace mozilla {
class VorbisDataDecoder : public MediaDataDecoder
{
public:
- VorbisDataDecoder(const AudioInfo& aConfig,
- TaskQueue* aTaskQueue,
- MediaDataDecoderCallback* aCallback);
+ explicit VorbisDataDecoder(const CreateDecoderParams& aParams);
~VorbisDataDecoder();
RefPtr<InitPromise> Init() override;
nsresult Input(MediaRawData* aSample) override;
nsresult Flush() override;
nsresult Drain() override;
nsresult Shutdown() override;
const char* GetDescriptionName() const override
--- a/dom/media/platforms/agnostic/WAVDecoder.cpp
+++ b/dom/media/platforms/agnostic/WAVDecoder.cpp
@@ -40,20 +40,19 @@ DecodeULawSample(uint8_t aValue)
aValue = aValue ^ 0xFF;
int8_t sign = (aValue & 0x80) ? -1 : 1;
uint8_t exponent = (aValue & 0x70) >> 4;
uint8_t mantissa = aValue & 0x0F;
int16_t sample = (33 + 2 * mantissa) * (2 << (exponent + 1)) - 33;
return sign * sample;
}
-WaveDataDecoder::WaveDataDecoder(const AudioInfo& aConfig,
- MediaDataDecoderCallback* aCallback)
- : mInfo(aConfig)
- , mCallback(aCallback)
+WaveDataDecoder::WaveDataDecoder(const CreateDecoderParams& aParams)
+ : mInfo(aParams.AudioConfig())
+ , mCallback(aParams.mCallback)
{
}
nsresult
WaveDataDecoder::Shutdown()
{
return NS_OK;
}
--- a/dom/media/platforms/agnostic/WAVDecoder.h
+++ b/dom/media/platforms/agnostic/WAVDecoder.h
@@ -10,18 +10,17 @@
#include "PlatformDecoderModule.h"
#include "mp4_demuxer/ByteReader.h"
namespace mozilla {
class WaveDataDecoder : public MediaDataDecoder
{
public:
- WaveDataDecoder(const AudioInfo& aConfig,
- MediaDataDecoderCallback* aCallback);
+ explicit WaveDataDecoder(const CreateDecoderParams& aParams);
// Return true if mimetype is Wave
static bool IsWave(const nsACString& aMimeType);
RefPtr<InitPromise> Init() override;
nsresult Input(MediaRawData* aSample) override;
nsresult Flush() override;
nsresult Drain() override;
--- a/dom/media/platforms/agnostic/eme/EMEDecoderModule.cpp
+++ b/dom/media/platforms/agnostic/eme/EMEDecoderModule.cpp
@@ -231,85 +231,72 @@ CreateDecoderWrapper(MediaDataDecoderCal
return nullptr;
}
RefPtr<MediaDataDecoderProxy> decoder(
new EMEMediaDataDecoderProxy(thread.forget(), aCallback, aProxy, aTaskQueue));
return decoder.forget();
}
already_AddRefed<MediaDataDecoder>
-EMEDecoderModule::CreateVideoDecoder(const VideoInfo& aConfig,
- layers::LayersBackend aLayersBackend,
- layers::ImageContainer* aImageContainer,
- TaskQueue* aTaskQueue,
- MediaDataDecoderCallback* aCallback,
- DecoderDoctorDiagnostics* aDiagnostics)
+EMEDecoderModule::CreateVideoDecoder(const CreateDecoderParams& aParams)
{
- MOZ_ASSERT(aConfig.mCrypto.mValid);
+ MOZ_ASSERT(aParams.mConfig.mCrypto.mValid);
- if (SupportsMimeType(aConfig.mMimeType, nullptr)) {
+ if (SupportsMimeType(aParams.mConfig.mMimeType, nullptr)) {
// GMP decodes. Assume that means it can decrypt too.
- RefPtr<MediaDataDecoderProxy> wrapper = CreateDecoderWrapper(aCallback, mProxy, aTaskQueue);
+ RefPtr<MediaDataDecoderProxy> wrapper =
+ CreateDecoderWrapper(aParams.mCallback, mProxy, aParams.mTaskQueue);
wrapper->SetProxyTarget(new EMEVideoDecoder(mProxy,
- aConfig,
- aLayersBackend,
- aImageContainer,
- aTaskQueue,
+ aParams.VideoConfig(),
+ aParams.mLayersBackend,
+ aParams.mImageContainer,
+ aParams.mTaskQueue,
wrapper->Callback()));
return wrapper.forget();
}
MOZ_ASSERT(mPDM);
- RefPtr<MediaDataDecoder> decoder(
- mPDM->CreateDecoder(aConfig,
- aTaskQueue,
- aCallback,
- aDiagnostics,
- aLayersBackend,
- aImageContainer));
+ RefPtr<MediaDataDecoder> decoder(mPDM->CreateDecoder(aParams));
if (!decoder) {
return nullptr;
}
RefPtr<MediaDataDecoder> emeDecoder(new EMEDecryptor(decoder,
- aCallback,
- mProxy,
- AbstractThread::GetCurrent()->AsTaskQueue()));
+ aParams.mCallback,
+ mProxy,
+ AbstractThread::GetCurrent()->AsTaskQueue()));
return emeDecoder.forget();
}
already_AddRefed<MediaDataDecoder>
-EMEDecoderModule::CreateAudioDecoder(const AudioInfo& aConfig,
- TaskQueue* aTaskQueue,
- MediaDataDecoderCallback* aCallback,
- DecoderDoctorDiagnostics* aDiagnostics)
+EMEDecoderModule::CreateAudioDecoder(const CreateDecoderParams& aParams)
{
- MOZ_ASSERT(aConfig.mCrypto.mValid);
+ MOZ_ASSERT(aParams.mConfig.mCrypto.mValid);
- if (SupportsMimeType(aConfig.mMimeType, nullptr)) {
+ if (SupportsMimeType(aParams.mConfig.mMimeType, nullptr)) {
// GMP decodes. Assume that means it can decrypt too.
- RefPtr<MediaDataDecoderProxy> wrapper = CreateDecoderWrapper(aCallback, mProxy, aTaskQueue);
+ RefPtr<MediaDataDecoderProxy> wrapper =
+ CreateDecoderWrapper(aParams.mCallback, mProxy, aParams.mTaskQueue);
wrapper->SetProxyTarget(new EMEAudioDecoder(mProxy,
- aConfig,
- aTaskQueue,
+ aParams.AudioConfig(),
+ aParams.mTaskQueue,
wrapper->Callback()));
return wrapper.forget();
}
MOZ_ASSERT(mPDM);
- RefPtr<MediaDataDecoder> decoder(
- mPDM->CreateDecoder(aConfig, aTaskQueue, aCallback, aDiagnostics));
+ RefPtr<MediaDataDecoder> decoder(mPDM->CreateDecoder(aParams));
if (!decoder) {
return nullptr;
}
RefPtr<MediaDataDecoder> emeDecoder(new EMEDecryptor(decoder,
- aCallback,
- mProxy,
- AbstractThread::GetCurrent()->AsTaskQueue()));
+ aParams.mCallback,
+ mProxy,
+ AbstractThread::GetCurrent()->AsTaskQueue()));
return emeDecoder.forget();
}
PlatformDecoderModule::ConversionRequired
EMEDecoderModule::DecoderNeedsConversion(const TrackInfo& aConfig) const
{
if (aConfig.IsVideo()) {
return kNeedAVCC;
--- a/dom/media/platforms/agnostic/eme/EMEDecoderModule.h
+++ b/dom/media/platforms/agnostic/eme/EMEDecoderModule.h
@@ -21,29 +21,21 @@ private:
public:
EMEDecoderModule(CDMProxy* aProxy, PDMFactory* aPDM);
virtual ~EMEDecoderModule();
protected:
// Decode thread.
already_AddRefed<MediaDataDecoder>
- CreateVideoDecoder(const VideoInfo& aConfig,
- layers::LayersBackend aLayersBackend,
- layers::ImageContainer* aImageContainer,
- TaskQueue* aTaskQueue,
- MediaDataDecoderCallback* aCallback,
- DecoderDoctorDiagnostics* aDiagnostics) override;
+ CreateVideoDecoder(const CreateDecoderParams& aParams) override;
// Decode thread.
already_AddRefed<MediaDataDecoder>
- CreateAudioDecoder(const AudioInfo& aConfig,
- TaskQueue* aTaskQueue,
- MediaDataDecoderCallback* aCallback,
- DecoderDoctorDiagnostics* aDiagnostics) override;
+ CreateAudioDecoder(const CreateDecoderParams& aParams) override;
ConversionRequired
DecoderNeedsConversion(const TrackInfo& aConfig) const override;
bool
SupportsMimeType(const nsACString& aMimeType,
DecoderDoctorDiagnostics* aDiagnostics) const override;
--- a/dom/media/platforms/agnostic/gmp/GMPDecoderModule.cpp
+++ b/dom/media/platforms/agnostic/gmp/GMPDecoderModule.cpp
@@ -41,63 +41,55 @@ CreateDecoderWrapper(MediaDataDecoderCal
if (!thread) {
return nullptr;
}
RefPtr<MediaDataDecoderProxy> decoder(new MediaDataDecoderProxy(thread.forget(), aCallback));
return decoder.forget();
}
already_AddRefed<MediaDataDecoder>
-GMPDecoderModule::CreateVideoDecoder(const VideoInfo& aConfig,
- layers::LayersBackend aLayersBackend,
- layers::ImageContainer* aImageContainer,
- TaskQueue* aTaskQueue,
- MediaDataDecoderCallback* aCallback,
- DecoderDoctorDiagnostics* aDiagnostics)
+GMPDecoderModule::CreateVideoDecoder(const CreateDecoderParams& aParams)
{
- if (!aConfig.mMimeType.EqualsLiteral("video/avc")) {
+ if (!aParams.mConfig.mMimeType.EqualsLiteral("video/avc")) {
return nullptr;
}
- if (aDiagnostics) {
- const Maybe<nsCString> preferredGMP = PreferredGMP(aConfig.mMimeType);
+ if (aParams.mDiagnostics) {
+ const Maybe<nsCString> preferredGMP = PreferredGMP(aParams.mConfig.mMimeType);
if (preferredGMP.isSome()) {
- aDiagnostics->SetGMP(preferredGMP.value());
+ aParams.mDiagnostics->SetGMP(preferredGMP.value());
}
}
- RefPtr<MediaDataDecoderProxy> wrapper = CreateDecoderWrapper(aCallback);
- wrapper->SetProxyTarget(new GMPVideoDecoder(aConfig,
- aLayersBackend,
- aImageContainer,
- aTaskQueue,
+ RefPtr<MediaDataDecoderProxy> wrapper = CreateDecoderWrapper(aParams.mCallback);
+ wrapper->SetProxyTarget(new GMPVideoDecoder(aParams.VideoConfig(),
+ aParams.mLayersBackend,
+ aParams.mImageContainer,
+ aParams.mTaskQueue,
wrapper->Callback()));
return wrapper.forget();
}
already_AddRefed<MediaDataDecoder>
-GMPDecoderModule::CreateAudioDecoder(const AudioInfo& aConfig,
- TaskQueue* aTaskQueue,
- MediaDataDecoderCallback* aCallback,
- DecoderDoctorDiagnostics* aDiagnostics)
+GMPDecoderModule::CreateAudioDecoder(const CreateDecoderParams& aParams)
{
- if (!aConfig.mMimeType.EqualsLiteral("audio/mp4a-latm")) {
+ if (!aParams.mConfig.mMimeType.EqualsLiteral("audio/mp4a-latm")) {
return nullptr;
}
- if (aDiagnostics) {
- const Maybe<nsCString> preferredGMP = PreferredGMP(aConfig.mMimeType);
+ if (aParams.mDiagnostics) {
+ const Maybe<nsCString> preferredGMP = PreferredGMP(aParams.mConfig.mMimeType);
if (preferredGMP.isSome()) {
- aDiagnostics->SetGMP(preferredGMP.value());
+ aParams.mDiagnostics->SetGMP(preferredGMP.value());
}
}
- RefPtr<MediaDataDecoderProxy> wrapper = CreateDecoderWrapper(aCallback);
- wrapper->SetProxyTarget(new GMPAudioDecoder(aConfig,
- aTaskQueue,
+ RefPtr<MediaDataDecoderProxy> wrapper = CreateDecoderWrapper(aParams.mCallback);
+ wrapper->SetProxyTarget(new GMPAudioDecoder(aParams.AudioConfig(),
+ aParams.mTaskQueue,
wrapper->Callback()));
return wrapper.forget();
}
PlatformDecoderModule::ConversionRequired
GMPDecoderModule::DecoderNeedsConversion(const TrackInfo& aConfig) const
{
// GMPVideoCodecType::kGMPVideoCodecH264 specifies that encoded frames must be in AVCC format.
--- a/dom/media/platforms/agnostic/gmp/GMPDecoderModule.h
+++ b/dom/media/platforms/agnostic/gmp/GMPDecoderModule.h
@@ -28,29 +28,21 @@ namespace mozilla {
class GMPDecoderModule : public PlatformDecoderModule {
public:
GMPDecoderModule();
virtual ~GMPDecoderModule();
// Decode thread.
already_AddRefed<MediaDataDecoder>
- CreateVideoDecoder(const VideoInfo& aConfig,
- layers::LayersBackend aLayersBackend,
- layers::ImageContainer* aImageContainer,
- TaskQueue* aTaskQueue,
- MediaDataDecoderCallback* aCallback,
- DecoderDoctorDiagnostics* aDiagnostics) override;
+ CreateVideoDecoder(const CreateDecoderParams& aParams) override;
// Decode thread.
already_AddRefed<MediaDataDecoder>
- CreateAudioDecoder(const AudioInfo& aConfig,
- TaskQueue* aTaskQueue,
- MediaDataDecoderCallback* aCallback,
- DecoderDoctorDiagnostics* aDiagnostics) override;
+ CreateAudioDecoder(const CreateDecoderParams& aParams) override;
ConversionRequired
DecoderNeedsConversion(const TrackInfo& aConfig) const override;
bool
SupportsMimeType(const nsACString& aMimeType,
DecoderDoctorDiagnostics* aDiagnostics) const override;
--- a/dom/media/platforms/android/AndroidDecoderModule.cpp
+++ b/dom/media/platforms/android/AndroidDecoderModule.cpp
@@ -277,57 +277,55 @@ AndroidDecoderModule::SupportsMimeType(c
return false;
}
return widget::HardwareCodecCapabilityUtils::FindDecoderCodecInfoForMimeType(
nsCString(TranslateMimeType(aMimeType)));
}
already_AddRefed<MediaDataDecoder>
-AndroidDecoderModule::CreateVideoDecoder(
- const VideoInfo& aConfig, layers::LayersBackend aLayersBackend,
- layers::ImageContainer* aImageContainer, TaskQueue* aTaskQueue,
- MediaDataDecoderCallback* aCallback,
- DecoderDoctorDiagnostics* aDiagnostics)
+AndroidDecoderModule::CreateVideoDecoder(const CreateDecoderParams& aParams)
{
MediaFormat::LocalRef format;
+ const VideoInfo& config = aParams.VideoConfig();
NS_ENSURE_SUCCESS(MediaFormat::CreateVideoFormat(
- TranslateMimeType(aConfig.mMimeType),
- aConfig.mDisplay.width,
- aConfig.mDisplay.height,
+ TranslateMimeType(config.mMimeType),
+ config.mDisplay.width,
+ config.mDisplay.height,
&format), nullptr);
RefPtr<MediaDataDecoder> decoder =
- new VideoDataDecoder(aConfig, format, aCallback, aImageContainer);
+ new VideoDataDecoder(config,
+ format,
+ aParams.mCallback,
+ aParams.mImageContainer);
return decoder.forget();
}
already_AddRefed<MediaDataDecoder>
-AndroidDecoderModule::CreateAudioDecoder(
- const AudioInfo& aConfig, TaskQueue* aTaskQueue,
- MediaDataDecoderCallback* aCallback,
- DecoderDoctorDiagnostics* aDiagnostics)
+AndroidDecoderModule::CreateAudioDecoder(const CreateDecoderParams& aParams)
{
- MOZ_ASSERT(aConfig.mBitDepth == 16, "We only handle 16-bit audio!");
+ const AudioInfo& config = aParams.AudioConfig();
+ MOZ_ASSERT(config.mBitDepth == 16, "We only handle 16-bit audio!");
MediaFormat::LocalRef format;
LOG("CreateAudioFormat with mimeType=%s, mRate=%d, channels=%d",
- aConfig.mMimeType.Data(), aConfig.mRate, aConfig.mChannels);
+ config.mMimeType.Data(), config.mRate, config.mChannels);
NS_ENSURE_SUCCESS(MediaFormat::CreateAudioFormat(
- aConfig.mMimeType,
- aConfig.mRate,
- aConfig.mChannels,
+ config.mMimeType,
+ config.mRate,
+ config.mChannels,
&format), nullptr);
RefPtr<MediaDataDecoder> decoder =
- new AudioDataDecoder(aConfig, format, aCallback);
+ new AudioDataDecoder(config, format, aParams.mCallback);
return decoder.forget();
}
PlatformDecoderModule::ConversionRequired
AndroidDecoderModule::DecoderNeedsConversion(const TrackInfo& aConfig) const
{
if (aConfig.IsVideo()) {
--- a/dom/media/platforms/android/AndroidDecoderModule.h
+++ b/dom/media/platforms/android/AndroidDecoderModule.h
@@ -17,28 +17,20 @@
namespace mozilla {
typedef std::deque<RefPtr<MediaRawData>> SampleQueue;
class AndroidDecoderModule : public PlatformDecoderModule {
public:
already_AddRefed<MediaDataDecoder>
- CreateVideoDecoder(const VideoInfo& aConfig,
- layers::LayersBackend aLayersBackend,
- layers::ImageContainer* aImageContainer,
- TaskQueue* aTaskQueue,
- MediaDataDecoderCallback* aCallback,
- DecoderDoctorDiagnostics* aDiagnostics) override;
+ CreateVideoDecoder(const CreateDecoderParams& aParams) override;
already_AddRefed<MediaDataDecoder>
- CreateAudioDecoder(const AudioInfo& aConfig,
- TaskQueue* aTaskQueue,
- MediaDataDecoderCallback* aCallback,
- DecoderDoctorDiagnostics* aDiagnostics) override;
+ CreateAudioDecoder(const CreateDecoderParams& aParams) override;
AndroidDecoderModule() {}
virtual ~AndroidDecoderModule() {}
bool SupportsMimeType(const nsACString& aMimeType,
DecoderDoctorDiagnostics* aDiagnostics) const override;
--- a/dom/media/platforms/apple/AppleDecoderModule.cpp
+++ b/dom/media/platforms/apple/AppleDecoderModule.cpp
@@ -69,52 +69,49 @@ AppleDecoderModule::Startup()
{
if (!sInitialized || (!sIsVDAAvailable && !sIsVTAvailable)) {
return NS_ERROR_FAILURE;
}
return NS_OK;
}
already_AddRefed<MediaDataDecoder>
-AppleDecoderModule::CreateVideoDecoder(const VideoInfo& aConfig,
- layers::LayersBackend aLayersBackend,
- layers::ImageContainer* aImageContainer,
- TaskQueue* aTaskQueue,
- MediaDataDecoderCallback* aCallback,
- DecoderDoctorDiagnostics* aDiagnostics)
+AppleDecoderModule::CreateVideoDecoder(const CreateDecoderParams& aParams)
{
RefPtr<MediaDataDecoder> decoder;
if (sIsVDAAvailable && (!sIsVTHWAvailable || MediaPrefs::AppleForceVDA())) {
decoder =
- AppleVDADecoder::CreateVDADecoder(aConfig,
- aTaskQueue,
- aCallback,
- aImageContainer);
+ AppleVDADecoder::CreateVDADecoder(aParams.VideoConfig(),
+ aParams.mTaskQueue,
+ aParams.mCallback,
+ aParams.mImageContainer);
if (decoder) {
return decoder.forget();
}
}
// We fallback here if VDA isn't available, or is available but isn't
// supported by the current platform.
if (sIsVTAvailable) {
decoder =
- new AppleVTDecoder(aConfig, aTaskQueue, aCallback, aImageContainer);
+ new AppleVTDecoder(aParams.VideoConfig(),
+ aParams.mTaskQueue,
+ aParams.mCallback,
+ aParams.mImageContainer);
}
return decoder.forget();
}
already_AddRefed<MediaDataDecoder>
-AppleDecoderModule::CreateAudioDecoder(const AudioInfo& aConfig,
- TaskQueue* aTaskQueue,
- MediaDataDecoderCallback* aCallback,
- DecoderDoctorDiagnostics* aDiagnostics)
+AppleDecoderModule::CreateAudioDecoder(const CreateDecoderParams& aParams)
{
RefPtr<MediaDataDecoder> decoder =
- new AppleATDecoder(aConfig, aTaskQueue, aCallback);
+ new AppleATDecoder(aParams.AudioConfig(),
+ aParams.mTaskQueue,
+ aParams.mCallback);
return decoder.forget();
}
bool
AppleDecoderModule::SupportsMimeType(const nsACString& aMimeType,
DecoderDoctorDiagnostics* aDiagnostics) const
{
return (sIsCoreMediaAvailable &&
--- a/dom/media/platforms/apple/AppleDecoderModule.h
+++ b/dom/media/platforms/apple/AppleDecoderModule.h
@@ -15,29 +15,21 @@ class AppleDecoderModule : public Platfo
public:
AppleDecoderModule();
virtual ~AppleDecoderModule();
nsresult Startup() override;
// Decode thread.
already_AddRefed<MediaDataDecoder>
- CreateVideoDecoder(const VideoInfo& aConfig,
- layers::LayersBackend aLayersBackend,
- layers::ImageContainer* aImageContainer,
- TaskQueue* aTaskQueue,
- MediaDataDecoderCallback* aCallback,
- DecoderDoctorDiagnostics* aDiagnostics) override;
+ CreateVideoDecoder(const CreateDecoderParams& aParams) override;
// Decode thread.
already_AddRefed<MediaDataDecoder>
- CreateAudioDecoder(const AudioInfo& aConfig,
- TaskQueue* aTaskQueue,
- MediaDataDecoderCallback* aCallback,
- DecoderDoctorDiagnostics* aDiagnostics) override;
+ CreateAudioDecoder(const CreateDecoderParams& aParams) override;
bool SupportsMimeType(const nsACString& aMimeType,
DecoderDoctorDiagnostics* aDiagnostics) const override;
ConversionRequired
DecoderNeedsConversion(const TrackInfo& aConfig) const override;
static void Init();
--- a/dom/media/platforms/ffmpeg/FFmpegDecoderModule.h
+++ b/dom/media/platforms/ffmpeg/FFmpegDecoderModule.h
@@ -26,40 +26,38 @@ public:
return pdm.forget();
}
explicit FFmpegDecoderModule(FFmpegLibWrapper* aLib) : mLib(aLib) {}
virtual ~FFmpegDecoderModule() {}
already_AddRefed<MediaDataDecoder>
- CreateVideoDecoder(const VideoInfo& aConfig,
- layers::LayersBackend aLayersBackend,
- layers::ImageContainer* aImageContainer,
- TaskQueue* aTaskQueue,
- MediaDataDecoderCallback* aCallback,
- DecoderDoctorDiagnostics* aDiagnostics) override
+ CreateVideoDecoder(const CreateDecoderParams& aParams) override
{
RefPtr<MediaDataDecoder> decoder =
- new FFmpegVideoDecoder<V>(mLib, aTaskQueue, aCallback, aConfig,
- aImageContainer);
+ new FFmpegVideoDecoder<V>(mLib,
+ aParams.mTaskQueue,
+ aParams.mCallback,
+ aParams.VideoConfig(),
+ aParams.mImageContainer);
return decoder.forget();
}
already_AddRefed<MediaDataDecoder>
- CreateAudioDecoder(const AudioInfo& aConfig,
- TaskQueue* aTaskQueue,
- MediaDataDecoderCallback* aCallback,
- DecoderDoctorDiagnostics* aDiagnostics) override
+ CreateAudioDecoder(const CreateDecoderParams& aParams) override
{
#ifdef USING_MOZFFVPX
return nullptr;
#else
RefPtr<MediaDataDecoder> decoder =
- new FFmpegAudioDecoder<V>(mLib, aTaskQueue, aCallback, aConfig);
+ new FFmpegAudioDecoder<V>(mLib,
+ aParams.mTaskQueue,
+ aParams.mCallback,
+ aParams.AudioConfig());
return decoder.forget();
#endif
}
bool SupportsMimeType(const nsACString& aMimeType,
DecoderDoctorDiagnostics* aDiagnostics) const override
{
AVCodecID videoCodec = FFmpegVideoDecoder<V>::GetCodecId(aMimeType);
--- a/dom/media/platforms/gonk/GonkDecoderModule.cpp
+++ b/dom/media/platforms/gonk/GonkDecoderModule.cpp
@@ -14,34 +14,26 @@ GonkDecoderModule::GonkDecoderModule()
{
}
GonkDecoderModule::~GonkDecoderModule()
{
}
already_AddRefed<MediaDataDecoder>
-GonkDecoderModule::CreateVideoDecoder(const VideoInfo& aConfig,
- mozilla::layers::LayersBackend aLayersBackend,
- mozilla::layers::ImageContainer* aImageContainer,
- TaskQueue* aTaskQueue,
- MediaDataDecoderCallback* aCallback,
- DecoderDoctorDiagnostics* aDiagnostics)
+GonkDecoderModule::CreateVideoDecoder(const CreateDecoderParams& aParams)
{
RefPtr<MediaDataDecoder> decoder =
new GonkMediaDataDecoder(new GonkVideoDecoderManager(aImageContainer, aConfig),
aCallback);
return decoder.forget();
}
already_AddRefed<MediaDataDecoder>
-GonkDecoderModule::CreateAudioDecoder(const AudioInfo& aConfig,
- TaskQueue* aTaskQueue,
- MediaDataDecoderCallback* aCallback,
- DecoderDoctorDiagnostics* aDiagnostics)
+GonkDecoderModule::CreateAudioDecoder(const CreateDecoderParams& aParams)
{
RefPtr<MediaDataDecoder> decoder =
new GonkMediaDataDecoder(new GonkAudioDecoderManager(aConfig),
aCallback);
return decoder.forget();
}
PlatformDecoderModule::ConversionRequired
--- a/dom/media/platforms/gonk/GonkDecoderModule.h
+++ b/dom/media/platforms/gonk/GonkDecoderModule.h
@@ -13,29 +13,21 @@ namespace mozilla {
class GonkDecoderModule : public PlatformDecoderModule {
public:
GonkDecoderModule();
virtual ~GonkDecoderModule();
// Decode thread.
already_AddRefed<MediaDataDecoder>
- CreateVideoDecoder(const VideoInfo& aConfig,
- mozilla::layers::LayersBackend aLayersBackend,
- mozilla::layers::ImageContainer* aImageContainer,
- TaskQueue* aTaskQueue,
- MediaDataDecoderCallback* aCallback,
- DecoderDoctorDiagnostics* aDiagnostics) override;
+ CreateVideoDecoder(const CreateDecoderParams& aParams) override;
// Decode thread.
already_AddRefed<MediaDataDecoder>
- CreateAudioDecoder(const AudioInfo& aConfig,
- TaskQueue* aTaskQueue,
- MediaDataDecoderCallback* aCallback,
- DecoderDoctorDiagnostics* aDiagnostics) override;
+ CreateAudioDecoder(const CreateDecoderParams& aParams) override;
ConversionRequired
DecoderNeedsConversion(const TrackInfo& aConfig) const override;
bool SupportsMimeType(const nsACString& aMimeType,
DecoderDoctorDiagnostics* aDiagnostics) const override;
};
--- a/dom/media/platforms/omx/OmxDecoderModule.cpp
+++ b/dom/media/platforms/omx/OmxDecoderModule.cpp
@@ -7,34 +7,30 @@
#include "OmxDecoderModule.h"
#include "OmxDataDecoder.h"
#include "OmxPlatformLayer.h"
namespace mozilla {
already_AddRefed<MediaDataDecoder>
-OmxDecoderModule::CreateVideoDecoder(const VideoInfo& aConfig,
- mozilla::layers::LayersBackend aLayersBackend,
- mozilla::layers::ImageContainer* aImageContainer,
- TaskQueue* aTaskQueue,
- MediaDataDecoderCallback* aCallback,
- DecoderDoctorDiagnostics* aDiagnostics)
+OmxDecoderModule::CreateVideoDecoder(const CreateDecoderParams& aParams)
{
- RefPtr<OmxDataDecoder> decoder = new OmxDataDecoder(aConfig, aCallback, aImageContainer);
+ RefPtr<OmxDataDecoder> decoder = new OmxDataDecoder(aParams.mConfig,
+ aParams.mCallback,
+ aParams.mImageContainer);
return decoder.forget();
}
already_AddRefed<MediaDataDecoder>
-OmxDecoderModule::CreateAudioDecoder(const AudioInfo& aConfig,
- TaskQueue* aTaskQueue,
- MediaDataDecoderCallback* aCallback,
- DecoderDoctorDiagnostics* aDiagnostics)
+OmxDecoderModule::CreateAudioDecoder(const CreateDecoderParams& aParams)
{
- RefPtr<OmxDataDecoder> decoder = new OmxDataDecoder(aConfig, aCallback, nullptr);
+ RefPtr<OmxDataDecoder> decoder = new OmxDataDecoder(aParams.mConfig,
+ aParams.mCallback,
+ nullptr);
return decoder.forget();
}
PlatformDecoderModule::ConversionRequired
OmxDecoderModule::DecoderNeedsConversion(const TrackInfo& aConfig) const
{
return kNeedNone;
}
--- a/dom/media/platforms/omx/OmxDecoderModule.h
+++ b/dom/media/platforms/omx/OmxDecoderModule.h
@@ -9,28 +9,20 @@
#include "PlatformDecoderModule.h"
namespace mozilla {
class OmxDecoderModule : public PlatformDecoderModule {
public:
already_AddRefed<MediaDataDecoder>
- CreateVideoDecoder(const VideoInfo& aConfig,
- mozilla::layers::LayersBackend aLayersBackend,
- mozilla::layers::ImageContainer* aImageContainer,
- TaskQueue* aTaskQueue,
- MediaDataDecoderCallback* aCallback,
- DecoderDoctorDiagnostics* aDiagnostics) override;
+ CreateVideoDecoder(const CreateDecoderParams& aParams) override;
already_AddRefed<MediaDataDecoder>
- CreateAudioDecoder(const AudioInfo& aConfig,
- TaskQueue* aTaskQueue,
- MediaDataDecoderCallback* aCallback,
- DecoderDoctorDiagnostics* aDiagnostics) override;
+ CreateAudioDecoder(const CreateDecoderParams& aParams) override;
bool SupportsMimeType(const nsACString& aMimeType,
DecoderDoctorDiagnostics* aDiagnostics) const override;
ConversionRequired DecoderNeedsConversion(const TrackInfo& aConfig) const override;
};
} // namespace mozilla
--- a/dom/media/platforms/wmf/WMFDecoderModule.cpp
+++ b/dom/media/platforms/wmf/WMFDecoderModule.cpp
@@ -71,53 +71,45 @@ WMFDecoderModule::GetNumDecoderThreads()
nsresult
WMFDecoderModule::Startup()
{
mWMFInitialized = SUCCEEDED(wmf::MFStartup());
return mWMFInitialized ? NS_OK : NS_ERROR_FAILURE;
}
already_AddRefed<MediaDataDecoder>
-WMFDecoderModule::CreateVideoDecoder(const VideoInfo& aConfig,
- layers::LayersBackend aLayersBackend,
- layers::ImageContainer* aImageContainer,
- TaskQueue* aTaskQueue,
- MediaDataDecoderCallback* aCallback,
- DecoderDoctorDiagnostics* aDiagnostics)
+WMFDecoderModule::CreateVideoDecoder(const CreateDecoderParams& aParams)
{
nsAutoPtr<WMFVideoMFTManager> manager(
- new WMFVideoMFTManager(aConfig,
- aLayersBackend,
- aImageContainer,
+ new WMFVideoMFTManager(aParams.VideoConfig(),
+ aParams.mLayersBackend,
+ aParams.mImageContainer,
sDXVAEnabled));
if (!manager->Init()) {
return nullptr;
}
RefPtr<MediaDataDecoder> decoder =
- new WMFMediaDataDecoder(manager.forget(), aTaskQueue, aCallback);
+ new WMFMediaDataDecoder(manager.forget(), aParams.mTaskQueue, aParams.mCallback);
return decoder.forget();
}
already_AddRefed<MediaDataDecoder>
-WMFDecoderModule::CreateAudioDecoder(const AudioInfo& aConfig,
- TaskQueue* aTaskQueue,
- MediaDataDecoderCallback* aCallback,
- DecoderDoctorDiagnostics* aDiagnostics)
+WMFDecoderModule::CreateAudioDecoder(const CreateDecoderParams& aParams)
{
- nsAutoPtr<WMFAudioMFTManager> manager(new WMFAudioMFTManager(aConfig));
+ nsAutoPtr<WMFAudioMFTManager> manager(new WMFAudioMFTManager(aParams.AudioConfig()));
if (!manager->Init()) {
return nullptr;
}
RefPtr<MediaDataDecoder> decoder =
- new WMFMediaDataDecoder(manager.forget(), aTaskQueue, aCallback);
+ new WMFMediaDataDecoder(manager.forget(), aParams.mTaskQueue, aParams.mCallback);
return decoder.forget();
}
static bool
CanCreateMFTDecoder(const GUID& aGuid)
{
if (FAILED(wmf::MFStartup())) {
return false;
--- a/dom/media/platforms/wmf/WMFDecoderModule.h
+++ b/dom/media/platforms/wmf/WMFDecoderModule.h
@@ -15,28 +15,20 @@ class WMFDecoderModule : public Platform
public:
WMFDecoderModule();
virtual ~WMFDecoderModule();
// Initializes the module, loads required dynamic libraries, etc.
nsresult Startup() override;
already_AddRefed<MediaDataDecoder>
- CreateVideoDecoder(const VideoInfo& aConfig,
- layers::LayersBackend aLayersBackend,
- layers::ImageContainer* aImageContainer,
- TaskQueue* aTaskQueue,
- MediaDataDecoderCallback* aCallback,
- DecoderDoctorDiagnostics* aDiagnostics) override;
+ CreateVideoDecoder(const CreateDecoderParams& aParams) override;
already_AddRefed<MediaDataDecoder>
- CreateAudioDecoder(const AudioInfo& aConfig,
- TaskQueue* aTaskQueue,
- MediaDataDecoderCallback* aCallback,
- DecoderDoctorDiagnostics* aDiagnostics) override;
+ CreateAudioDecoder(const CreateDecoderParams& aParams) override;
bool SupportsMimeType(const nsACString& aMimeType,
DecoderDoctorDiagnostics* aDiagnostics) const override;
ConversionRequired
DecoderNeedsConversion(const TrackInfo& aConfig) const override;
// Called on main thread.
--- a/dom/media/platforms/wrappers/H264Converter.cpp
+++ b/dom/media/platforms/wrappers/H264Converter.cpp
@@ -11,34 +11,29 @@
#include "MediaInfo.h"
#include "mp4_demuxer/AnnexB.h"
#include "mp4_demuxer/H264.h"
namespace mozilla
{
H264Converter::H264Converter(PlatformDecoderModule* aPDM,
- const VideoInfo& aConfig,
- layers::LayersBackend aLayersBackend,
- layers::ImageContainer* aImageContainer,
- TaskQueue* aTaskQueue,
- MediaDataDecoderCallback* aCallback,
- DecoderDoctorDiagnostics* aDiagnostics)
+ const CreateDecoderParams& aParams)
: mPDM(aPDM)
- , mOriginalConfig(aConfig)
- , mCurrentConfig(aConfig)
- , mLayersBackend(aLayersBackend)
- , mImageContainer(aImageContainer)
- , mTaskQueue(aTaskQueue)
- , mCallback(aCallback)
+ , mOriginalConfig(aParams.VideoConfig())
+ , mCurrentConfig(aParams.VideoConfig())
+ , mLayersBackend(aParams.mLayersBackend)
+ , mImageContainer(aParams.mImageContainer)
+ , mTaskQueue(aParams.mTaskQueue)
+ , mCallback(aParams.mCallback)
, mDecoder(nullptr)
- , mNeedAVCC(aPDM->DecoderNeedsConversion(aConfig) == PlatformDecoderModule::kNeedAVCC)
+ , mNeedAVCC(aPDM->DecoderNeedsConversion(aParams.mConfig) == PlatformDecoderModule::kNeedAVCC)
, mLastError(NS_OK)
{
- CreateDecoder(aDiagnostics);
+ CreateDecoder(aParams.mDiagnostics);
}
H264Converter::~H264Converter()
{
}
RefPtr<MediaDataDecoder::InitPromise>
H264Converter::Init()
@@ -141,22 +136,25 @@ H264Converter::CreateDecoder(DecoderDoct
}
UpdateConfigFromExtraData(mCurrentConfig.mExtraData);
if (!mNeedAVCC) {
// When using a decoder handling AnnexB, we get here only once from the
// constructor. We do want to get the dimensions extracted from the SPS.
mOriginalConfig = mCurrentConfig;
}
- mDecoder = mPDM->CreateVideoDecoder(mNeedAVCC ? mCurrentConfig : mOriginalConfig,
- mLayersBackend,
- mImageContainer,
- mTaskQueue,
- mCallback,
- aDiagnostics);
+ mDecoder = mPDM->CreateVideoDecoder({
+ mNeedAVCC ? mCurrentConfig : mOriginalConfig,
+ mTaskQueue,
+ mCallback,
+ aDiagnostics,
+ mImageContainer,
+ mLayersBackend
+ });
+
if (!mDecoder) {
mLastError = NS_ERROR_FAILURE;
return NS_ERROR_FAILURE;
}
return NS_OK;
}
nsresult
--- a/dom/media/platforms/wrappers/H264Converter.h
+++ b/dom/media/platforms/wrappers/H264Converter.h
@@ -17,22 +17,17 @@ namespace mozilla {
// provided in the init segment (e.g. AVC3 or Annex B)
// H264Converter will monitor the input data, and will delay creation of the
// MediaDataDecoder until a SPS and PPS NALs have been extracted.
class H264Converter : public MediaDataDecoder {
public:
H264Converter(PlatformDecoderModule* aPDM,
- const VideoInfo& aConfig,
- layers::LayersBackend aLayersBackend,
- layers::ImageContainer* aImageContainer,
- TaskQueue* aTaskQueue,
- MediaDataDecoderCallback* aCallback,
- DecoderDoctorDiagnostics* aDiagnostics);
+ const CreateDecoderParams& aParams);
virtual ~H264Converter();
RefPtr<InitPromise> Init() override;
nsresult Input(MediaRawData* aSample) override;
nsresult Flush() override;
nsresult Drain() override;
nsresult Shutdown() override;
bool IsHardwareAccelerated(nsACString& aFailureReason) const override;