From 2b64245c141326915bc15cc418476c426a5a5d7f Mon Sep 17 00:00:00 2001 From: ziyue <1213642868@qq.com> Date: Sat, 8 Oct 2022 10:47:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/source/mk_common.cpp | 3 +-- src/Rtp/RtpSender.cpp | 8 +++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/api/source/mk_common.cpp b/api/source/mk_common.cpp index c50971fe..4c5b5b9e 100644 --- a/api/source/mk_common.cpp +++ b/api/source/mk_common.cpp @@ -292,9 +292,8 @@ API_EXPORT void API_CALL mk_webrtc_get_answer_sdp(void *user_data, on_mk_webrtc_ std::string offer_str = offer; WebRtcPluginManager::Instance().getAnswerSdp(*session, type, WebRtcArgsUrl(url), [offer_str, session, user_data, cb](const WebRtcInterface &exchanger) mutable { - std::string sdp_answer; try { - sdp_answer = const_cast(exchanger).getAnswerSdp(offer_str); + auto sdp_answer = const_cast(exchanger).getAnswerSdp(offer_str); cb(user_data, sdp_answer.data(), nullptr); } catch (std::exception &ex) { cb(user_data, nullptr, ex.what()); diff --git a/src/Rtp/RtpSender.cpp b/src/Rtp/RtpSender.cpp index 9f6f8552..57b28cca 100644 --- a/src/Rtp/RtpSender.cpp +++ b/src/Rtp/RtpSender.cpp @@ -61,8 +61,9 @@ void RtpSender::startSend(const MediaSourceEvent::SendRtpArgs &args, const funct } // tcp服务器默认开启5秒 auto delay_task = _poller->doDelayTask(_args.tcp_passive_close_delay_ms, [tcp_listener, cb,is_wait]() mutable { - if(is_wait) + if (is_wait) { cb(0, SockException(Err_timeout, "wait tcp connection timeout")); + } tcp_listener = nullptr; return 0; }); @@ -75,12 +76,13 @@ void RtpSender::startSend(const MediaSourceEvent::SendRtpArgs &args, const funct delay_task->cancel(); strong_self->_socket_rtp = sock; strong_self->onConnect(); - if(is_wait) + if (is_wait) { cb(sock->get_local_port(), SockException()); + } InfoL << "accept connection from:" << sock->get_peer_ip() << ":" << sock->get_peer_port(); }); InfoL << "start tcp passive server on:" << tcp_listener->get_local_port(); - if(!is_wait){ + if (!is_wait) { // 随机端口马上返回端口,保证调用者知道端口 cb(tcp_listener->get_local_port(), SockException()); }