From c8cbbcaa8f537d9bbaa5e2d7f4ac147aaa34bdd1 Mon Sep 17 00:00:00 2001 From: wusspuss Date: Sun, 29 Oct 2023 21:45:44 +0400 Subject: [PATCH 1/2] If no ssrc is specified and there's only one track, forward packet to it. --- src/impl/peerconnection.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/impl/peerconnection.cpp b/src/impl/peerconnection.cpp index 6e0189c95..49333e1c4 100644 --- a/src/impl/peerconnection.cpp +++ b/src/impl/peerconnection.cpp @@ -586,6 +586,9 @@ void PeerConnection::dispatchMedia([[maybe_unused]] message_ptr message) { if (auto track = it->second.lock()) track->incoming(message); } else { + if (mTrackLines.size()==1) { + mTrackLines.front().lock()->incoming(message); + } /* * TODO: So the problem is that when stop sending streams, we stop getting report blocks for * those streams Therefore when we get compound RTCP packets, they are empty, and we can't From 61116cf3256f2b2b3daa1aa5ee99d4112c08d25a Mon Sep 17 00:00:00 2001 From: wusspuss Date: Sun, 12 Nov 2023 14:13:53 +0400 Subject: [PATCH 2/2] if there's only one track, don't go through SSRC lookup --- src/impl/peerconnection.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/impl/peerconnection.cpp b/src/impl/peerconnection.cpp index 49333e1c4..6c1f648d8 100644 --- a/src/impl/peerconnection.cpp +++ b/src/impl/peerconnection.cpp @@ -519,6 +519,12 @@ void PeerConnection::forwardMedia([[maybe_unused]] message_ptr message) { void PeerConnection::dispatchMedia([[maybe_unused]] message_ptr message) { #if RTC_ENABLE_MEDIA + std::shared_lock lock(mTracksMutex); // read-only + if (mTrackLines.size()==1) { + if (auto track = mTrackLines.front().lock()) + track->incoming(message); + return; + } // Browsers like to compound their packets with a random SSRC. // we have to do this monstrosity to distribute the report blocks if (message->type == Message::Control) { @@ -568,7 +574,6 @@ void PeerConnection::dispatchMedia([[maybe_unused]] message_ptr message) { } if (!ssrcs.empty()) { - std::shared_lock lock(mTracksMutex); // read-only for (uint32_t ssrc : ssrcs) { if (auto it = mTracksBySsrc.find(ssrc); it != mTracksBySsrc.end()) { if (auto track = it->second.lock()) @@ -581,14 +586,10 @@ void PeerConnection::dispatchMedia([[maybe_unused]] message_ptr message) { uint32_t ssrc = uint32_t(message->stream); - std::shared_lock lock(mTracksMutex); // read-only if (auto it = mTracksBySsrc.find(ssrc); it != mTracksBySsrc.end()) { if (auto track = it->second.lock()) track->incoming(message); } else { - if (mTrackLines.size()==1) { - mTrackLines.front().lock()->incoming(message); - } /* * TODO: So the problem is that when stop sending streams, we stop getting report blocks for * those streams Therefore when we get compound RTCP packets, they are empty, and we can't