diff --git a/3rdpart/ZLToolKit b/3rdpart/ZLToolKit index 5144e2aa..79c10fe4 160000 --- a/3rdpart/ZLToolKit +++ b/3rdpart/ZLToolKit @@ -1 +1 @@ -Subproject commit 5144e2aa521df6d473308bfb31172054772a634f +Subproject commit 79c10fe4773819d99efe905bb2fecf3446f3b36c diff --git a/src/Rtp/RtpServer.cpp b/src/Rtp/RtpServer.cpp index e8c944b0..bcf1675d 100644 --- a/src/Rtp/RtpServer.cpp +++ b/src/Rtp/RtpServer.cpp @@ -124,8 +124,9 @@ private: void RtpServer::start(uint16_t local_port, const string &stream_id, TcpMode tcp_mode, const char *local_ip, bool re_use_port, uint32_t ssrc, int only_track, bool multiplex) { //创建udp服务器 - Socket::Ptr rtp_socket = Socket::createSocket(nullptr, true); - Socket::Ptr rtcp_socket = Socket::createSocket(nullptr, true); + auto poller = EventPollerPool::Instance().getPoller(); + Socket::Ptr rtp_socket = Socket::createSocket(poller, true); + Socket::Ptr rtcp_socket = Socket::createSocket(poller, true); if (local_port == 0) { //随机端口,rtp端口采用偶数 auto pair = std::make_pair(rtp_socket, rtcp_socket); @@ -181,14 +182,14 @@ void RtpServer::start(uint16_t local_port, const string &stream_id, TcpMode tcp_ TcpServer::Ptr tcp_server; if (tcp_mode == PASSIVE || tcp_mode == ACTIVE) { - //创建tcp服务器 - tcp_server = std::make_shared(); + auto processor = helper ? helper->getProcess() : nullptr; + // 如果共享同一个processor对象,那么tcp server深圳为单线程模式确保线程安全 + tcp_server = std::make_shared(processor ? poller : nullptr); (*tcp_server)[RtpSession::kStreamID] = stream_id; (*tcp_server)[RtpSession::kSSRC] = ssrc; (*tcp_server)[RtpSession::kOnlyTrack] = only_track; if (tcp_mode == PASSIVE) { weak_ptr weak_self = shared_from_this(); - auto processor = helper ? helper->getProcess() : nullptr; tcp_server->start(local_port, local_ip, 1024, [weak_self, processor](std::shared_ptr &session) { session->setRtpProcess(processor); });