From d85e19fb744561daf345fcb9f05a65b22d375c21 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Thu, 30 May 2019 16:45:11 +0800 Subject: [PATCH] =?UTF-8?q?=E9=98=B2=E6=AD=A2=E6=8B=89=E6=B5=81=E4=B8=AD?= =?UTF-8?q?=E9=80=94=E9=87=8D=E5=A4=8D=E6=8B=89=E6=B5=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/WebApi.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/server/WebApi.cpp b/server/WebApi.cpp index c12aa89b..c026f609 100644 --- a/server/WebApi.cpp +++ b/server/WebApi.cpp @@ -414,15 +414,23 @@ void installWebApi() { int rtp_type, const function &cb){ auto key = getProxyKey(vhost,app,stream); + lock_guard lck(s_proxyMapMtx); + if(s_proxyMap.find(key) != s_proxyMap.end()){ + //已经在拉流了 + cb(SockException(Err_success),key); + return; + } //添加拉流代理 PlayerProxy::Ptr player(new PlayerProxy(vhost,app,stream,enable_hls,enable_mp4)); + s_proxyMap[key] = player; + //指定RTP over TCP(播放rtsp时有效) (*player)[kRtpType] = rtp_type; //开始播放,如果播放失败或者播放中止,将会自动重试若干次,默认一直重试 player->setPlayCallbackOnce([cb,player,key](const SockException &ex){ - if(!ex){ + if(ex){ lock_guard lck(s_proxyMapMtx); - s_proxyMap[key] = player; + s_proxyMap.erase(key); } const_cast(player).reset(); cb(ex,key);