From 255ccb4265c35dee7914b3e7dbad1e0674c513fa Mon Sep 17 00:00:00 2001 From: ziyue <1213642868@qq.com> Date: Fri, 18 Nov 2022 16:42:40 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B2=BE=E7=AE=80rtp=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E5=99=A8=E7=9B=B8=E5=85=B3=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 3rdpart/ZLToolKit | 2 +- src/Rtp/RtpServer.cpp | 2 -- src/Rtp/RtpSession.cpp | 15 +++++---------- src/Rtp/RtpSession.h | 3 --- 4 files changed, 6 insertions(+), 16 deletions(-) diff --git a/3rdpart/ZLToolKit b/3rdpart/ZLToolKit index 21fdfe4a..90ba564e 160000 --- a/3rdpart/ZLToolKit +++ b/3rdpart/ZLToolKit @@ -1 +1 @@ -Subproject commit 21fdfe4a6553356f1b01f7dde326535ba23aef45 +Subproject commit 90ba564e9e39a120ed7b99260f2835a19811af30 diff --git a/src/Rtp/RtpServer.cpp b/src/Rtp/RtpServer.cpp index c19070bf..ccf8590b 100644 --- a/src/Rtp/RtpServer.cpp +++ b/src/Rtp/RtpServer.cpp @@ -174,7 +174,6 @@ void RtpServer::start(uint16_t local_port, const string &stream_id, TcpMode tcp_ //创建tcp服务器 tcp_server = std::make_shared(rtp_socket->getPoller()); (*tcp_server)[RtpSession::kStreamID] = stream_id; - (*tcp_server)[RtpSession::kIsUDP] = 0; (*tcp_server)[RtpSession::kSSRC] = ssrc; if (tcp_mode == PASSIVE) { tcp_server->start(rtp_socket->get_local_port(), local_ip); @@ -205,7 +204,6 @@ void RtpServer::start(uint16_t local_port, const string &stream_id, TcpMode tcp_ #if 1 //单端口多线程接收多个流,根据ssrc区分流 udp_server = std::make_shared(rtp_socket->getPoller()); - (*udp_server)[RtpSession::kIsUDP] = 1; udp_server->start(rtp_socket->get_local_port(), local_ip); rtp_socket = nullptr; #else diff --git a/src/Rtp/RtpSession.cpp b/src/Rtp/RtpSession.cpp index 8b0de2bb..db72f822 100644 --- a/src/Rtp/RtpSession.cpp +++ b/src/Rtp/RtpSession.cpp @@ -20,27 +20,22 @@ using namespace toolkit; namespace mediakit{ const string RtpSession::kStreamID = "stream_id"; -const string RtpSession::kIsUDP = "is_udp"; const string RtpSession::kSSRC = "ssrc"; void RtpSession::attachServer(const Server &server) { _stream_id = const_cast(server)[kStreamID]; - _is_udp = const_cast(server)[kIsUDP]; _ssrc = const_cast(server)[kSSRC]; - - if (_is_udp) { - //设置udp socket读缓存 - SockUtil::setRecvBuf(getSock()->rawFD(), 4 * 1024 * 1024); - _statistic_udp = std::make_shared >(); - } else { - _statistic_tcp = std::make_shared >(); - } } RtpSession::RtpSession(const Socket::Ptr &sock) : Session(sock) { DebugP(this); socklen_t addr_len = sizeof(_addr); getpeername(sock->rawFD(), (struct sockaddr *)&_addr, &addr_len); + _is_udp = sock->sockType() == SockNum::Sock_UDP; + if (_is_udp) { + // 设置udp socket读缓存 + SockUtil::setRecvBuf(getSock()->rawFD(), 4 * 1024 * 1024); + } } RtpSession::~RtpSession() { diff --git a/src/Rtp/RtpSession.h b/src/Rtp/RtpSession.h index 62f65443..31e804c3 100644 --- a/src/Rtp/RtpSession.h +++ b/src/Rtp/RtpSession.h @@ -23,7 +23,6 @@ namespace mediakit{ class RtpSession : public toolkit::Session, public RtpSplitter, public MediaSourceEvent { public: static const std::string kStreamID; - static const std::string kIsUDP; static const std::string kSSRC; RtpSession(const toolkit::Socket::Ptr &sock); @@ -50,8 +49,6 @@ private: std::string _stream_id; struct sockaddr_storage _addr; RtpProcess::Ptr _process; - std::shared_ptr > _statistic_tcp; - std::shared_ptr > _statistic_udp; }; }//namespace mediakit