diff --git a/src/Rtp/RtpSender.cpp b/src/Rtp/RtpSender.cpp index 47f4a900..4990f7ff 100644 --- a/src/Rtp/RtpSender.cpp +++ b/src/Rtp/RtpSender.cpp @@ -281,38 +281,10 @@ void RtpSender::onFlushRtpList(shared_ptr > rtp_list) { }); } -void RtpSender::onErr(const SockException &ex, bool is_connect) { +void RtpSender::onErr(const SockException &ex) { _is_connect = false; - - if (_args.passive || !_args.is_udp) { - WarnL << "send rtp tcp connection lost: " << ex.what(); - //tcp模式,如果对方断开连接,应该停止发送rtp - onClose(ex); - return; - } - - //监听socket断开事件,方便重连 - if (is_connect) { - WarnL << "重连" << _args.dst_url << ":" << _args.dst_port << "失败, 原因为:" << ex.what(); - } else { - WarnL << "停止发送 rtp:" << _args.dst_url << ":" << _args.dst_port << ", 原因为:" << ex.what(); - } - - weak_ptr weak_self = shared_from_this(); - _connect_timer = std::make_shared(10.0f, [weak_self]() { - auto strong_self = weak_self.lock(); - if (!strong_self) { - return false; - } - strong_self->startSend(strong_self->_args, [weak_self](uint16_t local_port, const SockException &ex){ - auto strong_self = weak_self.lock(); - if (strong_self && ex) { - //连接失败且本对象未销毁,那么重试连接 - strong_self->onErr(ex, true); - } - }); - return false; - }, _poller); + WarnL << "send rtp tcp connection lost: " << ex.what(); + onClose(ex); } void RtpSender::setOnClose(std::function on_close){ diff --git a/src/Rtp/RtpSender.h b/src/Rtp/RtpSender.h index bebd2ac3..9bafd537 100644 --- a/src/Rtp/RtpSender.h +++ b/src/Rtp/RtpSender.h @@ -62,7 +62,7 @@ private: //udp/tcp连接成功回调 void onConnect(); //异常断开socket事件 - void onErr(const toolkit::SockException &ex, bool is_connect = false); + void onErr(const toolkit::SockException &ex); void createRtcpSocket(); void onRecvRtcp(RtcpHeader *rtcp); void onSendRtpUdp(const toolkit::Buffer::Ptr &buf, bool check); @@ -74,7 +74,6 @@ private: toolkit::Socket::Ptr _socket_rtp; toolkit::Socket::Ptr _socket_rtcp; toolkit::EventPoller::Ptr _poller; - toolkit::Timer::Ptr _connect_timer; MediaSinkInterface::Ptr _interface; std::shared_ptr _rtcp_context; toolkit::Ticker _rtcp_send_ticker;