151 lines
6.3 KiB
CMake
151 lines
6.3 KiB
CMake
set(RK_PLUGIN_OUTPUT_DIR ${CMAKE_BINARY_DIR}/plugins)
|
|
|
|
option(RK3588_ENABLE_FFMPEG "Enable FFmpeg-based RTSP input" OFF)
|
|
option(RK3588_ENABLE_MPP "Enable Rockchip MPP decode/encode" OFF)
|
|
option(RK3588_ENABLE_ZLMEDIAKIT "Enable embedded ZLMediaKit RTSP server" OFF)
|
|
option(RK3588_ENABLE_RGA "Enable Rockchip RGA hardware acceleration" OFF)
|
|
|
|
set(RK_RGA_ROOT "${RK_RKNN_ROOT}/examples/3rdparty/rga/RK3588" CACHE PATH "Path to RGA library")
|
|
set(RK_RGA_INCLUDE_DIR "${RK_RGA_ROOT}/include" CACHE PATH "RGA include directory")
|
|
set(RK_RGA_LIB_DIR "${RK_RGA_ROOT}/lib/Linux/aarch64" CACHE PATH "RGA library directory")
|
|
|
|
set(RK_ZLMEDIAKIT_ROOT "${RK_RKNN_ROOT}/examples/3rdparty/zlmediakit" CACHE PATH "Path to ZLMediaKit mk_api bundle")
|
|
set(RK_ZLMEDIAKIT_INCLUDE_DIR "${RK_ZLMEDIAKIT_ROOT}/include" CACHE PATH "ZLMediaKit mk_api include directory")
|
|
set(RK_ZLMEDIAKIT_LIB_DIR "${RK_ZLMEDIAKIT_ROOT}/aarch64" CACHE PATH "ZLMediaKit mk_api library directory")
|
|
set(RK_ZLMK_API_LIB_PATH "" CACHE FILEPATH "Absolute path to libmk_api.so")
|
|
|
|
if(RK3588_ENABLE_FFMPEG)
|
|
find_package(PkgConfig REQUIRED)
|
|
pkg_check_modules(FFMPEG REQUIRED IMPORTED_TARGET libavformat libavcodec libavutil)
|
|
endif()
|
|
|
|
if(RK3588_ENABLE_MPP)
|
|
# Prefer user-provided lib path; otherwise search common locations including rknpu2 prebuilts.
|
|
find_library(RK_MPP_LIB rockchip_mpp
|
|
HINTS
|
|
${RK_MPP_LIB_PATH}
|
|
${RK_MPP_ROOT}/build
|
|
${RK_MPP_ROOT}/lib
|
|
${RK_RKNN_ROOT}/examples/3rdparty/mpp/Linux/aarch64
|
|
${RK_RKNN_ROOT}/examples/3rdparty/mpp/Linux/armhf
|
|
NO_DEFAULT_PATH
|
|
)
|
|
if(NOT RK_MPP_LIB)
|
|
find_library(RK_MPP_LIB rockchip_mpp)
|
|
endif()
|
|
if(NOT RK_MPP_LIB)
|
|
message(WARNING "MPP enabled but rockchip_mpp library not found; disable RK3588_ENABLE_MPP or set RK_MPP_LIB_PATH")
|
|
endif()
|
|
endif()
|
|
|
|
if(RK3588_ENABLE_ZLMEDIAKIT)
|
|
if(RK_ZLMK_API_LIB_PATH)
|
|
set(RK_ZLMK_API_LIB "${RK_ZLMK_API_LIB_PATH}")
|
|
else()
|
|
find_library(RK_ZLMK_API_LIB mk_api
|
|
HINTS
|
|
${RK_ZLMEDIAKIT_LIB_DIR}
|
|
NO_DEFAULT_PATH
|
|
)
|
|
if(NOT RK_ZLMK_API_LIB)
|
|
find_library(RK_ZLMK_API_LIB mk_api)
|
|
endif()
|
|
endif()
|
|
|
|
if(NOT RK_ZLMK_API_LIB)
|
|
message(WARNING "ZLMediaKit enabled but mk_api library not found; set RK_ZLMK_API_LIB_PATH or RK_ZLMEDIAKIT_LIB_DIR")
|
|
endif()
|
|
endif()
|
|
|
|
if(RK3588_ENABLE_RGA)
|
|
find_library(RK_RGA_LIB rga
|
|
HINTS
|
|
${RK_RGA_LIB_DIR}
|
|
NO_DEFAULT_PATH
|
|
)
|
|
if(NOT RK_RGA_LIB)
|
|
find_library(RK_RGA_LIB rga)
|
|
endif()
|
|
if(NOT RK_RGA_LIB)
|
|
message(WARNING "RGA enabled but librga not found; disable RK3588_ENABLE_RGA or set RK_RGA_LIB_DIR")
|
|
endif()
|
|
endif()
|
|
|
|
add_library(input_rtsp SHARED input_rtsp/input_rtsp_node.cpp)
|
|
target_include_directories(input_rtsp PRIVATE ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/third_party)
|
|
target_link_libraries(input_rtsp PRIVATE project_options Threads::Threads)
|
|
if(RK3588_ENABLE_FFMPEG)
|
|
target_compile_definitions(input_rtsp PRIVATE RK3588_ENABLE_FFMPEG)
|
|
target_include_directories(input_rtsp PRIVATE ${FFMPEG_INCLUDE_DIRS})
|
|
target_link_libraries(input_rtsp PRIVATE PkgConfig::FFMPEG)
|
|
endif()
|
|
if(RK3588_ENABLE_MPP AND RK_MPP_LIB)
|
|
target_compile_definitions(input_rtsp PRIVATE RK3588_ENABLE_MPP)
|
|
target_include_directories(input_rtsp PRIVATE
|
|
${RK_MPP_ROOT}/inc
|
|
${RK_RKNN_ROOT}/examples/3rdparty/mpp/include
|
|
)
|
|
target_link_libraries(input_rtsp PRIVATE ${RK_MPP_LIB})
|
|
endif()
|
|
set_target_properties(input_rtsp PROPERTIES
|
|
OUTPUT_NAME "input_rtsp"
|
|
LIBRARY_OUTPUT_DIRECTORY ${RK_PLUGIN_OUTPUT_DIR}
|
|
RUNTIME_OUTPUT_DIRECTORY ${RK_PLUGIN_OUTPUT_DIR}
|
|
)
|
|
|
|
add_library(publish SHARED publish/publish_node.cpp)
|
|
target_include_directories(publish PRIVATE ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/third_party)
|
|
target_link_libraries(publish PRIVATE project_options Threads::Threads)
|
|
if(RK3588_ENABLE_FFMPEG)
|
|
target_compile_definitions(publish PRIVATE RK3588_ENABLE_FFMPEG)
|
|
target_include_directories(publish PRIVATE ${FFMPEG_INCLUDE_DIRS})
|
|
target_link_libraries(publish PRIVATE PkgConfig::FFMPEG)
|
|
endif()
|
|
if(RK3588_ENABLE_MPP AND RK_MPP_LIB)
|
|
target_compile_definitions(publish PRIVATE RK3588_ENABLE_MPP)
|
|
target_include_directories(publish PRIVATE
|
|
${RK_MPP_ROOT}/inc
|
|
${RK_RKNN_ROOT}/examples/3rdparty/mpp/include
|
|
)
|
|
target_link_libraries(publish PRIVATE ${RK_MPP_LIB})
|
|
endif()
|
|
if(RK3588_ENABLE_ZLMEDIAKIT AND RK_ZLMK_API_LIB)
|
|
target_compile_definitions(publish PRIVATE RK3588_ENABLE_ZLMEDIAKIT)
|
|
target_include_directories(publish PRIVATE ${RK_ZLMEDIAKIT_INCLUDE_DIR})
|
|
target_link_libraries(publish PRIVATE ${RK_ZLMK_API_LIB})
|
|
set_target_properties(publish PROPERTIES BUILD_RPATH "\$ORIGIN" INSTALL_RPATH "\$ORIGIN")
|
|
add_custom_command(TARGET publish POST_BUILD
|
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${RK_ZLMK_API_LIB}" $<TARGET_FILE_DIR:publish>
|
|
)
|
|
install(FILES "${RK_ZLMK_API_LIB}" DESTINATION ${CMAKE_INSTALL_LIBDIR}/rk3588-media-server/plugins)
|
|
endif()
|
|
set_target_properties(publish PROPERTIES
|
|
OUTPUT_NAME "publish"
|
|
LIBRARY_OUTPUT_DIRECTORY ${RK_PLUGIN_OUTPUT_DIR}
|
|
RUNTIME_OUTPUT_DIRECTORY ${RK_PLUGIN_OUTPUT_DIR}
|
|
)
|
|
|
|
add_library(preprocess SHARED preprocess/preprocess_node.cpp)
|
|
target_include_directories(preprocess PRIVATE ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/third_party)
|
|
target_link_libraries(preprocess PRIVATE project_options Threads::Threads)
|
|
if(RK3588_ENABLE_FFMPEG)
|
|
target_compile_definitions(preprocess PRIVATE RK3588_ENABLE_FFMPEG)
|
|
target_include_directories(preprocess PRIVATE ${FFMPEG_INCLUDE_DIRS})
|
|
target_link_libraries(preprocess PRIVATE PkgConfig::FFMPEG)
|
|
endif()
|
|
if(RK3588_ENABLE_RGA AND RK_RGA_LIB)
|
|
target_compile_definitions(preprocess PRIVATE RK3588_ENABLE_RGA)
|
|
target_include_directories(preprocess PRIVATE ${RK_RGA_INCLUDE_DIR})
|
|
target_link_libraries(preprocess PRIVATE ${RK_RGA_LIB})
|
|
endif()
|
|
set_target_properties(preprocess PROPERTIES
|
|
OUTPUT_NAME "preprocess"
|
|
LIBRARY_OUTPUT_DIRECTORY ${RK_PLUGIN_OUTPUT_DIR}
|
|
RUNTIME_OUTPUT_DIRECTORY ${RK_PLUGIN_OUTPUT_DIR}
|
|
)
|
|
|
|
install(TARGETS input_rtsp publish preprocess
|
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/rk3588-media-server/plugins
|
|
RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}/rk3588-media-server/plugins
|
|
)
|