Files
palemoon27/dom/media/platforms/apple/AppleDecoderModule.cpp
T
roytam1 fdb63ff9b9 import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1163201 - Part 1: Remove instances of #ifdef PR_LOGGING in dom/. r=froydnj (9979c0e74)
-  Bug 1183972 - No sync-dispatch of new GMPParent - r=cpearce (93339b530)
- Bug 1142935 - reset transports with NuwaAddConstructor(). r=tlee (277406812)
- Bug 1121676 - Use a lock to protect the list of top-level actors (r=bent) (3d0be2f87)
-  Bug 1121676 - Use static mutex to protect top-level protocols (r=bent) (4491dd318)
- Bug 1163201 - Part 2: Wrap expensive calls in PR_LOG_TEST. r=froydnj (7de4b9a97)
- Bug 1163201 - Part 3: Remove mSamples in |MediaEngineWebRTCAudioSource|. r=cpeterson (452442773)
- Bug 1163201 - Part 4: Fix b2g build. r=bustage (a824ea36d)
- Bug 1165518 - Part 1: Add Logging.h. r=froydnj (09d68aaa6)
- Bug 1162850 - Don't stop looking for style sheet load finishes after the FontFaceSet gets a DOMContentLoaded. r=jdaggett (c29fbffa0)
- Bug 1056479 p0 - rename ambiguous GetFontList method in Android fontlist. r=m_kato (76239d7a0)
- Bug 1056479 p1 - add language to FindFamily parameters. r=jfkthame (2271bd7d0)
- Bug 1056479 p1a - use lang as part of pref font fallback. r=karlt (5f5fd66c5)
- cleanup GetTableFromFontData() to match gecko code again (78076fc26)
- Bug 1056479 p2 - implement platform fontlist based on fontconfig. r=karlt (6a7631e44)
- Bug 1056479 p3 - fixup various reftests for Linux. r=jfkthame (b25360708)
- Bug 1056479 p4 - fix accessibility api for font-weight. r=jfkthame (efa8f5080)
- Bug 1056479 p5 - fixup printpreview test. r=jfkthame (3fe2ddc0b)
- Bug 1056479 p6 - handle font updates. r=jfkthame (eb78b2c54)
- Bug 1056479 p7 - fixup assertion for non-italic fallback. r=m_kato (f5e9f539e)
- Bug 1056479 p8 - switch gfxFontConfig to gfxFontconfig. r=karlt (4da146b50)
- Bug 1056479 p9 - fix build bustage. r=birtles (28f246c2b)
- Bug 1056479 p10 - activate bundled fonts. r=m_kato (d7627c3fa)
- Bug 1056479 p10 - activate bundled fonts. r=m_kato (251c02315)
- Bug 1056479 followup: Annotate gfxPlatformGtk::CreatePlatformFontList() as 'override'. rs=ehsan (993e65d6e)
2020-05-30 12:49:03 +08:00

136 lines
3.8 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 "AppleATDecoder.h"
#include "AppleCMLinker.h"
#include "AppleDecoderModule.h"
#include "AppleVDADecoder.h"
#include "AppleVDALinker.h"
#include "AppleVTDecoder.h"
#include "AppleVTLinker.h"
#include "mozilla/Preferences.h"
#include "mozilla/DebugOnly.h"
#include "prlog.h"
PRLogModuleInfo* GetAppleMediaLog() {
static PRLogModuleInfo* log = nullptr;
if (!log) {
log = PR_NewLogModule("AppleMedia");
}
return log;
}
namespace mozilla {
bool AppleDecoderModule::sInitialized = false;
bool AppleDecoderModule::sIsVTAvailable = false;
bool AppleDecoderModule::sIsVTHWAvailable = false;
bool AppleDecoderModule::sIsVDAAvailable = false;
bool AppleDecoderModule::sForceVDA = false;
AppleDecoderModule::AppleDecoderModule()
{
}
AppleDecoderModule::~AppleDecoderModule()
{
}
/* static */
void
AppleDecoderModule::Init()
{
MOZ_ASSERT(NS_IsMainThread(), "Must be on main thread.");
sForceVDA = Preferences::GetBool("media.apple.forcevda", false);
if (sInitialized) {
return;
}
// dlopen VideoDecodeAcceleration.framework if it's available.
sIsVDAAvailable = AppleVDALinker::Link();
// dlopen CoreMedia.framework if it's available.
bool haveCoreMedia = AppleCMLinker::Link();
// dlopen VideoToolbox.framework if it's available.
// We must link both CM and VideoToolbox framework to allow for proper
// paired Link/Unlink calls
bool haveVideoToolbox = AppleVTLinker::Link();
sIsVTAvailable = haveCoreMedia && haveVideoToolbox;
sIsVTHWAvailable = AppleVTLinker::skPropEnableHWAccel != nullptr;
sInitialized = true;
}
nsresult
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,
FlushableMediaTaskQueue* aVideoTaskQueue,
MediaDataDecoderCallback* aCallback)
{
nsRefPtr<MediaDataDecoder> decoder;
if (sIsVDAAvailable && (!sIsVTHWAvailable || sForceVDA)) {
decoder =
AppleVDADecoder::CreateVDADecoder(aConfig,
aVideoTaskQueue,
aCallback,
aImageContainer);
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, aVideoTaskQueue, aCallback, aImageContainer);
}
return decoder.forget();
}
already_AddRefed<MediaDataDecoder>
AppleDecoderModule::CreateAudioDecoder(const AudioInfo& aConfig,
FlushableMediaTaskQueue* aAudioTaskQueue,
MediaDataDecoderCallback* aCallback)
{
nsRefPtr<MediaDataDecoder> decoder =
new AppleATDecoder(aConfig, aAudioTaskQueue, aCallback);
return decoder.forget();
}
bool
AppleDecoderModule::SupportsMimeType(const nsACString& aMimeType)
{
return aMimeType.EqualsLiteral("audio/mpeg") ||
PlatformDecoderModule::SupportsMimeType(aMimeType);
}
PlatformDecoderModule::ConversionRequired
AppleDecoderModule::DecoderNeedsConversion(const TrackInfo& aConfig) const
{
if (aConfig.IsVideo()) {
return kNeedAVCC;
} else {
return kNeedNone;
}
}
} // namespace mozilla