Skip to content

Commit

Permalink
Update to latest Omega
Browse files Browse the repository at this point in the history
  • Loading branch information
TheDaChicken committed Oct 16, 2023
2 parents d11d29e + 315ea9b commit b1beb24
Show file tree
Hide file tree
Showing 22 changed files with 2,206 additions and 48 deletions.
247 changes: 200 additions & 47 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,51 +1,207 @@
cmake_minimum_required(VERSION 3.10)

project(inputstream.adaptive)

include(Helpers.cmake)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
# require at least gcc 4.8
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8)
message(FATAL_ERROR "GCC version must be at least 4.8!")
endif()
endif()

project(inputstream.adaptive)
option(BUILD_TESTING "Build the testing tree." ON)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR})
set(CMAKE_FIND_FRAMEWORK LAST)
# Sets the default path where the CDM library is contained (affects the default value of the add-on settings)
set(DECRYPTERPATH "special://home/cdm")

find_package(Kodi REQUIRED)
find_package(pugixml REQUIRED)
find_package(Bento4 REQUIRED)

# Function to add source files to the main file list
function(add_dir_sources source_files header_files)
foreach(_source ${${source_files}})
if (IS_ABSOLUTE "${_source}")
set(_source_abs "${_source}")
else()
get_filename_component(_source_abs "${_source}" ABSOLUTE)
endif()
set_property(GLOBAL APPEND PROPERTY GlobalSourceList "${_source_abs}")
endforeach()
foreach(_header ${${header_files}})
if (IS_ABSOLUTE "${_header}")
set(_header_abs "${_header}")
else()
get_filename_component(_header_abs "${_header}" ABSOLUTE)
endif()
set_property(GLOBAL APPEND PROPERTY GlobalHeaderList "${_header_abs}")
endforeach()
endfunction(add_dir_sources)

# Function to add an additional dependency
function(add_dependency project_name folder)
set_property(GLOBAL APPEND PROPERTY GlobalDepsNamesList "${project_name}")
set_property(GLOBAL APPEND PROPERTY GlobalDepsFoldersList "${folder}")
endfunction(add_dependency)

set(ADP_SOURCES
src/AdaptiveByteStream.cpp
src/main.cpp
src/codechandler/CodecHandler.cpp
src/codechandler/AudioCodecHandler.cpp
src/codechandler/AV1CodecHandler.cpp
src/codechandler/AVCCodecHandler.cpp
src/codechandler/HEVCCodecHandler.cpp
src/codechandler/TTMLCodecHandler.cpp
src/codechandler/VP9CodecHandler.cpp
src/codechandler/WebVTTCodecHandler.cpp
src/codechandler/ttml/TTML.cpp
src/common/AdaptationSet.cpp
src/common/AdaptiveCencSampleDecrypter.cpp
src/common/AdaptiveStream.cpp
src/common/AdaptiveTree.cpp
src/common/AdaptiveTreeFactory.cpp
src/common/AdaptiveUtils.cpp
src/common/Chooser.cpp
src/common/ChooserAskQuality.cpp
src/common/ChooserDefault.cpp
src/common/ChooserFixedRes.cpp
src/common/ChooserManualOSD.cpp
src/common/ChooserTest.cpp
src/common/CommonAttribs.cpp
src/common/CommonSegAttribs.cpp
src/common/Period.cpp
src/common/Representation.cpp
src/common/ReprSelector.cpp
src/common/Segment.cpp
src/common/SegmentBase.cpp
src/common/SegmentList.cpp
src/common/SegTemplate.cpp
src/parser/CodecParser.cpp
src/parser/DASHTree.cpp
src/parser/HLSTree.cpp
src/parser/SmoothTree.cpp
src/parser/PRProtectionParser.cpp
src/samplereader/ADTSSampleReader.cpp
src/samplereader/FragmentedSampleReader.cpp
src/samplereader/SubtitleSampleReader.cpp
src/samplereader/TSSampleReader.cpp
src/samplereader/WebmSampleReader.cpp
src/utils/Base64Utils.cpp
src/utils/CharArrayParser.cpp
src/utils/CurlUtils.cpp
src/utils/DigestMD5Utils.cpp
src/utils/FileUtils.cpp
src/utils/MemUtils.cpp
src/utils/PropertiesUtils.cpp
src/utils/StringUtils.cpp
src/utils/SettingsUtils.cpp
src/utils/UrlUtils.cpp
src/utils/Utils.cpp
src/utils/XMLUtils.cpp
src/oscompat.cpp
src/Session.cpp
src/Stream.cpp
src/TSReader.cpp
src/aes_decrypter.cpp
src/ADTSReader.cpp
src/WebmReader.cpp
)

