/* static */ bool AppleVTLinker::Link() { // Bump our reference count every time we're called. // Add a lock or change the thread assertion if // you need to call this off the main thread. MOZ_ASSERT(NS_IsMainThread()); ++sRefCount; if (sLinkStatus) { return sLinkStatus == LinkStatus_SUCCEEDED; } const char* dlnames[] = { "/System/Library/Frameworks/VideoToolbox.framework/VideoToolbox", "/System/Library/PrivateFrameworks/VideoToolbox.framework/VideoToolbox" }; bool dlfound = false; for (size_t i = 0; i < ArrayLength(dlnames); i++) { if ((sLink = dlopen(dlnames[i], RTLD_NOW | RTLD_LOCAL))) { dlfound = true; break; } } if (!dlfound) { NS_WARNING("Couldn't load VideoToolbox framework"); goto fail; } #define LINK_FUNC(func) \ func = (typeof(func))dlsym(sLink, #func); \ if (!func) { \ NS_WARNING("Couldn't load VideoToolbox function " #func ); \ goto fail; \ } #include "AppleVTFunctions.h" #undef LINK_FUNC // Will only resolve in 10.9 and later. skPropEnableHWAccel = GetIOConst("kVTVideoDecoderSpecification_EnableHardwareAcceleratedVideoDecoder"); skPropUsingHWAccel = GetIOConst("kVTDecompressionPropertyKey_UsingHardwareAcceleratedVideoDecoder"); LOG("Loaded VideoToolbox framework."); sLinkStatus = LinkStatus_SUCCEEDED; return true; fail: Unlink(); sLinkStatus = LinkStatus_FAILED; return false; }
/* static */ bool AppleCMLinker::Link() { // Bump our reference count every time we're called. // Add a lock or change the thread assertion if // you need to call this off the main thread. MOZ_ASSERT(NS_IsMainThread()); ++sRefCount; if (sLinkStatus) { return sLinkStatus == LinkStatus_SUCCEEDED; } const char* dlnames[] = { "/System/Library/Frameworks/CoreMedia.framework/CoreMedia", "/System/Library/PrivateFrameworks/CoreMedia.framework/CoreMedia" }; bool dlfound = false; for (size_t i = 0; i < ArrayLength(dlnames); i++) { if ((sLink = dlopen(dlnames[i], RTLD_NOW | RTLD_LOCAL))) { dlfound = true; break; } } if (!dlfound) { NS_WARNING("Couldn't load CoreMedia framework"); goto fail; } if (nsCocoaFeatures::OnLionOrLater()) { #define LINK_FUNC2(func) \ func = (typeof(func))dlsym(sLink, #func); \ if (!func) { \ NS_WARNING("Couldn't load CoreMedia function " #func ); \ goto fail; \ } #define LINK_FUNC(func) LINK_FUNC2(CM ## func) #include "AppleCMFunctions.h" #undef LINK_FUNC #undef LINK_FUNC2 skPropExtensionAtoms = GetIOConst("kCMFormatDescriptionExtension_SampleDescriptionExtensionAtoms"); skPropFullRangeVideo = GetIOConst("kCMFormatDescriptionExtension_FullRangeVideo"); } else { #define LINK_FUNC2(cm, fig) \ cm = (typeof(cm))dlsym(sLink, #fig); \ if (!cm) { \ NS_WARNING("Couldn't load CoreMedia function " #fig ); \ goto fail; \ } #define LINK_FUNC(func) LINK_FUNC2(CM ## func, Fig ## func) #include "AppleCMFunctions.h" #undef LINK_FUNC #undef LINK_FUNC2 skPropExtensionAtoms = GetIOConst("kFigFormatDescriptionExtension_SampleDescriptionExtensionAtoms"); } if (!skPropExtensionAtoms) { goto fail; } LOG("Loaded CoreMedia framework."); sLinkStatus = LinkStatus_SUCCEEDED; return true; fail: Unlink(); sLinkStatus = LinkStatus_FAILED; return false; }