Skip to content

Commit

Permalink
if there's only one track, don't go through SSRC lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
wusspuss committed Nov 12, 2023
1 parent c8cbbca commit 61116cf
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/impl/peerconnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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())
Expand All @@ -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
Expand Down

0 comments on commit 61116cf

Please sign in to comment.