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

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

Issue 3008773002: Use RtxReceiveStream. (Closed)
Patch Set: Improve TODO comments. 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
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
86 rtc::scoped_refptr<webrtc::VideoFrameBuffer> CreateBlackFrameBuffer( 112 rtc::scoped_refptr<webrtc::VideoFrameBuffer> CreateBlackFrameBuffer(
87 int width, 113 int width,
88 int height) { 114 int height) {
89 rtc::scoped_refptr<webrtc::I420Buffer> buffer = 115 rtc::scoped_refptr<webrtc::I420Buffer> buffer =
90 webrtc::I420Buffer::Create(width, height); 116 webrtc::I420Buffer::Create(width, height);
91 webrtc::I420Buffer::SetBlack(buffer); 117 webrtc::I420Buffer::SetBlack(buffer);
92 return buffer; 118 return buffer;
93 } 119 }
94 120
95 void VerifySendStreamHasRtxTypes(const webrtc::VideoSendStream::Config& config, 121 void VerifySendStreamHasRtxTypes(const webrtc::VideoSendStream::Config& config,
96 const std::map<int, int>& rtx_types) { 122 const std::map<int, int>& rtx_types) {
97 std::map<int, int>::const_iterator it; 123 std::map<int, int>::const_iterator it;
98 it = rtx_types.find(config.encoder_settings.payload_type); 124 it = rtx_types.find(config.encoder_settings.payload_type);
99 EXPECT_TRUE(it != rtx_types.end() && 125 EXPECT_TRUE(it != rtx_types.end() &&
100 it->second == config.rtp.rtx.payload_type); 126 it->second == config.rtp.rtx.payload_type);
101 127
102 if (config.rtp.ulpfec.red_rtx_payload_type != -1) { 128 if (config.rtp.ulpfec.red_rtx_payload_type != -1) {
103 it = rtx_types.find(config.rtp.ulpfec.red_payload_type); 129 it = rtx_types.find(config.rtp.ulpfec.red_payload_type);
104 EXPECT_TRUE(it != rtx_types.end() && 130 EXPECT_TRUE(it != rtx_types.end() &&
105 it->second == config.rtp.ulpfec.red_rtx_payload_type); 131 it->second == config.rtp.ulpfec.red_rtx_payload_type);
106 } 132 }
107 } 133 }
108 134
109 cricket::MediaConfig GetMediaConfig() { 135 cricket::MediaConfig GetMediaConfig() {
110 cricket::MediaConfig media_config; 136 cricket::MediaConfig media_config;
111 media_config.video.enable_cpu_overuse_detection = false; 137 media_config.video.enable_cpu_overuse_detection = false;
112 return media_config; 138 return media_config;
113 } 139 }
114 140
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
124 } // namespace 141 } // namespace
125 142
126 namespace cricket { 143 namespace cricket {
127 class WebRtcVideoEngineTest : public ::testing::Test { 144 class WebRtcVideoEngineTest : public ::testing::Test {
128 public: 145 public:
129 WebRtcVideoEngineTest() : WebRtcVideoEngineTest("") {} 146 WebRtcVideoEngineTest() : WebRtcVideoEngineTest("") {}
130 explicit WebRtcVideoEngineTest(const char* field_trials) 147 explicit WebRtcVideoEngineTest(const char* field_trials)
131 : override_field_trials_(field_trials), 148 : override_field_trials_(field_trials),
132 call_(webrtc::Call::Create(webrtc::Call::Config(&event_log_))), 149 call_(webrtc::Call::Create(webrtc::Call::Config(&event_log_))),
133 engine_() { 150 engine_() {
(...skipping 1175 matching lines...) Expand 10 before | Expand all | Expand 10 after
1309 1326
1310 ASSERT_EQ(rtx_ssrcs.size(), send_stream->GetConfig().rtp.rtx.ssrcs.size()); 1327 ASSERT_EQ(rtx_ssrcs.size(), send_stream->GetConfig().rtp.rtx.ssrcs.size());
1311 for (size_t i = 0; i < rtx_ssrcs.size(); ++i) 1328 for (size_t i = 0; i < rtx_ssrcs.size(); ++i)
1312 EXPECT_EQ(rtx_ssrcs[i], send_stream->GetConfig().rtp.rtx.ssrcs[i]); 1329 EXPECT_EQ(rtx_ssrcs[i], send_stream->GetConfig().rtp.rtx.ssrcs[i]);
1313 1330
1314 // Receiver side. 1331 // Receiver side.
1315 FakeVideoReceiveStream* recv_stream = AddRecvStream( 1332 FakeVideoReceiveStream* recv_stream = AddRecvStream(
1316 cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs)); 1333 cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs));
1317 EXPECT_FALSE( 1334 EXPECT_FALSE(
1318 recv_stream->GetConfig().rtp.rtx_associated_payload_types.empty()); 1335 recv_stream->GetConfig().rtp.rtx_associated_payload_types.empty());
1319 EXPECT_EQ(recv_stream->GetConfig().decoders.size(), 1336 EXPECT_TRUE(VerifyRtxReceiveAssociations(recv_stream->GetConfig()))
1320 recv_stream->GetConfig().rtp.rtx_associated_payload_types.size())
1321 << "RTX should be mapped for all decoders/payload types."; 1337 << "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
1322 EXPECT_EQ(rtx_ssrcs[0], recv_stream->GetConfig().rtp.rtx_ssrc); 1342 EXPECT_EQ(rtx_ssrcs[0], recv_stream->GetConfig().rtp.rtx_ssrc);
1323 } 1343 }
1324 1344
1325 TEST_F(WebRtcVideoChannelTest, RecvStreamWithRtx) { 1345 TEST_F(WebRtcVideoChannelTest, RecvStreamWithRtx) {
1326 // Setup one channel with an associated RTX stream. 1346 // Setup one channel with an associated RTX stream.
1327 cricket::StreamParams params = 1347 cricket::StreamParams params =
1328 cricket::StreamParams::CreateLegacy(kSsrcs1[0]); 1348 cricket::StreamParams::CreateLegacy(kSsrcs1[0]);
1329 params.AddFidSsrc(kSsrcs1[0], kRtxSsrcs1[0]); 1349 params.AddFidSsrc(kSsrcs1[0], kRtxSsrcs1[0]);
1330 FakeVideoReceiveStream* recv_stream = AddRecvStream(params); 1350 FakeVideoReceiveStream* recv_stream = AddRecvStream(params);
1331 EXPECT_EQ(kRtxSsrcs1[0], recv_stream->GetConfig().rtp.rtx_ssrc); 1351 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";
1332 } 1358 }
1333 1359
1334 TEST_F(WebRtcVideoChannelTest, RecvStreamNoRtx) { 1360 TEST_F(WebRtcVideoChannelTest, RecvStreamNoRtx) {
1335 // Setup one channel without an associated RTX stream. 1361 // Setup one channel without an associated RTX stream.
1336 cricket::StreamParams params = 1362 cricket::StreamParams params =
1337 cricket::StreamParams::CreateLegacy(kSsrcs1[0]); 1363 cricket::StreamParams::CreateLegacy(kSsrcs1[0]);
1338 FakeVideoReceiveStream* recv_stream = AddRecvStream(params); 1364 FakeVideoReceiveStream* recv_stream = AddRecvStream(params);
1339 ASSERT_EQ(0U, recv_stream->GetConfig().rtp.rtx_ssrc); 1365 ASSERT_EQ(0U, recv_stream->GetConfig().rtp.rtx_ssrc);
1340 } 1366 }
1341 1367
(...skipping 2447 matching lines...) Expand 10 before | Expand all | Expand 10 after
3789 EXPECT_EQ(0u, recv_stream->GetConfig().rtp.rtx_ssrc) 3815 EXPECT_EQ(0u, recv_stream->GetConfig().rtp.rtx_ssrc)
3790 << "Default receive stream should not have configured RTX"; 3816 << "Default receive stream should not have configured RTX";
3791 3817
3792 EXPECT_TRUE(channel_->AddRecvStream( 3818 EXPECT_TRUE(channel_->AddRecvStream(
3793 cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs))); 3819 cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs)));
3794 ASSERT_EQ(1u, fake_call_->GetVideoReceiveStreams().size()) 3820 ASSERT_EQ(1u, fake_call_->GetVideoReceiveStreams().size())
3795 << "AddRecvStream should have reconfigured, not added a new receiver."; 3821 << "AddRecvStream should have reconfigured, not added a new receiver.";
3796 recv_stream = fake_call_->GetVideoReceiveStreams()[0]; 3822 recv_stream = fake_call_->GetVideoReceiveStreams()[0];
3797 EXPECT_FALSE( 3823 EXPECT_FALSE(
3798 recv_stream->GetConfig().rtp.rtx_associated_payload_types.empty()); 3824 recv_stream->GetConfig().rtp.rtx_associated_payload_types.empty());
3799 EXPECT_EQ(recv_stream->GetConfig().decoders.size(), 3825 EXPECT_TRUE(VerifyRtxReceiveAssociations(recv_stream->GetConfig()))
3800 recv_stream->GetConfig().rtp.rtx_associated_payload_types.size())
3801 << "RTX should be mapped for all decoders/payload types."; 3826 << "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";
3802 EXPECT_EQ(rtx_ssrcs[0], recv_stream->GetConfig().rtp.rtx_ssrc); 3830 EXPECT_EQ(rtx_ssrcs[0], recv_stream->GetConfig().rtp.rtx_ssrc);
3803 } 3831 }
3804 3832
3805 TEST_F(WebRtcVideoChannelTest, RejectsAddingStreamsWithMissingSsrcsForRtx) { 3833 TEST_F(WebRtcVideoChannelTest, RejectsAddingStreamsWithMissingSsrcsForRtx) {
3806 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); 3834 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
3807 3835
3808 const std::vector<uint32_t> ssrcs = MAKE_VECTOR(kSsrcs1); 3836 const std::vector<uint32_t> ssrcs = MAKE_VECTOR(kSsrcs1);
3809 const std::vector<uint32_t> rtx_ssrcs = MAKE_VECTOR(kRtxSsrcs1); 3837 const std::vector<uint32_t> rtx_ssrcs = MAKE_VECTOR(kRtxSsrcs1);
3810 3838
3811 StreamParams sp = 3839 StreamParams sp =
(...skipping 858 matching lines...) Expand 10 before | Expand all | Expand 10 after
4670 4698
4671 TEST_F(WebRtcVideoChannelSimulcastTest, 4699 TEST_F(WebRtcVideoChannelSimulcastTest,
4672 NoSimulcastScreenshareWithoutConference) { 4700 NoSimulcastScreenshareWithoutConference) {
4673 webrtc::test::ScopedFieldTrials override_field_trials_( 4701 webrtc::test::ScopedFieldTrials override_field_trials_(
4674 "WebRTC-SimulcastScreenshare/Enabled/"); 4702 "WebRTC-SimulcastScreenshare/Enabled/");
4675 VerifySimulcastSettings(cricket::VideoCodec("VP8"), 1280, 720, 3, 1, true, 4703 VerifySimulcastSettings(cricket::VideoCodec("VP8"), 1280, 720, 3, 1, true,
4676 false); 4704 false);
4677 } 4705 }
4678 4706
4679 } // namespace cricket 4707 } // namespace cricket
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698