mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 19:00:01 +08:00
适配最新代码
This commit is contained in:
parent
b7304808b3
commit
7c7e9a7ea4
@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.8)
|
|||||||
project(MediaKitWrapper)
|
project(MediaKitWrapper)
|
||||||
|
|
||||||
#加载自定义模块
|
#加载自定义模块
|
||||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake")
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
|
||||||
#设置库文件路径
|
#设置库文件路径
|
||||||
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
|
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
|
||||||
#设置可执行程序路径
|
#设置可执行程序路径
|
||||||
@ -65,30 +65,32 @@ if(FAAC_FOUND)
|
|||||||
list(APPEND LINK_LIB_LIST ${FAAC_LIBRARIES})
|
list(APPEND LINK_LIB_LIST ${FAAC_LIBRARIES})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
#查找ZLToolKit是否安装
|
|
||||||
find_package(ZLTOOLKIT QUIET)
|
|
||||||
if(ZLTOOLKIT_FOUND)
|
|
||||||
message(STATUS "找到ZLToolKit库:\"${ZLTOOLKIT_INCLUDE_DIR}\"")
|
|
||||||
include_directories(${ZLTOOLKIT_INCLUDE_DIR})
|
|
||||||
list(APPEND LINK_LIB_LIST ${ZLTOOLKIT_LIBRARIES})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
#查找ZLMediaKit是否安装
|
#设置工程源码根目录
|
||||||
find_package(ZLMEDIAKIT QUIET)
|
set(ToolKit_Root ${CMAKE_SOURCE_DIR}/../ZLToolKit/src)
|
||||||
if(ZLMEDIAKIT_FOUND)
|
set(MediaKit_Root ${CMAKE_SOURCE_DIR}/../src)
|
||||||
message(STATUS "找到ZLMediaKit库:\"${ZLMEDIAKIT_INCLUDE_DIR}\"")
|
|
||||||
include_directories(${ZLMEDIAKIT_INCLUDE_DIR})
|
|
||||||
list(APPEND LINK_LIB_LIST ${ZLMEDIAKIT_LIBRARIES})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
|
#设置头文件目录
|
||||||
|
INCLUDE_DIRECTORIES(${ToolKit_Root})
|
||||||
|
INCLUDE_DIRECTORIES(${MediaKit_Root})
|
||||||
|
|
||||||
#打印库文件
|
#收集源代码
|
||||||
message(STATUS "将链接依赖库:${LINK_LIB_LIST}")
|
file(GLOB ToolKit_src_list ${ToolKit_Root}/*/*.cpp ${ToolKit_Root}/*/*.h ${ToolKit_Root}/*/*.c)
|
||||||
#开启RTSP/RTMP之间的互相转换,开启HLS
|
file(GLOB MediaKit_src_list ${MediaKit_Root}/*/*.cpp ${MediaKit_Root}/*/*.h ${MediaKit_Root}/*/*.c)
|
||||||
add_definitions(-DENABLE_RTMP2RTSP -DENABLE_RTSP2RTMP -DENABLE_HLS -DHAVE_CONFIG_H)
|
|
||||||
|
#去除win32的适配代码
|
||||||
|
if (NOT WIN32)
|
||||||
|
list(REMOVE_ITEM ToolKit_src_list ${ToolKit_Root}/win32/getopt.c)
|
||||||
|
else()
|
||||||
|
#防止Windows.h包含Winsock.h
|
||||||
|
add_definitions(-DWIN32_LEAN_AND_MEAN -DMP4V2_NO_STDINT_DEFS)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
#使能GOP缓存
|
||||||
|
add_definitions(-DENABLE_RING_USEBUF)
|
||||||
|
|
||||||
#引用头文件路径
|
#引用头文件路径
|
||||||
include_directories(${PROJECT_SOURCE_DIR}/src)
|
include_directories(${CMAKE_SOURCE_DIR}/src)
|
||||||
|
|
||||||
#使能c++11
|
#使能c++11
|
||||||
set(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}")
|
set(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}")
|
||||||
@ -103,22 +105,18 @@ endif(NOT WIN32)
|
|||||||
#收集源文件
|
#收集源文件
|
||||||
file(GLOB SRC_LIST src/*.cpp src/*.h)
|
file(GLOB SRC_LIST src/*.cpp src/*.h)
|
||||||
|
|
||||||
#编译动态库
|
if (WIN32)
|
||||||
if(NOT IOS AND NOT ANDROID)
|
list(APPEND LINK_LIB_LIST WS2_32 Iphlpapi shlwapi)
|
||||||
add_library(${CMAKE_PROJECT_NAME}_shared SHARED ${SRC_LIST})
|
elseif(NOT ANDROID OR IOS)
|
||||||
set_target_properties(${CMAKE_PROJECT_NAME}_shared PROPERTIES OUTPUT_NAME "${CMAKE_PROJECT_NAME}")
|
list(APPEND LINK_LIB_LIST pthread)
|
||||||
install(TARGETS ${CMAKE_PROJECT_NAME}_shared ARCHIVE DESTINATION ${INSTALL_PATH_LIB} LIBRARY DESTINATION ${INSTALL_PATH_LIB})
|
endif ()
|
||||||
if(WIN32)
|
|
||||||
target_link_libraries(${CMAKE_PROJECT_NAME}_shared ${LINK_LIB_LIST} WS2_32 Iphlpapi shlwapi)
|
|
||||||
else(WIN32)
|
|
||||||
target_link_libraries(${CMAKE_PROJECT_NAME}_shared ${LINK_LIB_LIST})
|
|
||||||
endif(WIN32)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
#编译静态库
|
|
||||||
add_library(${CMAKE_PROJECT_NAME}_static STATIC ${SRC_LIST})
|
add_library(zltoolkit STATIC ${ToolKit_src_list})
|
||||||
set_target_properties(${CMAKE_PROJECT_NAME}_static PROPERTIES OUTPUT_NAME "${CMAKE_PROJECT_NAME}")
|
add_library(zlmediakit STATIC ${MediaKit_src_list})
|
||||||
install(TARGETS ${CMAKE_PROJECT_NAME}_static ARCHIVE DESTINATION ${INSTALL_PATH_LIB})
|
|
||||||
|
add_library(${CMAKE_PROJECT_NAME}_shared SHARED ${SRC_LIST})
|
||||||
|
target_link_libraries(${CMAKE_PROJECT_NAME}_shared zlmediakit zltoolkit ${LINK_LIB_LIST})
|
||||||
|
|
||||||
#测试程序
|
#测试程序
|
||||||
if(NOT IOS)
|
if(NOT IOS)
|
||||||
|
@ -53,7 +53,7 @@ static TcpServer::Ptr s_pHttpSrv;
|
|||||||
API_EXPORT void API_CALL onAppStart(){
|
API_EXPORT void API_CALL onAppStart(){
|
||||||
static onceToken s_token([](){
|
static onceToken s_token([](){
|
||||||
Logger::Instance().add(std::make_shared<ConsoleChannel>("stdout", LTrace));
|
Logger::Instance().add(std::make_shared<ConsoleChannel>("stdout", LTrace));
|
||||||
EventPoller::Instance(true);
|
EventPoller::Instance().runLoop(false);
|
||||||
|
|
||||||
cleaner::Instance().push_back([](){
|
cleaner::Instance().push_back([](){
|
||||||
s_pRtspSrv.reset();
|
s_pRtspSrv.reset();
|
||||||
|
Loading…
Reference in New Issue
Block a user