Reland of Verify sender ssrc when receiving rtcp target bitrate (patchset #1 id:1 of https://codereview.webrtc.org/3005633002/ )
Reason for revert:
Landed fix in upstream project.
Original issue's description:
> Revert of Verify sender ssrc when receiving rtcp target bitrate (patchset #3 id:40001 of https://codereview.webrtc.org/3000373002/ )
>
> Reason for revert:
> Might be the root cause of an internal test failure.
>
> Original issue's description:
> > Verify sender ssrc when receiving rtcp target bitrate
> >
> > BUG=webrtc:8137
> >
> > Review-Url: https://codereview.webrtc.org/3000373002
> > Cr-Commit-Position: refs/heads/master@{#19524}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/a7a4beb419612e16e781e143f9bc0c812e044f75
>
> TBR=danilchap@webrtc.org,sprang@webrtc.org
> # Skipping CQ checks because original CL landed less than 1 days ago.
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=webrtc:8137
>
> Review-Url: https://codereview.webrtc.org/3005633002
> Cr-Commit-Position: refs/heads/master@{#19529}
> Committed: https://chromium.googlesource.com/external/webrtc/+/95a64ca8aa3ab20692bf8fbb24c7ea7b72abb0a6
TBR=danilchap@webrtc.org,zhihuang@webrtc.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=webrtc:8137
Review-Url: https://codereview.webrtc.org/3006683002
Cr-Original-Commit-Position: refs/heads/master@{#19557}
Cr-Mirrored-From: https://chromium.googlesource.com/external/webrtc
Cr-Mirrored-Commit: b32aaf97bd73d16604e9e85221f2dbc4a9433e61
diff --git a/modules/rtp_rtcp/source/rtcp_receiver.cc b/modules/rtp_rtcp/source/rtcp_receiver.cc
index 7270f39..666e1e2 100644
--- a/modules/rtp_rtcp/source/rtcp_receiver.cc
+++ b/modules/rtp_rtcp/source/rtcp_receiver.cc
@@ -688,8 +688,10 @@
for (const rtcp::ReceiveTimeInfo& time_info : xr.dlrr().sub_blocks())
HandleXrDlrrReportBlock(time_info);
- if (xr.target_bitrate())
- HandleXrTargetBitrate(*xr.target_bitrate(), packet_information);
+ if (xr.target_bitrate()) {
+ HandleXrTargetBitrate(xr.sender_ssrc(), *xr.target_bitrate(),
+ packet_information);
+ }
}
void RTCPReceiver::HandleXrReceiveReferenceTime(uint32_t sender_ssrc,
@@ -722,8 +724,13 @@
}
void RTCPReceiver::HandleXrTargetBitrate(
+ uint32_t ssrc,
const rtcp::TargetBitrate& target_bitrate,
PacketInformation* packet_information) {
+ if (ssrc != remote_ssrc_) {
+ return; // Not for us.
+ }
+
BitrateAllocation bitrate_allocation;
for (const auto& item : target_bitrate.GetTargetBitrates()) {
if (item.spatial_layer >= kMaxSpatialLayers ||
diff --git a/modules/rtp_rtcp/source/rtcp_receiver.h b/modules/rtp_rtcp/source/rtcp_receiver.h
index 5f0b151..a167c13 100644
--- a/modules/rtp_rtcp/source/rtcp_receiver.h
+++ b/modules/rtp_rtcp/source/rtcp_receiver.h
@@ -165,7 +165,8 @@
void HandleXrDlrrReportBlock(const rtcp::ReceiveTimeInfo& rti)
EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
- void HandleXrTargetBitrate(const rtcp::TargetBitrate& target_bitrate,
+ void HandleXrTargetBitrate(uint32_t ssrc,
+ const rtcp::TargetBitrate& target_bitrate,
PacketInformation* packet_information)
EXCLUSIVE_LOCKS_REQUIRED(rtcp_receiver_lock_);
diff --git a/modules/rtp_rtcp/source/rtcp_receiver_unittest.cc b/modules/rtp_rtcp/source/rtcp_receiver_unittest.cc
index 3ad333c..d42a74e 100644
--- a/modules/rtp_rtcp/source/rtcp_receiver_unittest.cc
+++ b/modules/rtp_rtcp/source/rtcp_receiver_unittest.cc
@@ -1225,6 +1225,15 @@
rtcp::ExtendedReports xr;
xr.SetTargetBitrate(bitrate);
+ // Wrong sender ssrc, target bitrate should be discarded.
+ xr.SetSenderSsrc(kSenderSsrc + 1);
+ EXPECT_CALL(bitrate_allocation_observer_,
+ OnBitrateAllocationUpdated(expected_allocation))
+ .Times(0);
+ InjectRtcpPacket(xr);
+
+ // Set correct ssrc, callback should be called once.
+ xr.SetSenderSsrc(kSenderSsrc);
EXPECT_CALL(bitrate_allocation_observer_,
OnBitrateAllocationUpdated(expected_allocation));
InjectRtcpPacket(xr);
@@ -1241,6 +1250,7 @@
rtcp::ExtendedReports xr;
xr.SetTargetBitrate(bitrate);
+ xr.SetSenderSsrc(kSenderSsrc);
EXPECT_CALL(bitrate_allocation_observer_,
OnBitrateAllocationUpdated(expected_allocation));