mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 19:00:01 +08:00
添加c api测试范例
This commit is contained in:
parent
2da0c884a1
commit
6796d0b592
@ -7,5 +7,7 @@ if(WIN32)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_link_libraries(api ${LINK_LIB_LIST})
|
target_link_libraries(api ${LINK_LIB_LIST})
|
||||||
|
add_subdirectory(tests)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ static TcpServer::Ptr http_server[2];
|
|||||||
#include "Rtp/UdpRecver.h"
|
#include "Rtp/UdpRecver.h"
|
||||||
#include "Rtp/RtpSession.h"
|
#include "Rtp/RtpSession.h"
|
||||||
static std::shared_ptr<UdpRecver> udpRtpServer;
|
static std::shared_ptr<UdpRecver> udpRtpServer;
|
||||||
static TcpServer::Ptr tcpRtpServer(new TcpServer());
|
static TcpServer::Ptr tcpRtpServer;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//////////////////////////environment init///////////////////////////
|
//////////////////////////environment init///////////////////////////
|
||||||
|
25
api/tests/CMakeLists.txt
Normal file
25
api/tests/CMakeLists.txt
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
aux_source_directory(. TEST_SRC_LIST)
|
||||||
|
foreach(TEST_SRC ${TEST_SRC_LIST})
|
||||||
|
STRING(REGEX REPLACE "^\\./|\\.c[a-zA-Z0-9_]*$" "" TEST_EXE_NAME ${TEST_SRC})
|
||||||
|
message(STATUS "add c api tester:${TEST_EXE_NAME}")
|
||||||
|
set(exe_name api_tester_${TEST_EXE_NAME})
|
||||||
|
add_executable(${exe_name} ${TEST_SRC})
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
set_target_properties(${exe_name} PROPERTIES COMPILE_FLAGS ${VS_FALGS} )
|
||||||
|
endif(WIN32)
|
||||||
|
|
||||||
|
target_link_libraries(${exe_name} api)
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
21
api/tests/server.cpp
Normal file
21
api/tests/server.cpp
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
//
|
||||||
|
// Created by xzl on 2019/12/23.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <csignal>
|
||||||
|
#include "mediakit.h"
|
||||||
|
#include "unistd.h"
|
||||||
|
int main(int argc,char *argv[]){
|
||||||
|
mk_env_init1(0,0,0, nullptr,0, nullptr, nullptr);
|
||||||
|
mk_http_server_start(80,false);
|
||||||
|
mk_rtsp_server_start(554,false);
|
||||||
|
mk_rtmp_server_start(1935,false);
|
||||||
|
mk_rtp_server_start(10000);
|
||||||
|
|
||||||
|
static bool flag = true;
|
||||||
|
signal(SIGINT, [](int) { flag = false; });// 设置退出信号
|
||||||
|
|
||||||
|
while (flag){
|
||||||
|
sleep(1);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user