瀏覽代碼

Compiling libsrtp inline

Staz M 4 年之前
父節點
當前提交
3e70af915f
共有 4 個文件被更改,包括 11 次插入20 次删除
  1. 3 0
      .gitmodules
  2. 6 19
      CMakeLists.txt
  3. 1 0
      deps/libsrtp
  4. 1 1
      src/dtlssrtptransport.hpp

+ 3 - 0
.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

+ 6 - 19
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)

+ 1 - 0
deps/libsrtp

@@ -0,0 +1 @@
+Subproject commit 7d351de8177b33c96669bb79dc684a8dc64c2483

+ 1 - 1
src/dtlssrtptransport.hpp

@@ -24,7 +24,7 @@
 
 #if RTC_ENABLE_MEDIA
 
-#include <srtp2/srtp.h>
+#include "srtp.h"
 
 #include <atomic>