Files
palemoon27/dom/media/platforms/apple/AppleDecoderModule.cpp
T
roytam1 0be1a20aba import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1206977: P1. Remove unused PDM function members. r=cpearce (3ff104135b)
- Bug 1193670: P1. Remove use of SharedDecoderManager. r=cpearce (adb5606e3e)
- Bug 1193670: P2. Remove use of SharedDecoderManager from MediaDecoderReader. r=cpearce (61b9170c51)
- Bug 1194612: P1. Dont reject init promise when initialising H264Converter. r=alfredo (d7d9e81361)
- Bug 1194612: P2. Don't drop first sample with SPS/PPS NALs. r=alfredo (ea42652155)
- Bug 1194612: P3. Remove redundant member. r=alfredo (2d30f940c9)
- Bug 1195625 - Use correct TaskQueue in SharedDecoderManager and H264Converter promise. r=jya (87e52cd322)
- Bug 1194518 - Part 1: Passthrough decoder wrapper, useful to spy on MediaFormatReader-decoder calls. r=jya (8e6f7df905)
- Bug 1194518 - Part 2: Using passthrough wrapper if pref 'media.fuzz.vdeo-decode-passthrough' is true. r=jya (2a50be71f0)
- Bug 1194518 - Part 3: Delaying decoder wrapper, ensures a decoder appears consistently slow. r=jya (9d461352e5)
- Bug 1194518 - Part 4: Using delaying wrapper according to pref 'media.fuzz.video-decode-minimum-frame-interval-ms'. r=jya (9ec9684024)
- Bug 1194518 - Part 5: Using std::deque instead of nsTArray to store delayed frames. r=jya (6f3f26578c)
- Bug 1197145 - Added BaseTimeDuration::IsZero(), BaseTimeDuration::operator bool(), TimeStamp::operator bool(). r=nfroyd (1ba008c9fa)
- Bug 1202556 - Detect underflow in TimeStamp addition/subtraction operators; r=froydnj (864a288877)
- Bug 1176731 - Don't mark static inline functions as MFBT_API in TimeStamp.h. r=Waldo (6c94439c61)
- bug 1170586 - Make TimeStamp::FromSystemTime available on iOS. r=froydnj (f9ae7bd8b8)
- Bug 1193670: P3. Remove no longer needed SharedDecoderManager class. r=cpearce (c56ef98e6d)
- Bug 1206977: P2. Wrap PDM creation in a new PDMFactory class. r=cpearce (6425ab58ca)
- Bug 1206977: P3. Allow PDM fallback. r=cpearce (6cce420063)
- Bug 1206977: P4. Add AgnosticDecoderModule object. r=cpearce (1d4581f74c)
- Bug 1206977: P5. Update PlatformDecoderModule documentation. r=cpearce (af14651d29)
- Bug 1206977: P6. Make PlatformDecoderModule::SupportsMimeType pure virtual. r=cpearce (f328eb0a48)
- Bug 1146086: Properly marking overridden member with override keyword. a=bustage (c809b2311c)
- Bug 1204776: P1. Have the PlatformDecoderModules use their own log. r=cpearce (b8565d268b)
- Bug 1204776: P2. Make Apple PDM use PlatformDecoderModule log. r=cpearce (74b9985af8)
- Bug 1204776: P3. Have FFmpeg PDM use PlatformDecoderModule log. r=cpearce (caa498a139)
- Bug 1204776: P4. Have VPX/Opus/Vorbis decoder use PlatformDecoderModule log. r=cpearce (f2fce6c79a)
- fix (215c918930)
- Bug 1206977: [webm] P7. Remove IntelWebMVideoDecoder. r=kinetik (c455347fe1)
- Bug 1206977: P8. Have PDMFactory directly manage the EMEDecoderModule. r=cpearce (d830cbe570)
- Bug 1212164: Prevent use of demuxer before initialization completes. r=cpearce (99c268d31d)
- Bug 1152652: Part1. Use mStandardMozillaStyle for crypto classes. r=edwin (af58e4e822)
- Bug 1206977: P9. Ensure PDMs are only ever created through the PDMFactory. r=cpearce (4d7375ea3d)
- Bug 1206977: P10. Remove redundant code. r=cpearce (8abd18ffe1)
- Bug 1206977: P11. Don't rely on SupportsMimeType to determine if a track can be played. r=cpearce (b569a8f5e1)
- Bug 1212246. Part 1 - remove the aBorrowedTaskQueue parameter from the MediaDecoderReader constructor. r=jya. (0f481aa22b)
- Bug 1212246. Part 2 - remove mTaskQueueIsBorrowed and unnecessary checks for mTaskQueue is never null. r=jya. (27ec74d634)
- Bug 1212723. Part 1 - don't share mBufferedState per bug 1212723 comment 6. r=jya. (59e1b89bee)
- Bug 1212723. Part 2 - remove unused argument aCloneDonor from MediaDecoderReader::Init(). r=jya. (45bc778f41)
2022-10-13 09:51:06 +08:00

130 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 "mozilla/Logging.h"
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,
FlushableTaskQueue* 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,
FlushableTaskQueue* 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") ||
aMimeType.EqualsLiteral("audio/mp4a-latm") ||
aMimeType.EqualsLiteral("video/mp4") ||
aMimeType.EqualsLiteral("video/avc");
}
PlatformDecoderModule::ConversionRequired
AppleDecoderModule::DecoderNeedsConversion(const TrackInfo& aConfig) const
{
if (aConfig.IsVideo()) {
return kNeedAVCC;
} else {
return kNeedNone;
}
}
} // namespace mozilla