Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(600)

Side by Side Diff: webrtc/media/engine/webrtcvideoengine_unittest.cc

Issue 3010983002: Revert of Use RtxReceiveStream. (Closed)
Patch Set: Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/media/engine/webrtcvideoengine.cc ('k') | webrtc/video/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 if (cricket::CodecNamesEq(codec.name.c_str(), "rtx") && 76 if (cricket::CodecNamesEq(codec.name.c_str(), "rtx") &&
77 codec.GetParam(cricket::kCodecParamAssociatedPayloadType, 77 codec.GetParam(cricket::kCodecParamAssociatedPayloadType,
78 &associated_payload_type) && 78 &associated_payload_type) &&
79 associated_payload_type == payload_type) { 79 associated_payload_type == payload_type) {
80 return true; 80 return true;
81 } 81 }
82 } 82 }
83 return false; 83 return false;
84 } 84 }
85 85
86 // TODO(nisse): Duplicated in call.cc.
87 const int* FindKeyByValue(const std::map<int, int>& m, int v) {
88 for (const auto& kv : m) {
89 if (kv.second == v)
90 return &kv.first;
91 }
92 return nullptr;
93 }
94
95 bool HasRtxReceiveAssociation(
96 const webrtc::VideoReceiveStream::Config& config,
97 int payload_type) {
98 return FindKeyByValue(config.rtp.rtx_associated_payload_types,
99 payload_type) != nullptr;
100 }
101
102 // Check that there's an Rtx payload type for each decoder.
103 bool VerifyRtxReceiveAssociations(
104 const webrtc::VideoReceiveStream::Config& config) {
105 for (const auto& decoder : config.decoders) {
106 if (!HasRtxReceiveAssociation(config, decoder.payload_type))
107 return false;
108 }
109 return true;
110 }
111
112 rtc::scoped_refptr<webrtc::VideoFrameBuffer> CreateBlackFrameBuffer( 86 rtc::scoped_refptr<webrtc::VideoFrameBuffer> CreateBlackFrameBuffer(
113 int width, 87 int width,
114 int height) { 88 int height) {
115 rtc::scoped_refptr<webrtc::I420Buffer> buffer = 89 rtc::scoped_refptr<webrtc::I420Buffer> buffer =
116 webrtc::I420Buffer::Create(width, height); 90 webrtc::I420Buffer::Create(width, height);
117 webrtc::I420Buffer::SetBlack(buffer); 91 webrtc::I420Buffer::SetBlack(buffer);
118 return buffer; 92 return buffer;
119 } 93 }
120 94
121 void VerifySendStreamHasRtxTypes(const webrtc::VideoSendStream::Config& config, 95 void VerifySendStreamHasRtxTypes(const webrtc::VideoSendStream::Config& config,
122 const std::map<int, int>& rtx_types) { 96 const std::map<int, int>& rtx_types) {
123 std::map<int, int>::const_iterator it; 97 std::map<int, int>::const_iterator it;
124 it = rtx_types.find(config.encoder_settings.payload_type); 98 it = rtx_types.find(config.encoder_settings.payload_type);
125 EXPECT_TRUE(it != rtx_types.end() && 99 EXPECT_TRUE(it != rtx_types.end() &&
126 it->second == config.rtp.rtx.payload_type); 100 it->second == config.rtp.rtx.payload_type);
127 101
128 if (config.rtp.ulpfec.red_rtx_payload_type != -1) { 102 if (config.rtp.ulpfec.red_rtx_payload_type != -1) {
129 it = rtx_types.find(config.rtp.ulpfec.red_payload_type); 103 it = rtx_types.find(config.rtp.ulpfec.red_payload_type);
130 EXPECT_TRUE(it != rtx_types.end() && 104 EXPECT_TRUE(it != rtx_types.end() &&
131 it->second == config.rtp.ulpfec.red_rtx_payload_type); 105 it->second == config.rtp.ulpfec.red_rtx_payload_type);
132 } 106 }
133 } 107 }
134 108
135 cricket::MediaConfig GetMediaConfig() { 109 cricket::MediaConfig GetMediaConfig() {
136 cricket::MediaConfig media_config; 110 cricket::MediaConfig media_config;
137 media_config.video.enable_cpu_overuse_detection = false; 111 media_config.video.enable_cpu_overuse_detection = false;
138 return media_config; 112 return media_config;
139 } 113 }
140 114
115 // TODO(nisse): Duplicated in call.cc.
116 const int* FindKeyByValue(const std::map<int, int>& m, int v) {
117 for (const auto& kv : m) {
118 if (kv.second == v)
119 return &kv.first;
120 }
121 return nullptr;
122 }
123
141 } // namespace 124 } // namespace
142 125
143 namespace cricket { 126 namespace cricket {
144 class WebRtcVideoEngineTest : public ::testing::Test { 127 class WebRtcVideoEngineTest : public ::testing::Test {
145 public: 128 public:
146 WebRtcVideoEngineTest() : WebRtcVideoEngineTest("") {} 129 WebRtcVideoEngineTest() : WebRtcVideoEngineTest("") {}
147 explicit WebRtcVideoEngineTest(const char* field_trials) 130 explicit WebRtcVideoEngineTest(const char* field_trials)
148 : override_field_trials_(field_trials), 131 : override_field_trials_(field_trials),
149 call_(webrtc::Call::Create(webrtc::Call::Config(&event_log_))), 132 call_(webrtc::Call::Create(webrtc::Call::Config(&event_log_))),
150 engine_() { 133 engine_() {
(...skipping 1175 matching lines...) Expand 10 before | Expand all | Expand 10 after
1326 1309
1327 ASSERT_EQ(rtx_ssrcs.size(), send_stream->GetConfig().rtp.rtx.ssrcs.size()); 1310 ASSERT_EQ(rtx_ssrcs.size(), send_stream->GetConfig().rtp.rtx.ssrcs.size());
1328 for (size_t i = 0; i < rtx_ssrcs.size(); ++i) 1311 for (size_t i = 0; i < rtx_ssrcs.size(); ++i)
1329 EXPECT_EQ(rtx_ssrcs[i], send_stream->GetConfig().rtp.rtx.ssrcs[i]); 1312 EXPECT_EQ(rtx_ssrcs[i], send_stream->GetConfig().rtp.rtx.ssrcs[i]);
1330 1313
1331 // Receiver side. 1314 // Receiver side.
1332 FakeVideoReceiveStream* recv_stream = AddRecvStream( 1315 FakeVideoReceiveStream* recv_stream = AddRecvStream(
1333 cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs)); 1316 cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs));
1334 EXPECT_FALSE( 1317 EXPECT_FALSE(
1335 recv_stream->GetConfig().rtp.rtx_associated_payload_types.empty()); 1318 recv_stream->GetConfig().rtp.rtx_associated_payload_types.empty());
1336 EXPECT_TRUE(VerifyRtxReceiveAssociations(recv_stream->GetConfig())) 1319 EXPECT_EQ(recv_stream->GetConfig().decoders.size(),
1320 recv_stream->GetConfig().rtp.rtx_associated_payload_types.size())
1337 << "RTX should be mapped for all decoders/payload types."; 1321 << "RTX should be mapped for all decoders/payload types.";
1338 EXPECT_TRUE(HasRtxReceiveAssociation(recv_stream->GetConfig(),
1339 GetEngineCodec("red").id))
1340 << "RTX should be mapped for the RED payload type";
1341
1342 EXPECT_EQ(rtx_ssrcs[0], recv_stream->GetConfig().rtp.rtx_ssrc); 1322 EXPECT_EQ(rtx_ssrcs[0], recv_stream->GetConfig().rtp.rtx_ssrc);
1343 } 1323 }
1344 1324
1345 TEST_F(WebRtcVideoChannelTest, RecvStreamWithRtx) { 1325 TEST_F(WebRtcVideoChannelTest, RecvStreamWithRtx) {
1346 // Setup one channel with an associated RTX stream. 1326 // Setup one channel with an associated RTX stream.
1347 cricket::StreamParams params = 1327 cricket::StreamParams params =
1348 cricket::StreamParams::CreateLegacy(kSsrcs1[0]); 1328 cricket::StreamParams::CreateLegacy(kSsrcs1[0]);
1349 params.AddFidSsrc(kSsrcs1[0], kRtxSsrcs1[0]); 1329 params.AddFidSsrc(kSsrcs1[0], kRtxSsrcs1[0]);
1350 FakeVideoReceiveStream* recv_stream = AddRecvStream(params); 1330 FakeVideoReceiveStream* recv_stream = AddRecvStream(params);
1351 EXPECT_EQ(kRtxSsrcs1[0], recv_stream->GetConfig().rtp.rtx_ssrc); 1331 EXPECT_EQ(kRtxSsrcs1[0], recv_stream->GetConfig().rtp.rtx_ssrc);
1352
1353 EXPECT_TRUE(VerifyRtxReceiveAssociations(recv_stream->GetConfig()))
1354 << "RTX should be mapped for all decoders/payload types.";
1355 EXPECT_TRUE(HasRtxReceiveAssociation(recv_stream->GetConfig(),
1356 GetEngineCodec("red").id))
1357 << "RTX should be mapped for the RED payload type";
1358 } 1332 }
1359 1333
1360 TEST_F(WebRtcVideoChannelTest, RecvStreamNoRtx) { 1334 TEST_F(WebRtcVideoChannelTest, RecvStreamNoRtx) {
1361 // Setup one channel without an associated RTX stream. 1335 // Setup one channel without an associated RTX stream.
1362 cricket::StreamParams params = 1336 cricket::StreamParams params =
1363 cricket::StreamParams::CreateLegacy(kSsrcs1[0]); 1337 cricket::StreamParams::CreateLegacy(kSsrcs1[0]);
1364 FakeVideoReceiveStream* recv_stream = AddRecvStream(params); 1338 FakeVideoReceiveStream* recv_stream = AddRecvStream(params);
1365 ASSERT_EQ(0U, recv_stream->GetConfig().rtp.rtx_ssrc); 1339 ASSERT_EQ(0U, recv_stream->GetConfig().rtp.rtx_ssrc);
1366 } 1340 }
1367 1341
(...skipping 2447 matching lines...) Expand 10 before | Expand all | Expand 10 after
3815 EXPECT_EQ(0u, recv_stream->GetConfig().rtp.rtx_ssrc) 3789 EXPECT_EQ(0u, recv_stream->GetConfig().rtp.rtx_ssrc)
3816 << "Default receive stream should not have configured RTX"; 3790 << "Default receive stream should not have configured RTX";
3817 3791
3818 EXPECT_TRUE(channel_->AddRecvStream( 3792 EXPECT_TRUE(channel_->AddRecvStream(
3819 cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs))); 3793 cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs)));
3820 ASSERT_EQ(1u, fake_call_->GetVideoReceiveStreams().size()) 3794 ASSERT_EQ(1u, fake_call_->GetVideoReceiveStreams().size())
3821 << "AddRecvStream should have reconfigured, not added a new receiver."; 3795 << "AddRecvStream should have reconfigured, not added a new receiver.";
3822 recv_stream = fake_call_->GetVideoReceiveStreams()[0]; 3796 recv_stream = fake_call_->GetVideoReceiveStreams()[0];
3823 EXPECT_FALSE( 3797 EXPECT_FALSE(
3824 recv_stream->GetConfig().rtp.rtx_associated_payload_types.empty()); 3798 recv_stream->GetConfig().rtp.rtx_associated_payload_types.empty());
3825 EXPECT_TRUE(VerifyRtxReceiveAssociations(recv_stream->GetConfig())) 3799 EXPECT_EQ(recv_stream->GetConfig().decoders.size(),
3800 recv_stream->GetConfig().rtp.rtx_associated_payload_types.size())
3826 << "RTX should be mapped for all decoders/payload types."; 3801 << "RTX should be mapped for all decoders/payload types.";
3827 EXPECT_TRUE(HasRtxReceiveAssociation(recv_stream->GetConfig(),
3828 GetEngineCodec("red").id))
3829 << "RTX should be mapped also for the RED payload type";
3830 EXPECT_EQ(rtx_ssrcs[0], recv_stream->GetConfig().rtp.rtx_ssrc); 3802 EXPECT_EQ(rtx_ssrcs[0], recv_stream->GetConfig().rtp.rtx_ssrc);
3831 } 3803 }
3832 3804
3833 TEST_F(WebRtcVideoChannelTest, RejectsAddingStreamsWithMissingSsrcsForRtx) { 3805 TEST_F(WebRtcVideoChannelTest, RejectsAddingStreamsWithMissingSsrcsForRtx) {
3834 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); 3806 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
3835 3807
3836 const std::vector<uint32_t> ssrcs = MAKE_VECTOR(kSsrcs1); 3808 const std::vector<uint32_t> ssrcs = MAKE_VECTOR(kSsrcs1);
3837 const std::vector<uint32_t> rtx_ssrcs = MAKE_VECTOR(kRtxSsrcs1); 3809 const std::vector<uint32_t> rtx_ssrcs = MAKE_VECTOR(kRtxSsrcs1);
3838 3810
3839 StreamParams sp = 3811 StreamParams sp =
(...skipping 858 matching lines...) Expand 10 before | Expand all | Expand 10 after
4698 4670
4699 TEST_F(WebRtcVideoChannelSimulcastTest, 4671 TEST_F(WebRtcVideoChannelSimulcastTest,
4700 NoSimulcastScreenshareWithoutConference) { 4672 NoSimulcastScreenshareWithoutConference) {
4701 webrtc::test::ScopedFieldTrials override_field_trials_( 4673 webrtc::test::ScopedFieldTrials override_field_trials_(
4702 "WebRTC-SimulcastScreenshare/Enabled/"); 4674 "WebRTC-SimulcastScreenshare/Enabled/");
4703 VerifySimulcastSettings(cricket::VideoCodec("VP8"), 1280, 720, 3, 1, true, 4675 VerifySimulcastSettings(cricket::VideoCodec("VP8"), 1280, 720, 3, 1, true,
4704 false); 4676 false);
4705 } 4677 }
4706 4678
4707 } // namespace cricket 4679 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/media/engine/webrtcvideoengine.cc ('k') | webrtc/video/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698