mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-26 04:31:37 +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)
|
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)
|
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
|
||||||
#设置可执行程序路径
|
#设置可执行程序路径
|
||||||
@ -83,14 +83,14 @@ add_compile_options(-Wno-deprecated-declarations)
|
|||||||
#关闭__FUNCTION__宏在函数外警告
|
#关闭__FUNCTION__宏在函数外警告
|
||||||
add_compile_options(-Wno-predefined-identifier-outside-function)
|
add_compile_options(-Wno-predefined-identifier-outside-function)
|
||||||
|
|
||||||
#编译静态库
|
#编译动态库
|
||||||
if(NOT IOS)
|
if(NOT IOS)
|
||||||
add_library(${CMAKE_PROJECT_NAME}_shared SHARED ${SRC_LIST})
|
add_library(${CMAKE_PROJECT_NAME}_shared SHARED ${SRC_LIST})
|
||||||
set_target_properties(${CMAKE_PROJECT_NAME}_shared PROPERTIES OUTPUT_NAME "${CMAKE_PROJECT_NAME}")
|
set_target_properties(${CMAKE_PROJECT_NAME}_shared PROPERTIES OUTPUT_NAME "${CMAKE_PROJECT_NAME}")
|
||||||
install(TARGETS ${CMAKE_PROJECT_NAME}_shared LIBRARY DESTINATION lib)
|
install(TARGETS ${CMAKE_PROJECT_NAME}_shared LIBRARY DESTINATION lib)
|
||||||
endif(NOT IOS)
|
endif(NOT IOS)
|
||||||
|
|
||||||
#编译动态库
|
#编译静态库
|
||||||
add_library(${CMAKE_PROJECT_NAME}_static STATIC ${SRC_LIST})
|
add_library(${CMAKE_PROJECT_NAME}_static STATIC ${SRC_LIST})
|
||||||
set_target_properties(${CMAKE_PROJECT_NAME}_static PROPERTIES OUTPUT_NAME "${CMAKE_PROJECT_NAME}")
|
set_target_properties(${CMAKE_PROJECT_NAME}_static PROPERTIES OUTPUT_NAME "${CMAKE_PROJECT_NAME}")
|
||||||
install(TARGETS ${CMAKE_PROJECT_NAME}_static ARCHIVE DESTINATION lib)
|
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)
|
if(NOT IOS)
|
||||||
#add_subdirectory(tests)
|
add_subdirectory(tests)
|
||||||
endif(NOT IOS)
|
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/SqlPool.h"
|
||||||
#include "Util/logger.h"
|
#include "Util/logger.h"
|
||||||
#include "Util/onceToken.h"
|
#include "Util/onceToken.h"
|
||||||
|
#include "Util/File.h"
|
||||||
#include "Network/TcpServer.h"
|
#include "Network/TcpServer.h"
|
||||||
#include "Poller/EventPoller.h"
|
#include "Poller/EventPoller.h"
|
||||||
#include "Thread/WorkThreadPool.h"
|
#include "Thread/WorkThreadPool.h"
|
||||||
#ifdef ENABLE_HKDEVICE
|
#include "Device/PlayerProxy.h"
|
||||||
#include "DeviceHK.h"
|
#include <map>
|
||||||
#endif //ENABLE_HKDEVICE
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace ZL::Util;
|
using namespace ZL::Util;
|
||||||
using namespace ZL::Http;
|
using namespace ZL::Http;
|
||||||
@ -31,26 +30,33 @@ using namespace ZL::Rtsp;
|
|||||||
using namespace ZL::Rtmp;
|
using namespace ZL::Rtmp;
|
||||||
using namespace ZL::Thread;
|
using namespace ZL::Thread;
|
||||||
using namespace ZL::Network;
|
using namespace ZL::Network;
|
||||||
|
using namespace ZL::DEV;
|
||||||
|
|
||||||
void programExit(int arg) {
|
void programExit(int arg) {
|
||||||
EventPoller::Instance().shutdown();
|
EventPoller::Instance().shutdown();
|
||||||
}
|
}
|
||||||
int main(int argc,char *argv[]){
|
int main(int argc,char *argv[]){
|
||||||
signal(SIGINT, programExit);
|
signal(SIGINT, programExit);
|
||||||
|
|
||||||
Logger::Instance().add(std::make_shared<ConsoleChannel>("stdout", LTrace));
|
Logger::Instance().add(std::make_shared<ConsoleChannel>("stdout", LTrace));
|
||||||
Logger::Instance().setWriter(std::make_shared<AsyncLogWriter>());
|
|
||||||
|
|
||||||
#ifdef ENABLE_HKDEVICE
|
//support rtmp and rtsp url
|
||||||
DeviceHK::Ptr dev(new DeviceHK());
|
//just support H264+AAC
|
||||||
dev->connectDevice( connectInfo("192.168.0.211", 8000, "admin", "password"), [dev](bool success,const connectResult &result) {
|
auto urlList = {"rtmp://live.hkstv.hk.lxdns.com/live/hks",
|
||||||
if(success) {
|
"rtsp://184.72.239.149/vod/mp4://BigBuckBunny_175k.mov"};
|
||||||
dev->addAllChannel();
|
map<string , PlayerProxy::Ptr> proxyMap;
|
||||||
}
|
int i=0;
|
||||||
});
|
for(auto url : urlList){
|
||||||
#endif //ENABLE_HKDEVICE
|
PlayerProxy::Ptr player(new PlayerProxy("live",std::to_string(i++).data()));
|
||||||
|
player->play(url);
|
||||||
SSL_Initor::Instance().loadServerPem((exeDir() + ".HttpServer.pem").data());
|
proxyMap.emplace(string(url),player);
|
||||||
|
}
|
||||||
|
//请把证书"test_server.pem"放置在本程序可执行程序同目录下
|
||||||
|
try{
|
||||||
|
SSL_Initor::Instance().loadServerPem((exePath() + ".pem").data());
|
||||||
|
}catch(...){
|
||||||
|
FatalL << "请把证书:" << (exeName() + ".pem") << "放置在本程序可执行程序同目录下:" << exeDir() << endl;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
TcpServer<RtspSession>::Ptr rtspSrv(new TcpServer<RtspSession>());
|
TcpServer<RtspSession>::Ptr rtspSrv(new TcpServer<RtspSession>());
|
||||||
TcpServer<RtmpSession>::Ptr rtmpSrv(new TcpServer<RtmpSession>());
|
TcpServer<RtmpSession>::Ptr rtmpSrv(new TcpServer<RtmpSession>());
|
||||||
@ -67,12 +73,11 @@ int main(int argc,char *argv[]){
|
|||||||
rtmpSrv.reset();
|
rtmpSrv.reset();
|
||||||
httpSrv.reset();
|
httpSrv.reset();
|
||||||
httpsSrv.reset();
|
httpsSrv.reset();
|
||||||
static onceToken token(nullptr, []() {
|
|
||||||
UDPServer::Destory();
|
UDPServer::Destory();
|
||||||
WorkThreadPool::Destory();
|
WorkThreadPool::Destory();
|
||||||
EventPoller::Destory();
|
EventPoller::Destory();
|
||||||
Logger::Destory();
|
Logger::Destory();
|
||||||
});
|
|
||||||
return 0;
|
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