From 5ad12d6257cda28e3a0798eecddb369bcc04e794 Mon Sep 17 00:00:00 2001 From: tqcq <99722391+tqcq@users.noreply.github.com> Date: Wed, 28 Aug 2024 09:57:33 +0800 Subject: [PATCH] feat build tools only BUILD_TOOLS=ON --- .gitignore | 1 + CMakeLists.txt | 61 ++++++++++++++++++++------------------------ src/base/frame.h | 8 ++++++ src/base/hk_sign.cpp | 4 +-- 4 files changed, 38 insertions(+), 36 deletions(-) diff --git a/.gitignore b/.gitignore index 27e86e5..f70a489 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ release/ .cache out/ compile_commands.json +build_* diff --git a/CMakeLists.txt b/CMakeLists.txt index 44e5af0..e6937c5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,10 +53,10 @@ foreach(src ${src_rtp}) message(STATUS "rtp src: ${src}") endforeach() -target_include_directories(rtp PUBLIC - ${MediaServer_Root}/librtp/include - ${MediaServer_Root}/libmpeg/include - ${MediaServer_Root}/libmpeg/source) +target_include_directories( + rtp + PUBLIC ${MediaServer_Root}/librtp/include ${MediaServer_Root}/libmpeg/include + ${MediaServer_Root}/libmpeg/source) include_directories(${SecMedia_Root}/SVAC/src/svac_src) # 添加svac解密 @@ -98,16 +98,9 @@ append_srcs(SecMedia_src_list ${SecMedia_Root}/base) # message(STATUS "SRCS: ${SecMedia_src_list}") -# file( -# GLOB -# SecMedia_src_list -# ${SecMedia_Root}/*/*.cpp -# ${SecMedia_Root}/*/*.h -# ${SecMedia_Root}/*/*.c -# ${SecMedia_Root}/*/*/*.cpp -# ${SecMedia_Root}/*/*/*.h -# ${SecMedia_Root}/*/*/*.c -# ) +# file( GLOB SecMedia_src_list ${SecMedia_Root}/*/*.cpp ${SecMedia_Root}/*/*.h +# ${SecMedia_Root}/*/*.c ${SecMedia_Root}/*/*/*.cpp ${SecMedia_Root}/*/*/*.h +# ${SecMedia_Root}/*/*/*.c ) file(GLOB SecMedia_api_list ${CMAKE_CURRENT_SOURCE_DIR}/include/common.h) # # target_compile_options(${PROJECT_NAME} PRIVATE -fvisibility=hidden) @@ -116,23 +109,22 @@ file(GLOB SecMedia_api_list ${CMAKE_CURRENT_SOURCE_DIR}/include/common.h) add_library(${PROJECT_NAME} SHARED ${SecMedia_src_list}) # add_library(${PROJECT_NAME} STATIC ${SecMedia_src_list}) target_link_libraries(${PROJECT_NAME} PUBLIC ${LINK_LIB_SVAC_LIST} rtp) -target_include_directories(${PROJECT_NAME} PRIVATE -${SecMedia_Root} -${SecMedia_Root}/3rdpart/media-server/libdash/include -${SecMedia_Root}/3rdpart/media-server/libflv/include -${SecMedia_Root}/3rdpart/media-server/libhls/include -${SecMedia_Root}/3rdpart/media-server/libmov/include -${SecMedia_Root}/3rdpart/media-server/libmpeg/include -${SecMedia_Root}/3rdpart/media-server/librtmp/include -${SecMedia_Root}/3rdpart/media-server/librtp/include -${SecMedia_Root}/3rdpart/media-server/librtsp/include -${SecMedia_Root}/3rdpart/media-server/libsip/include - -) +target_include_directories( + ${PROJECT_NAME} + PRIVATE ${SecMedia_Root} + ${SecMedia_Root}/3rdpart/media-server/libdash/include + ${SecMedia_Root}/3rdpart/media-server/libflv/include + ${SecMedia_Root}/3rdpart/media-server/libhls/include + ${SecMedia_Root}/3rdpart/media-server/libmov/include + ${SecMedia_Root}/3rdpart/media-server/libmpeg/include + ${SecMedia_Root}/3rdpart/media-server/librtmp/include + ${SecMedia_Root}/3rdpart/media-server/librtp/include + ${SecMedia_Root}/3rdpart/media-server/librtsp/include + ${SecMedia_Root}/3rdpart/media-server/libsip/include) # set_target_properties(${PROJECT_NAME} PROPERTIES VERSION ${PROJECT_VERSION} -# SOVERSION 1 PUBLIC_HEADER ${SecMedia_api_list} ) -# CXX_VISIBILITY_PRESET hidden CMAKE_C_FLAGS hidden) +# SOVERSION 1 PUBLIC_HEADER ${SecMedia_api_list} ) CXX_VISIBILITY_PRESET hidden +# CMAKE_C_FLAGS hidden) list(APPEND LINK_LIB_LIST ${PROJECT_NAME}) list(APPEND LINK_LIB_LIST pthread) @@ -155,8 +147,9 @@ endif() # ${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION # ${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig) -add_subdirectory(test) -add_subdirectory(PcapSender) -add_subdirectory(PcapRawSender) -add_subdirectory(SecSetGen) - +if(BUILD_TOOLS) + add_subdirectory(test) + add_subdirectory(PcapSender) + add_subdirectory(PcapRawSender) + add_subdirectory(SecSetGen) +endif(BUILD_TOOLS) diff --git a/src/base/frame.h b/src/base/frame.h index c7aeed1..d034f63 100644 --- a/src/base/frame.h +++ b/src/base/frame.h @@ -41,11 +41,19 @@ public: void Wait() { _event.Wait(); } + // For Interface + size_t sei_end_offset() const { return _sei_end_offset; } + + size_t append_length() const { return _append_length; } + private: Frame(Type type, const void *data, size_t len); friend class RTPManager; private: + size_t _sei_end_offset{0}; + size_t _append_length{0}; + Event _event{true}; Type _type; std::vector _data; diff --git a/src/base/hk_sign.cpp b/src/base/hk_sign.cpp index 0019b8b..9488ad8 100644 --- a/src/base/hk_sign.cpp +++ b/src/base/hk_sign.cpp @@ -37,8 +37,8 @@ HK_udp_out(void *Handle, char *buf, uint32_t *len, uint16_t *sei_end_offset, uin *len = frame->size(); if (buf) { std::copy(frame->data(), frame->data() + frame->size(), buf); } - *sei_end_offset = 0; - *append_length = 0; + *sei_end_offset = frame->sei_end_offset(); + *append_length = frame->append_length(); return 1; }