mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-26 04:31:37 +08:00
update
This commit is contained in:
parent
15f03476c3
commit
fe4da29fb1
@ -43,57 +43,58 @@ using namespace ZL::Thread;
|
|||||||
using namespace ZL::Network;
|
using namespace ZL::Network;
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char *argv[]){
|
int main(int argc, char *argv[]) {
|
||||||
//设置退出信号处理函数
|
//设置退出信号处理函数
|
||||||
signal(SIGINT, [](int){EventPoller::Instance().shutdown();});
|
signal(SIGINT, [](int) { EventPoller::Instance().shutdown(); });
|
||||||
//设置日志
|
//设置日志
|
||||||
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>());
|
Logger::Instance().setWriter(std::make_shared<AsyncLogWriter>());
|
||||||
|
|
||||||
if(argc != 5){
|
if (argc != 5) {
|
||||||
FatalL << "\r\n测试方法:./test_benchmark player_count play_interval rtxp_url rtp_type\r\n"
|
FatalL << "\r\n测试方法:./test_benchmark player_count play_interval rtxp_url rtp_type\r\n"
|
||||||
<< "例如你想每隔50毫秒启动共计100个播放器(tcp方式播放rtsp://127.0.0.1/live/0 )可以输入以下命令:\r\n"
|
<< "例如你想每隔50毫秒启动共计100个播放器(tcp方式播放rtsp://127.0.0.1/live/0 )可以输入以下命令:\r\n"
|
||||||
<< "./test_benchmark 100 50 rtsp://127.0.0.1/live/0 0\r\n"
|
<< "./test_benchmark 100 50 rtsp://127.0.0.1/live/0 0\r\n"
|
||||||
<<endl;
|
<< endl;
|
||||||
Logger::Destory();
|
Logger::Destory();
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
list<MediaPlayer::Ptr> playerList;
|
||||||
|
auto playerCnt = atoi(argv[1]);//启动的播放器个数
|
||||||
|
atomic_int alivePlayerCnt(0);
|
||||||
|
//每隔若干毫秒启动一个播放器(如果一次性全部启动,服务器和客户端可能都承受不了)
|
||||||
|
AsyncTaskThread::Instance().DoTaskDelay(0, atoi(argv[2]), [&]() {
|
||||||
|
MediaPlayer::Ptr player(new MediaPlayer());
|
||||||
|
player->setOnPlayResult([&](const SockException &ex) {
|
||||||
|
if (!ex) {
|
||||||
|
++alivePlayerCnt;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
player->setOnShutdown([&](const SockException &ex) {
|
||||||
|
--alivePlayerCnt;
|
||||||
|
});
|
||||||
|
(*player)[RtspPlayer::kRtpType] = atoi(argv[4]);
|
||||||
|
player->play(argv[3]);
|
||||||
|
playerList.push_back(player);
|
||||||
|
return playerCnt--;
|
||||||
|
});
|
||||||
|
|
||||||
list<MediaPlayer::Ptr> playerList;
|
AsyncTaskThread::Instance().DoTaskDelay(0, 1000, [&]() {
|
||||||
auto playerCnt = atoi(argv[1]);//启动的播放器个数
|
InfoL << "存活播放器个数:" << alivePlayerCnt.load();
|
||||||
atomic_int alivePlayerCnt(0);
|
return true;
|
||||||
//每隔若干毫秒启动一个播放器(如果一次性全部启动,服务器和客户端可能都承受不了)
|
});
|
||||||
AsyncTaskThread::Instance().DoTaskDelay(0, atoi(argv[2]), [&](){
|
EventPoller::Instance().runLoop();
|
||||||
MediaPlayer::Ptr player(new MediaPlayer());
|
AsyncTaskThread::Instance().CancelTask(0);
|
||||||
player->setOnPlayResult([&](const SockException &ex){
|
}
|
||||||
if(!ex){
|
|
||||||
++alivePlayerCnt;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
player->setOnShutdown([&](const SockException &ex){
|
|
||||||
--alivePlayerCnt;
|
|
||||||
});
|
|
||||||
(*player)[RtspPlayer::kRtpType] = atoi(argv[4]);
|
|
||||||
player->play(argv[3]);
|
|
||||||
playerList.push_back(player);
|
|
||||||
return playerCnt--;
|
|
||||||
});
|
|
||||||
|
|
||||||
AsyncTaskThread::Instance().DoTaskDelay(0, 1000, [&](){
|
static onceToken token(nullptr, []() {
|
||||||
InfoL << "存活播放器个数:" << alivePlayerCnt.load();
|
WorkThreadPool::Instance();
|
||||||
return true;
|
UDPServer::Destory();
|
||||||
});
|
EventPoller::Destory();
|
||||||
EventPoller::Instance().runLoop();
|
|
||||||
playerList.clear();
|
|
||||||
|
|
||||||
static onceToken token(nullptr, []() {
|
|
||||||
WorkThreadPool::Instance();
|
|
||||||
UDPServer::Destory();
|
|
||||||
AsyncTaskThread::Destory();
|
AsyncTaskThread::Destory();
|
||||||
EventPoller::Destory();
|
Logger::Destory();
|
||||||
Logger::Destory();
|
});
|
||||||
});
|
return 0;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,6 +150,7 @@ int main(int argc,char *argv[]){
|
|||||||
requesterPost.reset();
|
requesterPost.reset();
|
||||||
//程序开始退出
|
//程序开始退出
|
||||||
EventPoller::Destory();
|
EventPoller::Destory();
|
||||||
|
AsyncTaskThread::Destory();
|
||||||
Logger::Destory();
|
Logger::Destory();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -89,8 +89,8 @@ int main(int argc, char *argv[]){
|
|||||||
|
|
||||||
static onceToken token(nullptr, []() {
|
static onceToken token(nullptr, []() {
|
||||||
UDPServer::Destory();
|
UDPServer::Destory();
|
||||||
AsyncTaskThread::Destory();
|
|
||||||
EventPoller::Destory();
|
EventPoller::Destory();
|
||||||
|
AsyncTaskThread::Destory();
|
||||||
Logger::Destory();
|
Logger::Destory();
|
||||||
});
|
});
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -114,6 +114,7 @@ int domain(int argc, const char *argv[]) {
|
|||||||
|
|
||||||
//清理程序
|
//清理程序
|
||||||
EventPoller::Destory();
|
EventPoller::Destory();
|
||||||
|
AsyncTaskThread::Destory();
|
||||||
Logger::Destory();
|
Logger::Destory();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -121,6 +121,7 @@ int domain(int argc,const char *argv[]){
|
|||||||
|
|
||||||
//程序清理
|
//程序清理
|
||||||
EventPoller::Destory();
|
EventPoller::Destory();
|
||||||
|
AsyncTaskThread::Destory();
|
||||||
Logger::Destory();
|
Logger::Destory();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -250,9 +250,9 @@ int main(int argc,char *argv[]) {
|
|||||||
UDPServer::Destory();
|
UDPServer::Destory();
|
||||||
//TcpServer用到了WorkThreadPool
|
//TcpServer用到了WorkThreadPool
|
||||||
WorkThreadPool::Destory();
|
WorkThreadPool::Destory();
|
||||||
AsyncTaskThread::Destory();
|
|
||||||
EventPoller::Destory();
|
EventPoller::Destory();
|
||||||
Logger::Destory();
|
AsyncTaskThread::Destory();
|
||||||
|
Logger::Destory();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user