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

Side by Side Diff: talk/media/webrtc/webrtcvideoengine2_unittest.cc

Issue 1430433004: Replace rtc::cricket::Settable with rtc::Maybe (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 1 month 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 * libjingle 2 * libjingle
3 * Copyright 2004 Google Inc. 3 * Copyright 2004 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 1056 matching lines...) Expand 10 before | Expand all | Expand 10 after
1067 } 1067 }
1068 1068
1069 void TestCpuAdaptation(bool enable_overuse, bool is_screenshare); 1069 void TestCpuAdaptation(bool enable_overuse, bool is_screenshare);
1070 void TestReceiverLocalSsrcConfiguration(bool receiver_first); 1070 void TestReceiverLocalSsrcConfiguration(bool receiver_first);
1071 void TestReceiveUnsignalledSsrcPacket(uint8_t payload_type, 1071 void TestReceiveUnsignalledSsrcPacket(uint8_t payload_type,
1072 bool expect_created_receive_stream); 1072 bool expect_created_receive_stream);
1073 1073
1074 FakeVideoSendStream* SetDenoisingOption( 1074 FakeVideoSendStream* SetDenoisingOption(
1075 const cricket::VideoSendParameters& parameters, bool enabled) { 1075 const cricket::VideoSendParameters& parameters, bool enabled) {
1076 cricket::VideoSendParameters params = parameters; 1076 cricket::VideoSendParameters params = parameters;
1077 params.options.video_noise_reduction.Set(enabled); 1077 params.options.video_noise_reduction = enabled;
1078 channel_->SetSendParameters(params); 1078 channel_->SetSendParameters(params);
1079 return fake_call_->GetVideoSendStreams().back(); 1079 return fake_call_->GetVideoSendStreams().back();
1080 } 1080 }
1081 1081
1082 FakeVideoSendStream* SetUpSimulcast(bool enabled, bool with_rtx) { 1082 FakeVideoSendStream* SetUpSimulcast(bool enabled, bool with_rtx) {
1083 const int kRtxSsrcOffset = 0xDEADBEEF; 1083 const int kRtxSsrcOffset = 0xDEADBEEF;
1084 last_ssrc_ += 3; 1084 last_ssrc_ += 3;
1085 std::vector<uint32_t> ssrcs; 1085 std::vector<uint32_t> ssrcs;
1086 std::vector<uint32_t> rtx_ssrcs; 1086 std::vector<uint32_t> rtx_ssrcs;
1087 uint32_t num_streams = enabled ? 3 : 1; 1087 uint32_t num_streams = enabled ? 3 : 1;
(...skipping 30 matching lines...) Expand all
1118 EXPECT_EQ(kSyncLabel, 1118 EXPECT_EQ(kSyncLabel,
1119 fake_call_->GetVideoReceiveStreams()[0]->GetConfig().sync_group) 1119 fake_call_->GetVideoReceiveStreams()[0]->GetConfig().sync_group)
1120 << "SyncGroup should be set based on sync_label"; 1120 << "SyncGroup should be set based on sync_label";
1121 } 1121 }
1122 1122
1123 TEST_F(WebRtcVideoChannel2Test, RecvStreamWithSimAndRtx) { 1123 TEST_F(WebRtcVideoChannel2Test, RecvStreamWithSimAndRtx) {
1124 cricket::VideoSendParameters parameters; 1124 cricket::VideoSendParameters parameters;
1125 parameters.codecs = engine_.codecs(); 1125 parameters.codecs = engine_.codecs();
1126 EXPECT_TRUE(channel_->SetSendParameters(parameters)); 1126 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1127 EXPECT_TRUE(channel_->SetSend(true)); 1127 EXPECT_TRUE(channel_->SetSend(true));
1128 parameters.options.conference_mode.Set(true); 1128 parameters.options.conference_mode = true;
1129 EXPECT_TRUE(channel_->SetSendParameters(parameters)); 1129 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1130 1130
1131 // Send side. 1131 // Send side.
1132 const std::vector<uint32_t> ssrcs = MAKE_VECTOR(kSsrcs1); 1132 const std::vector<uint32_t> ssrcs = MAKE_VECTOR(kSsrcs1);
1133 const std::vector<uint32_t> rtx_ssrcs = MAKE_VECTOR(kRtxSsrcs1); 1133 const std::vector<uint32_t> rtx_ssrcs = MAKE_VECTOR(kRtxSsrcs1);
1134 FakeVideoSendStream* send_stream = AddSendStream( 1134 FakeVideoSendStream* send_stream = AddSendStream(
1135 cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs)); 1135 cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs));
1136 1136
1137 ASSERT_EQ(rtx_ssrcs.size(), send_stream->GetConfig().rtp.rtx.ssrcs.size()); 1137 ASSERT_EQ(rtx_ssrcs.size(), send_stream->GetConfig().rtp.rtx.ssrcs.size());
1138 for (size_t i = 0; i < rtx_ssrcs.size(); ++i) 1138 for (size_t i = 0; i < rtx_ssrcs.size(); ++i)
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
1514 1514
1515 TEST_F(WebRtcVideoChannel2Test, DISABLED_SetBandwidthInConference) { 1515 TEST_F(WebRtcVideoChannel2Test, DISABLED_SetBandwidthInConference) {
1516 FAIL() << "Not implemented."; // TODO(pbos): Implement. 1516 FAIL() << "Not implemented."; // TODO(pbos): Implement.
1517 } 1517 }
1518 1518
1519 TEST_F(WebRtcVideoChannel2Test, UsesCorrectSettingsForScreencast) { 1519 TEST_F(WebRtcVideoChannel2Test, UsesCorrectSettingsForScreencast) {
1520 static const int kScreenshareMinBitrateKbps = 800; 1520 static const int kScreenshareMinBitrateKbps = 800;
1521 cricket::VideoCodec codec = kVp8Codec360p; 1521 cricket::VideoCodec codec = kVp8Codec360p;
1522 cricket::VideoSendParameters parameters; 1522 cricket::VideoSendParameters parameters;
1523 parameters.codecs.push_back(codec); 1523 parameters.codecs.push_back(codec);
1524 parameters.options.screencast_min_bitrate.Set(kScreenshareMinBitrateKbps); 1524 parameters.options.screencast_min_bitrate = kScreenshareMinBitrateKbps;
1525 EXPECT_TRUE(channel_->SetSendParameters(parameters)); 1525 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1526 1526
1527 AddSendStream(); 1527 AddSendStream();
1528 1528
1529 cricket::FakeVideoCapturer capturer; 1529 cricket::FakeVideoCapturer capturer;
1530 capturer.SetScreencast(false); 1530 capturer.SetScreencast(false);
1531 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer)); 1531 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer));
1532 cricket::VideoFormat capture_format_hd = 1532 cricket::VideoFormat capture_format_hd =
1533 capturer.GetSupportedFormats()->front(); 1533 capturer.GetSupportedFormats()->front();
1534 EXPECT_EQ(1280, capture_format_hd.width); 1534 EXPECT_EQ(1280, capture_format_hd.width);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1568 EXPECT_EQ(capture_format_hd.height, encoder_config.streams.front().height); 1568 EXPECT_EQ(capture_format_hd.height, encoder_config.streams.front().height);
1569 EXPECT_TRUE(encoder_config.streams[0].temporal_layer_thresholds_bps.empty()); 1569 EXPECT_TRUE(encoder_config.streams[0].temporal_layer_thresholds_bps.empty());
1570 1570
1571 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL)); 1571 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL));
1572 } 1572 }
1573 1573
1574 TEST_F(WebRtcVideoChannel2Test, 1574 TEST_F(WebRtcVideoChannel2Test,
1575 ConferenceModeScreencastConfiguresTemporalLayer) { 1575 ConferenceModeScreencastConfiguresTemporalLayer) {
1576 static const int kConferenceScreencastTemporalBitrateBps = 1576 static const int kConferenceScreencastTemporalBitrateBps =
1577 ScreenshareLayerConfig::GetDefault().tl0_bitrate_kbps * 1000; 1577 ScreenshareLayerConfig::GetDefault().tl0_bitrate_kbps * 1000;
1578 send_parameters_.options.conference_mode.Set(true); 1578 send_parameters_.options.conference_mode = true;
1579 channel_->SetSendParameters(send_parameters_); 1579 channel_->SetSendParameters(send_parameters_);
1580 1580
1581 AddSendStream(); 1581 AddSendStream();
1582 1582
1583 cricket::FakeVideoCapturer capturer; 1583 cricket::FakeVideoCapturer capturer;
1584 capturer.SetScreencast(true); 1584 capturer.SetScreencast(true);
1585 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer)); 1585 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer));
1586 cricket::VideoFormat capture_format_hd = 1586 cricket::VideoFormat capture_format_hd =
1587 capturer.GetSupportedFormats()->front(); 1587 capturer.GetSupportedFormats()->front();
1588 EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(capture_format_hd)); 1588 EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(capture_format_hd));
(...skipping 26 matching lines...) Expand all
1615 DISABLED_SetSendSsrcAfterCreatingReceiveChannel) { 1615 DISABLED_SetSendSsrcAfterCreatingReceiveChannel) {
1616 FAIL() << "Not implemented."; // TODO(pbos): Implement. 1616 FAIL() << "Not implemented."; // TODO(pbos): Implement.
1617 } 1617 }
1618 1618
1619 TEST_F(WebRtcVideoChannel2Test, SuspendBelowMinBitrateDisabledByDefault) { 1619 TEST_F(WebRtcVideoChannel2Test, SuspendBelowMinBitrateDisabledByDefault) {
1620 FakeVideoSendStream* stream = AddSendStream(); 1620 FakeVideoSendStream* stream = AddSendStream();
1621 EXPECT_FALSE(stream->GetConfig().suspend_below_min_bitrate); 1621 EXPECT_FALSE(stream->GetConfig().suspend_below_min_bitrate);
1622 } 1622 }
1623 1623
1624 TEST_F(WebRtcVideoChannel2Test, SetOptionsWithSuspendBelowMinBitrate) { 1624 TEST_F(WebRtcVideoChannel2Test, SetOptionsWithSuspendBelowMinBitrate) {
1625 send_parameters_.options.suspend_below_min_bitrate.Set(true); 1625 send_parameters_.options.suspend_below_min_bitrate = true;
1626 channel_->SetSendParameters(send_parameters_); 1626 channel_->SetSendParameters(send_parameters_);
1627 1627
1628 FakeVideoSendStream* stream = AddSendStream(); 1628 FakeVideoSendStream* stream = AddSendStream();
1629 EXPECT_TRUE(stream->GetConfig().suspend_below_min_bitrate); 1629 EXPECT_TRUE(stream->GetConfig().suspend_below_min_bitrate);
1630 1630
1631 send_parameters_.options.suspend_below_min_bitrate.Set(false); 1631 send_parameters_.options.suspend_below_min_bitrate = false;
1632 channel_->SetSendParameters(send_parameters_); 1632 channel_->SetSendParameters(send_parameters_);
1633 1633
1634 stream = fake_call_->GetVideoSendStreams()[0]; 1634 stream = fake_call_->GetVideoSendStreams()[0];
1635 EXPECT_FALSE(stream->GetConfig().suspend_below_min_bitrate); 1635 EXPECT_FALSE(stream->GetConfig().suspend_below_min_bitrate);
1636 } 1636 }
1637 1637
1638 TEST_F(WebRtcVideoChannel2Test, Vp8DenoisingEnabledByDefault) { 1638 TEST_F(WebRtcVideoChannel2Test, Vp8DenoisingEnabledByDefault) {
1639 FakeVideoSendStream* stream = AddSendStream(); 1639 FakeVideoSendStream* stream = AddSendStream();
1640 webrtc::VideoCodecVP8 vp8_settings; 1640 webrtc::VideoCodecVP8 vp8_settings;
1641 ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set."; 1641 ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set.";
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
1809 TEST_F(WebRtcVideoChannel2Test, DoesNotAdaptOnOveruseWhenScreensharing) { 1809 TEST_F(WebRtcVideoChannel2Test, DoesNotAdaptOnOveruseWhenScreensharing) {
1810 TestCpuAdaptation(true, true); 1810 TestCpuAdaptation(true, true);
1811 } 1811 }
1812 1812
1813 void WebRtcVideoChannel2Test::TestCpuAdaptation(bool enable_overuse, 1813 void WebRtcVideoChannel2Test::TestCpuAdaptation(bool enable_overuse,
1814 bool is_screenshare) { 1814 bool is_screenshare) {
1815 cricket::VideoCodec codec = kVp8Codec720p; 1815 cricket::VideoCodec codec = kVp8Codec720p;
1816 cricket::VideoSendParameters parameters; 1816 cricket::VideoSendParameters parameters;
1817 parameters.codecs.push_back(codec); 1817 parameters.codecs.push_back(codec);
1818 if (!enable_overuse) { 1818 if (!enable_overuse) {
1819 parameters.options.cpu_overuse_detection.Set(false); 1819 parameters.options.cpu_overuse_detection = false;
1820 } 1820 }
1821 EXPECT_TRUE(channel_->SetSendParameters(parameters)); 1821 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1822 1822
1823 AddSendStream(); 1823 AddSendStream();
1824 1824
1825 cricket::FakeVideoCapturer capturer; 1825 cricket::FakeVideoCapturer capturer;
1826 capturer.SetScreencast(is_screenshare); 1826 capturer.SetScreencast(is_screenshare);
1827 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer)); 1827 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer));
1828 EXPECT_EQ(cricket::CS_RUNNING, 1828 EXPECT_EQ(cricket::CS_RUNNING,
1829 capturer.Start(capturer.GetSupportedFormats()->front())); 1829 capturer.Start(capturer.GetSupportedFormats()->front()));
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
2331 } 2331 }
2332 2332
2333 // This test verifies DSCP settings are properly applied on video media channel. 2333 // This test verifies DSCP settings are properly applied on video media channel.
2334 TEST_F(WebRtcVideoChannel2Test, TestSetDscpOptions) { 2334 TEST_F(WebRtcVideoChannel2Test, TestSetDscpOptions) {
2335 rtc::scoped_ptr<cricket::FakeNetworkInterface> network_interface( 2335 rtc::scoped_ptr<cricket::FakeNetworkInterface> network_interface(
2336 new cricket::FakeNetworkInterface); 2336 new cricket::FakeNetworkInterface);
2337 channel_->SetInterface(network_interface.get()); 2337 channel_->SetInterface(network_interface.get());
2338 cricket::VideoSendParameters parameters = send_parameters_; 2338 cricket::VideoSendParameters parameters = send_parameters_;
2339 EXPECT_TRUE(channel_->SetSendParameters(parameters)); 2339 EXPECT_TRUE(channel_->SetSendParameters(parameters));
2340 EXPECT_EQ(rtc::DSCP_NO_CHANGE, network_interface->dscp()); 2340 EXPECT_EQ(rtc::DSCP_NO_CHANGE, network_interface->dscp());
2341 parameters.options.dscp.Set(true); 2341 parameters.options.dscp = true;
2342 EXPECT_TRUE(channel_->SetSendParameters(parameters)); 2342 EXPECT_TRUE(channel_->SetSendParameters(parameters));
2343 EXPECT_EQ(rtc::DSCP_AF41, network_interface->dscp()); 2343 EXPECT_EQ(rtc::DSCP_AF41, network_interface->dscp());
2344 // Verify previous value is not modified if dscp option is not set. 2344 // Verify previous value is not modified if dscp option is not set.
2345 cricket::VideoSendParameters parameters1 = send_parameters_; 2345 cricket::VideoSendParameters parameters1 = send_parameters_;
2346 EXPECT_TRUE(channel_->SetSendParameters(parameters1)); 2346 EXPECT_TRUE(channel_->SetSendParameters(parameters1));
2347 EXPECT_EQ(rtc::DSCP_AF41, network_interface->dscp()); 2347 EXPECT_EQ(rtc::DSCP_AF41, network_interface->dscp());
2348 parameters1.options.dscp.Set(false); 2348 parameters1.options.dscp = false;
2349 EXPECT_TRUE(channel_->SetSendParameters(parameters1)); 2349 EXPECT_TRUE(channel_->SetSendParameters(parameters1));
2350 EXPECT_EQ(rtc::DSCP_DEFAULT, network_interface->dscp()); 2350 EXPECT_EQ(rtc::DSCP_DEFAULT, network_interface->dscp());
2351 channel_->SetInterface(NULL); 2351 channel_->SetInterface(NULL);
2352 } 2352 }
2353 2353
2354 TEST_F(WebRtcVideoChannel2Test, OnReadyToSendSignalsNetworkState) { 2354 TEST_F(WebRtcVideoChannel2Test, OnReadyToSendSignalsNetworkState) {
2355 EXPECT_EQ(webrtc::kNetworkUp, fake_call_->GetNetworkState()); 2355 EXPECT_EQ(webrtc::kNetworkUp, fake_call_->GetNetworkState());
2356 2356
2357 channel_->OnReadyToSend(false); 2357 channel_->OnReadyToSend(false);
2358 EXPECT_EQ(webrtc::kNetworkDown, fake_call_->GetNetworkState()); 2358 EXPECT_EQ(webrtc::kNetworkDown, fake_call_->GetNetworkState());
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
2416 EXPECT_TRUE(channel_->SetCapturer(kSsrcs3[0], &video_capturer_vga)); 2416 EXPECT_TRUE(channel_->SetCapturer(kSsrcs3[0], &video_capturer_vga));
2417 EXPECT_TRUE(video_capturer_vga.CaptureFrame()); 2417 EXPECT_TRUE(video_capturer_vga.CaptureFrame());
2418 2418
2419 cricket::VideoCodec send_codec(100, "VP8", 640, 480, 30, 0); 2419 cricket::VideoCodec send_codec(100, "VP8", 640, 480, 30, 0);
2420 cricket::VideoSendParameters parameters; 2420 cricket::VideoSendParameters parameters;
2421 parameters.codecs.push_back(send_codec); 2421 parameters.codecs.push_back(send_codec);
2422 EXPECT_TRUE(channel_->SetSendParameters(parameters)); 2422 EXPECT_TRUE(channel_->SetSendParameters(parameters));
2423 EXPECT_TRUE(channel_->SetSend(true)); 2423 EXPECT_TRUE(channel_->SetSend(true));
2424 2424
2425 // Verify that the CpuOveruseObserver is registered and trigger downgrade. 2425 // Verify that the CpuOveruseObserver is registered and trigger downgrade.
2426 parameters.options.cpu_overuse_detection.Set(true); 2426 parameters.options.cpu_overuse_detection = true;
2427 EXPECT_TRUE(channel_->SetSendParameters(parameters)); 2427 EXPECT_TRUE(channel_->SetSendParameters(parameters));
2428 2428
2429 // Trigger overuse. 2429 // Trigger overuse.
2430 ASSERT_EQ(1u, fake_call_->GetVideoSendStreams().size()); 2430 ASSERT_EQ(1u, fake_call_->GetVideoSendStreams().size());
2431 webrtc::LoadObserver* overuse_callback = 2431 webrtc::LoadObserver* overuse_callback =
2432 fake_call_->GetVideoSendStreams().front()->GetConfig().overuse_callback; 2432 fake_call_->GetVideoSendStreams().front()->GetConfig().overuse_callback;
2433 ASSERT_TRUE(overuse_callback != NULL); 2433 ASSERT_TRUE(overuse_callback != NULL);
2434 overuse_callback->OnLoadUpdate(webrtc::LoadObserver::kOveruse); 2434 overuse_callback->OnLoadUpdate(webrtc::LoadObserver::kOveruse);
2435 2435
2436 // Capture format VGA -> adapt (OnCpuResolutionRequest downgrade) -> VGA/2. 2436 // Capture format VGA -> adapt (OnCpuResolutionRequest downgrade) -> VGA/2.
(...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after
3234 // Ensures that the correct settings are applied to the codec when two temporal 3234 // Ensures that the correct settings are applied to the codec when two temporal
3235 // layer screencasting is enabled, and that the correct simulcast settings are 3235 // layer screencasting is enabled, and that the correct simulcast settings are
3236 // reapplied when disabling screencasting. 3236 // reapplied when disabling screencasting.
3237 TEST_F(WebRtcVideoChannel2SimulcastTest, 3237 TEST_F(WebRtcVideoChannel2SimulcastTest,
3238 DISABLED_TwoTemporalLayerScreencastSettings) { 3238 DISABLED_TwoTemporalLayerScreencastSettings) {
3239 // TODO(pbos): Implement. 3239 // TODO(pbos): Implement.
3240 FAIL() << "Not implemented."; 3240 FAIL() << "Not implemented.";
3241 } 3241 }
3242 3242
3243 } // namespace cricket 3243 } // namespace cricket
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698