mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:30:27 +00:00
faafb5fd9d
- As suggested in PR 101, use OpenBSD assembler files. Update the NetBSD on them and use .S instead of .s, to indicate files to process (or preprocessor would fail on comments). (6a17dbacc3) - Bug 1229769 - Expose Promise interface to WorkerDebugger #ifdef SPIDERMONKEY_PROMISE;r=bz (da9e838c23) - Bug 1155969 - Make xpt.py flake8 compliant. r=ted (84f8eab5a3) - Bug 977464 - Always relink XPT files for all changed XPIDL interfaces without requiring the IID to be revved; r=khuey (9b22512c41) - Bug 977464 follow-up: Fix the indentation to use 4 spaces (bd68a8ebc3) - Bug 1240053 - Consider the order of methods, their params, and constant important when comparing XPT interfaces to decide whether to relink XPT files; r=khuey (b9253dd183) - Bug 1264377. Get rid of some unnecessary custom JSClass hook functions in xpconnect sandboxes and DOM simple globals. r=bholley (60950b416b) - Bug 1258496 - Purge message manager cached scripts on 'message-manager-flush-caches' notification. r=smaug (028b229d02) - Bug 1251298 - Null out |*idp| when necessary in DoInterfaceDescriptor. r=khuey. (dbdd15dae8) - Bug 659625 - part1: implement Console::clear in dom/base/Console.cpp;r=baku (17c4b33789) - Bug 659625 - part2: implement console.clear in devtools webconsole;r=bgrins (b72c6173ee) - Bug 1248507 - p5. DecoderDoctorDiagnostics implementation - r=jya,bz (22f68130af) - Bug 1248507 - p6. Minimal notification definition - r=bz (02f3eeb2f9) - Bug 1248507 - p7. Notify decoder-doctor-notification listeners - r=jya,bz (2c2eb33388) - Bug 1248507 - p8. FFMpeg checks: Console message - r=bz (50a993c143) - Bug 1248507 - p9. FFMpeg checks: Notification definition - r=bz (0bcdcc090c) - Bug 1248507 - p10. Detect and report when FFMpeg/Linux fails to load - r=jya (28137efda0) - Bug 1190939: Decode VP9 4:4:4 properly. r=jya (98508bb48b) - Bug 1232911 - [1.2] Allow to test for specific VPX MIME type version. r=cpearce (1b53e02981) - Bug 1251887 - Add break to unintentional switch fallthrough in GfxInfoBase.cpp to fix -Wimplicit-fallthrough warning. r=milan (9969a7bec7) - Bug 1232911 - [2.2] Add VPX decoding blocking support. r=snorp (fa860a9d4d) - Bug 1249777: Added support for 10.11 in the blocklisting code as well. r=mstange (479f629083) - Bug 1242084 - Fix GfxInfoBase nsStringBuffer leak. r=dvander (87b38ee72d) - Bug 1222201: Only use container calculated dimensions. r=cpearce (693ebdf450) - Bug 1190240 - Cannot compile WMFVideoMFTManager.cpp using Windows 10 SDK. r=cpearce (8ee2e315f5) - Bug 1248496 - Enable D3D11 DXVA. r=ajones (a79df0baf2) - Bug 1248496 - Show which DXVA API is being used in about:support. r=jya (1f6b1f0c8e) - Bug 1257028 - Fallback to d3d9 decoding if d3d11 fails. r=cpearce (5ad7c159f1) - Bug 1232045 - WebMDemuxer handles resolution changes. r=jya (18bdc79b1c) - Bug 1243538: P1. Make MediaInfo::mImage an nsIntSize again and introduce a mImageRect member. r=mattwoodrow (a446cca01e) - Bug 1243538: P2. Add convenience VideoInfo::ScaledImageRect. r=mattwoodrow (657e675b72) - Bug 1243538: P3. Adjust libvpx decoder to allow different decoding size from metadata. r=mattwoodrow (50949ce02d) - Bug 1243538: P4. Adjust ffvpx decoder to allow different decoding size from metadata. r=mattwoodrow (392c8939f5) - Bug 1243538: P5. Adjust wmf decoder to allow different decoding size from metadata. r=cpearce (f50940564f) - Bug 1239611 - Remove GonkNativeWindowClient r=nical (2c7ccb54a4) - Bug 1170589 - Force decoder to use all allocated buffers. r=bwu (7e5c02e48a) - Bug 1222923 - Enable MOZ_FMP4 on gonk L r=jolin (c04ad6ff55) - Bug 1178214 - Return INIT_ERROR when video resolution exceeds hw codec capability. r=sotaro (bf3c45cde1) - Bug 1147304 - Send codec specific data for MPEG4 codec type only. r=jya (ca48d110f4) - Bug 1243538: P6. Adjust gonk decoder to allow different decoding size from metadata. r=alfredo (257e017762) - Bug 1243538: [webm] P7. Let the decoder handle picture resizing. r=SingingTree (32dc4a5aac) - Bug 1262727: [webm] Ensure first frame returned after seek is a keyframe. r=kinetik (f16140852a) - Bug 1246536: [webm] Only use discard padding information on last packet. r=kinetik (0bac4f8855) - Bug 1266013: Fix Firefox OS compile errors. r=gerald (f021717287) - cleanup (390cdec6ee) - Bug 1264991: Don't construct invalid channel configuration. r=gerald (661828e8b8) - Bug 1265093: Fix CID 1358648. r=gerald (55468c1261) - Bug 1262659 - Report HTTP Live Streaming playback requests. r=cpearce,bsmedberg (96b8cd2810) - Bug 1265400 - Use unsigned long for AudioBuffer length and numberOfChannels; r=smaug (f74f27ea4e)
367 lines
10 KiB
C++
367 lines
10 KiB
C++
/* -*- 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 "PDMFactory.h"
|
|
|
|
#ifdef XP_WIN
|
|
#include "WMFDecoderModule.h"
|
|
#endif
|
|
#ifdef MOZ_FFMPEG
|
|
#include "FFmpegRuntimeLinker.h"
|
|
#endif
|
|
#ifdef MOZ_APPLEMEDIA
|
|
#include "AppleDecoderModule.h"
|
|
#endif
|
|
#ifdef MOZ_GONK_MEDIACODEC
|
|
#include "GonkDecoderModule.h"
|
|
#endif
|
|
#ifdef MOZ_WIDGET_ANDROID
|
|
#include "AndroidDecoderModule.h"
|
|
#endif
|
|
#include "GMPDecoderModule.h"
|
|
|
|
#include "mozilla/Preferences.h"
|
|
#include "mozilla/TaskQueue.h"
|
|
|
|
#include "mozilla/SharedThreadPool.h"
|
|
|
|
#include "MediaInfo.h"
|
|
#include "FuzzingWrapper.h"
|
|
#include "H264Converter.h"
|
|
|
|
#include "AgnosticDecoderModule.h"
|
|
|
|
#ifdef MOZ_EME
|
|
#include "EMEDecoderModule.h"
|
|
#include "mozilla/CDMProxy.h"
|
|
#endif
|
|
|
|
#include "DecoderDoctorDiagnostics.h"
|
|
|
|
namespace mozilla {
|
|
|
|
extern already_AddRefed<PlatformDecoderModule> CreateAgnosticDecoderModule();
|
|
extern already_AddRefed<PlatformDecoderModule> CreateBlankDecoderModule();
|
|
|
|
bool PDMFactory::sUseBlankDecoder = false;
|
|
#ifdef MOZ_GONK_MEDIACODEC
|
|
bool PDMFactory::sGonkDecoderEnabled = false;
|
|
#endif
|
|
#ifdef MOZ_WIDGET_ANDROID
|
|
bool PDMFactory::sAndroidMCDecoderEnabled = false;
|
|
bool PDMFactory::sAndroidMCDecoderPreferred = false;
|
|
#endif
|
|
bool PDMFactory::sGMPDecoderEnabled = false;
|
|
#ifdef MOZ_FFMPEG
|
|
bool PDMFactory::sFFmpegDecoderEnabled = false;
|
|
#endif
|
|
#ifdef XP_WIN
|
|
bool PDMFactory::sWMFDecoderEnabled = false;
|
|
#endif
|
|
|
|
bool PDMFactory::sEnableFuzzingWrapper = false;
|
|
uint32_t PDMFactory::sVideoOutputMinimumInterval_ms = 0;
|
|
bool PDMFactory::sDontDelayInputExhausted = false;
|
|
|
|
/* static */
|
|
void
|
|
PDMFactory::Init()
|
|
{
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
static bool alreadyInitialized = false;
|
|
if (alreadyInitialized) {
|
|
return;
|
|
}
|
|
alreadyInitialized = true;
|
|
|
|
Preferences::AddBoolVarCache(&sUseBlankDecoder,
|
|
"media.use-blank-decoder", false);
|
|
#ifdef MOZ_GONK_MEDIACODEC
|
|
Preferences::AddBoolVarCache(&sGonkDecoderEnabled,
|
|
"media.gonk.enabled", true);
|
|
#endif
|
|
#ifdef MOZ_WIDGET_ANDROID
|
|
Preferences::AddBoolVarCache(&sAndroidMCDecoderEnabled,
|
|
"media.android-media-codec.enabled", false);
|
|
Preferences::AddBoolVarCache(&sAndroidMCDecoderPreferred,
|
|
"media.android-media-codec.preferred", false);
|
|
#endif
|
|
|
|
Preferences::AddBoolVarCache(&sGMPDecoderEnabled,
|
|
"media.gmp.decoder.enabled", true);
|
|
#ifdef MOZ_FFMPEG
|
|
Preferences::AddBoolVarCache(&sFFmpegDecoderEnabled,
|
|
"media.ffmpeg.enabled", true);
|
|
#endif
|
|
#ifdef XP_WIN
|
|
Preferences::AddBoolVarCache(&sWMFDecoderEnabled,
|
|
"media.wmf.enabled", true);
|
|
#endif
|
|
|
|
Preferences::AddBoolVarCache(&sEnableFuzzingWrapper,
|
|
"media.decoder.fuzzing.enabled", false);
|
|
Preferences::AddUintVarCache(&sVideoOutputMinimumInterval_ms,
|
|
"media.decoder.fuzzing.video-output-minimum-interval-ms", 0);
|
|
Preferences::AddBoolVarCache(&sDontDelayInputExhausted,
|
|
"media.decoder.fuzzing.dont-delay-inputexhausted", false);
|
|
|
|
#ifdef XP_WIN
|
|
WMFDecoderModule::Init();
|
|
#endif
|
|
#ifdef MOZ_APPLEMEDIA
|
|
AppleDecoderModule::Init();
|
|
#endif
|
|
#ifdef MOZ_FFMPEG
|
|
FFmpegRuntimeLinker::Link();
|
|
#endif
|
|
GMPDecoderModule::Init();
|
|
}
|
|
|
|
PDMFactory::PDMFactory()
|
|
{
|
|
CreatePDMs();
|
|
}
|
|
|
|
PDMFactory::~PDMFactory()
|
|
{
|
|
}
|
|
|
|
already_AddRefed<MediaDataDecoder>
|
|
PDMFactory::CreateDecoder(const TrackInfo& aConfig,
|
|
FlushableTaskQueue* aTaskQueue,
|
|
MediaDataDecoderCallback* aCallback,
|
|
DecoderDoctorDiagnostics* aDiagnostics,
|
|
layers::LayersBackend aLayersBackend,
|
|
layers::ImageContainer* aImageContainer)
|
|
{
|
|
bool isEncrypted = mEMEPDM && aConfig.mCrypto.mValid;
|
|
|
|
if (isEncrypted) {
|
|
return CreateDecoderWithPDM(mEMEPDM,
|
|
aConfig,
|
|
aTaskQueue,
|
|
aCallback,
|
|
aDiagnostics,
|
|
aLayersBackend,
|
|
aImageContainer);
|
|
}
|
|
|
|
if (aDiagnostics) {
|
|
// If libraries failed to load, the following loop over mCurrentPDMs
|
|
// will not even try to use them. So we record failures now.
|
|
if (mFFmpegFailedToLoad) {
|
|
aDiagnostics->SetFFmpegFailedToLoad();
|
|
}
|
|
}
|
|
|
|
for (auto& current : mCurrentPDMs) {
|
|
if (!current->SupportsMimeType(aConfig.mMimeType, aDiagnostics)) {
|
|
continue;
|
|
}
|
|
RefPtr<MediaDataDecoder> m =
|
|
CreateDecoderWithPDM(current,
|
|
aConfig,
|
|
aTaskQueue,
|
|
aCallback,
|
|
aDiagnostics,
|
|
aLayersBackend,
|
|
aImageContainer);
|
|
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,
|
|
FlushableTaskQueue* aTaskQueue,
|
|
MediaDataDecoderCallback* aCallback,
|
|
DecoderDoctorDiagnostics* aDiagnostics,
|
|
layers::LayersBackend aLayersBackend,
|
|
layers::ImageContainer* aImageContainer)
|
|
{
|
|
MOZ_ASSERT(aPDM);
|
|
RefPtr<MediaDataDecoder> m;
|
|
|
|
if (aConfig.GetAsAudioInfo()) {
|
|
m = aPDM->CreateAudioDecoder(*aConfig.GetAsAudioInfo(),
|
|
aTaskQueue,
|
|
aCallback,
|
|
aDiagnostics);
|
|
return m.forget();
|
|
}
|
|
|
|
if (!aConfig.GetAsVideoInfo()) {
|
|
return nullptr;
|
|
}
|
|
|
|
MediaDataDecoderCallback* callback = aCallback;
|
|
RefPtr<DecoderCallbackFuzzingWrapper> callbackWrapper;
|
|
if (sEnableFuzzingWrapper) {
|
|
callbackWrapper = new DecoderCallbackFuzzingWrapper(aCallback);
|
|
callbackWrapper->SetVideoOutputMinimumInterval(
|
|
TimeDuration::FromMilliseconds(sVideoOutputMinimumInterval_ms));
|
|
callbackWrapper->SetDontDelayInputExhausted(sDontDelayInputExhausted);
|
|
callback = callbackWrapper.get();
|
|
}
|
|
|
|
if (H264Converter::IsH264(aConfig)) {
|
|
RefPtr<H264Converter> h
|
|
= new H264Converter(aPDM,
|
|
*aConfig.GetAsVideoInfo(),
|
|
aLayersBackend,
|
|
aImageContainer,
|
|
aTaskQueue,
|
|
callback,
|
|
aDiagnostics);
|
|
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);
|
|
}
|
|
|
|
if (callbackWrapper && m) {
|
|
m = new DecoderFuzzingWrapper(m.forget(), callbackWrapper.forget());
|
|
}
|
|
|
|
return m.forget();
|
|
}
|
|
|
|
bool
|
|
PDMFactory::SupportsMimeType(const nsACString& aMimeType,
|
|
DecoderDoctorDiagnostics* aDiagnostics) const
|
|
{
|
|
if (mEMEPDM) {
|
|
return mEMEPDM->SupportsMimeType(aMimeType, aDiagnostics);
|
|
}
|
|
RefPtr<PlatformDecoderModule> current = GetDecoder(aMimeType, aDiagnostics);
|
|
return !!current;
|
|
}
|
|
|
|
void
|
|
PDMFactory::CreatePDMs()
|
|
{
|
|
RefPtr<PlatformDecoderModule> m;
|
|
|
|
if (sUseBlankDecoder) {
|
|
m = CreateBlankDecoderModule();
|
|
StartupPDM(m);
|
|
// The Blank PDM SupportsMimeType reports true for all codecs; the creation
|
|
// of its decoder is infallible. As such it will be used for all media, we
|
|
// can stop creating more PDM from this point.
|
|
return;
|
|
}
|
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
|
if(sAndroidMCDecoderPreferred && sAndroidMCDecoderEnabled) {
|
|
m = new AndroidDecoderModule();
|
|
StartupPDM(m);
|
|
}
|
|
#endif
|
|
#ifdef XP_WIN
|
|
if (sWMFDecoderEnabled) {
|
|
m = new WMFDecoderModule();
|
|
StartupPDM(m);
|
|
}
|
|
#endif
|
|
#ifdef MOZ_FFMPEG
|
|
if (sFFmpegDecoderEnabled) {
|
|
m = FFmpegRuntimeLinker::CreateDecoderModule();
|
|
if (!StartupPDM(m)) {
|
|
mFFmpegFailedToLoad = true;
|
|
}
|
|
}
|
|
#endif
|
|
#ifdef MOZ_APPLEMEDIA
|
|
m = new AppleDecoderModule();
|
|
StartupPDM(m);
|
|
#endif
|
|
#ifdef MOZ_GONK_MEDIACODEC
|
|
if (sGonkDecoderEnabled) {
|
|
m = new GonkDecoderModule();
|
|
StartupPDM(m);
|
|
}
|
|
#endif
|
|
#ifdef MOZ_WIDGET_ANDROID
|
|
if(sAndroidMCDecoderEnabled){
|
|
m = new AndroidDecoderModule();
|
|
StartupPDM(m);
|
|
}
|
|
#endif
|
|
|
|
m = new AgnosticDecoderModule();
|
|
StartupPDM(m);
|
|
|
|
if (sGMPDecoderEnabled) {
|
|
m = new GMPDecoderModule();
|
|
StartupPDM(m);
|
|
}
|
|
}
|
|
|
|
bool
|
|
PDMFactory::StartupPDM(PlatformDecoderModule* aPDM)
|
|
{
|
|
if (aPDM && NS_SUCCEEDED(aPDM->Startup())) {
|
|
mCurrentPDMs.AppendElement(aPDM);
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
already_AddRefed<PlatformDecoderModule>
|
|
PDMFactory::GetDecoder(const nsACString& aMimeType,
|
|
DecoderDoctorDiagnostics* aDiagnostics) const
|
|
{
|
|
if (aDiagnostics) {
|
|
// If libraries failed to load, the following loop over mCurrentPDMs
|
|
// will not even try to use them. So we record failures now.
|
|
if (mFFmpegFailedToLoad) {
|
|
aDiagnostics->SetFFmpegFailedToLoad();
|
|
}
|
|
}
|
|
|
|
RefPtr<PlatformDecoderModule> pdm;
|
|
for (auto& current : mCurrentPDMs) {
|
|
if (current->SupportsMimeType(aMimeType, aDiagnostics)) {
|
|
pdm = current;
|
|
break;
|
|
}
|
|
}
|
|
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();
|
|
}
|
|
|
|
RefPtr<PDMFactory> m = new PDMFactory();
|
|
mEMEPDM = new EMEDecoderModule(aProxy, m, cdmDecodesAudio, cdmDecodesVideo);
|
|
}
|
|
#endif
|
|
|
|
} // namespace mozilla
|