set(ADP_HEADERS
src/AdaptiveByteStream.h
src/main.h
src/oscompat.h
src/codechandler/CodecHandler.h
src/codechandler/AudioCodecHandler.h
src/codechandler/AV1CodecHandler.h
src/codechandler/AVCCodecHandler.h
src/codechandler/HEVCCodecHandler.h
src/codechandler/TTMLCodecHandler.h
src/codechandler/VP9CodecHandler.h
src/codechandler/WebVTTCodecHandler.h
src/codechandler/ttml/TTML.h
src/common/AdaptationSet.h
src/common/AdaptiveCencSampleDecrypter.h
src/common/AdaptiveDecrypter.h
src/common/AdaptiveStream.h
src/common/AdaptiveTree.h
src/common/AdaptiveTreeFactory.h
src/common/AdaptiveUtils.h
src/common/Chooser.h
src/common/ChooserAskQuality.h
src/common/ChooserDefault.h
src/common/ChooserFixedRes.h
src/common/ChooserManualOSD.h
src/common/ChooserTest.h
src/common/CommonAttribs.h
src/common/CommonSegAttribs.h
src/common/Period.h
src/common/Representation.h
src/common/ReprSelector.h
src/common/Segment.h
src/common/SegmentBase.h
src/common/SegmentList.h
src/common/SegTemplate.h
src/parser/CodecParser.h
src/parser/DASHTree.h
src/parser/HLSTree.h
src/parser/SmoothTree.h
src/parser/PRProtectionParser.h
src/samplereader/ADTSSampleReader.h
src/samplereader/FragmentedSampleReader.h
src/samplereader/SampleReader.h
src/samplereader/SubtitleSampleReader.h
src/samplereader/TSSampleReader.h
src/samplereader/WebmSampleReader.h
src/utils/Base64Utils.h
src/utils/CharArrayParser.h
src/utils/CryptoUtils.h
src/utils/CurlUtils.h
src/utils/DigestMD5Utils.h
src/utils/FileUtils.h
src/utils/log.h
src/utils/MemUtils.h
src/utils/PropertiesUtils.h
src/utils/SettingsUtils.h
src/utils/StringUtils.h
src/utils/UrlUtils.h
src/utils/Utils.h
src/utils/XMLUtils.h
src/Session.h
src/Stream.h
src/TSReader.h
src/aes_decrypter.h
src/ADTSReader.h
src/Iaes_decrypter.h
src/WebmReader.h
)

add_subdirectory(src/decrypters)

if(WIN32)
if(MSVC)
# Allow build for WindowsStore with Visual Studio
add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
endif()
# Allow unicode build for windows api
add_definitions(-DUNICODE -D_UNICODE)
# dlfcn implementation for windows, allow to use e.g. dlopen as POSIX-compatible way
find_package(dlfcn-win32 REQUIRED)
list(APPEND DEPLIBS ${dlfcn-win32_LIBRARIES})
include_directories(${dlfcn-win32_INCLUDE_DIRS})
else()
list(APPEND DEPLIBS ${CMAKE_DL_LIBS})
# Required on some old linux platforms to use macro like PRIu64
add_definitions(-D__STDC_FORMAT_MACROS)
endif()

# Sources to build
# (use add_dir_sources function to add source/header files from the CMakeLists files of subdirectories)
add_subdirectory(src)
# Appends sources declared by add_dir_sources to main ADP_SOURCES/ADP_HEADERS lists,
# build_addon function requires those variables
get_property(SOURCES_LIST GLOBAL PROPERTY GlobalSourceList)
list(APPEND ADP_SOURCES ${SOURCES_LIST})
get_property(HEADERS_LIST GLOBAL PROPERTY GlobalHeaderList)
list(APPEND ADP_HEADERS ${HEADERS_LIST})

include_directories(${INCLUDES}
${KODI_INCLUDE_DIR}/.. # Hack way with "/..", need bigger Kodi cmake rework to match right include ways (becomes done in future)
src/
lib/webm_parser/include
)

set(CMAKE_FIND_FRAMEWORK LAST)

find_package(Bento4 REQUIRED)
find_package(pugixml REQUIRED)

if(WIN32)
add_definitions(-DXML_STATIC -D_CRT_NONSTDC_NO_DEPRECATE)
list(APPEND DEPLIBS ws2_32)
else()
add_definitions(-D__STDC_FORMAT_MACROS)
endif()

add_definitions(-DUNICODE -D_UNICODE)

include_directories(${PUGIXML_INCLUDE_DIRS})

add_subdirectory(lib/mpegts)
add_subdirectory(lib/webm_parser)

Expand All @@ -55,11 +211,18 @@ if(ENABLE_INTERNAL_BENTO4)
add_dependencies(webm_parser bento4)
endif()

list(APPEND DEPLIBS ${PUGIXML_LIBRARIES}
${BENTO4_LIBRARIES}
mpegts
webm_parser
)
set(DECRYPTERPATH "special://home/cdm")

