Commit 8d679da7 authored by François Grisez's avatar François Grisez

Use dlsym() to find H265 specific symblols.

parent a85f4c09
......@@ -515,11 +515,6 @@ if(VOIP_SOURCE_FILES_CXX)
set_source_files_properties(${VOIP_SOURCE_FILES_CXX} PROPERTIES LANGUAGE CXX)
bc_apply_compile_flags(VOIP_SOURCE_FILES_CXX STRICT_OPTIONS_CPP STRICT_OPTIONS_CXX)
if (APPLE AND ENABLE_VT_H265 AND (CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64"))
if (IOS)
set_source_files_properties(voip/h26x/videotoolbox-h265-utilities.cpp
PROPERTIES COMPILE_FLAGS "-miphoneos-version-min=11.0"
)
endif()
set_source_files_properties(
voip/h26x/videotoolbox-utils.cpp
voip/h26x/videotoolbox.cpp
......
......@@ -17,28 +17,48 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <dlfcn.h>
#include "videotoolbox-h265-utilities.h"
using namespace std;
namespace mediastreamer {
CFStringRef VideoToolboxH265Utilities::_kVTProfileLevel_HEVC_Main_AutoLevel = nullptr;
VideoToolboxH265Utilities::GetParameterSetNativeFunc VideoToolboxH265Utilities::_CMVideoFormatDescriptionGetHEVCParameterSetAtIndex = nullptr;
VideoToolboxH265Utilities::CreateFormatDescriptionNativeFunc VideoToolboxH265Utilities::_CMVideoFormatDescriptionCreateFromHEVCParameterSets = nullptr;
VideoToolboxH265Utilities::VideoToolboxH265Utilities() {
if (_kVTProfileLevel_HEVC_Main_AutoLevel == nullptr) {
_kVTProfileLevel_HEVC_Main_AutoLevel = *reinterpret_cast<CFStringRef *>(dlsym(RTLD_DEFAULT, "kVTProfileLevel_HEVC_Main_AutoLevel"));
}
if (_CMVideoFormatDescriptionGetHEVCParameterSetAtIndex == nullptr) {
void *symPtr = dlsym(RTLD_DEFAULT, "CMVideoFormatDescriptionGetHEVCParameterSetAtIndex");
_CMVideoFormatDescriptionGetHEVCParameterSetAtIndex = reinterpret_cast<GetParameterSetNativeFunc>(symPtr);
}
if (_CMVideoFormatDescriptionCreateFromHEVCParameterSets == nullptr) {
void *symPtr = dlsym(RTLD_DEFAULT, "CMVideoFormatDescriptionCreateFromHEVCParameterSets");
_CMVideoFormatDescriptionCreateFromHEVCParameterSets = reinterpret_cast<CreateFormatDescriptionNativeFunc>(symPtr);
}
}
CMVideoCodecType VideoToolboxH265Utilities::getCodecType() const {
return kCMVideoCodecType_HEVC;
}
CFStringRef VideoToolboxH265Utilities::getDefaultProfileLevel() const {
return kVTProfileLevel_HEVC_Main_AutoLevel;
return _kVTProfileLevel_HEVC_Main_AutoLevel;
}
void VideoToolboxH265Utilities::getParameterSet(const CMFormatDescriptionRef format, size_t offset, const uint8_t *&parameterSet, size_t &parameterSetSize, size_t &parameterSetsCount) const {
OSStatus status = CMVideoFormatDescriptionGetHEVCParameterSetAtIndex(format, offset, &parameterSet, &parameterSetSize, &parameterSetsCount, nullptr);
OSStatus status = _CMVideoFormatDescriptionGetHEVCParameterSetAtIndex(format, offset, &parameterSet, &parameterSetSize, &parameterSetsCount, nullptr);
if (status != noErr) throw AppleOSError(status);
}
CMFormatDescriptionRef VideoToolboxH265Utilities::createFormatDescription(size_t paramterSetsCount, const uint8_t *parameterSets[], const size_t parameterSetSizes[]) const {
CMFormatDescriptionRef formatDesc;
OSStatus status = CMVideoFormatDescriptionCreateFromHEVCParameterSets(nullptr, paramterSetsCount, parameterSets, parameterSetSizes, 4, nullptr, &formatDesc);
OSStatus status = _CMVideoFormatDescriptionCreateFromHEVCParameterSets(nullptr, paramterSetsCount, parameterSets, parameterSetSizes, 4, nullptr, &formatDesc);
if (status != noErr) {
throw AppleOSError(status);
}
......
......@@ -25,12 +25,23 @@ namespace mediastreamer {
class VideoToolboxH265Utilities: public VideoToolboxUtilities {
public:
VideoToolboxH265Utilities();
CMVideoCodecType getCodecType() const override;
CFStringRef getDefaultProfileLevel() const override;
private:
typedef OSStatus (*GetParameterSetNativeFunc)(CMFormatDescriptionRef videoDesc, size_t parameterSetIndex, const uint8_t **parameterSetPointerOut,
size_t *parameterSetSizeOut, size_t *parameterSetCountOut, int *NALUnitHeaderLengthOut );
typedef OSStatus (*CreateFormatDescriptionNativeFunc)(CFAllocatorRef allocator, size_t parameterSetCount, const uint8_t * const *parameterSetPointers,
const size_t *parameterSetSizes, int NALUnitHeaderLength, CFDictionaryRef extensions, CMFormatDescriptionRef *formatDescriptionOut);
void getParameterSet(const CMFormatDescriptionRef format, size_t offset, const uint8_t *&parameterSet, size_t &parameterSetSize, size_t &parameterSetsCount) const override;
CMFormatDescriptionRef createFormatDescription(size_t paramterSetsCount, const uint8_t *parameterSets[], const size_t parameterSetSizes[]) const override;
static CFStringRef _kVTProfileLevel_HEVC_Main_AutoLevel;
static GetParameterSetNativeFunc _CMVideoFormatDescriptionGetHEVCParameterSetAtIndex;
static CreateFormatDescriptionNativeFunc _CMVideoFormatDescriptionCreateFromHEVCParameterSets;
};
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment