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

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

Issue 1432553007: Rename Maybe to Optional (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase 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
« no previous file with comments | « talk/media/webrtc/webrtcvideoengine2.cc ('k') | talk/media/webrtc/webrtcvoiceengine.h » ('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 * 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 1079 matching lines...) Expand 10 before | Expand all | Expand 10 after
1090 } 1090 }
1091 1091
1092 void TestCpuAdaptation(bool enable_overuse, bool is_screenshare); 1092 void TestCpuAdaptation(bool enable_overuse, bool is_screenshare);
1093 void TestReceiverLocalSsrcConfiguration(bool receiver_first); 1093 void TestReceiverLocalSsrcConfiguration(bool receiver_first);
1094 void TestReceiveUnsignalledSsrcPacket(uint8_t payload_type, 1094 void TestReceiveUnsignalledSsrcPacket(uint8_t payload_type,
1095 bool expect_created_receive_stream); 1095 bool expect_created_receive_stream);
1096 1096
1097 FakeVideoSendStream* SetDenoisingOption( 1097 FakeVideoSendStream* SetDenoisingOption(
1098 const cricket::VideoSendParameters& parameters, bool enabled) { 1098 const cricket::VideoSendParameters& parameters, bool enabled) {
1099 cricket::VideoSendParameters params = parameters; 1099 cricket::VideoSendParameters params = parameters;
1100 params.options.video_noise_reduction = rtc::Maybe<bool>(enabled); 1100 params.options.video_noise_reduction = rtc::Optional<bool>(enabled);
1101 channel_->SetSendParameters(params); 1101 channel_->SetSendParameters(params);
1102 return fake_call_->GetVideoSendStreams().back(); 1102 return fake_call_->GetVideoSendStreams().back();
1103 } 1103 }
1104 1104
1105 FakeVideoSendStream* SetUpSimulcast(bool enabled, bool with_rtx) { 1105 FakeVideoSendStream* SetUpSimulcast(bool enabled, bool with_rtx) {
1106 const int kRtxSsrcOffset = 0xDEADBEEF; 1106 const int kRtxSsrcOffset = 0xDEADBEEF;
1107 last_ssrc_ += 3; 1107 last_ssrc_ += 3;
1108 std::vector<uint32_t> ssrcs; 1108 std::vector<uint32_t> ssrcs;
1109 std::vector<uint32_t> rtx_ssrcs; 1109 std::vector<uint32_t> rtx_ssrcs;
1110 uint32_t num_streams = enabled ? 3 : 1; 1110 uint32_t num_streams = enabled ? 3 : 1;
(...skipping 30 matching lines...) Expand all
1141 EXPECT_EQ(kSyncLabel, 1141 EXPECT_EQ(kSyncLabel,
1142 fake_call_->GetVideoReceiveStreams()[0]->GetConfig().sync_group) 1142 fake_call_->GetVideoReceiveStreams()[0]->GetConfig().sync_group)
1143 << "SyncGroup should be set based on sync_label"; 1143 << "SyncGroup should be set based on sync_label";
1144 } 1144 }
1145 1145
1146 TEST_F(WebRtcVideoChannel2Test, RecvStreamWithSimAndRtx) { 1146 TEST_F(WebRtcVideoChannel2Test, RecvStreamWithSimAndRtx) {
1147 cricket::VideoSendParameters parameters; 1147 cricket::VideoSendParameters parameters;
1148 parameters.codecs = engine_.codecs(); 1148 parameters.codecs = engine_.codecs();
1149 EXPECT_TRUE(channel_->SetSendParameters(parameters)); 1149 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1150 EXPECT_TRUE(channel_->SetSend(true)); 1150 EXPECT_TRUE(channel_->SetSend(true));
1151 parameters.options.conference_mode = rtc::Maybe<bool>(true); 1151 parameters.options.conference_mode = rtc::Optional<bool>(true);
1152 EXPECT_TRUE(channel_->SetSendParameters(parameters)); 1152 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1153 1153
1154 // Send side. 1154 // Send side.
1155 const std::vector<uint32_t> ssrcs = MAKE_VECTOR(kSsrcs1); 1155 const std::vector<uint32_t> ssrcs = MAKE_VECTOR(kSsrcs1);
1156 const std::vector<uint32_t> rtx_ssrcs = MAKE_VECTOR(kRtxSsrcs1); 1156 const std::vector<uint32_t> rtx_ssrcs = MAKE_VECTOR(kRtxSsrcs1);
1157 FakeVideoSendStream* send_stream = AddSendStream( 1157 FakeVideoSendStream* send_stream = AddSendStream(
1158 cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs)); 1158 cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs));
1159 1159
1160 ASSERT_EQ(rtx_ssrcs.size(), send_stream->GetConfig().rtp.rtx.ssrcs.size()); 1160 ASSERT_EQ(rtx_ssrcs.size(), send_stream->GetConfig().rtp.rtx.ssrcs.size());
1161 for (size_t i = 0; i < rtx_ssrcs.size(); ++i) 1161 for (size_t i = 0; i < rtx_ssrcs.size(); ++i)
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
1552 TEST_F(WebRtcVideoChannel2Test, DISABLED_SetBandwidthInConference) { 1552 TEST_F(WebRtcVideoChannel2Test, DISABLED_SetBandwidthInConference) {
1553 FAIL() << "Not implemented."; // TODO(pbos): Implement. 1553 FAIL() << "Not implemented."; // TODO(pbos): Implement.
1554 } 1554 }
1555 1555
1556 TEST_F(WebRtcVideoChannel2Test, UsesCorrectSettingsForScreencast) { 1556 TEST_F(WebRtcVideoChannel2Test, UsesCorrectSettingsForScreencast) {
1557 static const int kScreenshareMinBitrateKbps = 800; 1557 static const int kScreenshareMinBitrateKbps = 800;
1558 cricket::VideoCodec codec = kVp8Codec360p; 1558 cricket::VideoCodec codec = kVp8Codec360p;
1559 cricket::VideoSendParameters parameters; 1559 cricket::VideoSendParameters parameters;
1560 parameters.codecs.push_back(codec); 1560 parameters.codecs.push_back(codec);
1561 parameters.options.screencast_min_bitrate = 1561 parameters.options.screencast_min_bitrate =
1562 rtc::Maybe<int>(kScreenshareMinBitrateKbps); 1562 rtc::Optional<int>(kScreenshareMinBitrateKbps);
1563 EXPECT_TRUE(channel_->SetSendParameters(parameters)); 1563 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1564 1564
1565 AddSendStream(); 1565 AddSendStream();
1566 1566
1567 cricket::FakeVideoCapturer capturer; 1567 cricket::FakeVideoCapturer capturer;
1568 capturer.SetScreencast(false); 1568 capturer.SetScreencast(false);
1569 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer)); 1569 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer));
1570 cricket::VideoFormat capture_format_hd = 1570 cricket::VideoFormat capture_format_hd =
1571 capturer.GetSupportedFormats()->front(); 1571 capturer.GetSupportedFormats()->front();
1572 EXPECT_EQ(1280, capture_format_hd.width); 1572 EXPECT_EQ(1280, capture_format_hd.width);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1606 EXPECT_EQ(capture_format_hd.height, encoder_config.streams.front().height); 1606 EXPECT_EQ(capture_format_hd.height, encoder_config.streams.front().height);
1607 EXPECT_TRUE(encoder_config.streams[0].temporal_layer_thresholds_bps.empty()); 1607 EXPECT_TRUE(encoder_config.streams[0].temporal_layer_thresholds_bps.empty());
1608 1608
1609 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL)); 1609 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, NULL));
1610 } 1610 }
1611 1611
1612 TEST_F(WebRtcVideoChannel2Test, 1612 TEST_F(WebRtcVideoChannel2Test,
1613 ConferenceModeScreencastConfiguresTemporalLayer) { 1613 ConferenceModeScreencastConfiguresTemporalLayer) {
1614 static const int kConferenceScreencastTemporalBitrateBps = 1614 static const int kConferenceScreencastTemporalBitrateBps =
1615 ScreenshareLayerConfig::GetDefault().tl0_bitrate_kbps * 1000; 1615 ScreenshareLayerConfig::GetDefault().tl0_bitrate_kbps * 1000;
1616 send_parameters_.options.conference_mode = rtc::Maybe<bool>(true); 1616 send_parameters_.options.conference_mode = rtc::Optional<bool>(true);
1617 channel_->SetSendParameters(send_parameters_); 1617 channel_->SetSendParameters(send_parameters_);
1618 1618
1619 AddSendStream(); 1619 AddSendStream();
1620 1620
1621 cricket::FakeVideoCapturer capturer; 1621 cricket::FakeVideoCapturer capturer;
1622 capturer.SetScreencast(true); 1622 capturer.SetScreencast(true);
1623 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer)); 1623 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer));
1624 cricket::VideoFormat capture_format_hd = 1624 cricket::VideoFormat capture_format_hd =
1625 capturer.GetSupportedFormats()->front(); 1625 capturer.GetSupportedFormats()->front();
1626 EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(capture_format_hd)); 1626 EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(capture_format_hd));
(...skipping 26 matching lines...) Expand all
1653 DISABLED_SetSendSsrcAfterCreatingReceiveChannel) { 1653 DISABLED_SetSendSsrcAfterCreatingReceiveChannel) {
1654 FAIL() << "Not implemented."; // TODO(pbos): Implement. 1654 FAIL() << "Not implemented."; // TODO(pbos): Implement.
1655 } 1655 }
1656 1656
1657 TEST_F(WebRtcVideoChannel2Test, SuspendBelowMinBitrateDisabledByDefault) { 1657 TEST_F(WebRtcVideoChannel2Test, SuspendBelowMinBitrateDisabledByDefault) {
1658 FakeVideoSendStream* stream = AddSendStream(); 1658 FakeVideoSendStream* stream = AddSendStream();
1659 EXPECT_FALSE(stream->GetConfig().suspend_below_min_bitrate); 1659 EXPECT_FALSE(stream->GetConfig().suspend_below_min_bitrate);
1660 } 1660 }
1661 1661
1662 TEST_F(WebRtcVideoChannel2Test, SetOptionsWithSuspendBelowMinBitrate) { 1662 TEST_F(WebRtcVideoChannel2Test, SetOptionsWithSuspendBelowMinBitrate) {
1663 send_parameters_.options.suspend_below_min_bitrate = rtc::Maybe<bool>(true); 1663 send_parameters_.options.suspend_below_min_bitrate =
1664 rtc::Optional<bool>(true);
1664 channel_->SetSendParameters(send_parameters_); 1665 channel_->SetSendParameters(send_parameters_);
1665 1666
1666 FakeVideoSendStream* stream = AddSendStream(); 1667 FakeVideoSendStream* stream = AddSendStream();
1667 EXPECT_TRUE(stream->GetConfig().suspend_below_min_bitrate); 1668 EXPECT_TRUE(stream->GetConfig().suspend_below_min_bitrate);
1668 1669
1669 send_parameters_.options.suspend_below_min_bitrate = rtc::Maybe<bool>(false); 1670 send_parameters_.options.suspend_below_min_bitrate =
1671 rtc::Optional<bool>(false);
1670 channel_->SetSendParameters(send_parameters_); 1672 channel_->SetSendParameters(send_parameters_);
1671 1673
1672 stream = fake_call_->GetVideoSendStreams()[0]; 1674 stream = fake_call_->GetVideoSendStreams()[0];
1673 EXPECT_FALSE(stream->GetConfig().suspend_below_min_bitrate); 1675 EXPECT_FALSE(stream->GetConfig().suspend_below_min_bitrate);
1674 } 1676 }
1675 1677
1676 TEST_F(WebRtcVideoChannel2Test, Vp8DenoisingEnabledByDefault) { 1678 TEST_F(WebRtcVideoChannel2Test, Vp8DenoisingEnabledByDefault) {
1677 FakeVideoSendStream* stream = AddSendStream(); 1679 FakeVideoSendStream* stream = AddSendStream();
1678 webrtc::VideoCodecVP8 vp8_settings; 1680 webrtc::VideoCodecVP8 vp8_settings;
1679 ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set."; 1681 ASSERT_TRUE(stream->GetVp8Settings(&vp8_settings)) << "No VP8 config set.";
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
1847 TEST_F(WebRtcVideoChannel2Test, DoesNotAdaptOnOveruseWhenScreensharing) { 1849 TEST_F(WebRtcVideoChannel2Test, DoesNotAdaptOnOveruseWhenScreensharing) {
1848 TestCpuAdaptation(true, true); 1850 TestCpuAdaptation(true, true);
1849 } 1851 }
1850 1852
1851 void WebRtcVideoChannel2Test::TestCpuAdaptation(bool enable_overuse, 1853 void WebRtcVideoChannel2Test::TestCpuAdaptation(bool enable_overuse,
1852 bool is_screenshare) { 1854 bool is_screenshare) {
1853 cricket::VideoCodec codec = kVp8Codec720p; 1855 cricket::VideoCodec codec = kVp8Codec720p;
1854 cricket::VideoSendParameters parameters; 1856 cricket::VideoSendParameters parameters;
1855 parameters.codecs.push_back(codec); 1857 parameters.codecs.push_back(codec);
1856 if (!enable_overuse) { 1858 if (!enable_overuse) {
1857 parameters.options.cpu_overuse_detection = rtc::Maybe<bool>(false); 1859 parameters.options.cpu_overuse_detection = rtc::Optional<bool>(false);
1858 } 1860 }
1859 EXPECT_TRUE(channel_->SetSendParameters(parameters)); 1861 EXPECT_TRUE(channel_->SetSendParameters(parameters));
1860 1862
1861 AddSendStream(); 1863 AddSendStream();
1862 1864
1863 cricket::FakeVideoCapturer capturer; 1865 cricket::FakeVideoCapturer capturer;
1864 capturer.SetScreencast(is_screenshare); 1866 capturer.SetScreencast(is_screenshare);
1865 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer)); 1867 EXPECT_TRUE(channel_->SetCapturer(last_ssrc_, &capturer));
1866 EXPECT_EQ(cricket::CS_RUNNING, 1868 EXPECT_EQ(cricket::CS_RUNNING,
1867 capturer.Start(capturer.GetSupportedFormats()->front())); 1869 capturer.Start(capturer.GetSupportedFormats()->front()));
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
2369 } 2371 }
2370 2372
2371 // This test verifies DSCP settings are properly applied on video media channel. 2373 // This test verifies DSCP settings are properly applied on video media channel.
2372 TEST_F(WebRtcVideoChannel2Test, TestSetDscpOptions) { 2374 TEST_F(WebRtcVideoChannel2Test, TestSetDscpOptions) {
2373 rtc::scoped_ptr<cricket::FakeNetworkInterface> network_interface( 2375 rtc::scoped_ptr<cricket::FakeNetworkInterface> network_interface(
2374 new cricket::FakeNetworkInterface); 2376 new cricket::FakeNetworkInterface);
2375 channel_->SetInterface(network_interface.get()); 2377 channel_->SetInterface(network_interface.get());
2376 cricket::VideoSendParameters parameters = send_parameters_; 2378 cricket::VideoSendParameters parameters = send_parameters_;
2377 EXPECT_TRUE(channel_->SetSendParameters(parameters)); 2379 EXPECT_TRUE(channel_->SetSendParameters(parameters));
2378 EXPECT_EQ(rtc::DSCP_NO_CHANGE, network_interface->dscp()); 2380 EXPECT_EQ(rtc::DSCP_NO_CHANGE, network_interface->dscp());
2379 parameters.options.dscp = rtc::Maybe<bool>(true); 2381 parameters.options.dscp = rtc::Optional<bool>(true);
2380 EXPECT_TRUE(channel_->SetSendParameters(parameters)); 2382 EXPECT_TRUE(channel_->SetSendParameters(parameters));
2381 EXPECT_EQ(rtc::DSCP_AF41, network_interface->dscp()); 2383 EXPECT_EQ(rtc::DSCP_AF41, network_interface->dscp());
2382 // Verify previous value is not modified if dscp option is not set. 2384 // Verify previous value is not modified if dscp option is not set.
2383 cricket::VideoSendParameters parameters1 = send_parameters_; 2385 cricket::VideoSendParameters parameters1 = send_parameters_;
2384 EXPECT_TRUE(channel_->SetSendParameters(parameters1)); 2386 EXPECT_TRUE(channel_->SetSendParameters(parameters1));
2385 EXPECT_EQ(rtc::DSCP_AF41, network_interface->dscp()); 2387 EXPECT_EQ(rtc::DSCP_AF41, network_interface->dscp());
2386 parameters1.options.dscp = rtc::Maybe<bool>(false); 2388 parameters1.options.dscp = rtc::Optional<bool>(false);
2387 EXPECT_TRUE(channel_->SetSendParameters(parameters1)); 2389 EXPECT_TRUE(channel_->SetSendParameters(parameters1));
2388 EXPECT_EQ(rtc::DSCP_DEFAULT, network_interface->dscp()); 2390 EXPECT_EQ(rtc::DSCP_DEFAULT, network_interface->dscp());
2389 channel_->SetInterface(NULL); 2391 channel_->SetInterface(NULL);
2390 } 2392 }
2391 2393
2392 TEST_F(WebRtcVideoChannel2Test, OnReadyToSendSignalsNetworkState) { 2394 TEST_F(WebRtcVideoChannel2Test, OnReadyToSendSignalsNetworkState) {
2393 EXPECT_EQ(webrtc::kNetworkUp, fake_call_->GetNetworkState()); 2395 EXPECT_EQ(webrtc::kNetworkUp, fake_call_->GetNetworkState());
2394 2396
2395 channel_->OnReadyToSend(false); 2397 channel_->OnReadyToSend(false);
2396 EXPECT_EQ(webrtc::kNetworkDown, fake_call_->GetNetworkState()); 2398 EXPECT_EQ(webrtc::kNetworkDown, fake_call_->GetNetworkState());
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
2454 EXPECT_TRUE(channel_->SetCapturer(kSsrcs3[0], &video_capturer_vga)); 2456 EXPECT_TRUE(channel_->SetCapturer(kSsrcs3[0], &video_capturer_vga));
2455 EXPECT_TRUE(video_capturer_vga.CaptureFrame()); 2457 EXPECT_TRUE(video_capturer_vga.CaptureFrame());
2456 2458
2457 cricket::VideoCodec send_codec(100, "VP8", 640, 480, 30, 0); 2459 cricket::VideoCodec send_codec(100, "VP8", 640, 480, 30, 0);
2458 cricket::VideoSendParameters parameters; 2460 cricket::VideoSendParameters parameters;
2459 parameters.codecs.push_back(send_codec); 2461 parameters.codecs.push_back(send_codec);
2460 EXPECT_TRUE(channel_->SetSendParameters(parameters)); 2462 EXPECT_TRUE(channel_->SetSendParameters(parameters));
2461 EXPECT_TRUE(channel_->SetSend(true)); 2463 EXPECT_TRUE(channel_->SetSend(true));
2462 2464
2463 // Verify that the CpuOveruseObserver is registered and trigger downgrade. 2465 // Verify that the CpuOveruseObserver is registered and trigger downgrade.
2464 parameters.options.cpu_overuse_detection = rtc::Maybe<bool>(true); 2466 parameters.options.cpu_overuse_detection = rtc::Optional<bool>(true);
2465 EXPECT_TRUE(channel_->SetSendParameters(parameters)); 2467 EXPECT_TRUE(channel_->SetSendParameters(parameters));
2466 2468
2467 // Trigger overuse. 2469 // Trigger overuse.
2468 ASSERT_EQ(1u, fake_call_->GetVideoSendStreams().size()); 2470 ASSERT_EQ(1u, fake_call_->GetVideoSendStreams().size());
2469 webrtc::LoadObserver* overuse_callback = 2471 webrtc::LoadObserver* overuse_callback =
2470 fake_call_->GetVideoSendStreams().front()->GetConfig().overuse_callback; 2472 fake_call_->GetVideoSendStreams().front()->GetConfig().overuse_callback;
2471 ASSERT_TRUE(overuse_callback != NULL); 2473 ASSERT_TRUE(overuse_callback != NULL);
2472 overuse_callback->OnLoadUpdate(webrtc::LoadObserver::kOveruse); 2474 overuse_callback->OnLoadUpdate(webrtc::LoadObserver::kOveruse);
2473 2475
2474 // Capture format VGA -> adapt (OnCpuResolutionRequest downgrade) -> VGA/2. 2476 // Capture format VGA -> adapt (OnCpuResolutionRequest downgrade) -> VGA/2.
(...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after
3272 // Ensures that the correct settings are applied to the codec when two temporal 3274 // Ensures that the correct settings are applied to the codec when two temporal
3273 // layer screencasting is enabled, and that the correct simulcast settings are 3275 // layer screencasting is enabled, and that the correct simulcast settings are
3274 // reapplied when disabling screencasting. 3276 // reapplied when disabling screencasting.
3275 TEST_F(WebRtcVideoChannel2SimulcastTest, 3277 TEST_F(WebRtcVideoChannel2SimulcastTest,
3276 DISABLED_TwoTemporalLayerScreencastSettings) { 3278 DISABLED_TwoTemporalLayerScreencastSettings) {
3277 // TODO(pbos): Implement. 3279 // TODO(pbos): Implement.
3278 FAIL() << "Not implemented."; 3280 FAIL() << "Not implemented.";
3279 } 3281 }
3280 3282
3281 } // namespace cricket 3283 } // namespace cricket
OLDNEW
« no previous file with comments | « talk/media/webrtc/webrtcvideoengine2.cc ('k') | talk/media/webrtc/webrtcvoiceengine.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698