Turning off a stream should results in target bitrate 0 signal

Bug: webrtc:9734, b:116850043
Change-Id: Ia7b4a8ecf2099c3026c83b06febca833d428d0a2
Reviewed-on: https://webrtc-review.googlesource.com/c/103981
Commit-Queue: Erik Språng <sprang@webrtc.org>
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25014}
This commit is contained in:
Erik Språng
2018-10-05 12:57:59 +02:00
committed by Commit Bot
parent be8b5348c7
commit 1cd7391c00
3 changed files with 59 additions and 10 deletions

View File

@ -681,4 +681,41 @@ TEST_F(RtcpSenderTest, SendImmediateXrWithTargetBitrate) {
EXPECT_TRUE(rtcp_sender_->TimeToSendRTCPReport(false));
}
TEST_F(RtcpSenderTest, SendTargetBitrateExplicitZeroOnStreamRemoval) {
// Set up and send a bitrate allocation with two layers.
rtcp_sender_->SetRTCPStatus(RtcpMode::kCompound);
VideoBitrateAllocation allocation;
allocation.SetBitrate(0, 0, 100000);
allocation.SetBitrate(1, 0, 200000);
rtcp_sender_->SetVideoBitrateAllocation(allocation);
EXPECT_EQ(0, rtcp_sender_->SendRTCP(feedback_state(), kRtcpReport));
absl::optional<rtcp::TargetBitrate> target_bitrate =
parser()->xr()->target_bitrate();
ASSERT_TRUE(target_bitrate);
std::vector<rtcp::TargetBitrate::BitrateItem> bitrates =
target_bitrate->GetTargetBitrates();
ASSERT_EQ(2u, bitrates.size());
EXPECT_EQ(bitrates[0].target_bitrate_kbps,
allocation.GetBitrate(0, 0) / 1000);
EXPECT_EQ(bitrates[1].target_bitrate_kbps,
allocation.GetBitrate(1, 0) / 1000);
// Create a new allocation, where the second stream is no longer available.
VideoBitrateAllocation new_allocation;
new_allocation.SetBitrate(0, 0, 150000);
rtcp_sender_->SetVideoBitrateAllocation(new_allocation);
EXPECT_EQ(0, rtcp_sender_->SendRTCP(feedback_state(), kRtcpReport));
target_bitrate = parser()->xr()->target_bitrate();
ASSERT_TRUE(target_bitrate);
bitrates = target_bitrate->GetTargetBitrates();
// Two bitrates should still be set, with an explicit entry indicating the
// removed stream is gone.
ASSERT_EQ(2u, bitrates.size());
EXPECT_EQ(bitrates[0].target_bitrate_kbps,
new_allocation.GetBitrate(0, 0) / 1000);
EXPECT_EQ(bitrates[1].target_bitrate_kbps, 0u);
}
} // namespace webrtc