mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1206977: P4. Add AgnosticDecoderModule object. r=cpearce
This removes the need for PDMFactory to know anything about decoders.
This commit is contained in:
parent
6893a3c385
commit
ddb4ca14aa
@ -32,9 +32,7 @@
|
||||
#include "FuzzingWrapper.h"
|
||||
#include "H264Converter.h"
|
||||
|
||||
#include "OpusDecoder.h"
|
||||
#include "VorbisDecoder.h"
|
||||
#include "VPXDecoder.h"
|
||||
#include "AgnosticDecoderModule.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
@ -112,22 +110,15 @@ PDMFactory::CreateDecoder(const TrackInfo& aConfig,
|
||||
layers::ImageContainer* aImageContainer)
|
||||
{
|
||||
nsRefPtr<PlatformDecoderModule> current = GetDecoder(aConfig.mMimeType);
|
||||
if (!current) {
|
||||
return nullptr;
|
||||
}
|
||||
nsRefPtr<MediaDataDecoder> m;
|
||||
|
||||
if (aConfig.GetAsAudioInfo()) {
|
||||
if (!current && VorbisDataDecoder::IsVorbis(aConfig.mMimeType)) {
|
||||
m = new VorbisDataDecoder(*aConfig.GetAsAudioInfo(),
|
||||
aTaskQueue,
|
||||
aCallback);
|
||||
} else if (!current && OpusDataDecoder::IsOpus(aConfig.mMimeType)) {
|
||||
m = new OpusDataDecoder(*aConfig.GetAsAudioInfo(),
|
||||
aTaskQueue,
|
||||
aCallback);
|
||||
} else if (current) {
|
||||
m = current->CreateAudioDecoder(*aConfig.GetAsAudioInfo(),
|
||||
m = current->CreateAudioDecoder(*aConfig.GetAsAudioInfo(),
|
||||
aTaskQueue,
|
||||
aCallback);
|
||||
}
|
||||
return m.forget();
|
||||
}
|
||||
|
||||
@ -145,34 +136,27 @@ PDMFactory::CreateDecoder(const TrackInfo& aConfig,
|
||||
callback = callbackWrapper.get();
|
||||
}
|
||||
|
||||
if (!current && VPXDecoder::IsVPX(aConfig.mMimeType)) {
|
||||
m = new VPXDecoder(*aConfig.GetAsVideoInfo(),
|
||||
aImageContainer,
|
||||
aTaskQueue,
|
||||
callback);
|
||||
} else if (current) {
|
||||
if (H264Converter::IsH264(aConfig)) {
|
||||
nsRefPtr<H264Converter> h
|
||||
= new H264Converter(current,
|
||||
*aConfig.GetAsVideoInfo(),
|
||||
aLayersBackend,
|
||||
aImageContainer,
|
||||
aTaskQueue,
|
||||
callback);
|
||||
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 = current->CreateVideoDecoder(*aConfig.GetAsVideoInfo(),
|
||||
aLayersBackend,
|
||||
aImageContainer,
|
||||
aTaskQueue,
|
||||
callback);
|
||||
if (H264Converter::IsH264(aConfig)) {
|
||||
nsRefPtr<H264Converter> h
|
||||
= new H264Converter(current,
|
||||
*aConfig.GetAsVideoInfo(),
|
||||
aLayersBackend,
|
||||
aImageContainer,
|
||||
aTaskQueue,
|
||||
callback);
|
||||
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 = current->CreateVideoDecoder(*aConfig.GetAsVideoInfo(),
|
||||
aLayersBackend,
|
||||
aImageContainer,
|
||||
aTaskQueue,
|
||||
callback);
|
||||
}
|
||||
|
||||
if (callbackWrapper && m) {
|
||||
@ -186,10 +170,7 @@ bool
|
||||
PDMFactory::SupportsMimeType(const nsACString& aMimeType)
|
||||
{
|
||||
nsRefPtr<PlatformDecoderModule> current = GetDecoder(aMimeType);
|
||||
return current ||
|
||||
VPXDecoder::IsVPX(aMimeType) ||
|
||||
OpusDataDecoder::IsOpus(aMimeType) ||
|
||||
VorbisDataDecoder::IsVorbis(aMimeType);
|
||||
return !!current;
|
||||
}
|
||||
|
||||
void
|
||||
@ -231,6 +212,10 @@ PDMFactory::CreatePDMs()
|
||||
StartupPDM(m);
|
||||
}
|
||||
#endif
|
||||
|
||||
m = new AgnosticDecoderModule();
|
||||
StartupPDM(m);
|
||||
|
||||
if (sUseBlankDecoder) {
|
||||
m = CreateBlankDecoderModule();
|
||||
StartupPDM(m);
|
||||
|
61
dom/media/platforms/agnostic/AgnosticDecoderModule.cpp
Normal file
61
dom/media/platforms/agnostic/AgnosticDecoderModule.cpp
Normal file
@ -0,0 +1,61 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "AgnosticDecoderModule.h"
|
||||
#include "OpusDecoder.h"
|
||||
#include "VorbisDecoder.h"
|
||||
#include "VPXDecoder.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
bool
|
||||
AgnosticDecoderModule::SupportsMimeType(const nsACString& aMimeType)
|
||||
{
|
||||
return VPXDecoder::IsVPX(aMimeType) ||
|
||||
OpusDataDecoder::IsOpus(aMimeType) ||
|
||||
VorbisDataDecoder::IsVorbis(aMimeType);
|
||||
}
|
||||
|
||||
already_AddRefed<MediaDataDecoder>
|
||||
AgnosticDecoderModule::CreateVideoDecoder(const VideoInfo& aConfig,
|
||||
layers::LayersBackend aLayersBackend,
|
||||
layers::ImageContainer* aImageContainer,
|
||||
FlushableTaskQueue* aVideoTaskQueue,
|
||||
MediaDataDecoderCallback* aCallback)
|
||||
{
|
||||
nsRefPtr<MediaDataDecoder> m;
|
||||
|
||||
if (VPXDecoder::IsVPX(aConfig.mMimeType)) {
|
||||
m = new VPXDecoder(*aConfig.GetAsVideoInfo(),
|
||||
aImageContainer,
|
||||
aVideoTaskQueue,
|
||||
aCallback);
|
||||
}
|
||||
|
||||
return m.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<MediaDataDecoder>
|
||||
AgnosticDecoderModule::CreateAudioDecoder(const AudioInfo& aConfig,
|
||||
FlushableTaskQueue* aAudioTaskQueue,
|
||||
MediaDataDecoderCallback* aCallback)
|
||||
{
|
||||
nsRefPtr<MediaDataDecoder> m;
|
||||
|
||||
if (VorbisDataDecoder::IsVorbis(aConfig.mMimeType)) {
|
||||
m = new VorbisDataDecoder(*aConfig.GetAsAudioInfo(),
|
||||
aAudioTaskQueue,
|
||||
aCallback);
|
||||
} else if (OpusDataDecoder::IsOpus(aConfig.mMimeType)) {
|
||||
m = new OpusDataDecoder(*aConfig.GetAsAudioInfo(),
|
||||
aAudioTaskQueue,
|
||||
aCallback);
|
||||
}
|
||||
|
||||
return m.forget();
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
39
dom/media/platforms/agnostic/AgnosticDecoderModule.h
Normal file
39
dom/media/platforms/agnostic/AgnosticDecoderModule.h
Normal file
@ -0,0 +1,39 @@
|
||||
#if !defined(AgnosticDecoderModule_h_)
|
||||
#define AgnosticDecoderModule_h_
|
||||
|
||||
#include "PlatformDecoderModule.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class AgnosticDecoderModule : public PlatformDecoderModule {
|
||||
public:
|
||||
AgnosticDecoderModule() = default;
|
||||
virtual ~AgnosticDecoderModule() = default;
|
||||
|
||||
bool SupportsMimeType(const nsACString& aMimeType) override;
|
||||
|
||||
ConversionRequired
|
||||
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,
|
||||
FlushableTaskQueue* aVideoTaskQueue,
|
||||
MediaDataDecoderCallback* aCallback) override;
|
||||
|
||||
// Decode thread.
|
||||
already_AddRefed<MediaDataDecoder>
|
||||
CreateAudioDecoder(const AudioInfo& aConfig,
|
||||
FlushableTaskQueue* aAudioTaskQueue,
|
||||
MediaDataDecoderCallback* aCallback) override;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
#endif /* AgnosticDecoderModule_h_ */
|
@ -259,27 +259,10 @@ public:
|
||||
|
||||
};
|
||||
|
||||
class AgnosticDecoderModule : public BlankDecoderModule {
|
||||
public:
|
||||
|
||||
bool SupportsMimeType(const nsACString& aMimeType) override
|
||||
{
|
||||
// This module does not support any decoders itself,
|
||||
// agnostic decoders are created in PlatformDecoderModule::CreateDecoder
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
already_AddRefed<PlatformDecoderModule> CreateBlankDecoderModule()
|
||||
{
|
||||
nsRefPtr<PlatformDecoderModule> pdm = new BlankDecoderModule();
|
||||
return pdm.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<PlatformDecoderModule> CreateAgnosticDecoderModule()
|
||||
{
|
||||
nsRefPtr<PlatformDecoderModule> adm = new AgnosticDecoderModule();
|
||||
return adm.forget();
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
@ -5,6 +5,7 @@
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
EXPORTS += [
|
||||
'agnostic/AgnosticDecoderModule.h',
|
||||
'agnostic/OpusDecoder.h',
|
||||
'agnostic/VorbisDecoder.h',
|
||||
'agnostic/VPXDecoder.h',
|
||||
@ -14,6 +15,7 @@ EXPORTS += [
|
||||
]
|
||||
|
||||
UNIFIED_SOURCES += [
|
||||
'agnostic/AgnosticDecoderModule.cpp',
|
||||
'agnostic/BlankDecoderModule.cpp',
|
||||
'agnostic/OpusDecoder.cpp',
|
||||
'agnostic/VorbisDecoder.cpp',
|
||||
|
Loading…
Reference in New Issue
Block a user