Bug 1425277 - p2: remove dynamic apple framework linkers. r=jya No need for own linkers anymore for CoreMedia and VideoToolbox are both available on our minimal supported version (10.9).

Differential Revision: https://phabricator.services.mozilla.com/D7558

--HG--
extra : moz-landing-system : lando
This commit is contained in:
John Lin 2018-11-26 18:27:32 +00:00
parent 25c2e37423
commit 0ea8bb4a7a
9 changed files with 43 additions and 81 deletions

View File

@ -1,12 +0,0 @@
/* -*- 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/. */
// Construct references to each of the CoreMedia symbols we use.
LINK_FUNC(VideoFormatDescriptionCreate)
LINK_FUNC(BlockBufferCreateWithMemoryBlock)
LINK_FUNC(SampleBufferCreate)
LINK_FUNC(TimeMake)

View File

@ -5,10 +5,8 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "AppleATDecoder.h"
#include "AppleCMLinker.h"
#include "AppleDecoderModule.h"
#include "AppleVTDecoder.h"
#include "AppleVTLinker.h"
#include "MacIOSurfaceImage.h"
#include "mozilla/DebugOnly.h"
#include "mozilla/Logging.h"
@ -17,9 +15,6 @@
namespace mozilla {
bool AppleDecoderModule::sInitialized = false;
bool AppleDecoderModule::sIsCoreMediaAvailable = false;
bool AppleDecoderModule::sIsVTAvailable = false;
bool AppleDecoderModule::sIsVTHWAvailable = false;
bool AppleDecoderModule::sCanUseHardwareVideoDecoder = true;
AppleDecoderModule::AppleDecoderModule() {}
@ -34,26 +29,15 @@ void AppleDecoderModule::Init() {
// Ensure IOSurface framework is loaded.
MacIOSurfaceLib::LoadLibrary();
const bool loaded = MacIOSurfaceLib::isInit();
// dlopen CoreMedia.framework if it's available.
sIsCoreMediaAvailable = 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 = loaded && AppleVTLinker::Link();
sIsVTAvailable = sIsCoreMediaAvailable && haveVideoToolbox;
sIsVTHWAvailable = AppleVTLinker::skPropEnableHWAccel != nullptr;
sCanUseHardwareVideoDecoder =
loaded && gfx::gfxVars::CanUseHardwareVideoDecoding();
MacIOSurfaceLib::isInit() && gfx::gfxVars::CanUseHardwareVideoDecoding();
sInitialized = true;
}
nsresult AppleDecoderModule::Startup() {
if (!sInitialized || !sIsVTAvailable) {
if (!sInitialized) {
return NS_ERROR_FAILURE;
}
return NS_OK;
@ -76,11 +60,10 @@ already_AddRefed<MediaDataDecoder> AppleDecoderModule::CreateAudioDecoder(
bool AppleDecoderModule::SupportsMimeType(
const nsACString& aMimeType, DecoderDoctorDiagnostics* aDiagnostics) const {
return (sIsCoreMediaAvailable &&
(aMimeType.EqualsLiteral("audio/mpeg") ||
aMimeType.EqualsLiteral("audio/mp4a-latm"))) ||
(sIsVTAvailable && (aMimeType.EqualsLiteral("video/mp4") ||
aMimeType.EqualsLiteral("video/avc")));
return aMimeType.EqualsLiteral("audio/mpeg") ||
aMimeType.EqualsLiteral("audio/mp4a-latm") ||
aMimeType.EqualsLiteral("video/mp4") ||
aMimeType.EqualsLiteral("video/avc");
}
} // namespace mozilla

View File

@ -0,0 +1,12 @@
diff a/dom/media/platforms/apple/AppleDecoderModule.cpp b/dom/media/platforms/apple/AppleDecoderModule.cpp (rejected hunks)
@@ -30,8 +30,8 @@ void AppleDecoderModule::Init() {
// Ensure IOSurface framework is loaded.
MacIOSurfaceLib::LoadLibrary();
- sCanUseHardwareVideoDecoder = MacIOSurfaceLib::isInit() &&
- gfx::gfxVars::CanUseHardwareVideoDecoding();
+ sCanUseHardwareVideoDecoder =
+ MacIOSurfaceLib::isInit() && gfx::gfxVars::CanUseHardwareVideoDecoding();
sInitialized = true;
}

View File

@ -35,9 +35,6 @@ class AppleDecoderModule : public PlatformDecoderModule {
private:
static bool sInitialized;
static bool sIsCoreMediaAvailable;
static bool sIsVTAvailable;
static bool sIsVTHWAvailable;
};
} // namespace mozilla

View File

@ -4,13 +4,10 @@
* 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 <CoreFoundation/CFString.h>
#include "AppleVTDecoder.h"
#include "AppleCMLinker.h"
#include "AppleDecoderModule.h"
#include "AppleUtils.h"
#include "AppleVTLinker.h"
#include "MacIOSurfaceImage.h"
#include "MediaData.h"
#include "mozilla/ArrayUtils.h"
@ -459,19 +456,18 @@ MediaResult AppleVTDecoder::InitializeSession() {
RESULT_DETAIL("Couldn't create decompression session!"));
}
if (AppleVTLinker::skPropUsingHWAccel) {
CFBooleanRef isUsingHW = nullptr;
rv = VTSessionCopyProperty(mSession, AppleVTLinker::skPropUsingHWAccel,
kCFAllocatorDefault, &isUsingHW);
if (rv != noErr) {
LOG("AppleVTDecoder: system doesn't support hardware acceleration");
}
mIsHardwareAccelerated = rv == noErr && isUsingHW == kCFBooleanTrue;
LOG("AppleVTDecoder: %s hardware accelerated decoding",
mIsHardwareAccelerated ? "using" : "not using");
} else {
LOG("AppleVTDecoder: couldn't determine hardware acceleration status.");
CFBooleanRef isUsingHW = nullptr;
rv = VTSessionCopyProperty(
mSession,
kVTVideoDecoderSpecification_EnableHardwareAcceleratedVideoDecoder,
kCFAllocatorDefault, &isUsingHW);
if (rv != noErr) {
LOG("AppleVTDecoder: system doesn't support hardware acceleration");
}
mIsHardwareAccelerated = rv == noErr && isUsingHW == kCFBooleanTrue;
LOG("AppleVTDecoder: %s hardware accelerated decoding",
mIsHardwareAccelerated ? "using" : "not using");
return NS_OK;
}
@ -488,9 +484,10 @@ CFDictionaryRef AppleVTDecoder::CreateDecoderExtensions() {
kCFAllocatorDefault, atomsKey, atomsValue, ArrayLength(atomsKey),
&kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
const void* extensionKeys[] = {kCVImageBufferChromaLocationBottomFieldKey,
kCVImageBufferChromaLocationTopFieldKey,
AppleCMLinker::skPropExtensionAtoms};
const void* extensionKeys[] = {
kCVImageBufferChromaLocationBottomFieldKey,
kCVImageBufferChromaLocationTopFieldKey,
kCMFormatDescriptionExtension_SampleDescriptionExtensionAtoms};
const void* extensionValues[] = {kCVImageBufferChromaLocation_Left,
kCVImageBufferChromaLocation_Left, atoms};
@ -504,11 +501,8 @@ CFDictionaryRef AppleVTDecoder::CreateDecoderExtensions() {
}
CFDictionaryRef AppleVTDecoder::CreateDecoderSpecification() {
if (!AppleVTLinker::skPropEnableHWAccel) {
return nullptr;
}
const void* specKeys[] = {AppleVTLinker::skPropEnableHWAccel};
const void* specKeys[] = {
kVTVideoDecoderSpecification_EnableHardwareAcceleratedVideoDecoder};
const void* specValues[1];
if (AppleDecoderModule::sCanUseHardwareVideoDecoder) {
specValues[0] = kCFBooleanTrue;

View File

@ -7,14 +7,16 @@
#ifndef mozilla_AppleVTDecoder_h
#define mozilla_AppleVTDecoder_h
#include <CoreFoundation/CFDictionary.h> // For CFDictionaryRef
#include <CoreMedia/CoreMedia.h> // For CMVideoFormatDescriptionRef
#include <VideoToolbox/VideoToolbox.h> // For VTDecompressionSessionRef
#include "PlatformDecoderModule.h"
#include "mozilla/Atomics.h"
#include "nsIThread.h"
#include "ReorderQueue.h"
#include "TimeUnits.h"
#include "VideoToolbox/VideoToolbox.h"
namespace mozilla {
DDLoggedTypeDeclNameAndBase(AppleVTDecoder, MediaDataDecoder);

View File

@ -1,14 +0,0 @@
/* -*- 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/. */
// Construct references to each of the VideoToolbox symbols we use.
LINK_FUNC(VTDecompressionSessionCreate)
LINK_FUNC(VTDecompressionSessionDecodeFrame)
LINK_FUNC(VTDecompressionSessionInvalidate)
LINK_FUNC(VTDecompressionSessionWaitForAsynchronousFrames)
LINK_FUNC(VTSessionCopyProperty)
LINK_FUNC(VTSessionCopySupportedPropertyDictionary)

View File

@ -89,13 +89,13 @@ if CONFIG['MOZ_APPLEMEDIA']:
]
UNIFIED_SOURCES += [
'apple/AppleATDecoder.cpp',
'apple/AppleCMLinker.cpp',
'apple/AppleDecoderModule.cpp',
'apple/AppleVTDecoder.cpp',
'apple/AppleVTLinker.cpp',
]
OS_LIBS += [
'-framework AudioToolbox',
'-framework CoreMedia',
'-framework VideoToolbox',
]
include('/ipc/chromium/chromium-config.mozbuild')

View File

@ -2275,7 +2275,7 @@ if test -n "$MOZ_APPLEMEDIA"; then
# We load VideoToolbox and CoreMedia dynamically, so they don't appear here.
LDFLAGS="$LDFLAGS -framework AudioToolbox"
dnl Verify CoreMedia is available.
AC_CHECK_HEADER([CoreMedia/CoreMedia.h], [],
AC_CHECK_HEADERS([CoreMedia/CoreMedia.h VideoToolbox/VideoToolbox.h], [],
[AC_MSG_ERROR([MacOS X 10.9 SDK or later is required])])
fi
fi # COMPILE_ENVIRONMENT