From a37268f003ea5f5fc8f4640e3cbe23d6a79653c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=8F=E6=A5=9A?= <771730766@qq.com> Date: Sat, 12 Nov 2022 01:52:49 +0000 Subject: [PATCH] =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/WebHook.cpp | 9 ++++----- src/Rtp/RtpServer.cpp | 18 ++++++++---------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/server/WebHook.cpp b/server/WebHook.cpp index 879c5f51..4544d30b 100755 --- a/server/WebHook.cpp +++ b/server/WebHook.cpp @@ -650,9 +650,9 @@ void installWebHook(){ }); }); - NoticeCenter::Instance().addListener(&web_hook_tag,Broadcast::KBroadcastRtpServerTimeout,[](BroadcastRtpServerTimeout){ - GET_CONFIG(string,rtp_server_timeout,Hook::kOnRtpServerTimeout); - if(!hook_enable || rtp_server_timeout.empty()){ + NoticeCenter::Instance().addListener(&web_hook_tag, Broadcast::KBroadcastRtpServerTimeout, [](BroadcastRtpServerTimeout) { + GET_CONFIG(string, rtp_server_timeout, Hook::kOnRtpServerTimeout); + if (!hook_enable || rtp_server_timeout.empty()) { return; } @@ -662,8 +662,7 @@ void installWebHook(){ body["tcp_mode"] = tcp_mode; body["re_use_port"] = re_use_port; body["ssrc"] = ssrc; - do_http_hook(rtp_server_timeout,body); - + do_http_hook(rtp_server_timeout, body); }); //汇报服务器重新启动 diff --git a/src/Rtp/RtpServer.cpp b/src/Rtp/RtpServer.cpp index af17cc95..7ebe081f 100644 --- a/src/Rtp/RtpServer.cpp +++ b/src/Rtp/RtpServer.cpp @@ -36,14 +36,13 @@ public: _stream_id = std::move(stream_id); } - - ~RtcpHelper() { if (_process) { // 删除rtp处理器 RtpSelector::Instance().delProcess(_stream_id, _process.get()); } } + void setRtpServerInfo(uint16_t local_port,RtpServer::TcpMode mode,bool re_use_port,uint32_t ssrc){ _local_port = local_port; _tcp_mode = mode; @@ -98,16 +97,16 @@ public: if (!process && strong_self->_on_detach) { strong_self->_on_detach(); } - if(!process){ // process 未创建,触发rtp server 超时事件 - NoticeCenter::Instance().emitEvent(Broadcast::KBroadcastRtpServerTimeout,strong_self->_local_port,strong_self->_stream_id,(int)strong_self->_tcp_mode,strong_self->_re_use_port,strong_self->_ssrc); - } + if (!process) { // process 未创建,触发rtp server 超时事件 + NoticeCenter::Instance().emitEvent(Broadcast::KBroadcastRtpServerTimeout,strong_self->_local_port,strong_self->_stream_id,(int)strong_self->_tcp_mode,strong_self->_re_use_port,strong_self->_ssrc); + } } return 0; }); } - void cancelDelayTask(){ - if(_delay_task){ + void cancelDelayTask() { + if (_delay_task) { _delay_task->cancel(); _delay_task = nullptr; } @@ -135,11 +134,10 @@ private: } private: - uint16_t _local_port = 0; - RtpServer::TcpMode _tcp_mode = RtpServer::NONE; bool _re_use_port = false; + uint16_t _local_port = 0; uint32_t _ssrc = 0; - + RtpServer::TcpMode _tcp_mode = RtpServer::NONE; Ticker _ticker; Socket::Ptr _rtcp_sock;