Bug 1848749 - Route received RTCP packets directly to PacketReceiver via PCImpl. r=bwc

This patch moves from a model where every received RTCP packet goes through all
MediaPipelines for a given transport, being duplicated along the way to the same
webrtc::PacketReceiver instance; to a model where every received RTCP packet
goes through PeerConnectionImpl to webrtc::PacketReceiver.

With this patch, no duplications occur.

The PacketDumper API expects received RTCP/SRTCP packet to be tied to a level so
this patch maintains the old behavior by dumping received RTCP/SRTCP on all
levels that have dumping enabled.

Differential Revision: https://phabricator.services.mozilla.com/D186227
This commit is contained in:
Andreas Pehrson 2023-08-16 10:06:14 +00:00
Родитель f9ae3e211d
Коммит 7710707346
12 изменённых файлов: 144 добавлений и 169 удалений

Просмотреть файл

@ -22,9 +22,7 @@ RefPtr<PacketDumper> PacketDumper::GetPacketDumper(
}
PacketDumper::PacketDumper(const std::string& aPcHandle)
: mPcHandle(aPcHandle),
mPacketDumpEnabled(false),
mPacketDumpFlagsMutex("Packet dump flags mutex") {}
: mPcHandle(aPcHandle), mPacketDumpFlagsMutex("Packet dump flags mutex") {}
void PacketDumper::Dump(size_t aLevel, dom::mozPacketDumpType aType,
bool aSending, const void* aData, size_t aSize) {
@ -41,13 +39,36 @@ void PacketDumper::Dump(size_t aLevel, dom::mozPacketDumpType aType,
[this, self = RefPtr<PacketDumper>(this), aLevel, aType, aSending,
aSize](UniquePtr<uint8_t[]>& aPacket) -> nsresult {
// Check again; packet dump might have been disabled since the dispatch
if (ShouldDumpPacket(aLevel, aType, aSending)) {
if (!ShouldDumpPacket(aLevel, aType, aSending)) {
return NS_OK;
}
PeerConnectionWrapper pcw(mPcHandle);
RefPtr<PeerConnectionImpl> pc = pcw.impl();
if (pc) {
if (!pc) {
return NS_OK;
}
if (!aSending && (aType == dom::mozPacketDumpType::Rtcp ||
aType == dom::mozPacketDumpType::Srtcp)) {
AutoTArray<size_t, 4> dumpLevels;
{
MutexAutoLock lock(mPacketDumpFlagsMutex);
unsigned flag = 1 << (unsigned)aType;
for (size_t i = 0; i < mRecvPacketDumpFlags.size(); ++i) {
if (mRecvPacketDumpFlags[i] & flag) {
dumpLevels.AppendElement(i);
}
}
}
for (size_t level : dumpLevels) {
pc->DumpPacket_m(level, aType, aSending, aPacket, aSize);
}
return NS_OK;
}
pc->DumpPacket_m(aLevel, aType, aSending, aPacket, aSize);
}
}
return NS_OK;
},
std::move(ownedPacket)));
@ -73,6 +94,11 @@ nsresult PacketDumper::EnablePacketDump(unsigned long aLevel,
packetDumpFlags->resize(aLevel + 1);
}
mPacketDumpRtcpRecvCount += !aSending &&
(aType == dom::mozPacketDumpType::Rtcp ||
aType == dom::mozPacketDumpType::Srtcp) &&
!((*packetDumpFlags)[aLevel] & flag);
(*packetDumpFlags)[aLevel] |= flag;
return NS_OK;
}
@ -91,6 +117,10 @@ nsresult PacketDumper::DisablePacketDump(unsigned long aLevel,
MutexAutoLock lock(mPacketDumpFlagsMutex);
if (aLevel < packetDumpFlags->size()) {
mPacketDumpRtcpRecvCount -= !aSending &&
(aType == dom::mozPacketDumpType::Rtcp ||
aType == dom::mozPacketDumpType::Srtcp) &&
((*packetDumpFlags)[aLevel] & flag);
(*packetDumpFlags)[aLevel] &= ~flag;
}
@ -103,6 +133,12 @@ bool PacketDumper::ShouldDumpPacket(size_t aLevel, dom::mozPacketDumpType aType,
return false;
}
if (!aSending && (aType == dom::mozPacketDumpType::Rtcp ||
aType == dom::mozPacketDumpType::Srtcp)) {
// Received (S)RTCP is dumped per-transport, not per-pipeline.
return mPacketDumpRtcpRecvCount > 0;
}
MutexAutoLock lock(mPacketDumpFlagsMutex);
const std::vector<unsigned>* packetDumpFlags;

Просмотреть файл

@ -41,9 +41,12 @@ class PacketDumper {
// This class is not cycle-collected, so it cannot hold onto a strong ref
const std::string mPcHandle;
std::vector<unsigned> mSendPacketDumpFlags;
std::vector<unsigned> mRecvPacketDumpFlags;
Atomic<bool> mPacketDumpEnabled;
std::vector<unsigned> mSendPacketDumpFlags
MOZ_GUARDED_BY(mPacketDumpFlagsMutex);
std::vector<unsigned> mRecvPacketDumpFlags
MOZ_GUARDED_BY(mPacketDumpFlagsMutex);
Atomic<bool> mPacketDumpEnabled{false};
Atomic<int> mPacketDumpRtcpRecvCount{0};
mutable Mutex mPacketDumpFlagsMutex;
};

Просмотреть файл

@ -47,11 +47,13 @@
#include "jsep/JsepSessionImpl.h"
#include "transportbridge/MediaPipeline.h"
#include "transportbridge/RtpLogger.h"
#include "jsapi/RTCRtpReceiver.h"
#include "jsapi/RTCRtpSender.h"
#include "mozilla/IntegerPrintfMacros.h"
#include "mozilla/Sprintf.h"
#include "mozilla/StaticPrefs_media.h"
#ifdef XP_WIN
// We need to undef the MS macro for Document::CreateEvent
@ -1997,6 +1999,14 @@ PeerConnectionImpl::SetPeerIdentity(const nsAString& aPeerIdentity) {
return NS_OK;
}
void PeerConnectionImpl::OnRtcpPacketReceived(MediaPacket aPacket) {
MOZ_ASSERT(mCall->mCallThread->IsOnCurrentThread());
MOZ_ASSERT(mCall->Call());
mCall->Call()->Receiver()->DeliverRtcpPacket(
rtc::CopyOnWriteBuffer(aPacket.data(), aPacket.len()));
}
nsresult PeerConnectionImpl::OnAlpnNegotiated(bool aPrivacyRequested) {
PC_AUTO_ENTER_API_CALL(false);
MOZ_DIAGNOSTIC_ASSERT(!mRequestedPrivacy ||
@ -2574,6 +2584,7 @@ PeerConnectionImpl::Close() {
"%s: Closing PeerConnectionImpl %s; "
"ending call",
__FUNCTION__, mHandle.c_str());
mRtcpReceiveListener.DisconnectIfExists();
if (mJsepSession) {
mJsepSession->Close();
}
@ -4223,7 +4234,8 @@ PeerConnectionImpl::SignalHandler::SignalHandler(PeerConnectionImpl* aPc,
MediaTransportHandler* aSource)
: mHandle(aPc->GetHandle()),
mSource(aSource),
mSTSThread(aPc->GetSTSThread()) {
mSTSThread(aPc->GetSTSThread()),
mPacketDumper(aPc->GetPacketDumper()) {
ConnectSignals();
}
@ -4244,6 +4256,8 @@ void PeerConnectionImpl::SignalHandler::ConnectSignals() {
this, &PeerConnectionImpl::SignalHandler::ConnectionStateChange_s);
mSource->SignalRtcpStateChange.connect(
this, &PeerConnectionImpl::SignalHandler::ConnectionStateChange_s);
mSource->SignalPacketReceived.connect(
this, &PeerConnectionImpl::SignalHandler::OnPacketReceived_s);
}
void PeerConnectionImpl::AddIceCandidate(const std::string& aCandidate,
@ -4436,6 +4450,8 @@ already_AddRefed<dom::RTCRtpTransceiver> PeerConnectionImpl::CreateTransceiver(
u"WebrtcCallWrapper shutdown blocker"_ns,
NS_LITERAL_STRING_FROM_CSTRING(__FILE__), __LINE__),
ctx->GetSharedWebrtcState());
mRtcpReceiveListener = mSignalHandler->RtcpReceiveEvent().Connect(
mCall->mCallThread, this, &PeerConnectionImpl::OnRtcpPacketReceived);
}
if (aAddTrackMagic) {
@ -4559,6 +4575,39 @@ void PeerConnectionImpl::SignalHandler::ConnectionStateChange_s(
NS_DISPATCH_NORMAL);
}
void PeerConnectionImpl::SignalHandler::OnPacketReceived_s(
const std::string& aTransportId, const MediaPacket& aPacket) {
ASSERT_ON_THREAD(mSTSThread);
if (!aPacket.len()) {
return;
}
if (aPacket.type() != MediaPacket::RTCP) {
return;
}
CSFLogVerbose(LOGTAG, "%s received RTCP packet.", mHandle.c_str());
RtpLogger::LogPacket(aPacket, true, mHandle);
// Might be nice to pass ownership of the buffer in this case, but it is a
// small optimization in a rare case.
mPacketDumper->Dump(SIZE_MAX, dom::mozPacketDumpType::Srtcp, false,
aPacket.encrypted_data(), aPacket.encrypted_len());
mPacketDumper->Dump(SIZE_MAX, dom::mozPacketDumpType::Rtcp, false,
aPacket.data(), aPacket.len());
if (StaticPrefs::media_webrtc_net_force_disable_rtcp_reception()) {
CSFLogVerbose(LOGTAG, "%s RTCP packet forced to be dropped",
mHandle.c_str());
return;
}
mRtcpReceiveEvent.Notify(aPacket.Clone());
}
/**
* Tells you if any local track is isolated to a specific peer identity.
* Obviously, we want all the tracks to be isolated equally so that they can

Просмотреть файл

@ -48,6 +48,7 @@
#include "RTCStatsReport.h"
#include "mozilla/net/StunAddrsRequestChild.h"
#include "MediaEventSource.h"
#include "MediaTransportHandler.h"
#include "nsIHttpChannelInternal.h"
#include "RTCDtlsTransport.h"
@ -490,6 +491,8 @@ class PeerConnectionImpl final
bool IsClosed() const;
void OnRtcpPacketReceived(MediaPacket aPacket);
// called when DTLS connects; we only need this once
nsresult OnAlpnNegotiated(bool aPrivacyRequested);
@ -930,14 +933,23 @@ class PeerConnectionImpl final
void AlpnNegotiated_s(const std::string& aAlpn, bool aPrivacyRequested);
void ConnectionStateChange_s(const std::string& aTransportId,
TransportLayer::State aState);
void OnPacketReceived_s(const std::string& aTransportId,
const MediaPacket& aPacket);
MediaEventSourceExc<MediaPacket>& RtcpReceiveEvent() {
return mRtcpReceiveEvent;
}
private:
const std::string mHandle;
RefPtr<MediaTransportHandler> mSource;
RefPtr<nsISerialEventTarget> mSTSThread;
RefPtr<PacketDumper> mPacketDumper;
MediaEventProducerExc<MediaPacket> mRtcpReceiveEvent;
};
mozilla::UniquePtr<SignalHandler> mSignalHandler;
MediaEventListener mRtcpReceiveListener;
// Make absolutely sure our refcount does not go to 0 before Close() is called
// This is because Close does a stats query, which needs the

Просмотреть файл

@ -516,12 +516,8 @@ void WebrtcAudioConduit::SetTransportActive(bool aActive) {
MOZ_ALWAYS_SUCCEEDS(mCallThread->Dispatch(NS_NewRunnableFunction(
__func__,
[self = RefPtr<WebrtcAudioConduit>(this),
recvRtpListener = std::move(mReceiverRtpEventListener),
recvRtcpListener = std::move(mReceiverRtcpEventListener),
sendRtcpListener = std::move(mSenderRtcpEventListener)]() mutable {
recvRtpListener = std::move(mReceiverRtpEventListener)]() mutable {
recvRtpListener.DisconnectIfExists();
recvRtcpListener.DisconnectIfExists();
sendRtcpListener.DisconnectIfExists();
})));
}
}
@ -662,16 +658,6 @@ void WebrtcAudioConduit::OnRtpReceived(webrtc::RtpPacketReceived&& aPacket,
}
}
void WebrtcAudioConduit::OnRtcpReceived(MediaPacket&& aPacket) {
CSFLogDebug(LOGTAG, "%s", __FUNCTION__);
MOZ_ASSERT(mCallThread->IsOnCurrentThread());
if (mCall->Call()) {
mCall->Call()->Receiver()->DeliverRtcpPacket(
rtc::CopyOnWriteBuffer(aPacket.data(), aPacket.len()));
}
}
Maybe<uint16_t> WebrtcAudioConduit::RtpSendBaseSeqFor(uint32_t aSsrc) const {
MOZ_ASSERT(mCallThread->IsOnCurrentThread());
auto it = mRtpSendBaseSeqs.find(aSsrc);

Просмотреть файл

@ -34,7 +34,6 @@ class WebrtcAudioConduit : public AudioSessionConduit,
void OnRtpReceived(webrtc::RtpPacketReceived&& aPacket,
webrtc::RTPHeader&& aHeader);
void OnRtcpReceived(MediaPacket&& aPacket);
void OnRtcpBye() override;
void OnRtcpTimeout() override;
@ -56,16 +55,6 @@ class WebrtcAudioConduit : public AudioSessionConduit,
mReceiverRtpEventListener =
aEvent.Connect(mCallThread, this, &WebrtcAudioConduit::OnRtpReceived);
}
void ConnectReceiverRtcpEvent(
MediaEventSourceExc<MediaPacket>& aEvent) override {
mReceiverRtcpEventListener =
aEvent.Connect(mCallThread, this, &WebrtcAudioConduit::OnRtcpReceived);
}
void ConnectSenderRtcpEvent(
MediaEventSourceExc<MediaPacket>& aEvent) override {
mSenderRtcpEventListener =
aEvent.Connect(mCallThread, this, &WebrtcAudioConduit::OnRtcpReceived);
}
Maybe<uint16_t> RtpSendBaseSeqFor(uint32_t aSsrc) const override;
@ -303,8 +292,6 @@ class WebrtcAudioConduit : public AudioSessionConduit,
MediaEventProducerExc<MediaPacket> mReceiverRtcpSendEvent;
// Assigned and revoked on mStsThread. Listeners for receiving packets.
MediaEventListener mSenderRtcpEventListener; // Rtp-transmitting pipeline
MediaEventListener mReceiverRtcpEventListener; // Rtp-receiving pipeline
MediaEventListener mReceiverRtpEventListener; // Rtp-receiving pipeline
};

Просмотреть файл

@ -134,17 +134,10 @@ class MediaSessionConduit {
virtual MediaEventSourceExc<MediaPacket>& SenderRtcpSendEvent() = 0;
virtual MediaEventSourceExc<MediaPacket>& ReceiverRtcpSendEvent() = 0;
// Receiving packets...
// from an rtp-receiving pipeline
// Receiving RTP packets
virtual void ConnectReceiverRtpEvent(
MediaEventSourceExc<webrtc::RtpPacketReceived, webrtc::RTPHeader>&
aEvent) = 0;
// from an rtp-receiving pipeline
virtual void ConnectReceiverRtcpEvent(
MediaEventSourceExc<MediaPacket>& aEvent) = 0;
// from an rtp-transmitting pipeline
virtual void ConnectSenderRtcpEvent(
MediaEventSourceExc<MediaPacket>& aEvent) = 0;
// Sts thread only.
virtual Maybe<uint16_t> RtpSendBaseSeqFor(uint32_t aSsrc) const = 0;

Просмотреть файл

@ -1576,18 +1576,6 @@ void WebrtcVideoConduit::OnRtpReceived(webrtc::RtpPacketReceived&& aPacket,
}
}
void WebrtcVideoConduit::OnRtcpReceived(MediaPacket&& aPacket) {
MOZ_ASSERT(mCallThread->IsOnCurrentThread());
CSFLogVerbose(LOGTAG, "VideoConduit %p: Received RTCP Packet, len %zu ", this,
aPacket.len());
if (mCall->Call()) {
mCall->Call()->Receiver()->DeliverRtcpPacket(
rtc::CopyOnWriteBuffer(aPacket.data(), aPacket.len()));
}
}
Maybe<uint16_t> WebrtcVideoConduit::RtpSendBaseSeqFor(uint32_t aSsrc) const {
MOZ_ASSERT(mCallThread->IsOnCurrentThread());
auto it = mRtpSendBaseSeqs.find(aSsrc);
@ -1941,12 +1929,8 @@ void WebrtcVideoConduit::SetTransportActive(bool aActive) {
MOZ_ALWAYS_SUCCEEDS(mCallThread->Dispatch(NS_NewRunnableFunction(
__func__,
[self = RefPtr<WebrtcVideoConduit>(this),
recvRtpListener = std::move(mReceiverRtpEventListener),
recvRtcpListener = std::move(mReceiverRtcpEventListener),
sendRtcpListener = std::move(mSenderRtcpEventListener)]() mutable {
recvRtpListener = std::move(mReceiverRtpEventListener)]() mutable {
recvRtpListener.DisconnectIfExists();
recvRtcpListener.DisconnectIfExists();
sendRtcpListener.DisconnectIfExists();
})));
}
}

Просмотреть файл

@ -196,7 +196,6 @@ class WebrtcVideoConduit
void OnRtpReceived(webrtc::RtpPacketReceived&& aPacket,
webrtc::RTPHeader&& aHeader);
void OnRtcpReceived(MediaPacket&& aPacket);
void OnRtcpBye() override;
void OnRtcpTimeout() override;
@ -218,16 +217,6 @@ class WebrtcVideoConduit
mReceiverRtpEventListener =
aEvent.Connect(mCallThread, this, &WebrtcVideoConduit::OnRtpReceived);
}
void ConnectReceiverRtcpEvent(
MediaEventSourceExc<MediaPacket>& aEvent) override {
mReceiverRtcpEventListener =
aEvent.Connect(mCallThread, this, &WebrtcVideoConduit::OnRtcpReceived);
}
void ConnectSenderRtcpEvent(
MediaEventSourceExc<MediaPacket>& aEvent) override {
mSenderRtcpEventListener =
aEvent.Connect(mCallThread, this, &WebrtcVideoConduit::OnRtcpReceived);
}
std::vector<webrtc::RtpSource> GetUpstreamRtpSources() const override;
@ -501,8 +490,6 @@ class WebrtcVideoConduit
MediaEventProducerExc<MediaPacket> mReceiverRtcpSendEvent;
// Assigned and revoked on mStsThread. Listeners for receiving packets.
MediaEventListener mSenderRtcpEventListener; // Rtp-transmitting pipeline
MediaEventListener mReceiverRtcpEventListener; // Rtp-receiving pipeline
MediaEventListener mReceiverRtpEventListener; // Rtp-receiving pipeline
};
} // namespace mozilla

Просмотреть файл

@ -259,7 +259,6 @@ MediaPipeline::MediaPipeline(const std::string& aPc,
mRtpPacketsSent(0),
mRtcpPacketsSent(0),
mRtpPacketsReceived(0),
mRtcpPacketsReceived(0),
mRtpBytesSent(0),
mRtpBytesReceived(0),
mPc(aPc),
@ -426,13 +425,11 @@ void MediaPipeline::CheckTransportStates() {
if (mRtpState == TransportLayer::TS_OPEN && mRtcpState == mRtpState) {
if (mDirection == DirectionType::TRANSMIT) {
mConduit->ConnectSenderRtcpEvent(mSenderRtcpReceiveEvent);
mRtpSendEventListener = mConduit->SenderRtpSendEvent().Connect(
mStsThread, this, &MediaPipeline::SendPacket);
mSenderRtcpSendEventListener = mConduit->SenderRtcpSendEvent().Connect(
mStsThread, this, &MediaPipeline::SendPacket);
} else {
mConduit->ConnectReceiverRtcpEvent(mReceiverRtcpReceiveEvent);
mConduit->ConnectReceiverRtpEvent(mRtpReceiveEvent);
mReceiverRtcpSendEventListener =
mConduit->ReceiverRtcpSendEvent().Connect(mStsThread, this,
@ -513,18 +510,20 @@ void MediaPipeline::IncrementRtpPacketsReceived(int32_t aBytes) {
}
}
void MediaPipeline::IncrementRtcpPacketsReceived() {
void MediaPipeline::PacketReceived(const std::string& aTransportId,
const MediaPacket& packet) {
ASSERT_ON_THREAD(mStsThread);
++mRtcpPacketsReceived;
if (!(mRtcpPacketsReceived % 100)) {
MOZ_LOG(gMediaPipelineLog, LogLevel::Info,
("RTCP received packet count for %s Pipeline %p: %u",
mDescription.c_str(), this, mRtcpPacketsReceived));
}
}
void MediaPipeline::RtpPacketReceived(const MediaPacket& packet) {
ASSERT_ON_THREAD(mStsThread);
if (mTransportId != aTransportId) {
return;
}
MOZ_ASSERT(mRtpState == TransportLayer::TS_OPEN);
MOZ_ASSERT(mRtcpState == mRtpState);
if (packet.type() != MediaPacket::RTP) {
return;
}
if (mDirection == DirectionType::TRANSMIT) {
return;
@ -595,68 +594,6 @@ void MediaPipeline::RtpPacketReceived(const MediaPacket& packet) {
mRtpReceiveEvent.Notify(std::move(parsedPacket), header);
}
void MediaPipeline::RtcpPacketReceived(const MediaPacket& packet) {
ASSERT_ON_THREAD(mStsThread);
if (!packet.len()) {
return;
}
// We do not filter RTCP. This is because a compound RTCP packet can contain
// any collection of RTCP packets, and webrtc.org already knows how to filter
// out what it is interested in, and what it is not. Maybe someday we should
// have a TransportLayer that breaks up compound RTCP so we can filter them
// individually, but I doubt that will matter much.
MOZ_LOG(gMediaPipelineLog, LogLevel::Debug,
("%s received RTCP packet.", mDescription.c_str()));
IncrementRtcpPacketsReceived();
RtpLogger::LogPacket(packet, true, mDescription);
// Might be nice to pass ownership of the buffer in this case, but it is a
// small optimization in a rare case.
mPacketDumper->Dump(mLevel, dom::mozPacketDumpType::Srtcp, false,
packet.encrypted_data(), packet.encrypted_len());
mPacketDumper->Dump(mLevel, dom::mozPacketDumpType::Rtcp, false,
packet.data(), packet.len());
if (StaticPrefs::media_webrtc_net_force_disable_rtcp_reception()) {
MOZ_LOG(gMediaPipelineLog, LogLevel::Debug,
("%s RTCP packet forced to be dropped", mDescription.c_str()));
return;
}
if (mDirection == DirectionType::TRANSMIT) {
mSenderRtcpReceiveEvent.Notify(packet.Clone());
} else {
mReceiverRtcpReceiveEvent.Notify(packet.Clone());
}
}
void MediaPipeline::PacketReceived(const std::string& aTransportId,
const MediaPacket& packet) {
ASSERT_ON_THREAD(mStsThread);
if (mTransportId != aTransportId) {
return;
}
MOZ_ASSERT(mRtpState == TransportLayer::TS_OPEN);
MOZ_ASSERT(mRtcpState == mRtpState);
switch (packet.type()) {
case MediaPacket::RTP:
RtpPacketReceived(packet);
break;
case MediaPacket::RTCP:
RtcpPacketReceived(packet);
break;
default:;
}
}
void MediaPipeline::AlpnNegotiated(const std::string& aAlpn,
bool aPrivacyRequested) {
ASSERT_ON_THREAD(mStsThread);

Просмотреть файл

@ -163,7 +163,6 @@ class MediaPipeline : public sigslot::has_slots<> {
int32_t RtcpPacketsSent() const { return mRtcpPacketsSent; }
int32_t RtpPacketsReceived() const { return mRtpPacketsReceived; }
int64_t RtpBytesReceived() const { return mRtpBytesReceived; }
int32_t RtcpPacketsReceived() const { return mRtcpPacketsReceived; }
const dom::RTCStatsTimestampMaker& GetTimestampMaker() const;
@ -179,7 +178,6 @@ class MediaPipeline : public sigslot::has_slots<> {
void IncrementRtpPacketsSent(const MediaPacket& aPacket);
void IncrementRtcpPacketsSent();
void IncrementRtpPacketsReceived(int aBytes);
void IncrementRtcpPacketsReceived();
virtual void SendPacket(MediaPacket&& packet);
@ -191,9 +189,6 @@ class MediaPipeline : public sigslot::has_slots<> {
const MediaPacket& packet);
void AlpnNegotiated(const std::string& aAlpn, bool aPrivacyRequested);
void RtpPacketReceived(const MediaPacket& packet);
void RtcpPacketReceived(const MediaPacket& packet);
void EncryptedPacketSending(const std::string& aTransportId,
const MediaPacket& aPacket);
@ -224,7 +219,6 @@ class MediaPipeline : public sigslot::has_slots<> {
int32_t mRtpPacketsSent;
int32_t mRtcpPacketsSent;
int32_t mRtpPacketsReceived;
int32_t mRtcpPacketsReceived;
int64_t mRtpBytesSent;
int64_t mRtpBytesReceived;
@ -246,8 +240,6 @@ class MediaPipeline : public sigslot::has_slots<> {
MediaEventProducerExc<webrtc::RtpPacketReceived, webrtc::RTPHeader>
mRtpReceiveEvent;
MediaEventProducerExc<MediaPacket> mSenderRtcpReceiveEvent;
MediaEventProducerExc<MediaPacket> mReceiverRtcpReceiveEvent;
MediaEventListener mRtpSendEventListener;
MediaEventListener mSenderRtcpSendEventListener;

Просмотреть файл

@ -224,7 +224,7 @@ class LoopbackTransport : public MediaTransportHandler {
void SendPacket(const std::string& aTransportId,
MediaPacket&& aPacket) override {
peer_->SignalPacketReceived(aTransportId, aPacket);
peer_->LoopbackPacketReceived(aTransportId, aPacket);
}
void SetState(const std::string& aTransportId, TransportLayer::State aState) {
@ -236,8 +236,19 @@ class LoopbackTransport : public MediaTransportHandler {
MediaTransportHandler::OnRtcpStateChange(aTransportId, aState);
}
void LoopbackPacketReceived(const std::string& aTransportId,
const MediaPacket& aPacket) {
if (aPacket.len() && aPacket.type() == MediaPacket::RTCP) {
++rtcp_packets_received_;
}
SignalPacketReceived(aTransportId, aPacket);
}
int RtcpPacketsReceived() const { return rtcp_packets_received_; }
private:
RefPtr<MediaTransportHandler> peer_;
RefPtr<LoopbackTransport> peer_;
std::atomic<int> rtcp_packets_received_{0};
};
class TestAgent {
@ -326,9 +337,7 @@ class TestAgent {
int GetAudioRtcpCountSent() { return audio_pipeline_->RtcpPacketsSent(); }
int GetAudioRtcpCountReceived() {
return audio_pipeline_->RtcpPacketsReceived();
}
int GetAudioRtcpCountReceived() { return transport_->RtcpPacketsReceived(); }
protected:
ConcreteControl control_;