mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 19:00:01 +08:00
add test for multi server
This commit is contained in:
parent
777bd95358
commit
74d3a75bbb
@ -2,7 +2,7 @@ project(ZLMediaKit)
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
#加载自定义模块
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}")
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake")
|
||||
#设置库文件路径
|
||||
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
|
||||
#设置可执行程序路径
|
||||
@ -83,14 +83,14 @@ add_compile_options(-Wno-deprecated-declarations)
|
||||
#关闭__FUNCTION__宏在函数外警告
|
||||
add_compile_options(-Wno-predefined-identifier-outside-function)
|
||||
|
||||
#编译静态库
|
||||
#编译动态库
|
||||
if(NOT IOS)
|
||||
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 LIBRARY DESTINATION lib)
|
||||
endif(NOT IOS)
|
||||
|
||||
#编译动态库
|
||||
#编译静态库
|
||||
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 lib)
|
||||
@ -100,7 +100,7 @@ install(DIRECTORY ${PROJECT_BINARY_DIR}/include/${CMAKE_PROJECT_NAME} DESTINATIO
|
||||
|
||||
#测试程序
|
||||
if(NOT IOS)
|
||||
#add_subdirectory(tests)
|
||||
add_subdirectory(tests)
|
||||
endif(NOT IOS)
|
||||
|
||||
|
||||
|
39
tests/CMakeLists.txt
Normal file
39
tests/CMakeLists.txt
Normal file
@ -0,0 +1,39 @@
|
||||
aux_source_directory(. TEST_SRC_LIST)
|
||||
foreach(TEST_SRC ${TEST_SRC_LIST})
|
||||
STRING(REGEX REPLACE ".cpp" "" TEST_EXE_NAME ${TEST_SRC})
|
||||
STRING(REGEX REPLACE "./" "" TEST_EXE_NAME ${TEST_EXE_NAME})
|
||||
message(STATUS "add test program:${TEST_EXE_NAME}")
|
||||
add_executable(${TEST_EXE_NAME} ${TEST_SRC})
|
||||
target_link_libraries(${TEST_EXE_NAME} ${CMAKE_PROJECT_NAME}_shared pthread)
|
||||
|
||||
#查找mp4v2是否安装
|
||||
if(MP4V2_FOUND)
|
||||
target_link_libraries(${TEST_EXE_NAME} mp4v2)
|
||||
endif(MP4V2_FOUND)
|
||||
|
||||
#查找x264是否安装
|
||||
if(X264_FOUND)
|
||||
target_link_libraries(${TEST_EXE_NAME} x264)
|
||||
endif(X264_FOUND)
|
||||
|
||||
#查找faac是否安装
|
||||
if(FAAC_FOUND)
|
||||
target_link_libraries(${TEST_EXE_NAME} faac)
|
||||
endif(FAAC_FOUND)
|
||||
|
||||
#查找ZLToolKit是否安装
|
||||
if(ZLTOOLKIT_FOUND)
|
||||
target_link_libraries(${TEST_EXE_NAME} ZLToolKit)
|
||||
endif(ZLTOOLKIT_FOUND)
|
||||
|
||||
#查找openssl是否安装
|
||||
if(OPENSSL_FOUND)
|
||||
target_link_libraries(${TEST_EXE_NAME} ssl)
|
||||
endif(OPENSSL_FOUND)
|
||||
|
||||
#查找mysql是否安装
|
||||
if(MYSQL_FOUND)
|
||||
target_link_libraries(${TEST_EXE_NAME} mysqlclient)
|
||||
endif(MYSQL_FOUND)
|
||||
|
||||
endforeach(TEST_SRC ${TEST_SRC_LIST})
|
@ -17,13 +17,12 @@
|
||||
#include "Util/SqlPool.h"
|
||||
#include "Util/logger.h"
|
||||
#include "Util/onceToken.h"
|
||||
#include "Util/File.h"
|
||||
#include "Network/TcpServer.h"
|
||||
#include "Poller/EventPoller.h"
|
||||
#include "Thread/WorkThreadPool.h"
|
||||
#ifdef ENABLE_HKDEVICE
|
||||
#include "DeviceHK.h"
|
||||
#endif //ENABLE_HKDEVICE
|
||||
|
||||
#include "Device/PlayerProxy.h"
|
||||
#include <map>
|
||||
using namespace std;
|
||||
using namespace ZL::Util;
|
||||
using namespace ZL::Http;
|
||||
@ -31,26 +30,33 @@ using namespace ZL::Rtsp;
|
||||
using namespace ZL::Rtmp;
|
||||
using namespace ZL::Thread;
|
||||
using namespace ZL::Network;
|
||||
using namespace ZL::DEV;
|
||||
|
||||
void programExit(int arg) {
|
||||
EventPoller::Instance().shutdown();
|
||||
}
|
||||
int main(int argc,char *argv[]){
|
||||
signal(SIGINT, programExit);
|
||||
|
||||
Logger::Instance().add(std::make_shared<ConsoleChannel>("stdout", LTrace));
|
||||
Logger::Instance().setWriter(std::make_shared<AsyncLogWriter>());
|
||||
|
||||
#ifdef ENABLE_HKDEVICE
|
||||
DeviceHK::Ptr dev(new DeviceHK());
|
||||
dev->connectDevice( connectInfo("192.168.0.211", 8000, "admin", "password"), [dev](bool success,const connectResult &result) {
|
||||
if(success) {
|
||||
dev->addAllChannel();
|
||||
//support rtmp and rtsp url
|
||||
//just support H264+AAC
|
||||
auto urlList = {"rtmp://live.hkstv.hk.lxdns.com/live/hks",
|
||||
"rtsp://184.72.239.149/vod/mp4://BigBuckBunny_175k.mov"};
|
||||
map<string , PlayerProxy::Ptr> proxyMap;
|
||||
int i=0;
|
||||
for(auto url : urlList){
|
||||
PlayerProxy::Ptr player(new PlayerProxy("live",std::to_string(i++).data()));
|
||||
player->play(url);
|
||||
proxyMap.emplace(string(url),player);
|
||||
}
|
||||
//请把证书"test_server.pem"放置在本程序可执行程序同目录下
|
||||
try{
|
||||
SSL_Initor::Instance().loadServerPem((exePath() + ".pem").data());
|
||||
}catch(...){
|
||||
FatalL << "请把证书:" << (exeName() + ".pem") << "放置在本程序可执行程序同目录下:" << exeDir() << endl;
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
#endif //ENABLE_HKDEVICE
|
||||
|
||||
SSL_Initor::Instance().loadServerPem((exeDir() + ".HttpServer.pem").data());
|
||||
|
||||
TcpServer<RtspSession>::Ptr rtspSrv(new TcpServer<RtspSession>());
|
||||
TcpServer<RtmpSession>::Ptr rtmpSrv(new TcpServer<RtmpSession>());
|
||||
@ -67,12 +73,11 @@ int main(int argc,char *argv[]){
|
||||
rtmpSrv.reset();
|
||||
httpSrv.reset();
|
||||
httpsSrv.reset();
|
||||
static onceToken token(nullptr, []() {
|
||||
|
||||
UDPServer::Destory();
|
||||
WorkThreadPool::Destory();
|
||||
EventPoller::Destory();
|
||||
Logger::Destory();
|
||||
});
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
30
tests/test_server.pem
Normal file
30
tests/test_server.pem
Normal file
@ -0,0 +1,30 @@
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIICXAIBAAKBgQDe56xOopefsL3K+kfpDohkBnjZaTCLVdS+p6BUeRbeFO9xOaGy
|
||||
5hPnVLHI1nlpRZaKfxm1MY9fDBh1kSbjhSqim9HUBoSvEE32yMM+0GIoNKKDWmhd
|
||||
ePDXuSNO6d9nabg+5gmrR2fyYtSigTH6liqGSjhblAozlaXVZVYZOs/ePwIDAQAB
|
||||
AoGAYcjkMALn3SgduoOdNEIp1yd3sHiS0S0wDQtgLG6Kd5ZbjCIqK17/cEYZT++2
|
||||
h1X9ungTgQdiy+F0gW7RzpHGp4lso2a8PgEUIt4HICLZqBOWv6kId43kysBZQS/5
|
||||
5g0ZGJGU5BFTdHzN5chaPE32MRGPpukNngRuRruRvoQaOuECQQD0EoC6EHwLehFI
|
||||
KoLnDtzXpR1f4eRRbxJ6U/05Kr4+nz+MB7A2ilGEf+E7iCvoRGYkuieEuKYS9+NQ
|
||||
Bv67i/aZAkEA6cxan6Q5BsSCoIKGbqATxW40j7m0Ii3VFb4w9vgaI0mHdRl9x59x
|
||||
LKsIamcJZI7szmJdOi3tBKB9Xc3PxfD6lwJBAIYOU53eyAMVvMBCeTunsizPh97O
|
||||
F7WSqDeAQilQDMYgearT3jlWp4d7JZ6pIFSmnOO3S1VehfkNJlEiRm+EZKECQCEb
|
||||
+IV9GzpTH/CdK26FKueduMHV2aWxeeivW33OGt1+bzltF7vqX3uk6Pcwikr8VprP
|
||||
oUY49MTf+YEMQW1VuBcCQA3UvxGx7YbD3RihysBmTLHyF2DOR3pBQdL1jH5fFI9k
|
||||
mMo0M2cvHytsIYZ69oULJkQ0TyNBslm/TLaHAK6fHbo=
|
||||
-----END RSA PRIVATE KEY-----
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIICWDCCAcGgAwIBAgIJANTNO5CfgnKmMA0GCSqGSIb3DQEBCwUAMEUxCzAJBgNV
|
||||
BAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBX
|
||||
aWRnaXRzIFB0eSBMdGQwHhcNMTYwMTExMDgyNTIxWhcNMTkwMTEwMDgyNTIxWjBF
|
||||
MQswCQYDVQQGEwJBVTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50
|
||||
ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKB
|
||||
gQDe56xOopefsL3K+kfpDohkBnjZaTCLVdS+p6BUeRbeFO9xOaGy5hPnVLHI1nlp
|
||||
RZaKfxm1MY9fDBh1kSbjhSqim9HUBoSvEE32yMM+0GIoNKKDWmhdePDXuSNO6d9n
|
||||
abg+5gmrR2fyYtSigTH6liqGSjhblAozlaXVZVYZOs/ePwIDAQABo1AwTjAdBgNV
|
||||
HQ4EFgQUKOfhSgRHIkKMX7cwlVIBR493EXQwHwYDVR0jBBgwFoAUKOfhSgRHIkKM
|
||||
X7cwlVIBR493EXQwDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQsFAAOBgQCxs7Ge
|
||||
0mjdtHhFd7qerYVYS0uvVzRdYsYnK+rY6Y5wtXEWDNG2EOLA5/puaj93mvesKXTl
|
||||
plTjFUnhmyXwwvXuKx+PdK87FXl4sTIyvf4/1eN2QIpy6WU4lAE11ONNF8djNc4W
|
||||
FCu9etyoYfy6NE4C/ntJpB0xCNrX1cvrmukb6g==
|
||||
-----END CERTIFICATE-----
|
Loading…
Reference in New Issue
Block a user