适配最新代码

This commit is contained in:
xiongziliang 2018-07-03 17:30:58 +08:00
parent b7304808b3
commit 7c7e9a7ea4
2 changed files with 34 additions and 36 deletions

View File

@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.8)
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)
#
@ -65,30 +65,32 @@ if(FAAC_FOUND)
list(APPEND LINK_LIB_LIST ${FAAC_LIBRARIES})
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})
#
set(ToolKit_Root ${CMAKE_SOURCE_DIR}/../ZLToolKit/src)
set(MediaKit_Root ${CMAKE_SOURCE_DIR}/../src)
#
INCLUDE_DIRECTORIES(${ToolKit_Root})
INCLUDE_DIRECTORIES(${MediaKit_Root})
#
file(GLOB ToolKit_src_list ${ToolKit_Root}/*/*.cpp ${ToolKit_Root}/*/*.h ${ToolKit_Root}/*/*.c)
file(GLOB MediaKit_src_list ${MediaKit_Root}/*/*.cpp ${MediaKit_Root}/*/*.h ${MediaKit_Root}/*/*.c)
#win32
if (NOT WIN32)
list(REMOVE_ITEM ToolKit_src_list ${ToolKit_Root}/win32/getopt.c)
else()
#Windows.hWinsock.h
add_definitions(-DWIN32_LEAN_AND_MEAN -DMP4V2_NO_STDINT_DEFS)
endif ()
#ZLMediaKit
find_package(ZLMEDIAKIT QUIET)
if(ZLMEDIAKIT_FOUND)
message(STATUS "找到ZLMediaKit库:\"${ZLMEDIAKIT_INCLUDE_DIR}\"")
include_directories(${ZLMEDIAKIT_INCLUDE_DIR})
list(APPEND LINK_LIB_LIST ${ZLMEDIAKIT_LIBRARIES})
endif()
#
message(STATUS "将链接依赖库:${LINK_LIB_LIST}")
#RTSP/RTMP,HLS
add_definitions(-DENABLE_RTMP2RTSP -DENABLE_RTSP2RTMP -DENABLE_HLS -DHAVE_CONFIG_H)
#使GOP
add_definitions(-DENABLE_RING_USEBUF)
#
include_directories(${PROJECT_SOURCE_DIR}/src)
include_directories(${CMAKE_SOURCE_DIR}/src)
#使c++11
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)
#
if(NOT IOS AND NOT ANDROID)
add_library(${CMAKE_PROJECT_NAME}_shared SHARED ${SRC_LIST})
set_target_properties(${CMAKE_PROJECT_NAME}_shared PROPERTIES OUTPUT_NAME "${CMAKE_PROJECT_NAME}")
install(TARGETS ${CMAKE_PROJECT_NAME}_shared ARCHIVE DESTINATION ${INSTALL_PATH_LIB} LIBRARY DESTINATION ${INSTALL_PATH_LIB})
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)
list(APPEND LINK_LIB_LIST WS2_32 Iphlpapi shlwapi)
elseif(NOT ANDROID OR IOS)
list(APPEND LINK_LIB_LIST pthread)
endif ()
#
add_library(${CMAKE_PROJECT_NAME}_static STATIC ${SRC_LIST})
set_target_properties(${CMAKE_PROJECT_NAME}_static PROPERTIES OUTPUT_NAME "${CMAKE_PROJECT_NAME}")
install(TARGETS ${CMAKE_PROJECT_NAME}_static ARCHIVE DESTINATION ${INSTALL_PATH_LIB})
add_library(zltoolkit STATIC ${ToolKit_src_list})
add_library(zlmediakit STATIC ${MediaKit_src_list})
add_library(${CMAKE_PROJECT_NAME}_shared SHARED ${SRC_LIST})
target_link_libraries(${CMAKE_PROJECT_NAME}_shared zlmediakit zltoolkit ${LINK_LIB_LIST})
#
if(NOT IOS)

View File

@ -53,7 +53,7 @@ static TcpServer::Ptr s_pHttpSrv;
API_EXPORT void API_CALL onAppStart(){
static onceToken s_token([](){
Logger::Instance().add(std::make_shared<ConsoleChannel>("stdout", LTrace));
EventPoller::Instance(true);
EventPoller::Instance().runLoop(false);
cleaner::Instance().push_back([](){
s_pRtspSrv.reset();