提交 cbc7c0ba authored 作者: Iñaki Baz Castillo's avatar Iñaki Baz Castillo

Room.cpp: unify code

上级 71b8cccf
......@@ -51,6 +51,7 @@ namespace RTC
private:
RTC::Peer* GetPeerFromRequest(Channel::Request* request, uint32_t* peerId = nullptr) const;
void SetCapabilities(std::vector<RTC::RtpCodecParameters>& mediaCodecs);
void AddRtpSenderForRtpReceiver(RTC::Peer* senderPeer, const RTC::RtpReceiver* rtpReceiver);
/* Pure virtual methods inherited from RTC::Peer::Listener. */
public:
......
......@@ -442,6 +442,28 @@ namespace RTC
this->capabilities.fecMechanisms = Room::supportedRtpCapabilities.fecMechanisms;
}
inline void Room::AddRtpSenderForRtpReceiver(RTC::Peer* senderPeer, const RTC::RtpReceiver* rtpReceiver)
{
MS_TRACE();
MS_ASSERT(senderPeer->HasCapabilities(), "sender peer has no capabilities");
MS_ASSERT(rtpReceiver->GetParameters(), "rtpReceiver has no parameters");
uint32_t rtpSenderId = Utils::Crypto::GetRandomUInt(10000000, 99999999);
RTC::RtpSender* rtpSender =
new RTC::RtpSender(senderPeer, this->notifier, rtpSenderId, rtpReceiver->kind);
// Store into the maps.
this->mapRtpReceiverRtpSenders[rtpReceiver].insert(rtpSender);
this->mapRtpSenderRtpReceiver[rtpSender] = rtpReceiver;
auto rtpParameters = rtpReceiver->GetParameters();
auto associatedRtpReceiverId = rtpReceiver->rtpReceiverId;
// Attach the RtpSender to the peer.
senderPeer->AddRtpSender(rtpSender, rtpParameters, associatedRtpReceiverId);
}
void Room::onPeerClosed(const RTC::Peer* peer)
{
MS_TRACE();
......@@ -502,19 +524,7 @@ namespace RTC
if (!rtpReceiver->GetParameters())
continue;
uint32_t rtpSenderId = Utils::Crypto::GetRandomUInt(10000000, 99999999);
RTC::RtpSender* rtpSender =
new RTC::RtpSender(peer, this->notifier, rtpSenderId, rtpReceiver->kind);
// Store into the maps.
this->mapRtpReceiverRtpSenders[rtpReceiver].insert(rtpSender);
this->mapRtpSenderRtpReceiver[rtpSender] = rtpReceiver;
auto rtpParameters = rtpReceiver->GetParameters();
auto associatedRtpReceiverId = rtpReceiver->rtpReceiverId;
// Attach the RtpSender to the peer.
peer->AddRtpSender(rtpSender, rtpParameters, associatedRtpReceiverId);
AddRtpSenderForRtpReceiver(peer, rtpReceiver);
}
}
}
......@@ -544,20 +554,7 @@ namespace RTC
if (!senderPeer->HasCapabilities())
continue;
// Create a RtpSender for the other Peer.
uint32_t rtpSenderId = Utils::Crypto::GetRandomUInt(10000000, 99999999);
RTC::RtpSender* rtpSender =
new RTC::RtpSender(senderPeer, this->notifier, rtpSenderId, rtpReceiver->kind);
// Store into the maps.
this->mapRtpReceiverRtpSenders[rtpReceiver].insert(rtpSender);
this->mapRtpSenderRtpReceiver[rtpSender] = rtpReceiver;
auto rtpParameters = rtpReceiver->GetParameters();
auto associatedRtpReceiverId = rtpReceiver->rtpReceiverId;
// Attach the RtpSender to the senderPeer.
senderPeer->AddRtpSender(rtpSender, rtpParameters, associatedRtpReceiverId);
AddRtpSenderForRtpReceiver(senderPeer, rtpReceiver);
}
}
// If this is not a new RtpReceiver let's retrieve its updated parameters
......
......@@ -758,7 +758,7 @@ namespace RTC
// Ensure DTLS is connected.
if (this->dtlsTransport->GetState() != RTC::DtlsTransport::DtlsState::CONNECTED)
{
MS_WARN_2TAGS(dtls, rtp, "ignoring RTP packet while DTLS not connected");
MS_DEBUG_2TAGS(dtls, rtp, "ignoring RTP packet while DTLS not connected");
return;
}
......@@ -766,7 +766,7 @@ namespace RTC
// Ensure there is receiving SRTP session.
if (!this->srtpRecvSession)
{
MS_WARN_TAG(srtp, "ignoring RTP packet due to non receiving SRTP session");
MS_DEBUG_TAG(srtp, "ignoring RTP packet due to non receiving SRTP session");
return;
}
......@@ -868,7 +868,7 @@ namespace RTC
// Ensure DTLS is connected.
if (this->dtlsTransport->GetState() != RTC::DtlsTransport::DtlsState::CONNECTED)
{
MS_WARN_2TAGS(dtls, rtcp, "ignoring RTCP packet while DTLS not connected");
MS_DEBUG_2TAGS(dtls, rtcp, "ignoring RTCP packet while DTLS not connected");
return;
}
......@@ -876,7 +876,7 @@ namespace RTC
// Ensure there is receiving SRTP session.
if (!this->srtpRecvSession)
{
MS_WARN_TAG(srtp, "ignoring RTCP packet due to non receiving SRTP session");
MS_DEBUG_TAG(srtp, "ignoring RTCP packet due to non receiving SRTP session");
return;
}
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论