Bug 1212795: P3. Make AppleDecoderModule detects if the required modules are loaded. r=jwwang

This commit is contained in:
Jean-Yves Avenard 2015-10-12 14:20:11 +11:00
parent 6d8c447776
commit a39d774fa7
2 changed files with 15 additions and 9 deletions

View File

@ -11,6 +11,7 @@
#include "AppleVDALinker.h"
#include "AppleVTDecoder.h"
#include "AppleVTLinker.h"
#include "MacIOSurfaceImage.h"
#include "mozilla/Preferences.h"
#include "mozilla/DebugOnly.h"
#include "mozilla/Logging.h"
@ -18,6 +19,7 @@
namespace mozilla {
bool AppleDecoderModule::sInitialized = false;
bool AppleDecoderModule::sIsCoreMediaAvailable = false;
bool AppleDecoderModule::sIsVTAvailable = false;
bool AppleDecoderModule::sIsVTHWAvailable = false;
bool AppleDecoderModule::sIsVDAAvailable = false;
@ -46,21 +48,22 @@ AppleDecoderModule::Init()
// Ensure IOSurface framework is loaded.
MacIOSurfaceLib::LoadLibrary();
const bool loaded = MacIOSurfaceLib::isInit();
// dlopen VideoDecodeAcceleration.framework if it's available.
sIsVDAAvailable = AppleVDALinker::Link();
sIsVDAAvailable = loaded && AppleVDALinker::Link();
// dlopen CoreMedia.framework if it's available.
bool haveCoreMedia = AppleCMLinker::Link();
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 = AppleVTLinker::Link();
sIsVTAvailable = haveCoreMedia && haveVideoToolbox;
bool haveVideoToolbox = loaded && AppleVTLinker::Link();
sIsVTAvailable = sIsCoreMediaAvailable && haveVideoToolbox;
sIsVTHWAvailable = AppleVTLinker::skPropEnableHWAccel != nullptr;
sCanUseHardwareVideoDecoder =
sCanUseHardwareVideoDecoder = loaded &&
gfxPlatform::GetPlatform()->CanUseHardwareVideoDecoding();
sInitialized = true;
@ -116,10 +119,12 @@ AppleDecoderModule::CreateAudioDecoder(const AudioInfo& aConfig,
bool
AppleDecoderModule::SupportsMimeType(const nsACString& aMimeType)
{
return aMimeType.EqualsLiteral("audio/mpeg") ||
aMimeType.EqualsLiteral("audio/mp4a-latm") ||
aMimeType.EqualsLiteral("video/mp4") ||
aMimeType.EqualsLiteral("video/avc");
return (sIsCoreMediaAvailable &&
(aMimeType.EqualsLiteral("audio/mpeg") ||
aMimeType.EqualsLiteral("audio/mp4a-latm"))) ||
((sIsVTAvailable || sIsVDAAvailable) &&
(aMimeType.EqualsLiteral("video/mp4") ||
aMimeType.EqualsLiteral("video/avc")));
}
PlatformDecoderModule::ConversionRequired

View File

@ -43,6 +43,7 @@ public:
private:
static bool sInitialized;
static bool sIsCoreMediaAvailable;
static bool sIsVTAvailable;
static bool sIsVTHWAvailable;
static bool sIsVDAAvailable;