mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:18:48 +00:00
d1af43433c
- Bug 1187817. Part 1 - Move Set{Volume,PlaybackRate,PreservesPitch} to the audio thread. r=kinetik. (a234a7080)
- Bug 1187817. Part 2 - remove unused code. r=kinetik. (836c52a19)
- Bug 1187763. Part 1 - move while loop out of WaitingForAudioToPlay(). r=kinetik. (a80d70f87)
- Bug 1187763. Part 2 - extract some code of AudioLoop() into its own function. r=kinetik. (275b8bfb6)
- Bug 1187763. Part 3 - refactor AudioSink::AudioLoop into a series of events. r=kinetik (7eb3f506f)
- Bug 1187817. Part 3 - move SetPlaying to the audio thread. r=kinetik. (0fef85968)
- Bug 1187817. Part 4 - move some code in Shutdown to the audio thread. r=kinetik. (8c73fbe6d)
- Bug 1187817. Part 5 - assert some code in the audio thread and don't enter the monitor. r=kinetik. (64de4616f)
- move include (f842b4b1e)
- Bug 1163486 - Update test to use new MP4Demuxer. r=bholley (b853be477)
- Bug 1190496 - Namespace the SharedThreadPool.h include. r=cpearce (196d25d42)
- Bug 1190496 - Hoist SharedThreadPool into xpcom. r=froydnj (3dad8176f)
- Bug 1190492 - Hoist AbstractThread and TaskDispatcher to xpcom. r=froydnj (c3329fa29)
- bug 1166107 documentation of mWaitForInternalDrain thread access r=gerald (f762764b1)
- correct comment (b623b2959)
- revert demuxer check from promise reject to assert like in 1156708 (f540b270c)
- more chekcs back to asserts (7e82a0f99)
- space (733bd85a3)
- Bug 1188220: Allow disabling HW acceleration even when SharedDecoderManager isn't used. r=cpearce (909a86682)
- bug 1161903 ensure pending DrainComplete is not run after Flush() r=cpearce (648cabbb7)
- Bug 1158089 - Fall back to d3d9 DXVA if d3d11 initialization fails. r=cpearce (84b3a8e6d)
239 lines
7.0 KiB
C++
239 lines
7.0 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 "PlatformDecoderModule.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/WindowsVersion.h"
|
|
#include "mozilla/SharedThreadPool.h"
|
|
|
|
#include "MediaInfo.h"
|
|
#include "H264Converter.h"
|
|
|
|
#include "OpusDecoder.h"
|
|
#include "VorbisDecoder.h"
|
|
#include "VPXDecoder.h"
|
|
|
|
namespace mozilla {
|
|
|
|
extern already_AddRefed<PlatformDecoderModule> CreateAgnosticDecoderModule();
|
|
extern already_AddRefed<PlatformDecoderModule> CreateBlankDecoderModule();
|
|
|
|
bool PlatformDecoderModule::sUseBlankDecoder = false;
|
|
#ifdef MOZ_FFMPEG
|
|
bool PlatformDecoderModule::sFFmpegDecoderEnabled = false;
|
|
#endif
|
|
#ifdef MOZ_GONK_MEDIACODEC
|
|
bool PlatformDecoderModule::sGonkDecoderEnabled = false;
|
|
#endif
|
|
#ifdef MOZ_WIDGET_ANDROID
|
|
bool PlatformDecoderModule::sAndroidMCDecoderEnabled = false;
|
|
bool PlatformDecoderModule::sAndroidMCDecoderPreferred = false;
|
|
#endif
|
|
bool PlatformDecoderModule::sGMPDecoderEnabled = false;
|
|
|
|
/* static */
|
|
void
|
|
PlatformDecoderModule::Init()
|
|
{
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
static bool alreadyInitialized = false;
|
|
if (alreadyInitialized) {
|
|
return;
|
|
}
|
|
alreadyInitialized = true;
|
|
|
|
Preferences::AddBoolVarCache(&sUseBlankDecoder,
|
|
"media.use-blank-decoder");
|
|
#ifdef MOZ_FFMPEG
|
|
Preferences::AddBoolVarCache(&sFFmpegDecoderEnabled,
|
|
"media.ffmpeg.enabled", false);
|
|
#endif
|
|
#ifdef MOZ_GONK_MEDIACODEC
|
|
Preferences::AddBoolVarCache(&sGonkDecoderEnabled,
|
|
"media.gonk.enabled", false);
|
|
#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", false);
|
|
|
|
#ifdef XP_WIN
|
|
WMFDecoderModule::Init();
|
|
#endif
|
|
#ifdef MOZ_APPLEMEDIA
|
|
AppleDecoderModule::Init();
|
|
#endif
|
|
}
|
|
|
|
/* static */
|
|
already_AddRefed<PlatformDecoderModule>
|
|
PlatformDecoderModule::Create()
|
|
{
|
|
// Note: This (usually) runs on the decode thread.
|
|
|
|
nsRefPtr<PlatformDecoderModule> m(CreatePDM());
|
|
|
|
if (m && NS_SUCCEEDED(m->Startup())) {
|
|
return m.forget();
|
|
}
|
|
return CreateAgnosticDecoderModule();
|
|
}
|
|
|
|
/* static */
|
|
already_AddRefed<PlatformDecoderModule>
|
|
PlatformDecoderModule::CreatePDM()
|
|
{
|
|
#ifdef MOZ_WIDGET_ANDROID
|
|
if(sAndroidMCDecoderPreferred && sAndroidMCDecoderEnabled){
|
|
nsRefPtr<PlatformDecoderModule> m(new AndroidDecoderModule());
|
|
return m.forget();
|
|
}
|
|
#endif
|
|
if (sUseBlankDecoder) {
|
|
return CreateBlankDecoderModule();
|
|
}
|
|
#ifdef XP_WIN
|
|
if(IsVistaOrLater()&&!Preferences::GetBool("media.ffmpeg.enabled", false)){
|
|
nsRefPtr<PlatformDecoderModule> m(new WMFDecoderModule());
|
|
return m.forget();
|
|
}
|
|
#endif
|
|
#ifdef MOZ_FFMPEG
|
|
nsRefPtr<PlatformDecoderModule> mffmpeg = FFmpegRuntimeLinker::CreateDecoderModule();
|
|
if (mffmpeg) {
|
|
return mffmpeg.forget();
|
|
}
|
|
#endif
|
|
#ifdef MOZ_APPLEMEDIA
|
|
nsRefPtr<PlatformDecoderModule> m(new AppleDecoderModule());
|
|
return m.forget();
|
|
#endif
|
|
#ifdef MOZ_GONK_MEDIACODEC
|
|
if (sGonkDecoderEnabled) {
|
|
nsRefPtr<PlatformDecoderModule> m(new GonkDecoderModule());
|
|
return m.forget();
|
|
}
|
|
#endif
|
|
#ifdef MOZ_WIDGET_ANDROID
|
|
if(sAndroidMCDecoderEnabled){
|
|
nsRefPtr<PlatformDecoderModule> m(new AndroidDecoderModule());
|
|
return m.forget();
|
|
}
|
|
#endif
|
|
if (sGMPDecoderEnabled) {
|
|
nsRefPtr<PlatformDecoderModule> m(new GMPDecoderModule());
|
|
return m.forget();
|
|
}
|
|
return nullptr;
|
|
}
|
|
|
|
already_AddRefed<MediaDataDecoder>
|
|
PlatformDecoderModule::CreateDecoder(const TrackInfo& aConfig,
|
|
FlushableTaskQueue* aTaskQueue,
|
|
MediaDataDecoderCallback* aCallback,
|
|
layers::LayersBackend aLayersBackend,
|
|
layers::ImageContainer* aImageContainer)
|
|
{
|
|
nsRefPtr<MediaDataDecoder> m;
|
|
|
|
bool hasPlatformDecoder = SupportsMimeType(aConfig.mMimeType);
|
|
|
|
if (aConfig.GetAsAudioInfo()) {
|
|
if (!hasPlatformDecoder && VorbisDataDecoder::IsVorbis(aConfig.mMimeType)) {
|
|
m = new VorbisDataDecoder(*aConfig.GetAsAudioInfo(),
|
|
aTaskQueue,
|
|
aCallback);
|
|
} else if (!hasPlatformDecoder && OpusDataDecoder::IsOpus(aConfig.mMimeType)) {
|
|
m = new OpusDataDecoder(*aConfig.GetAsAudioInfo(),
|
|
aTaskQueue,
|
|
aCallback);
|
|
} else {
|
|
m = CreateAudioDecoder(*aConfig.GetAsAudioInfo(),
|
|
aTaskQueue,
|
|
aCallback);
|
|
}
|
|
return m.forget();
|
|
}
|
|
|
|
if (!aConfig.GetAsVideoInfo()) {
|
|
return nullptr;
|
|
}
|
|
|
|
if (H264Converter::IsH264(aConfig)) {
|
|
nsRefPtr<H264Converter> h
|
|
= new H264Converter(this,
|
|
*aConfig.GetAsVideoInfo(),
|
|
aLayersBackend,
|
|
aImageContainer,
|
|
aTaskQueue,
|
|
aCallback);
|
|
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 if (!hasPlatformDecoder && VPXDecoder::IsVPX(aConfig.mMimeType)) {
|
|
m = new VPXDecoder(*aConfig.GetAsVideoInfo(),
|
|
aImageContainer,
|
|
aTaskQueue,
|
|
aCallback);
|
|
} else {
|
|
m = CreateVideoDecoder(*aConfig.GetAsVideoInfo(),
|
|
aLayersBackend,
|
|
aImageContainer,
|
|
aTaskQueue,
|
|
aCallback);
|
|
}
|
|
return m.forget();
|
|
}
|
|
|
|
bool
|
|
PlatformDecoderModule::SupportsMimeType(const nsACString& aMimeType)
|
|
{
|
|
return aMimeType.EqualsLiteral("audio/mp4a-latm") ||
|
|
aMimeType.EqualsLiteral("video/mp4") ||
|
|
aMimeType.EqualsLiteral("video/avc");
|
|
}
|
|
|
|
/* static */
|
|
bool
|
|
PlatformDecoderModule::AgnosticMimeType(const nsACString& aMimeType)
|
|
{
|
|
return VPXDecoder::IsVPX(aMimeType) ||
|
|
OpusDataDecoder::IsOpus(aMimeType) ||
|
|
VorbisDataDecoder::IsVorbis(aMimeType);
|
|
}
|
|
|
|
|
|
} // namespace mozilla
|