Skip to content

Commit

Permalink
Merge pull request #1344 from glennguy/decrypter-refactor
Browse files Browse the repository at this point in the history
Decrypter refactor
  • Loading branch information
glennguy authored Sep 11, 2023
2 parents aec6f37 + b2199ea commit 9fcb8d6
Show file tree
Hide file tree
Showing 90 changed files with 4,609 additions and 4,060 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# build artifacts
build/
!*/build/
/build/
inputstream.*/addon.xml

# Debian build files
Expand Down
62 changes: 50 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,45 @@
cmake_minimum_required(VERSION 3.10)

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})

find_package(Kodi 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
Expand Down Expand Up @@ -61,7 +95,6 @@ set(ADP_SOURCES
src/utils/UrlUtils.cpp
src/utils/Utils.cpp
src/utils/XMLUtils.cpp
src/KodiHost.cpp
src/oscompat.cpp
src/Session.cpp
src/Stream.cpp
Expand All @@ -75,7 +108,6 @@ set(ADP_HEADERS
src/AdaptiveByteStream.h
src/main.h
src/oscompat.h
src/SSD_dll.h
src/codechandler/CodecHandler.h
src/codechandler/AudioCodecHandler.h
src/codechandler/AV1CodecHandler.h
Expand Down Expand Up @@ -132,7 +164,6 @@ set(ADP_HEADERS
src/utils/UrlUtils.h
src/utils/Utils.h
src/utils/XMLUtils.h
src/KodiHost.h
src/Session.h
src/Stream.h
src/TSReader.h
Expand All @@ -142,6 +173,8 @@ set(ADP_HEADERS
src/WebmReader.h
)

add_subdirectory(src/decrypters)

if(WIN32)
find_package(dlfcn-win32 REQUIRED)
list(APPEND DEPLIBS ${dlfcn-win32_LIBRARIES})
Expand Down Expand Up @@ -169,20 +202,11 @@ add_definitions(-DUNICODE -D_UNICODE)

include_directories(${PUGIXML_INCLUDE_DIRS})

if(CORE_SYSTEM_NAME STREQUAL ios OR CORE_SYSTEM_NAME STREQUAL darwin_embedded)
set(BENTOUSESTCFS 1)
include_directories(${BENTO4_INCLUDE_DIRS})
else()
add_subdirectory(wvdecrypter)
set(ADP_ADDITIONAL_BINARY $<TARGET_FILE:ssd_wv>)
endif()

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

if(ENABLE_INTERNAL_BENTO4)
include_directories(${BENTO4_INCLUDE_DIRS})
add_dependencies(ssd_wv bento4)
add_dependencies(mpegts bento4)
add_dependencies(webm_parser bento4)
endif()
Expand All @@ -194,6 +218,20 @@ 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)
foreach(DEP_FOLDER ${DEPS_FOLDERS_LIST})
add_subdirectory(${DEP_FOLDER})
endforeach()
get_property(DEPS_NAMES_LIST GLOBAL PROPERTY GlobalDepsNamesList)
list(APPEND DEPLIBS ${DEPS_NAMES_LIST})

build_addon(inputstream.adaptive ADP DEPLIBS)

include(CPack)
Expand Down
25 changes: 25 additions & 0 deletions lib/cdm/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
cmake_minimum_required(VERSION 3.10)
project(cdm_library)

if(WIN32)
set(CDMTYPE "win.cc")
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(CDMTYPE "mac.mm")
else()
set(CDMTYPE "posix.cc")
endif()

add_library(cdm_library STATIC
cdm/base/native_library.cc
cdm/base/native_library_${CDMTYPE}
cdm/media/cdm/cdm_adapter.cc
cdm/media/cdm/cdm_adapter.h
)

target_include_directories(cdm_library PUBLIC ${PROJECT_SOURCE_DIR})

set_target_properties(cdm_library PROPERTIES POSITION_INDEPENDENT_CODE True)

if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
target_link_libraries(cdm_library "-framework CoreFoundation")
endif()
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

#if defined(OS_WIN)
#include <windows.h>
// Windows "ERROR" define can conflicts with definitions of projects that use this name, so remove it
#undef ERROR
#elif defined(OS_MACOSX)
#import <CoreFoundation/CoreFoundation.h>
#endif // OS_*
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

#include "cdm_adapter.h"

#include "../../../Helper.h"
//! @todo: provide an appropriate interface for log output
#include "../../../src/utils/log.h"

#include <chrono>
#include <thread>
Expand Down Expand Up @@ -163,7 +164,7 @@ void CdmAdapter::Initialize()

if (!library_)
{
LOG::Log(SSD::SSDERROR, "%s: Failed to load library: %s", __FUNCTION__,
LOG::LogF(LOGERROR, "%s: Failed to load library: %s", __FUNCTION__,
error.ToString().c_str());
return;
}
Expand All @@ -181,7 +182,7 @@ void CdmAdapter::Initialize()
}

std::string version{get_cdm_verion_func()};
LOG::Log(SSD::SSDDEBUG, "CDM version: %s", version.c_str());
LOG::LogF(LOGDEBUG, "CDM version: %s", version.c_str());

#if defined(OS_WIN)
// Load DXVA before sandbox lockdown to give CDM access to Output Protection
Expand Down Expand Up @@ -547,7 +548,7 @@ void CdmAdapter::OnSessionKeysChange(const char* session_id,
char* bufferPtr{buffer};
for (uint32_t j{0}; j < keys_info[i].key_id_size; ++j)
bufferPtr += sprintf(bufferPtr, "%02X", (int)keys_info[i].key_id[j]);
LOG::Log(SSD::SSDDEBUG, "%s: Sessionkey %s status: %d syscode: %u", __func__, buffer,
LOG::Log(LOGDEBUG, "%s: Sessionkey %s status: %d syscode: %u", __func__, buffer,
keys_info[i].status, keys_info[i].system_code);

SendClientMessage(session_id, session_id_size, CdmAdapterClient::kSessionKeysChange,
Expand Down Expand Up @@ -623,7 +624,7 @@ void CdmAdapter::RequestStorageId(uint32_t version)

void CdmAdapter::OnInitialized(bool success)
{
LOG::Log(SSD::SSDDEBUG, "CDM is initialized: %s", success ? "true" : "false");
LOG::LogF(LOGDEBUG, "CDM is initialized: %s", success ? "true" : "false");
}


Expand Down
File renamed without changes.
28 changes: 28 additions & 0 deletions lib/jni/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
cmake_minimum_required(VERSION 3.5)
project(jni)

add_library(jni STATIC
jni/jutils/jutils-details.hpp
jni/jutils/jutils.cpp
jni/jutils/jutils.hpp
jni/src/ClassLoader.cpp
jni/src/ClassLoader.h
jni/src/ClassLoader.cpp
jni/src/HashMap.cpp
jni/src/HashMap.h
jni/src/JNIBase.cpp
jni/src/JNIBase.h
jni/src/Log.h
jni/src/MediaDrm.cpp
jni/src/MediaDrm.h
jni/src/MediaDrmKeyRequest.cpp
jni/src/MediaDrmKeyRequest.h
jni/src/MediaDrmOnEventListener.cpp
jni/src/MediaDrmOnEventListener.h
jni/src/MediaDrmProvisionRequest.cpp
jni/src/MediaDrmProvisionRequest.h
jni/src/UUID.cpp
jni/src/UUID.h
)

target_include_directories(jni PUBLIC ${PROJECT_SOURCE_DIR} PRIVATE ${PROJECT_SOURCE_DIR}/jni/jutils)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#pragma once

#include "jutils.hpp"
#include "../jutils/jutils.hpp"

#include <list>

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
119 changes: 0 additions & 119 deletions src/KodiHost.cpp

This file was deleted.

Loading

0 comments on commit 9fcb8d6

Please sign in to comment.