From 3e70af915f80b714c1c885169d1d7c4726354a64 Mon Sep 17 00:00:00 2001 From: Staz M Date: Thu, 29 Oct 2020 01:10:33 -0400 Subject: [PATCH] Compiling libsrtp inline --- .gitmodules | 3 +++ CMakeLists.txt | 25 ++++++------------------- deps/libsrtp | 1 + src/dtlssrtptransport.hpp | 2 +- 4 files changed, 11 insertions(+), 20 deletions(-) create mode 160000 deps/libsrtp diff --git a/.gitmodules b/.gitmodules index 2396c8f..5b296b7 100644 --- a/.gitmodules +++ b/.gitmodules @@ -10,3 +10,6 @@ [submodule "deps/json"] path = deps/json url = https://github.com/nlohmann/json.git +[submodule "deps/libsrtp"] + path = deps/libsrtp + url = https://github.com/cisco/libsrtp.git diff --git a/CMakeLists.txt b/CMakeLists.txt index fcc0627..a5ae946 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -161,25 +161,12 @@ if(WIN32) target_link_libraries(datachannel-static PRIVATE wsock32 ws2_32) # winsock2 endif() -find_package(SRTP) -if(SRTP_FOUND) - if(NOT TARGET SRTP::SRTP) - add_library(SRTP::SRTP UNKNOWN IMPORTED) - set_target_properties(SRTP::SRTP PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES ${SRTP_INCLUDE_DIRS} - IMPORTED_LINK_INTERFACE_LANGUAGES C - IMPORTED_LOCATION ${SRTP_LIBRARIES}) - endif() - message(STATUS "LibSRTP found, compiling with media transport") - target_compile_definitions(datachannel PUBLIC RTC_ENABLE_MEDIA=1) - target_compile_definitions(datachannel-static PUBLIC RTC_ENABLE_MEDIA=1) - target_link_libraries(datachannel PRIVATE SRTP::SRTP) - target_link_libraries(datachannel-static PRIVATE SRTP::SRTP) -else() - message(STATUS "LibSRTP NOT found, compiling WITHOUT media transport") - target_compile_definitions(datachannel PUBLIC RTC_ENABLE_MEDIA=0) - target_compile_definitions(datachannel-static PUBLIC RTC_ENABLE_MEDIA=0) -endif() +add_subdirectory(deps/libsrtp EXCLUDE_FROM_ALL) +message(STATUS "LibSRTP found, compiling with media transport") +target_compile_definitions(datachannel PUBLIC RTC_ENABLE_MEDIA=1) +target_compile_definitions(datachannel-static PUBLIC RTC_ENABLE_MEDIA=1) +target_link_libraries(datachannel PRIVATE srtp2) +target_link_libraries(datachannel-static PRIVATE srtp2) if (USE_GNUTLS) find_package(GnuTLS REQUIRED) diff --git a/deps/libsrtp b/deps/libsrtp new file mode 160000 index 0000000..7d351de --- /dev/null +++ b/deps/libsrtp @@ -0,0 +1 @@ +Subproject commit 7d351de8177b33c96669bb79dc684a8dc64c2483 diff --git a/src/dtlssrtptransport.hpp b/src/dtlssrtptransport.hpp index 03a9968..579ce29 100644 --- a/src/dtlssrtptransport.hpp +++ b/src/dtlssrtptransport.hpp @@ -24,7 +24,7 @@ #if RTC_ENABLE_MEDIA -#include +#include "srtp.h" #include