list(APPEND DEPLIBS ${BENTO4_LIBRARIES})
list(APPEND DEPLIBS mpegts)
list(APPEND DEPLIBS webm_parser)
list(APPEND DEPLIBS ${PUGIXML_LIBRARIES})

# Add sources from CMakeLists on subfolders
get_property(SOURCES_LIST GLOBAL PROPERTY GlobalSourceList)
list(APPEND ADP_SOURCES ${SOURCES_LIST})
get_property(HEADERS_LIST GLOBAL PROPERTY GlobalHeaderList)
list(APPEND ADP_HEADERS ${HEADERS_LIST})

# Add additional dependencies
get_property(DEPS_FOLDERS_LIST GLOBAL PROPERTY GlobalDepsFoldersList)
Expand All @@ -69,18 +232,10 @@ endforeach()
get_property(DEPS_NAMES_LIST GLOBAL PROPERTY GlobalDepsNamesList)
list(APPEND DEPLIBS ${DEPS_NAMES_LIST})

# Add additional shared dependencies
get_property(DEPS_FOLDERS_LIST GLOBAL PROPERTY GlobalSharedDepsFoldersList)
foreach(DEP_FOLDER ${DEPS_FOLDERS_LIST})
add_subdirectory(${DEP_FOLDER})
endforeach()
get_property(DEPS_NAMES_LIST GLOBAL PROPERTY GlobalSharedDepsNamesList)
foreach(DEP_NAME ${DEPS_NAMES_LIST})
list(APPEND ADP_ADDITIONAL_BINARY $<TARGET_FILE:${DEP_NAME}>)
endforeach()

build_addon(inputstream.adaptive ADP DEPLIBS)

include(CPack)

if(NOT CMAKE_CROSSCOMPILING AND BUILD_TESTING)
list(APPEND CMAKE_CTEST_ARGUMENTS "-V")
enable_testing()
Expand All @@ -92,5 +247,3 @@ if(NOT CMAKE_CROSSCOMPILING AND BUILD_TESTING)
add_dependencies(${CMAKE_PROJECT_NAME}_test bento4)
endif()
endif()

include(CPack)
17 changes: 17 additions & 0 deletions lib/mfcdm/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
cmake_minimum_required(VERSION 3.10)
project(mfcdm_library)

add_library(mfcdm_library STATIC
mfcdm/MediaFoundationCdm.h
mfcdm/MediaFoundationCdm.cpp
mfcdm/MediaFoundationCdmFactory.cpp
mfcdm/MediaFoundationCdmSession.cpp
mfcdm/MediaFoundationSession.cpp
mfcdm/Log.cpp
)

target_include_directories(mfcdm_library PUBLIC ${PROJECT_SOURCE_DIR})

target_link_libraries(mfcdm_library PRIVATE cdm_library propsys mf mfplat mfplay mfreadwrite mfuuid wmcodecdspuuid)

set_target_properties(mfcdm_library PROPERTIES POSITION_INDEPENDENT_CODE True)
47 changes: 47 additions & 0 deletions lib/mfcdm/mfcdm/Log.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#include "Log.h"

#include <cstdarg>
#include <cstdio>

typedef struct
{
const char* name;
int cur_level;
void (*msg_callback)(int level, char* msg);
} debug_ctx_t;

static debug_ctx_t debug_ctx = {"MF", MFCDM::MFLOG_NONE, NULL};


static inline void __dbg(debug_ctx_t* ctx, int level, const char* fmt, va_list ap)
{
if (ctx != NULL && level <= ctx->cur_level)
{
char msg[4096];
int len = snprintf(msg, sizeof(msg), "[%s] ", ctx->name);
vsnprintf(msg + len, sizeof(msg) - len, fmt, ap);
if (ctx->msg_callback)
{
ctx->msg_callback(level, msg);
}
}
}

void MFCDM::LogAll()
{
debug_ctx.cur_level = MFLOG_ALL;
}

void MFCDM::Log(LogLevel level, const char* fmt, ...)
{
va_list ap;

va_start(ap, fmt);
__dbg(&debug_ctx, level, fmt, ap);
va_end(ap);
}

void MFCDM::SetMFMsgCallback(void (*msgcb)(int level, char*))
{
debug_ctx.msg_callback = msgcb;
}
17 changes: 17 additions & 0 deletions lib/mfcdm/mfcdm/Log.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace MFCDM
{
enum LogLevel
{
MFLOG_NONE = -1,
MFLOG_ERROR,
MFLOG_WARN,
MFLOG_INFO,
MFLOG_DEBUG,
MFLOG_ALL = 100
};

void LogAll();
void Log(LogLevel level, const char* fmt, ...);
void SetMFMsgCallback(void (*msgcb)(int level, char*));

} // namespace MFCDM
Loading

0 comments on commit b1beb24

Please sign in to comment.