From 887466dfc1ff8ed20d3b9268f76da987f7d53635 Mon Sep 17 00:00:00 2001 From: LazyHamster Date: Thu, 5 Oct 2017 15:56:49 +0300 Subject: [PATCH] Added port for librtmp 2.3 --- ports/librtmp/CMakeLists.txt | 57 ++++++++++++++ ports/librtmp/CONTROL | 4 + ports/librtmp/fix_strncasecmp.patch | 16 ++++ ports/librtmp/hide_netstackdump.patch | 22 ++++++ ports/librtmp/librtmp.def | 105 ++++++++++++++++++++++++++ ports/librtmp/portfile.cmake | 36 +++++++++ 6 files changed, 240 insertions(+) create mode 100644 ports/librtmp/CMakeLists.txt create mode 100644 ports/librtmp/CONTROL create mode 100644 ports/librtmp/fix_strncasecmp.patch create mode 100644 ports/librtmp/hide_netstackdump.patch create mode 100644 ports/librtmp/librtmp.def create mode 100644 ports/librtmp/portfile.cmake diff --git a/ports/librtmp/CMakeLists.txt b/ports/librtmp/CMakeLists.txt new file mode 100644 index 0000000000..c12ddc0ef9 --- /dev/null +++ b/ports/librtmp/CMakeLists.txt @@ -0,0 +1,57 @@ +cmake_minimum_required(VERSION 3.8) + +project(librtmp C) + +find_package(zlib REQUIRED) +find_package(openssl REQUIRED) + +include_directories(${ZLIB_INCLUDE_DIRS}) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}) + +set(CMAKE_DEBUG_POSTFIX "d") + +if(MSVC) + add_definitions(-D_CRT_SECURE_NO_DEPRECATE) + add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE) + add_definitions(-D_WINSOCK_DEPRECATED_NO_WARNINGS) +endif() + +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 +) + +# List the source files +set(SRCS librtmp/amf.c + librtmp/hashswf.c + librtmp/log.c + librtmp/parseurl.c + librtmp/rtmp.c + librtmp/librtmp.def +) + +if(MSVC) + set(SRCS_MSVC "librtmp/librtmp.def") +endif() + +add_library(librtmp ${SRCS} ${HEADERS} ${SRCS_MSVC}) + +target_include_directories(librtmp PRIVATE ./librtmp) +target_link_libraries(librtmp PRIVATE ${ZLIB_LIBRARIES} ${OPENSSL_LIBRARIES}) +target_link_libraries(librtmp PRIVATE Ws2_32.lib Winmm.lib) + +install(TARGETS librtmp + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib) + +install(FILES librtmp/rtmp.h librtmp/amf.h DESTINATION include/librtmp) \ No newline at end of file diff --git a/ports/librtmp/CONTROL b/ports/librtmp/CONTROL new file mode 100644 index 0000000000..d26541d912 --- /dev/null +++ b/ports/librtmp/CONTROL @@ -0,0 +1,4 @@ +Source: librtmp +Version: 2.3 +Build-Depends: zlib, openssl +Description: RTMPDump Real-Time Messaging Protocol API diff --git a/ports/librtmp/fix_strncasecmp.patch b/ports/librtmp/fix_strncasecmp.patch new file mode 100644 index 0000000000..c1cadc4acf --- /dev/null +++ b/ports/librtmp/fix_strncasecmp.patch @@ -0,0 +1,16 @@ +diff --git a/librtmp/rtmp_sys.h b/librtmp/rtmp_sys.h +index 0874cbe..b43d587 100644 +--- a/librtmp/rtmp_sys.h ++++ b/librtmp/rtmp_sys.h +@@ -37,6 +37,11 @@ + #include + #endif + ++#ifdef _MSC_VER ++#define strncasecmp _strnicmp ++#define strcasecmp _stricmp ++#endif ++ + #define GetSockError() WSAGetLastError() + #define SetSockError(e) WSASetLastError(e) + #define setsockopt(a,b,c,d,e) (setsockopt)(a,b,c,(const char *)d,(int)e) diff --git a/ports/librtmp/hide_netstackdump.patch b/ports/librtmp/hide_netstackdump.patch new file mode 100644 index 0000000000..e2a5e42076 --- /dev/null +++ b/ports/librtmp/hide_netstackdump.patch @@ -0,0 +1,22 @@ +diff --git a/librtmp/rtmp.c b/librtmp/rtmp.c +index f152648..0bf3f7d 100644 +--- a/librtmp/rtmp.c ++++ b/librtmp/rtmp.c +@@ -1316,7 +1316,7 @@ ReadN(RTMP *r, char *buffer, int n) + SendBytesReceived(r); + } + /*RTMP_Log(RTMP_LOGDEBUG, "%s: %d bytes\n", __FUNCTION__, nBytes); */ +-#ifdef _DEBUG ++#if defined(_DEBUG) && !defined(LIBRTMP_ONLY) + fwrite(ptr, 1, nBytes, netstackdump_read); + #endif + +@@ -3527,7 +3527,7 @@ RTMPSockBuf_Send(RTMPSockBuf *sb, const char *buf, int len) + { + int rc; + +-#ifdef _DEBUG ++#if defined(_DEBUG) && !defined(LIBRTMP_ONLY) + fwrite(buf, 1, len, netstackdump); + #endif + diff --git a/ports/librtmp/librtmp.def b/ports/librtmp/librtmp.def new file mode 100644 index 0000000000..d9f8b91366 --- /dev/null +++ b/ports/librtmp/librtmp.def @@ -0,0 +1,105 @@ +EXPORTS + AMF_AddProp + AMF_CountProp + AMF_Decode + AMF_DecodeArray + AMF_DecodeBoolean + AMF_DecodeInt16 + AMF_DecodeInt24 + AMF_DecodeInt32 + AMF_DecodeLongString + AMF_DecodeNumber + AMF_DecodeString + AMF_Dump + AMF_Encode + AMF_EncodeBoolean + AMF_EncodeInt16 + AMF_EncodeInt24 + AMF_EncodeInt32 + AMF_EncodeNamedBoolean + AMF_EncodeNamedNumber + AMF_EncodeNamedString + AMF_EncodeNumber + AMF_EncodeString + AMF_GetProp + AMF_Reset + + AMF3_Decode + AMF3CD_AddProp + AMF3CD_GetProp + AMF3Prop_Decode + AMF3ReadInteger + AMF3ReadString + + AMFProp_Decode + AMFProp_Dump + AMFProp_Encode + AMFProp_GetBoolean + AMFProp_GetName + AMFProp_GetNumber + AMFProp_GetObject + AMFProp_GetString + AMFProp_GetType + AMFProp_IsValid + AMFProp_Reset + AMFProp_SetName + + RTMP_Alloc + RTMP_ClientPacket + RTMP_Close + RTMP_Connect + RTMP_Connect0 + RTMP_Connect1 + RTMP_ConnectStream + RTMP_ctrlC + RTMP_debuglevel + RTMP_DefaultFlashVer + RTMP_DeleteStream + RTMP_DropRequest + RTMP_EnableWrite + RTMP_FindFirstMatchingProperty + RTMP_FindPrefixProperty + RTMP_Free + RTMP_GetDuration + RTMP_GetNextMediaPacket + RTMP_GetTime + RTMP_HashSWF + RTMP_Init + RTMP_IsConnected + RTMP_IsTimedout + RTMP_LibVersion + RTMP_Log + RTMP_LogGetLevel + RTMP_LogHex + RTMP_LogHexString + RTMP_LogPrintf + RTMP_LogSetCallback + RTMP_LogSetLevel + RTMP_LogSetOutput + RTMP_LogStatus + RTMP_ParsePlaypath + RTMP_ParseURL + RTMP_Pause + RTMP_Read + RTMP_ReadPacket + RTMP_ReconnectStream + RTMP_SendChunk + RTMP_SendClientBW + RTMP_SendCreateStream + RTMP_SendCtrl + RTMP_SendPacket + RTMP_SendPause + RTMP_SendSeek + RTMP_SendServerBW + RTMP_Serve + RTMP_SetBufferMS + RTMP_SetOpt + RTMP_SetupStream + RTMP_SetupURL + RTMP_Socket + RTMP_TLS_ctx + RTMP_TLS_Init + RTMP_ToggleStream + RTMP_UpdateBufferMS + RTMP_UserInterrupt + RTMP_Write diff --git a/ports/librtmp/portfile.cmake b/ports/librtmp/portfile.cmake new file mode 100644 index 0000000000..18423f1527 --- /dev/null +++ b/ports/librtmp/portfile.cmake @@ -0,0 +1,36 @@ +include(vcpkg_common_functions) + +set(RTMPDUMP_VERSION 2.3) +set(RTMPDUMP_FILENAME rtmpdump-${RTMPDUMP_VERSION}.tgz) +set(SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/rtmpdump-${RTMPDUMP_VERSION}) + +vcpkg_download_distfile(ARCHIVE + URLS "http://rtmpdump.mplayerhq.hu/download/${RTMPDUMP_FILENAME}" + FILENAME "${RTMPDUMP_FILENAME}" + SHA512 d8240ba372a704231286b81bbf75716d8b76874840538c4e1527f7f8b6ca66eeaba6b03167fe6fab06bf80f20f07d89ecb84cc428b3196234174a43f3328ec2a +) +vcpkg_extract_source_archive(${ARCHIVE}) + +file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH}) +file(COPY ${CMAKE_CURRENT_LIST_DIR}/librtmp.def DESTINATION ${SOURCE_PATH}/librtmp) + +vcpkg_apply_patches( + SOURCE_PATH ${SOURCE_PATH} + PATCHES + ${CMAKE_CURRENT_LIST_DIR}/fix_strncasecmp.patch + ${CMAKE_CURRENT_LIST_DIR}/hide_netstackdump.patch +) + +vcpkg_configure_cmake( + SOURCE_PATH ${SOURCE_PATH} +) + +vcpkg_install_cmake() + +file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include) + +# License and man +file(INSTALL ${SOURCE_PATH}/librtmp/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/librtmp RENAME copyright) +file(INSTALL ${SOURCE_PATH}/librtmp/librtmp.3.html DESTINATION ${CURRENT_PACKAGES_DIR}/share/librtmp) + +vcpkg_copy_pdbs()