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

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

Issue 2351633002: Let ViEEncoder handle resolution changes. (Closed)
Patch Set: rebased Created 4 years, 2 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/webrtcvideoengine2.cc ('k') | webrtc/test/call_test.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 * 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 1059 matching lines...) Expand 10 before | Expand all | Expand 10 after
1070 rtx_ssrcs.push_back(ssrc + kRtxSsrcOffset); 1070 rtx_ssrcs.push_back(ssrc + kRtxSsrcOffset);
1071 } 1071 }
1072 } 1072 }
1073 if (with_rtx) { 1073 if (with_rtx) {
1074 return AddSendStream( 1074 return AddSendStream(
1075 cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs)); 1075 cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs));
1076 } 1076 }
1077 return AddSendStream(CreateSimStreamParams("cname", ssrcs)); 1077 return AddSendStream(CreateSimStreamParams("cname", ssrcs));
1078 } 1078 }
1079 1079
1080 int GetMaxEncoderBitrate(cricket::FakeVideoCapturer& capturer) { 1080 int GetMaxEncoderBitrate() {
1081 EXPECT_TRUE(capturer.CaptureFrame());
1082
1083 std::vector<FakeVideoSendStream*> streams = 1081 std::vector<FakeVideoSendStream*> streams =
1084 fake_call_->GetVideoSendStreams(); 1082 fake_call_->GetVideoSendStreams();
1085 EXPECT_TRUE(streams.size() > 0); 1083 EXPECT_EQ(1u, streams.size());
1086 FakeVideoSendStream* stream = streams[streams.size() - 1]; 1084 FakeVideoSendStream* stream = streams[streams.size() - 1];
1087 1085 EXPECT_EQ(1, stream->GetEncoderConfig().number_of_streams);
1088 webrtc::VideoEncoderConfig encoder_config = 1086 return stream->GetVideoStreams()[0].max_bitrate_bps;
1089 stream->GetEncoderConfig().Copy();
1090 EXPECT_EQ(1, encoder_config.streams.size());
1091 return encoder_config.streams[0].max_bitrate_bps;
1092 } 1087 }
1093 1088
1094 void SetAndExpectMaxBitrate(cricket::FakeVideoCapturer& capturer, 1089 void SetAndExpectMaxBitrate(int global_max,
1095 int global_max,
1096 int stream_max, 1090 int stream_max,
1097 int expected_encoder_bitrate) { 1091 int expected_encoder_bitrate) {
1098 VideoSendParameters limited_send_params = send_parameters_; 1092 VideoSendParameters limited_send_params = send_parameters_;
1099 limited_send_params.max_bandwidth_bps = global_max; 1093 limited_send_params.max_bandwidth_bps = global_max;
1100 EXPECT_TRUE(channel_->SetSendParameters(limited_send_params)); 1094 EXPECT_TRUE(channel_->SetSendParameters(limited_send_params));
1101 webrtc::RtpParameters parameters = 1095 webrtc::RtpParameters parameters =
1102 channel_->GetRtpSendParameters(last_ssrc_); 1096 channel_->GetRtpSendParameters(last_ssrc_);
1103 EXPECT_EQ(1UL, parameters.encodings.size()); 1097 EXPECT_EQ(1UL, parameters.encodings.size());
1104 parameters.encodings[0].max_bitrate_bps = stream_max; 1098 parameters.encodings[0].max_bitrate_bps = stream_max;
1105 EXPECT_TRUE(channel_->SetRtpSendParameters(last_ssrc_, parameters)); 1099 EXPECT_TRUE(channel_->SetRtpSendParameters(last_ssrc_, parameters));
1106 // Read back the parameteres and verify they have the correct value 1100 // Read back the parameteres and verify they have the correct value
1107 parameters = channel_->GetRtpSendParameters(last_ssrc_); 1101 parameters = channel_->GetRtpSendParameters(last_ssrc_);
1108 EXPECT_EQ(1UL, parameters.encodings.size()); 1102 EXPECT_EQ(1UL, parameters.encodings.size());
1109 EXPECT_EQ(stream_max, parameters.encodings[0].max_bitrate_bps); 1103 EXPECT_EQ(stream_max, parameters.encodings[0].max_bitrate_bps);
1110 // Verify that the new value propagated down to the encoder 1104 // Verify that the new value propagated down to the encoder
1111 EXPECT_EQ(expected_encoder_bitrate, GetMaxEncoderBitrate(capturer)); 1105 EXPECT_EQ(expected_encoder_bitrate, GetMaxEncoderBitrate());
1112 } 1106 }
1113 1107
1114 std::unique_ptr<FakeCall> fake_call_; 1108 std::unique_ptr<FakeCall> fake_call_;
1115 std::unique_ptr<VideoMediaChannel> channel_; 1109 std::unique_ptr<VideoMediaChannel> channel_;
1116 cricket::VideoSendParameters send_parameters_; 1110 cricket::VideoSendParameters send_parameters_;
1117 cricket::VideoRecvParameters recv_parameters_; 1111 cricket::VideoRecvParameters recv_parameters_;
1118 uint32_t last_ssrc_; 1112 uint32_t last_ssrc_;
1119 }; 1113 };
1120 1114
1121 TEST_F(WebRtcVideoChannel2Test, SetsSyncGroupFromSyncLabel) { 1115 TEST_F(WebRtcVideoChannel2Test, SetsSyncGroupFromSyncLabel) {
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
1513 // same source that will be sent later, which just means that we're ready 1507 // same source that will be sent later, which just means that we're ready
1514 // earlier. 1508 // earlier.
1515 TEST_F(WebRtcVideoChannel2Test, ReconfiguresEncodersWhenNotSending) { 1509 TEST_F(WebRtcVideoChannel2Test, ReconfiguresEncodersWhenNotSending) {
1516 cricket::VideoSendParameters parameters; 1510 cricket::VideoSendParameters parameters;
1517 parameters.codecs.push_back(kVp8Codec720p); 1511 parameters.codecs.push_back(kVp8Codec720p);
1518 ASSERT_TRUE(channel_->SetSendParameters(parameters)); 1512 ASSERT_TRUE(channel_->SetSendParameters(parameters));
1519 channel_->SetSend(false); 1513 channel_->SetSend(false);
1520 1514
1521 FakeVideoSendStream* stream = AddSendStream(); 1515 FakeVideoSendStream* stream = AddSendStream();
1522 1516
1523 // No frames entered, using default dimensions. 1517 // No frames entered.
1524 std::vector<webrtc::VideoStream> streams = stream->GetVideoStreams(); 1518 std::vector<webrtc::VideoStream> streams = stream->GetVideoStreams();
1525 EXPECT_EQ(176u, streams[0].width); 1519 EXPECT_EQ(0u, streams[0].width);
1526 EXPECT_EQ(144u, streams[0].height); 1520 EXPECT_EQ(0u, streams[0].height);
1527 1521
1528 cricket::FakeVideoCapturer capturer; 1522 cricket::FakeVideoCapturer capturer;
1529 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, &capturer)); 1523 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, &capturer));
1530 EXPECT_EQ(cricket::CS_RUNNING, 1524 EXPECT_EQ(cricket::CS_RUNNING,
1531 capturer.Start(capturer.GetSupportedFormats()->front())); 1525 capturer.Start(capturer.GetSupportedFormats()->front()));
1532 EXPECT_TRUE(capturer.CaptureFrame()); 1526 EXPECT_TRUE(capturer.CaptureFrame());
1533 1527
1534 // Frame entered, should be reconfigured to new dimensions. 1528 // Frame entered, should be reconfigured to new dimensions.
1535 streams = stream->GetVideoStreams(); 1529 streams = stream->GetVideoStreams();
1536 EXPECT_EQ(kVp8Codec720p.width, streams[0].width); 1530 EXPECT_EQ(kVp8Codec720p.width, streams[0].width);
1537 EXPECT_EQ(kVp8Codec720p.height, streams[0].height); 1531 EXPECT_EQ(kVp8Codec720p.height, streams[0].height);
1538 // No frames should have been actually put in there though.
1539 EXPECT_EQ(0, stream->GetNumberOfSwappedFrames());
1540 1532
1541 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); 1533 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr));
1542 } 1534 }
1543 1535
1544 TEST_F(WebRtcVideoChannel2Test, UsesCorrectSettingsForScreencast) { 1536 TEST_F(WebRtcVideoChannel2Test, UsesCorrectSettingsForScreencast) {
1545 static const int kScreenshareMinBitrateKbps = 800; 1537 static const int kScreenshareMinBitrateKbps = 800;
1546 cricket::VideoCodec codec = kVp8Codec360p; 1538 cricket::VideoCodec codec = kVp8Codec360p;
1547 cricket::VideoSendParameters parameters; 1539 cricket::VideoSendParameters parameters;
1548 parameters.codecs.push_back(codec); 1540 parameters.codecs.push_back(codec);
1549 EXPECT_TRUE(channel_->SetSendParameters(parameters)); 1541 EXPECT_TRUE(channel_->SetSendParameters(parameters));
(...skipping 17 matching lines...) Expand all
1567 ASSERT_EQ(1u, fake_call_->GetVideoSendStreams().size()); 1559 ASSERT_EQ(1u, fake_call_->GetVideoSendStreams().size());
1568 FakeVideoSendStream* send_stream = fake_call_->GetVideoSendStreams().front(); 1560 FakeVideoSendStream* send_stream = fake_call_->GetVideoSendStreams().front();
1569 1561
1570 EXPECT_EQ(1, send_stream->GetNumberOfSwappedFrames()); 1562 EXPECT_EQ(1, send_stream->GetNumberOfSwappedFrames());
1571 1563
1572 // Verify non-screencast settings. 1564 // Verify non-screencast settings.
1573 webrtc::VideoEncoderConfig encoder_config = 1565 webrtc::VideoEncoderConfig encoder_config =
1574 send_stream->GetEncoderConfig().Copy(); 1566 send_stream->GetEncoderConfig().Copy();
1575 EXPECT_EQ(webrtc::VideoEncoderConfig::ContentType::kRealtimeVideo, 1567 EXPECT_EQ(webrtc::VideoEncoderConfig::ContentType::kRealtimeVideo,
1576 encoder_config.content_type); 1568 encoder_config.content_type);
1577 EXPECT_EQ(codec.width, encoder_config.streams.front().width); 1569 std::vector<webrtc::VideoStream> streams = send_stream->GetVideoStreams();
1578 EXPECT_EQ(codec.height, encoder_config.streams.front().height); 1570 EXPECT_EQ(capture_format_hd.width, streams.front().width);
1571 EXPECT_EQ(capture_format_hd.height, streams.front().height);
1579 EXPECT_EQ(0, encoder_config.min_transmit_bitrate_bps) 1572 EXPECT_EQ(0, encoder_config.min_transmit_bitrate_bps)
1580 << "Non-screenshare shouldn't use min-transmit bitrate."; 1573 << "Non-screenshare shouldn't use min-transmit bitrate.";
1581 1574
1582 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); 1575 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr));
1583 // Removing a capturer triggers a black frame to be sent. 1576 // Removing a capturer triggers a black frame to be sent.
1584 EXPECT_EQ(2, send_stream->GetNumberOfSwappedFrames()); 1577 EXPECT_EQ(2, send_stream->GetNumberOfSwappedFrames());
1585 VideoOptions screencast_options; 1578 VideoOptions screencast_options;
1586 screencast_options.is_screencast = rtc::Optional<bool>(true); 1579 screencast_options.is_screencast = rtc::Optional<bool>(true);
1587 EXPECT_TRUE( 1580 EXPECT_TRUE(
1588 channel_->SetVideoSend(last_ssrc_, true, &screencast_options, &capturer)); 1581 channel_->SetVideoSend(last_ssrc_, true, &screencast_options, &capturer));
1589 EXPECT_TRUE(capturer.CaptureFrame()); 1582 EXPECT_TRUE(capturer.CaptureFrame());
1590 // Send stream not recreated after option change. 1583 // Send stream not recreated after option change.
1591 ASSERT_EQ(send_stream, fake_call_->GetVideoSendStreams().front()); 1584 ASSERT_EQ(send_stream, fake_call_->GetVideoSendStreams().front());
1592 EXPECT_EQ(3, send_stream->GetNumberOfSwappedFrames()); 1585 EXPECT_EQ(3, send_stream->GetNumberOfSwappedFrames());
1593 1586
1594 // Verify screencast settings. 1587 // Verify screencast settings.
1595 encoder_config = send_stream->GetEncoderConfig().Copy(); 1588 encoder_config = send_stream->GetEncoderConfig().Copy();
1596 EXPECT_EQ(webrtc::VideoEncoderConfig::ContentType::kScreen, 1589 EXPECT_EQ(webrtc::VideoEncoderConfig::ContentType::kScreen,
1597 encoder_config.content_type); 1590 encoder_config.content_type);
1598 EXPECT_EQ(kScreenshareMinBitrateKbps * 1000, 1591 EXPECT_EQ(kScreenshareMinBitrateKbps * 1000,
1599 encoder_config.min_transmit_bitrate_bps); 1592 encoder_config.min_transmit_bitrate_bps);
1600 1593
1601 EXPECT_EQ(capture_format_hd.width, encoder_config.streams.front().width); 1594 streams = send_stream->GetVideoStreams();
1602 EXPECT_EQ(capture_format_hd.height, encoder_config.streams.front().height); 1595 EXPECT_EQ(capture_format_hd.width, streams.front().width);
1603 EXPECT_TRUE(encoder_config.streams[0].temporal_layer_thresholds_bps.empty()); 1596 EXPECT_EQ(capture_format_hd.height, streams.front().height);
1604 1597 EXPECT_TRUE(streams[0].temporal_layer_thresholds_bps.empty());
1605 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); 1598 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr));
1606 } 1599 }
1607 1600
1608 TEST_F(WebRtcVideoChannel2Test, NoRecreateStreamForScreencast) { 1601 TEST_F(WebRtcVideoChannel2Test, NoRecreateStreamForScreencast) {
1609 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); 1602 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_));
1610 ASSERT_TRUE( 1603 ASSERT_TRUE(
1611 channel_->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc))); 1604 channel_->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc)));
1612 EXPECT_TRUE(channel_->SetSend(true)); 1605 EXPECT_TRUE(channel_->SetSend(true));
1613 1606
1614 cricket::FakeVideoCapturer capturer; 1607 cricket::FakeVideoCapturer capturer;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1678 ASSERT_EQ(1u, fake_call_->GetVideoSendStreams().size()); 1671 ASSERT_EQ(1u, fake_call_->GetVideoSendStreams().size());
1679 FakeVideoSendStream* send_stream = fake_call_->GetVideoSendStreams().front(); 1672 FakeVideoSendStream* send_stream = fake_call_->GetVideoSendStreams().front();
1680 1673
1681 webrtc::VideoEncoderConfig encoder_config = 1674 webrtc::VideoEncoderConfig encoder_config =
1682 send_stream->GetEncoderConfig().Copy(); 1675 send_stream->GetEncoderConfig().Copy();
1683 1676
1684 // Verify screencast settings. 1677 // Verify screencast settings.
1685 encoder_config = send_stream->GetEncoderConfig().Copy(); 1678 encoder_config = send_stream->GetEncoderConfig().Copy();
1686 EXPECT_EQ(webrtc::VideoEncoderConfig::ContentType::kScreen, 1679 EXPECT_EQ(webrtc::VideoEncoderConfig::ContentType::kScreen,
1687 encoder_config.content_type); 1680 encoder_config.content_type);
1688 ASSERT_EQ(1u, encoder_config.streams.size()); 1681
1689 ASSERT_EQ(1u, encoder_config.streams[0].temporal_layer_thresholds_bps.size()); 1682 std::vector<webrtc::VideoStream> streams = send_stream->GetVideoStreams();
1683 ASSERT_EQ(1u, streams.size());
1684 ASSERT_EQ(1u, streams[0].temporal_layer_thresholds_bps.size());
1690 EXPECT_EQ(kConferenceScreencastTemporalBitrateBps, 1685 EXPECT_EQ(kConferenceScreencastTemporalBitrateBps,
1691 encoder_config.streams[0].temporal_layer_thresholds_bps[0]); 1686 streams[0].temporal_layer_thresholds_bps[0]);
1692 1687
1693 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); 1688 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr));
1694 } 1689 }
1695 1690
1696 TEST_F(WebRtcVideoChannel2Test, SuspendBelowMinBitrateDisabledByDefault) { 1691 TEST_F(WebRtcVideoChannel2Test, SuspendBelowMinBitrateDisabledByDefault) {
1697 FakeVideoSendStream* stream = AddSendStream(); 1692 FakeVideoSendStream* stream = AddSendStream();
1698 EXPECT_FALSE(stream->GetConfig().suspend_below_min_bitrate); 1693 EXPECT_FALSE(stream->GetConfig().suspend_below_min_bitrate);
1699 } 1694 }
1700 1695
1701 TEST_F(WebRtcVideoChannel2Test, SetMediaConfigSuspendBelowMinBitrate) { 1696 TEST_F(WebRtcVideoChannel2Test, SetMediaConfigSuspendBelowMinBitrate) {
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
1799 1794
1800 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); 1795 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr));
1801 } 1796 }
1802 1797
1803 // Test that setting the same options doesn't result in the encoder being 1798 // Test that setting the same options doesn't result in the encoder being
1804 // reconfigured. 1799 // reconfigured.
1805 TEST_F(WebRtcVideoChannel2Test, SetIdenticalOptionsDoesntReconfigureEncoder) { 1800 TEST_F(WebRtcVideoChannel2Test, SetIdenticalOptionsDoesntReconfigureEncoder) {
1806 VideoOptions options; 1801 VideoOptions options;
1807 cricket::FakeVideoCapturer capturer; 1802 cricket::FakeVideoCapturer capturer;
1808 1803
1809 FakeVideoSendStream* send_stream = AddSendStream(); 1804 AddSendStream();
1810 EXPECT_EQ(cricket::CS_RUNNING, 1805 EXPECT_EQ(cricket::CS_RUNNING,
1811 capturer.Start(capturer.GetSupportedFormats()->front())); 1806 capturer.Start(capturer.GetSupportedFormats()->front()));
1807 cricket::VideoSendParameters parameters;
1808 parameters.codecs.push_back(kVp8Codec720p);
1809 ASSERT_TRUE(channel_->SetSendParameters(parameters));
1810 FakeVideoSendStream* send_stream = fake_call_->GetVideoSendStreams().front();
1811
1812 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &options, &capturer));
1812 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &options, &capturer)); 1813 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &options, &capturer));
1813 EXPECT_TRUE(capturer.CaptureFrame()); 1814 EXPECT_TRUE(capturer.CaptureFrame());
1814 // Expect 2 reconfigurations at this point, from the initial configuration 1815 // Expect 1 reconfigurations at this point from the initial configuration.
1815 // and from the dimensions of the first frame. 1816 EXPECT_EQ(1, send_stream->num_encoder_reconfigurations());
1816 EXPECT_EQ(2, send_stream->num_encoder_reconfigurations());
1817 1817
1818 // Set the options one more time and expect no additional reconfigurations. 1818 // Set the options one more time and expect no additional reconfigurations.
1819 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &options, &capturer)); 1819 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &options, &capturer));
1820 EXPECT_TRUE(capturer.CaptureFrame()); 1820 EXPECT_EQ(1, send_stream->num_encoder_reconfigurations());
1821
1822 // Change |options| and expect 2 reconfigurations.
1823 options.is_screencast = rtc::Optional<bool>(true);
1824 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &options, &capturer));
1821 EXPECT_EQ(2, send_stream->num_encoder_reconfigurations()); 1825 EXPECT_EQ(2, send_stream->num_encoder_reconfigurations());
1822 1826
1823 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); 1827 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr));
1824 } 1828 }
1825 1829
1826 class Vp9SettingsTest : public WebRtcVideoChannel2Test { 1830 class Vp9SettingsTest : public WebRtcVideoChannel2Test {
1827 public: 1831 public:
1828 Vp9SettingsTest() : Vp9SettingsTest("") {} 1832 Vp9SettingsTest() : Vp9SettingsTest("") {}
1829 explicit Vp9SettingsTest(const char* field_trials) 1833 explicit Vp9SettingsTest(const char* field_trials)
1830 : WebRtcVideoChannel2Test(field_trials) { 1834 : WebRtcVideoChannel2Test(field_trials) {
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
2303 ASSERT_TRUE(channel_->SetSendParameters(parameters)); 2307 ASSERT_TRUE(channel_->SetSendParameters(parameters));
2304 stream = fake_call_->GetVideoSendStreams()[0]; 2308 stream = fake_call_->GetVideoSendStreams()[0];
2305 ASSERT_TRUE(stream != NULL); 2309 ASSERT_TRUE(stream != NULL);
2306 config = stream->GetConfig().Copy(); 2310 config = stream->GetConfig().Copy();
2307 EXPECT_EQ(-1, config.rtp.fec.ulpfec_payload_type) 2311 EXPECT_EQ(-1, config.rtp.fec.ulpfec_payload_type)
2308 << "SetSendCodec without FEC should disable current FEC."; 2312 << "SetSendCodec without FEC should disable current FEC.";
2309 } 2313 }
2310 2314
2311 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsChangesExistingStreams) { 2315 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsChangesExistingStreams) {
2312 cricket::VideoSendParameters parameters; 2316 cricket::VideoSendParameters parameters;
2313 parameters.codecs.push_back(kVp8Codec720p); 2317 cricket::VideoCodec codec720p(100, "VP8", 1280, 720, 30);
2318 codec720p.SetParam(kCodecParamMaxQuantization, kDefaultQpMax);
2319 parameters.codecs.push_back(codec720p);
2320
2314 ASSERT_TRUE(channel_->SetSendParameters(parameters)); 2321 ASSERT_TRUE(channel_->SetSendParameters(parameters));
2315 channel_->SetSend(true); 2322 channel_->SetSend(true);
2316 2323
2317 FakeVideoSendStream* stream = AddSendStream(); 2324 FakeVideoSendStream* stream = AddSendStream();
2318
2319 cricket::FakeVideoCapturer capturer; 2325 cricket::FakeVideoCapturer capturer;
2320 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, &capturer)); 2326 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, &capturer));
2321 EXPECT_EQ(cricket::CS_RUNNING,
2322 capturer.Start(capturer.GetSupportedFormats()->front()));
2323 EXPECT_TRUE(capturer.CaptureFrame());
2324 2327
2325 std::vector<webrtc::VideoStream> streams = stream->GetVideoStreams(); 2328 std::vector<webrtc::VideoStream> streams = stream->GetVideoStreams();
2326 EXPECT_EQ(kVp8Codec720p.width, streams[0].width); 2329 EXPECT_EQ(kDefaultQpMax, streams[0].max_qp);
2327 EXPECT_EQ(kVp8Codec720p.height, streams[0].height);
2328 2330
2329 parameters.codecs.clear(); 2331 parameters.codecs.clear();
2330 parameters.codecs.push_back(kVp8Codec360p); 2332 codec720p.SetParam(kCodecParamMaxQuantization, kDefaultQpMax + 1);
2333 parameters.codecs.push_back(codec720p);
2331 ASSERT_TRUE(channel_->SetSendParameters(parameters)); 2334 ASSERT_TRUE(channel_->SetSendParameters(parameters));
2332 streams = fake_call_->GetVideoSendStreams()[0]->GetVideoStreams(); 2335 streams = fake_call_->GetVideoSendStreams()[0]->GetVideoStreams();
2333 EXPECT_EQ(kVp8Codec360p.width, streams[0].width); 2336 EXPECT_EQ(kDefaultQpMax + 1, streams[0].max_qp);
2334 EXPECT_EQ(kVp8Codec360p.height, streams[0].height);
2335 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); 2337 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr));
2336 } 2338 }
2337 2339
2338 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithBitrates) { 2340 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithBitrates) {
2339 SetSendCodecsShouldWorkForBitrates("100", 100000, "150", 150000, "200", 2341 SetSendCodecsShouldWorkForBitrates("100", 100000, "150", 150000, "200",
2340 200000); 2342 200000);
2341 } 2343 }
2342 2344
2343 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithHighMaxBitrate) { 2345 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithHighMaxBitrate) {
2344 SetSendCodecsShouldWorkForBitrates("", 0, "", -1, "10000", 10000000); 2346 SetSendCodecsShouldWorkForBitrates("", 0, "", -1, "10000", 10000000);
(...skipping 1064 matching lines...) Expand 10 before | Expand all | Expand 10 after
3409 AddSendStream(); 3411 AddSendStream();
3410 3412
3411 cricket::FakeVideoCapturer capturer; 3413 cricket::FakeVideoCapturer capturer;
3412 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, &capturer)); 3414 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, &capturer));
3413 cricket::VideoFormat capture_format_hd = 3415 cricket::VideoFormat capture_format_hd =
3414 capturer.GetSupportedFormats()->front(); 3416 capturer.GetSupportedFormats()->front();
3415 EXPECT_EQ(1280, capture_format_hd.width); 3417 EXPECT_EQ(1280, capture_format_hd.width);
3416 EXPECT_EQ(720, capture_format_hd.height); 3418 EXPECT_EQ(720, capture_format_hd.height);
3417 EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(capture_format_hd)); 3419 EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(capture_format_hd));
3418 EXPECT_TRUE(channel_->SetSend(true)); 3420 EXPECT_TRUE(channel_->SetSend(true));
3421 capturer.CaptureFrame();
3419 3422
3420 int default_encoder_bitrate = GetMaxEncoderBitrate(capturer); 3423 int default_encoder_bitrate = GetMaxEncoderBitrate();
3421 EXPECT_TRUE(default_encoder_bitrate > 1000); 3424 EXPECT_TRUE(default_encoder_bitrate > 1000);
3422 3425
3423 // TODO(skvlad): Resolve the inconsistency between the interpretation 3426 // TODO(skvlad): Resolve the inconsistency between the interpretation
3424 // of the global bitrate limit for audio and video: 3427 // of the global bitrate limit for audio and video:
3425 // - Audio: max_bandwidth_bps = 0 - fail the operation, 3428 // - Audio: max_bandwidth_bps = 0 - fail the operation,
3426 // max_bandwidth_bps = -1 - remove the bandwidth limit 3429 // max_bandwidth_bps = -1 - remove the bandwidth limit
3427 // - Video: max_bandwidth_bps = 0 - remove the bandwidth limit, 3430 // - Video: max_bandwidth_bps = 0 - remove the bandwidth limit,
3428 // max_bandwidth_bps = -1 - do not change the previously set 3431 // max_bandwidth_bps = -1 - do not change the previously set
3429 // limit. 3432 // limit.
3430 3433
3431 SetAndExpectMaxBitrate(capturer, 1000, 0, 1000); 3434 SetAndExpectMaxBitrate(1000, 0, 1000);
3432 SetAndExpectMaxBitrate(capturer, 1000, 800, 800); 3435 SetAndExpectMaxBitrate(1000, 800, 800);
3433 SetAndExpectMaxBitrate(capturer, 600, 800, 600); 3436 SetAndExpectMaxBitrate(600, 800, 600);
3434 SetAndExpectMaxBitrate(capturer, 0, 800, 800); 3437 SetAndExpectMaxBitrate(0, 800, 800);
3435 SetAndExpectMaxBitrate(capturer, 0, 0, default_encoder_bitrate); 3438 SetAndExpectMaxBitrate(0, 0, default_encoder_bitrate);
3436 3439
3437 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); 3440 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr));
3438 } 3441 }
3439 3442
3440 TEST_F(WebRtcVideoChannel2Test, CannotSetMaxBitrateForNonexistentStream) { 3443 TEST_F(WebRtcVideoChannel2Test, CannotSetMaxBitrateForNonexistentStream) {
3441 webrtc::RtpParameters nonexistent_parameters = 3444 webrtc::RtpParameters nonexistent_parameters =
3442 channel_->GetRtpSendParameters(last_ssrc_); 3445 channel_->GetRtpSendParameters(last_ssrc_);
3443 EXPECT_EQ(0, nonexistent_parameters.encodings.size()); 3446 EXPECT_EQ(0, nonexistent_parameters.encodings.size());
3444 3447
3445 nonexistent_parameters.encodings.push_back(webrtc::RtpEncodingParameters()); 3448 nonexistent_parameters.encodings.push_back(webrtc::RtpEncodingParameters());
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
3831 } 3834 }
3832 3835
3833 // Test that we normalize send codec format size in simulcast. 3836 // Test that we normalize send codec format size in simulcast.
3834 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWithOddSizeInSimulcast) { 3837 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWithOddSizeInSimulcast) {
3835 cricket::VideoCodec codec(kVp8Codec270p); 3838 cricket::VideoCodec codec(kVp8Codec270p);
3836 codec.width += 1; 3839 codec.width += 1;
3837 codec.height += 1; 3840 codec.height += 1;
3838 VerifySimulcastSettings(codec, 2, 2); 3841 VerifySimulcastSettings(codec, 2, 2);
3839 } 3842 }
3840 } // namespace cricket 3843 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/media/engine/webrtcvideoengine2.cc ('k') | webrtc/test/call_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698