From 03d0b6a9edd9602a69e1e78b4829979cb64e386b Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Sun, 17 Jan 2021 10:32:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=8B=89=E6=B5=81=E4=BB=A3?= =?UTF-8?q?=E7=90=86=E6=80=A7=E8=83=BD=E6=B5=8B=E8=AF=95=E5=B7=A5=E5=85=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/test_proxy.cpp | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 tests/test_proxy.cpp diff --git a/tests/test_proxy.cpp b/tests/test_proxy.cpp new file mode 100644 index 00000000..1994a2f0 --- /dev/null +++ b/tests/test_proxy.cpp @@ -0,0 +1,44 @@ +#include +#include +#include +#include "Util/logger.h" +#include "Network/TcpServer.h" +#include "Common/config.h" +#include "Player/PlayerProxy.h" +#include "Http/WebSocketSession.h" + +using namespace std; +using namespace toolkit; +using namespace mediakit; + +//此程序为zlm的拉流代理性能测试工具,用于测试拉流代理性能 +int main(int argc, char *argv[]) { + { + Logger::Instance().add(std::make_shared()); + Logger::Instance().setWriter(std::make_shared()); + + EventPollerPool::Instance().preferCurrentThread(false); + mINI::Instance()[General::kRtspDemand] = atoi(argv[3]); + mINI::Instance()[General::kRtmpDemand] = atoi(argv[3]); + mINI::Instance()[General::kHlsDemand] = 1; + mINI::Instance()[General::kTSDemand] = 1; + mINI::Instance()[General::kFMP4Demand] = 1; + + string url = argv[1]; + int count = atoi(argv[2]); + map proxyMap; + for (auto i = 0; i < count; ++i) { + auto stream = to_string(i); + PlayerProxy::Ptr player(new PlayerProxy(DEFAULT_VHOST, "live", stream, false, false)); + (*player)[kRtpType] = Rtsp::RTP_TCP; + player->play(url); + proxyMap.emplace(stream, player); + } + + static semaphore sem; + signal(SIGINT, [](int) { sem.post(); });// 设置退出信号 + sem.wait(); + } + return 0; +} +