-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Tal Regev <[email protected]>
- Loading branch information
Showing
12 changed files
with
228 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
diff --git a/CMake/curl-config.cmake.in b/CMake/curl-config.cmake.in | ||
index c290064daa..4122b260f2 100644 | ||
--- a/CMake/curl-config.cmake.in | ||
+++ b/CMake/curl-config.cmake.in | ||
@@ -50,6 +50,9 @@ endif() | ||
if("@HAVE_ZSTD@") | ||
find_dependency(zstd CONFIG) | ||
endif() | ||
+if("@USE_LIBRTMP@") | ||
+ find_dependency(unofficial-librtmp CONFIG) | ||
+endif() | ||
|
||
include("${CMAKE_CURRENT_LIST_DIR}/@[email protected]") | ||
check_required_components("@PROJECT_NAME@") | ||
diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
index 0cba6f626b..e4a5f05ade 100644 | ||
--- a/CMakeLists.txt | ||
+++ b/CMakeLists.txt | ||
@@ -1309,6 +1309,10 @@ endif() | ||
|
||
option(USE_LIBRTMP "Enable librtmp from rtmpdump" OFF) | ||
if(USE_LIBRTMP) | ||
+ find_package(OpenSSL REQUIRED) | ||
+ find_package(unofficial-librtmp CONFIG REQUIRED) | ||
+ list(APPEND CURL_LIBS unofficial::librtmp::librtmp) | ||
+elseif(0) | ||
set(_extra_libs "rtmp") | ||
if(WIN32) | ||
list(APPEND _extra_libs "winmm") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
diff --git a/librtmp/rtmp_sys.h b/librtmp/rtmp_sys.h | ||
index 5b3eb54e86767a45a91f941014113ca9e62b5b74..5b4c1e98a12b2b2dc3009fee007ac140fd2745f8 100644 | ||
--- a/librtmp/rtmp_sys.h | ||
+++ b/librtmp/rtmp_sys.h | ||
@@ -43,6 +43,7 @@ | ||
#define sleep(n) Sleep(n*1000) | ||
#define msleep(n) Sleep(n) | ||
#define SET_RCVTIMEO(tv,s) int tv = s*1000 | ||
+#include <sys/types.h> | ||
#else /* !_WIN32 */ | ||
#include <sys/types.h> | ||
#include <sys/socket.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,133 @@ | ||
cmake_minimum_required(VERSION 3.10) | ||
# Unofficial librtmp CMakeLists.txt from Makefile of https://git.ffmpeg.org/gitweb/rtmpdump.git/blob/6f6bb1353fc84f4cc37138baa99f586750028a01:/librtmp/Makefile | ||
cmake_minimum_required(VERSION 3.29) | ||
|
||
project(librtmp C) | ||
project(librtmp | ||
VERSION ${VERSION} | ||
DESCRIPTION "RTMP implementation" | ||
HOMEPAGE_URL "http://rtmpdump.mplayerhq.hu" | ||
LANGUAGES C | ||
) | ||
set(LIBRTMP_SO_VERSION ${LIBRTMP_SO_VERSION}) | ||
|
||
find_package(ZLIB REQUIRED) | ||
find_package(OpenSSL REQUIRED) | ||
# options switch `LIBRTMP_CRYPTO` and string `LIBRTMP_SSL` of "NOSSL;POLARSSL;OPENSSL;GNUTLS" | ||
option(LIBRTMP_CRYPTO "" ON) | ||
if(LIBRTMP_CRYPTO) | ||
set(LIBRTMP_SSL "OPENSSL" CACHE STRING "") | ||
set(LIBRTMP_SSL_ITEMS "NOSSL" "POLARSSL" "OPENSSL" "GNUTLS") | ||
set_property(CACHE LIBRTMP_SSL PROPERTY STRINGS ${LIBRTMP_SSL_ITEMS}) | ||
if(NOT LIBRTMP_SSL IN_LIST LIBRTMP_SSL_ITEMS) | ||
message(FATAL_ERROR "String option LIBRTMP_SSL must be one of ${LIBRTMP_SSL_ITEMS}") | ||
endif() | ||
endif() | ||
|
||
include_directories(${ZLIB_INCLUDE_DIRS}) | ||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}) | ||
# target librtmp | ||
set(librtmp_target "librtmp") | ||
add_library(${librtmp_target}) | ||
set_target_properties(${librtmp_target} PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${LIBRTMP_SO_VERSION}) | ||
if(WIN32) | ||
target_sources(${librtmp_target} PRIVATE "librtmp.def") | ||
endif() | ||
|
||
set(CMAKE_DEBUG_POSTFIX "d") | ||
# target librtmp_public | ||
set(librtmp_public "librtmp_public") | ||
add_library(${librtmp_public} INTERFACE) | ||
target_compile_definitions(${librtmp_public} INTERFACE "RTMPDUMP_VERSION=\"${PROJECT_VERSION}\"") | ||
|
||
if(MSVC) | ||
add_definitions(-D_CRT_SECURE_NO_DEPRECATE) | ||
add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE) | ||
add_definitions(-D_WINSOCK_DEPRECATED_NO_WARNINGS) | ||
endif() | ||
# target librtmp_local | ||
set(librtmp_local "librtmp_local") | ||
add_library(${librtmp_local} INTERFACE) | ||
target_compile_definitions(${librtmp_local} INTERFACE "LIBRTMP_ONLY") | ||
|
||
add_definitions(-DLIBRTMP_ONLY) | ||
|
||
# List the header files | ||
set(HEADERS librtmp/amf.h | ||
librtmp/bytes.h | ||
librtmp/dh.h | ||
librtmp/dhgroups.h | ||
librtmp/handshake.h | ||
librtmp/http.h | ||
librtmp/log.h | ||
librtmp/rtmp.h | ||
librtmp/rtmp_sys.h | ||
) | ||
# target librtmp_transitive | ||
set(librtmp_transitive "librtmp_transitive") | ||
add_library(${librtmp_transitive} INTERFACE) | ||
|
||
# List the source files | ||
set(SRCS librtmp/amf.c | ||
librtmp/hashswf.c | ||
librtmp/log.c | ||
librtmp/parseurl.c | ||
librtmp/rtmp.c | ||
) | ||
# dependency zlib | ||
find_package(ZLIB REQUIRED) | ||
target_link_libraries(${librtmp_transitive} INTERFACE ZLIB::ZLIB) | ||
|
||
if(MSVC) | ||
set(SRCS_MSVC "librtmp/librtmp.def") | ||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4996") | ||
# dependency crypto | ||
if(NOT LIBRTMP_CRYPTO) | ||
target_compile_definitions(${librtmp_public} INTERFACE "NO_CRYPTO") | ||
else() | ||
if(LIBRTMP_SSL STREQUAL "OPENSSL") | ||
target_compile_definitions(${librtmp_public} INTERFACE "USE_OPENSSL") | ||
find_package(OpenSSL CONFIG REQUIRED) | ||
target_link_libraries(${librtmp_transitive} INTERFACE OpenSSL::SSL OpenSSL::Crypto) | ||
else() | ||
message(FATAL_ERROR "Unsupported LIBRTMP_SSL: ${LIBRTMP_SSL}") | ||
endif() | ||
endif() | ||
|
||
add_library(rtmp ${SRCS} ${HEADERS} ${SRCS_MSVC}) | ||
|
||
target_include_directories(rtmp PRIVATE ./librtmp) | ||
target_link_libraries(rtmp PRIVATE ${ZLIB_LIBRARIES} ${OPENSSL_LIBRARIES}) | ||
if(MSVC OR MINGW) | ||
target_link_libraries(rtmp PRIVATE Ws2_32.lib Winmm.lib) | ||
# dependency system | ||
if(WIN32) | ||
target_link_libraries(${librtmp_transitive} INTERFACE ws2_32 winmm) | ||
endif() | ||
|
||
set(libdir [[${prefix}/lib]]) | ||
set(VERSION 2.6) # from ChangeLog | ||
set(CRYPTO_REQ "libssl,libcrypto") | ||
if(MSVC OR MINGW) | ||
set(PRIVATE_LIBS "-lWS2_32 -lWinMM") | ||
# target objects | ||
set(librtmp_obj_list "log" "rtmp" "amf" "hashswf" "parseurl") | ||
add_library(log OBJECT) | ||
target_sources(log PRIVATE "log.c" PUBLIC FILE_SET HEADERS FILES "log.h") | ||
add_library(rtmp OBJECT) | ||
target_sources(rtmp PRIVATE "rtmp.c" PUBLIC FILE_SET HEADERS FILES "rtmp.h" "rtmp_sys.h" "handshake.h" "dh.h" "log.h" "amf.h") | ||
add_library(amf OBJECT) | ||
target_sources(amf PRIVATE "amf.c" PUBLIC FILE_SET HEADERS FILES "amf.h" "bytes.h" "log.h") | ||
add_library(hashswf OBJECT) | ||
target_sources(hashswf PRIVATE "hashswf.c" PUBLIC FILE_SET HEADERS FILES "http.h" "rtmp.h" "rtmp_sys.h") | ||
add_library(parseurl OBJECT) | ||
target_sources(parseurl PRIVATE "parseurl.c" PUBLIC FILE_SET HEADERS FILES "rtmp.h" "rtmp_sys.h" "log.h") | ||
|
||
# link | ||
foreach(obj IN LISTS librtmp_obj_list) | ||
target_link_libraries(${obj} PUBLIC ${librtmp_public} PRIVATE ${librtmp_transitive} $<BUILD_LOCAL_INTERFACE:${librtmp_local}>) | ||
endforeach() | ||
target_link_libraries(${librtmp_target} PUBLIC ${librtmp_obj_list}) | ||
|
||
# === Install === | ||
|
||
# install settings | ||
include(GNUInstallDirs) | ||
set(librtmp_package_name "unofficial-librtmp") | ||
set(librtmp_namespace "unofficial::librtmp::") | ||
set(librtmp_target_list "${librtmp_target};${librtmp_obj_list};${librtmp_public};${librtmp_transitive}") | ||
set(librtmp_export_targets "librtmp-targets") | ||
set(librtmp_install_include "${CMAKE_INSTALL_INCLUDEDIR}/librtmp") | ||
set(librtmp_install_share "${CMAKE_INSTALL_DATAROOTDIR}/${librtmp_package_name}") | ||
set(librtmp_config_filename "${librtmp_package_name}-config.cmake") | ||
set(librtmp_config_template_path "${CMAKE_CURRENT_BINARY_DIR}/Config.cmake.in") | ||
|
||
# install targets | ||
install(TARGETS ${librtmp_target_list} | ||
EXPORT "${librtmp_export_targets}" | ||
FILE_SET HEADERS DESTINATION "${librtmp_install_include}" | ||
) | ||
|
||
install(EXPORT "${librtmp_export_targets}" | ||
NAMESPACE "${librtmp_namespace}" | ||
DESTINATION "${librtmp_install_share}" | ||
) | ||
|
||
# generate configs | ||
file(WRITE "${librtmp_config_template_path}" | ||
[[@PACKAGE_INIT@ | ||
set(LIBRTMP_CRYPTO @LIBRTMP_CRYPTO@) | ||
set(LIBRTMP_SSL @LIBRTMP_SSL@) | ||
include(CMakeFindDependencyMacro) | ||
find_dependency(ZLIB REQUIRED) | ||
if(LIBRTMP_CRYPTO AND LIBRTMP_SSL STREQUAL "OPENSSL") | ||
find_dependency(OpenSSL CONFIG REQUIRED) | ||
endif() | ||
configure_file(librtmp/librtmp.pc.in librtmp.pc @ONLY) | ||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/librtmp.pc | ||
DESTINATION lib/pkgconfig | ||
include("${CMAKE_CURRENT_LIST_DIR}/@[email protected]") | ||
]] | ||
) | ||
include(CMakePackageConfigHelpers) | ||
configure_package_config_file("${librtmp_config_template_path}" | ||
"${librtmp_config_filename}" | ||
INSTALL_DESTINATION "${librtmp_install_share}" | ||
) | ||
|
||
install(TARGETS rtmp | ||
RUNTIME DESTINATION bin | ||
LIBRARY DESTINATION lib | ||
ARCHIVE DESTINATION lib) | ||
# install configs | ||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${librtmp_config_filename}" DESTINATION "${librtmp_install_share}") | ||
|
||
install(DIRECTORY ${PROJECT_SOURCE_DIR}/librtmp DESTINATION include FILES_MATCHING PATTERN "*.h") | ||
# install man | ||
install(FILES "librtmp.3" "librtmp.3.html" DESTINATION "${CMAKE_INSTALL_MANDIR}/man3") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
librtmp can be imported via CMake FindPkgConfig module: | ||
|
||
find_package(PkgConfig REQUIRED) | ||
pkg_check_modules(librtmp REQUIRED IMPORTED_TARGET librtmp) | ||
target_link_libraries(main PkgConfig::librtmp) | ||
@PORT@ provides CMake targets: | ||
|
||
find_package(unofficial-librtmp CONFIG REQUIRED) | ||
target_link_libraries(main PRIVATE unofficial::librtmp::librtmp) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,30 @@ | ||
{ | ||
"name": "librtmp", | ||
"version-date": "2024-03-01", | ||
"port-version": 1, | ||
"description": "RTMPDump Real-Time Messaging Protocol API", | ||
"homepage": "https://rtmpdump.mplayerhq.hu", | ||
"license": "LGPL-2.1-only", | ||
"dependencies": [ | ||
"openssl", | ||
{ | ||
"name": "vcpkg-cmake", | ||
"host": true | ||
}, | ||
{ | ||
"name": "vcpkg-cmake-config", | ||
"host": true | ||
}, | ||
"zlib" | ||
] | ||
], | ||
"default-features": [ | ||
"crypto" | ||
], | ||
"features": { | ||
"crypto": { | ||
"description": "Build librtmp with CRYPTO and SSL support", | ||
"dependencies": [ | ||
"openssl" | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.