OLD | NEW |
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 1063 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1074 rtx_ssrcs.push_back(ssrc + kRtxSsrcOffset); | 1074 rtx_ssrcs.push_back(ssrc + kRtxSsrcOffset); |
1075 } | 1075 } |
1076 } | 1076 } |
1077 if (with_rtx) { | 1077 if (with_rtx) { |
1078 return AddSendStream( | 1078 return AddSendStream( |
1079 cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs)); | 1079 cricket::CreateSimWithRtxStreamParams("cname", ssrcs, rtx_ssrcs)); |
1080 } | 1080 } |
1081 return AddSendStream(CreateSimStreamParams("cname", ssrcs)); | 1081 return AddSendStream(CreateSimStreamParams("cname", ssrcs)); |
1082 } | 1082 } |
1083 | 1083 |
1084 int GetMaxEncoderBitrate(cricket::FakeVideoCapturer& capturer) { | 1084 int GetMaxEncoderBitrate() { |
1085 EXPECT_TRUE(capturer.CaptureFrame()); | |
1086 | |
1087 std::vector<FakeVideoSendStream*> streams = | 1085 std::vector<FakeVideoSendStream*> streams = |
1088 fake_call_->GetVideoSendStreams(); | 1086 fake_call_->GetVideoSendStreams(); |
1089 EXPECT_TRUE(streams.size() > 0); | 1087 EXPECT_EQ(1u, streams.size()); |
1090 FakeVideoSendStream* stream = streams[streams.size() - 1]; | 1088 FakeVideoSendStream* stream = streams[streams.size() - 1]; |
1091 | 1089 EXPECT_EQ(1, stream->GetEncoderConfig().number_of_streams); |
1092 webrtc::VideoEncoderConfig encoder_config = | 1090 return stream->GetVideoStreams()[0].max_bitrate_bps; |
1093 stream->GetEncoderConfig().Copy(); | |
1094 EXPECT_EQ(1, encoder_config.streams.size()); | |
1095 return encoder_config.streams[0].max_bitrate_bps; | |
1096 } | 1091 } |
1097 | 1092 |
1098 void SetAndExpectMaxBitrate(cricket::FakeVideoCapturer& capturer, | 1093 void SetAndExpectMaxBitrate(int global_max, |
1099 int global_max, | |
1100 int stream_max, | 1094 int stream_max, |
1101 int expected_encoder_bitrate) { | 1095 int expected_encoder_bitrate) { |
1102 VideoSendParameters limited_send_params = send_parameters_; | 1096 VideoSendParameters limited_send_params = send_parameters_; |
1103 limited_send_params.max_bandwidth_bps = global_max; | 1097 limited_send_params.max_bandwidth_bps = global_max; |
1104 EXPECT_TRUE(channel_->SetSendParameters(limited_send_params)); | 1098 EXPECT_TRUE(channel_->SetSendParameters(limited_send_params)); |
1105 webrtc::RtpParameters parameters = | 1099 webrtc::RtpParameters parameters = |
1106 channel_->GetRtpSendParameters(last_ssrc_); | 1100 channel_->GetRtpSendParameters(last_ssrc_); |
1107 EXPECT_EQ(1UL, parameters.encodings.size()); | 1101 EXPECT_EQ(1UL, parameters.encodings.size()); |
1108 parameters.encodings[0].max_bitrate_bps = stream_max; | 1102 parameters.encodings[0].max_bitrate_bps = stream_max; |
1109 EXPECT_TRUE(channel_->SetRtpSendParameters(last_ssrc_, parameters)); | 1103 EXPECT_TRUE(channel_->SetRtpSendParameters(last_ssrc_, parameters)); |
1110 // Read back the parameteres and verify they have the correct value | 1104 // Read back the parameteres and verify they have the correct value |
1111 parameters = channel_->GetRtpSendParameters(last_ssrc_); | 1105 parameters = channel_->GetRtpSendParameters(last_ssrc_); |
1112 EXPECT_EQ(1UL, parameters.encodings.size()); | 1106 EXPECT_EQ(1UL, parameters.encodings.size()); |
1113 EXPECT_EQ(stream_max, parameters.encodings[0].max_bitrate_bps); | 1107 EXPECT_EQ(stream_max, parameters.encodings[0].max_bitrate_bps); |
1114 // Verify that the new value propagated down to the encoder | 1108 // Verify that the new value propagated down to the encoder |
1115 EXPECT_EQ(expected_encoder_bitrate, GetMaxEncoderBitrate(capturer)); | 1109 EXPECT_EQ(expected_encoder_bitrate, GetMaxEncoderBitrate()); |
1116 } | 1110 } |
1117 | 1111 |
1118 std::unique_ptr<FakeCall> fake_call_; | 1112 std::unique_ptr<FakeCall> fake_call_; |
1119 std::unique_ptr<VideoMediaChannel> channel_; | 1113 std::unique_ptr<VideoMediaChannel> channel_; |
1120 cricket::VideoSendParameters send_parameters_; | 1114 cricket::VideoSendParameters send_parameters_; |
1121 cricket::VideoRecvParameters recv_parameters_; | 1115 cricket::VideoRecvParameters recv_parameters_; |
1122 uint32_t last_ssrc_; | 1116 uint32_t last_ssrc_; |
1123 }; | 1117 }; |
1124 | 1118 |
1125 TEST_F(WebRtcVideoChannel2Test, SetsSyncGroupFromSyncLabel) { | 1119 TEST_F(WebRtcVideoChannel2Test, SetsSyncGroupFromSyncLabel) { |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1509 EXPECT_GT(recv_stream->GetConfig().rtp.nack.rtp_history_ms, 0); | 1503 EXPECT_GT(recv_stream->GetConfig().rtp.nack.rtp_history_ms, 0); |
1510 send_stream = fake_call_->GetVideoSendStreams()[0]; | 1504 send_stream = fake_call_->GetVideoSendStreams()[0]; |
1511 EXPECT_GT(send_stream->GetConfig().rtp.nack.rtp_history_ms, 0); | 1505 EXPECT_GT(send_stream->GetConfig().rtp.nack.rtp_history_ms, 0); |
1512 } | 1506 } |
1513 | 1507 |
1514 // This test verifies that new frame sizes reconfigures encoders even though not | 1508 // This test verifies that new frame sizes reconfigures encoders even though not |
1515 // (yet) sending. The purpose of this is to permit encoding as quickly as | 1509 // (yet) sending. The purpose of this is to permit encoding as quickly as |
1516 // possible once we start sending. Likely the frames being input are from the | 1510 // possible once we start sending. Likely the frames being input are from the |
1517 // same source that will be sent later, which just means that we're ready | 1511 // same source that will be sent later, which just means that we're ready |
1518 // earlier. | 1512 // earlier. |
| 1513 |
| 1514 // TODO now! Add similar test to VideoSendStreams tests to test actuall |
| 1515 // implementation. |
1519 TEST_F(WebRtcVideoChannel2Test, ReconfiguresEncodersWhenNotSending) { | 1516 TEST_F(WebRtcVideoChannel2Test, ReconfiguresEncodersWhenNotSending) { |
1520 cricket::VideoSendParameters parameters; | 1517 cricket::VideoSendParameters parameters; |
1521 parameters.codecs.push_back(kVp8Codec720p); | 1518 parameters.codecs.push_back(kVp8Codec720p); |
1522 ASSERT_TRUE(channel_->SetSendParameters(parameters)); | 1519 ASSERT_TRUE(channel_->SetSendParameters(parameters)); |
1523 channel_->SetSend(false); | 1520 channel_->SetSend(false); |
1524 | 1521 |
1525 FakeVideoSendStream* stream = AddSendStream(); | 1522 FakeVideoSendStream* stream = AddSendStream(); |
1526 | 1523 |
1527 // No frames entered, using default dimensions. | 1524 // No frames entered. |
1528 std::vector<webrtc::VideoStream> streams = stream->GetVideoStreams(); | 1525 std::vector<webrtc::VideoStream> streams = stream->GetVideoStreams(); |
1529 EXPECT_EQ(176u, streams[0].width); | 1526 EXPECT_EQ(0u, streams[0].width); |
1530 EXPECT_EQ(144u, streams[0].height); | 1527 EXPECT_EQ(0u, streams[0].height); |
1531 | 1528 |
1532 cricket::FakeVideoCapturer capturer; | 1529 cricket::FakeVideoCapturer capturer; |
1533 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, &capturer)); | 1530 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, &capturer)); |
1534 EXPECT_EQ(cricket::CS_RUNNING, | 1531 EXPECT_EQ(cricket::CS_RUNNING, |
1535 capturer.Start(capturer.GetSupportedFormats()->front())); | 1532 capturer.Start(capturer.GetSupportedFormats()->front())); |
1536 EXPECT_TRUE(capturer.CaptureFrame()); | 1533 EXPECT_TRUE(capturer.CaptureFrame()); |
1537 | 1534 |
1538 // Frame entered, should be reconfigured to new dimensions. | 1535 // Frame entered, should be reconfigured to new dimensions. |
1539 streams = stream->GetVideoStreams(); | 1536 streams = stream->GetVideoStreams(); |
1540 EXPECT_EQ(kVp8Codec720p.width, streams[0].width); | 1537 EXPECT_EQ(kVp8Codec720p.width, streams[0].width); |
1541 EXPECT_EQ(kVp8Codec720p.height, streams[0].height); | 1538 EXPECT_EQ(kVp8Codec720p.height, streams[0].height); |
1542 // No frames should have been actually put in there though. | |
1543 EXPECT_EQ(0, stream->GetNumberOfSwappedFrames()); | |
1544 | 1539 |
1545 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); | 1540 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); |
1546 } | 1541 } |
1547 | 1542 |
1548 TEST_F(WebRtcVideoChannel2Test, UsesCorrectSettingsForScreencast) { | 1543 TEST_F(WebRtcVideoChannel2Test, UsesCorrectSettingsForScreencast) { |
1549 static const int kScreenshareMinBitrateKbps = 800; | 1544 static const int kScreenshareMinBitrateKbps = 800; |
1550 cricket::VideoCodec codec = kVp8Codec360p; | 1545 cricket::VideoCodec codec = kVp8Codec360p; |
1551 cricket::VideoSendParameters parameters; | 1546 cricket::VideoSendParameters parameters; |
1552 parameters.codecs.push_back(codec); | 1547 parameters.codecs.push_back(codec); |
1553 EXPECT_TRUE(channel_->SetSendParameters(parameters)); | 1548 EXPECT_TRUE(channel_->SetSendParameters(parameters)); |
(...skipping 17 matching lines...) Expand all Loading... |
1571 ASSERT_EQ(1u, fake_call_->GetVideoSendStreams().size()); | 1566 ASSERT_EQ(1u, fake_call_->GetVideoSendStreams().size()); |
1572 FakeVideoSendStream* send_stream = fake_call_->GetVideoSendStreams().front(); | 1567 FakeVideoSendStream* send_stream = fake_call_->GetVideoSendStreams().front(); |
1573 | 1568 |
1574 EXPECT_EQ(1, send_stream->GetNumberOfSwappedFrames()); | 1569 EXPECT_EQ(1, send_stream->GetNumberOfSwappedFrames()); |
1575 | 1570 |
1576 // Verify non-screencast settings. | 1571 // Verify non-screencast settings. |
1577 webrtc::VideoEncoderConfig encoder_config = | 1572 webrtc::VideoEncoderConfig encoder_config = |
1578 send_stream->GetEncoderConfig().Copy(); | 1573 send_stream->GetEncoderConfig().Copy(); |
1579 EXPECT_EQ(webrtc::VideoEncoderConfig::ContentType::kRealtimeVideo, | 1574 EXPECT_EQ(webrtc::VideoEncoderConfig::ContentType::kRealtimeVideo, |
1580 encoder_config.content_type); | 1575 encoder_config.content_type); |
1581 EXPECT_EQ(codec.width, encoder_config.streams.front().width); | 1576 std::vector<webrtc::VideoStream> streams = send_stream->GetVideoStreams(); |
1582 EXPECT_EQ(codec.height, encoder_config.streams.front().height); | 1577 EXPECT_EQ(capture_format_hd.width, streams.front().width); |
| 1578 EXPECT_EQ(capture_format_hd.height, streams.front().height); |
1583 EXPECT_EQ(0, encoder_config.min_transmit_bitrate_bps) | 1579 EXPECT_EQ(0, encoder_config.min_transmit_bitrate_bps) |
1584 << "Non-screenshare shouldn't use min-transmit bitrate."; | 1580 << "Non-screenshare shouldn't use min-transmit bitrate."; |
1585 | 1581 |
1586 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); | 1582 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); |
1587 // Removing a capturer triggers a black frame to be sent. | 1583 // Removing a capturer triggers a black frame to be sent. |
1588 EXPECT_EQ(2, send_stream->GetNumberOfSwappedFrames()); | 1584 EXPECT_EQ(2, send_stream->GetNumberOfSwappedFrames()); |
1589 VideoOptions screencast_options; | 1585 VideoOptions screencast_options; |
1590 screencast_options.is_screencast = rtc::Optional<bool>(true); | 1586 screencast_options.is_screencast = rtc::Optional<bool>(true); |
1591 EXPECT_TRUE( | 1587 EXPECT_TRUE( |
1592 channel_->SetVideoSend(last_ssrc_, true, &screencast_options, &capturer)); | 1588 channel_->SetVideoSend(last_ssrc_, true, &screencast_options, &capturer)); |
1593 EXPECT_TRUE(capturer.CaptureFrame()); | 1589 EXPECT_TRUE(capturer.CaptureFrame()); |
1594 // Send stream not recreated after option change. | 1590 // Send stream not recreated after option change. |
1595 ASSERT_EQ(send_stream, fake_call_->GetVideoSendStreams().front()); | 1591 ASSERT_EQ(send_stream, fake_call_->GetVideoSendStreams().front()); |
1596 EXPECT_EQ(3, send_stream->GetNumberOfSwappedFrames()); | 1592 EXPECT_EQ(3, send_stream->GetNumberOfSwappedFrames()); |
1597 | 1593 |
1598 // Verify screencast settings. | 1594 // Verify screencast settings. |
1599 encoder_config = send_stream->GetEncoderConfig().Copy(); | 1595 encoder_config = send_stream->GetEncoderConfig().Copy(); |
1600 EXPECT_EQ(webrtc::VideoEncoderConfig::ContentType::kScreen, | 1596 EXPECT_EQ(webrtc::VideoEncoderConfig::ContentType::kScreen, |
1601 encoder_config.content_type); | 1597 encoder_config.content_type); |
1602 EXPECT_EQ(kScreenshareMinBitrateKbps * 1000, | 1598 EXPECT_EQ(kScreenshareMinBitrateKbps * 1000, |
1603 encoder_config.min_transmit_bitrate_bps); | 1599 encoder_config.min_transmit_bitrate_bps); |
1604 | 1600 |
1605 EXPECT_EQ(capture_format_hd.width, encoder_config.streams.front().width); | 1601 streams = send_stream->GetVideoStreams(); |
1606 EXPECT_EQ(capture_format_hd.height, encoder_config.streams.front().height); | 1602 EXPECT_EQ(capture_format_hd.width, streams.front().width); |
1607 EXPECT_TRUE(encoder_config.streams[0].temporal_layer_thresholds_bps.empty()); | 1603 EXPECT_EQ(capture_format_hd.height, streams.front().height); |
1608 | 1604 EXPECT_TRUE(streams[0].temporal_layer_thresholds_bps.empty()); |
1609 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); | 1605 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); |
1610 } | 1606 } |
1611 | 1607 |
1612 TEST_F(WebRtcVideoChannel2Test, NoRecreateStreamForScreencast) { | 1608 TEST_F(WebRtcVideoChannel2Test, NoRecreateStreamForScreencast) { |
1613 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); | 1609 EXPECT_TRUE(channel_->SetSendParameters(send_parameters_)); |
1614 ASSERT_TRUE( | 1610 ASSERT_TRUE( |
1615 channel_->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc))); | 1611 channel_->AddSendStream(cricket::StreamParams::CreateLegacy(kSsrc))); |
1616 EXPECT_TRUE(channel_->SetSend(true)); | 1612 EXPECT_TRUE(channel_->SetSend(true)); |
1617 | 1613 |
1618 cricket::FakeVideoCapturer capturer; | 1614 cricket::FakeVideoCapturer capturer; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1682 ASSERT_EQ(1u, fake_call_->GetVideoSendStreams().size()); | 1678 ASSERT_EQ(1u, fake_call_->GetVideoSendStreams().size()); |
1683 FakeVideoSendStream* send_stream = fake_call_->GetVideoSendStreams().front(); | 1679 FakeVideoSendStream* send_stream = fake_call_->GetVideoSendStreams().front(); |
1684 | 1680 |
1685 webrtc::VideoEncoderConfig encoder_config = | 1681 webrtc::VideoEncoderConfig encoder_config = |
1686 send_stream->GetEncoderConfig().Copy(); | 1682 send_stream->GetEncoderConfig().Copy(); |
1687 | 1683 |
1688 // Verify screencast settings. | 1684 // Verify screencast settings. |
1689 encoder_config = send_stream->GetEncoderConfig().Copy(); | 1685 encoder_config = send_stream->GetEncoderConfig().Copy(); |
1690 EXPECT_EQ(webrtc::VideoEncoderConfig::ContentType::kScreen, | 1686 EXPECT_EQ(webrtc::VideoEncoderConfig::ContentType::kScreen, |
1691 encoder_config.content_type); | 1687 encoder_config.content_type); |
1692 ASSERT_EQ(1u, encoder_config.streams.size()); | 1688 |
1693 ASSERT_EQ(1u, encoder_config.streams[0].temporal_layer_thresholds_bps.size()); | 1689 std::vector<webrtc::VideoStream> streams = send_stream->GetVideoStreams(); |
| 1690 ASSERT_EQ(1u, streams.size()); |
| 1691 ASSERT_EQ(1u, streams[0].temporal_layer_thresholds_bps.size()); |
1694 EXPECT_EQ(kConferenceScreencastTemporalBitrateBps, | 1692 EXPECT_EQ(kConferenceScreencastTemporalBitrateBps, |
1695 encoder_config.streams[0].temporal_layer_thresholds_bps[0]); | 1693 streams[0].temporal_layer_thresholds_bps[0]); |
1696 | 1694 |
1697 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); | 1695 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); |
1698 } | 1696 } |
1699 | 1697 |
1700 TEST_F(WebRtcVideoChannel2Test, SuspendBelowMinBitrateDisabledByDefault) { | 1698 TEST_F(WebRtcVideoChannel2Test, SuspendBelowMinBitrateDisabledByDefault) { |
1701 FakeVideoSendStream* stream = AddSendStream(); | 1699 FakeVideoSendStream* stream = AddSendStream(); |
1702 EXPECT_FALSE(stream->GetConfig().suspend_below_min_bitrate); | 1700 EXPECT_FALSE(stream->GetConfig().suspend_below_min_bitrate); |
1703 } | 1701 } |
1704 | 1702 |
1705 TEST_F(WebRtcVideoChannel2Test, SetMediaConfigSuspendBelowMinBitrate) { | 1703 TEST_F(WebRtcVideoChannel2Test, SetMediaConfigSuspendBelowMinBitrate) { |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1806 | 1804 |
1807 // Test that setting the same options doesn't result in the encoder being | 1805 // Test that setting the same options doesn't result in the encoder being |
1808 // reconfigured. | 1806 // reconfigured. |
1809 TEST_F(WebRtcVideoChannel2Test, SetIdenticalOptionsDoesntReconfigureEncoder) { | 1807 TEST_F(WebRtcVideoChannel2Test, SetIdenticalOptionsDoesntReconfigureEncoder) { |
1810 VideoOptions options; | 1808 VideoOptions options; |
1811 cricket::FakeVideoCapturer capturer; | 1809 cricket::FakeVideoCapturer capturer; |
1812 | 1810 |
1813 FakeVideoSendStream* send_stream = AddSendStream(); | 1811 FakeVideoSendStream* send_stream = AddSendStream(); |
1814 EXPECT_EQ(cricket::CS_RUNNING, | 1812 EXPECT_EQ(cricket::CS_RUNNING, |
1815 capturer.Start(capturer.GetSupportedFormats()->front())); | 1813 capturer.Start(capturer.GetSupportedFormats()->front())); |
| 1814 cricket::VideoSendParameters parameters; |
| 1815 parameters.codecs.push_back(kVp8Codec720p); |
| 1816 ASSERT_TRUE(channel_->SetSendParameters(parameters)); |
| 1817 |
| 1818 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &options, &capturer)); |
1816 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &options, &capturer)); | 1819 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &options, &capturer)); |
1817 EXPECT_TRUE(capturer.CaptureFrame()); | 1820 EXPECT_TRUE(capturer.CaptureFrame()); |
1818 // Expect 2 reconfigurations at this point, from the initial configuration | 1821 // Expect 1 reconfigurations at this point from the initial configuration. |
1819 // and from the dimensions of the first frame. | 1822 EXPECT_EQ(1, send_stream->num_encoder_reconfigurations()); |
1820 EXPECT_EQ(2, send_stream->num_encoder_reconfigurations()); | |
1821 | 1823 |
1822 // Set the options one more time and expect no additional reconfigurations. | 1824 // Set the options one more time and expect no additional reconfigurations. |
1823 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &options, &capturer)); | 1825 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &options, &capturer)); |
1824 EXPECT_TRUE(capturer.CaptureFrame()); | 1826 EXPECT_EQ(1, send_stream->num_encoder_reconfigurations()); |
| 1827 |
| 1828 // Change |options| and expect 2 reconfigurations. |
| 1829 options.is_screencast = rtc::Optional<bool>(true); |
| 1830 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, &options, &capturer)); |
1825 EXPECT_EQ(2, send_stream->num_encoder_reconfigurations()); | 1831 EXPECT_EQ(2, send_stream->num_encoder_reconfigurations()); |
1826 | 1832 |
1827 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); | 1833 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); |
1828 } | 1834 } |
1829 | 1835 |
1830 class Vp9SettingsTest : public WebRtcVideoChannel2Test { | 1836 class Vp9SettingsTest : public WebRtcVideoChannel2Test { |
1831 public: | 1837 public: |
1832 Vp9SettingsTest() : Vp9SettingsTest("") {} | 1838 Vp9SettingsTest() : Vp9SettingsTest("") {} |
1833 explicit Vp9SettingsTest(const char* field_trials) | 1839 explicit Vp9SettingsTest(const char* field_trials) |
1834 : WebRtcVideoChannel2Test(field_trials) { | 1840 : WebRtcVideoChannel2Test(field_trials) { |
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2307 ASSERT_TRUE(channel_->SetSendParameters(parameters)); | 2313 ASSERT_TRUE(channel_->SetSendParameters(parameters)); |
2308 stream = fake_call_->GetVideoSendStreams()[0]; | 2314 stream = fake_call_->GetVideoSendStreams()[0]; |
2309 ASSERT_TRUE(stream != NULL); | 2315 ASSERT_TRUE(stream != NULL); |
2310 config = stream->GetConfig().Copy(); | 2316 config = stream->GetConfig().Copy(); |
2311 EXPECT_EQ(-1, config.rtp.fec.ulpfec_payload_type) | 2317 EXPECT_EQ(-1, config.rtp.fec.ulpfec_payload_type) |
2312 << "SetSendCodec without FEC should disable current FEC."; | 2318 << "SetSendCodec without FEC should disable current FEC."; |
2313 } | 2319 } |
2314 | 2320 |
2315 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsChangesExistingStreams) { | 2321 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsChangesExistingStreams) { |
2316 cricket::VideoSendParameters parameters; | 2322 cricket::VideoSendParameters parameters; |
2317 parameters.codecs.push_back(kVp8Codec720p); | 2323 cricket::VideoCodec codec720p(100, "VP8", 1280, 720, 30); |
| 2324 codec720p.SetParam(kCodecParamMaxQuantization, kDefaultQpMax); |
| 2325 parameters.codecs.push_back(codec720p); |
| 2326 |
2318 ASSERT_TRUE(channel_->SetSendParameters(parameters)); | 2327 ASSERT_TRUE(channel_->SetSendParameters(parameters)); |
2319 channel_->SetSend(true); | 2328 channel_->SetSend(true); |
2320 | 2329 |
2321 FakeVideoSendStream* stream = AddSendStream(); | 2330 FakeVideoSendStream* stream = AddSendStream(); |
2322 | |
2323 cricket::FakeVideoCapturer capturer; | 2331 cricket::FakeVideoCapturer capturer; |
2324 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, &capturer)); | 2332 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, &capturer)); |
2325 EXPECT_EQ(cricket::CS_RUNNING, | |
2326 capturer.Start(capturer.GetSupportedFormats()->front())); | |
2327 EXPECT_TRUE(capturer.CaptureFrame()); | |
2328 | 2333 |
2329 std::vector<webrtc::VideoStream> streams = stream->GetVideoStreams(); | 2334 std::vector<webrtc::VideoStream> streams = stream->GetVideoStreams(); |
2330 EXPECT_EQ(kVp8Codec720p.width, streams[0].width); | 2335 EXPECT_EQ(kDefaultQpMax, streams[0].max_qp); |
2331 EXPECT_EQ(kVp8Codec720p.height, streams[0].height); | |
2332 | 2336 |
2333 parameters.codecs.clear(); | 2337 parameters.codecs.clear(); |
2334 parameters.codecs.push_back(kVp8Codec360p); | 2338 codec720p.SetParam(kCodecParamMaxQuantization, kDefaultQpMax + 1); |
| 2339 parameters.codecs.push_back(codec720p); |
2335 ASSERT_TRUE(channel_->SetSendParameters(parameters)); | 2340 ASSERT_TRUE(channel_->SetSendParameters(parameters)); |
2336 streams = fake_call_->GetVideoSendStreams()[0]->GetVideoStreams(); | 2341 streams = stream->GetVideoStreams(); |
2337 EXPECT_EQ(kVp8Codec360p.width, streams[0].width); | 2342 EXPECT_EQ(kDefaultQpMax + 1, streams[0].max_qp); |
2338 EXPECT_EQ(kVp8Codec360p.height, streams[0].height); | |
2339 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); | 2343 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); |
2340 } | 2344 } |
2341 | 2345 |
2342 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithBitrates) { | 2346 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithBitrates) { |
2343 SetSendCodecsShouldWorkForBitrates("100", 100000, "150", 150000, "200", | 2347 SetSendCodecsShouldWorkForBitrates("100", 100000, "150", 150000, "200", |
2344 200000); | 2348 200000); |
2345 } | 2349 } |
2346 | 2350 |
2347 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithHighMaxBitrate) { | 2351 TEST_F(WebRtcVideoChannel2Test, SetSendCodecsWithHighMaxBitrate) { |
2348 SetSendCodecsShouldWorkForBitrates("", 0, "", -1, "10000", 10000000); | 2352 SetSendCodecsShouldWorkForBitrates("", 0, "", -1, "10000", 10000000); |
(...skipping 1052 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3401 AddSendStream(); | 3405 AddSendStream(); |
3402 | 3406 |
3403 cricket::FakeVideoCapturer capturer; | 3407 cricket::FakeVideoCapturer capturer; |
3404 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, &capturer)); | 3408 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, &capturer)); |
3405 cricket::VideoFormat capture_format_hd = | 3409 cricket::VideoFormat capture_format_hd = |
3406 capturer.GetSupportedFormats()->front(); | 3410 capturer.GetSupportedFormats()->front(); |
3407 EXPECT_EQ(1280, capture_format_hd.width); | 3411 EXPECT_EQ(1280, capture_format_hd.width); |
3408 EXPECT_EQ(720, capture_format_hd.height); | 3412 EXPECT_EQ(720, capture_format_hd.height); |
3409 EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(capture_format_hd)); | 3413 EXPECT_EQ(cricket::CS_RUNNING, capturer.Start(capture_format_hd)); |
3410 EXPECT_TRUE(channel_->SetSend(true)); | 3414 EXPECT_TRUE(channel_->SetSend(true)); |
| 3415 capturer.CaptureFrame(); |
3411 | 3416 |
3412 int default_encoder_bitrate = GetMaxEncoderBitrate(capturer); | 3417 int default_encoder_bitrate = GetMaxEncoderBitrate(); |
3413 EXPECT_TRUE(default_encoder_bitrate > 1000); | 3418 EXPECT_TRUE(default_encoder_bitrate > 1000); |
3414 | 3419 |
3415 // TODO(skvlad): Resolve the inconsistency between the interpretation | 3420 // TODO(skvlad): Resolve the inconsistency between the interpretation |
3416 // of the global bitrate limit for audio and video: | 3421 // of the global bitrate limit for audio and video: |
3417 // - Audio: max_bandwidth_bps = 0 - fail the operation, | 3422 // - Audio: max_bandwidth_bps = 0 - fail the operation, |
3418 // max_bandwidth_bps = -1 - remove the bandwidth limit | 3423 // max_bandwidth_bps = -1 - remove the bandwidth limit |
3419 // - Video: max_bandwidth_bps = 0 - remove the bandwidth limit, | 3424 // - Video: max_bandwidth_bps = 0 - remove the bandwidth limit, |
3420 // max_bandwidth_bps = -1 - do not change the previously set | 3425 // max_bandwidth_bps = -1 - do not change the previously set |
3421 // limit. | 3426 // limit. |
3422 | 3427 |
3423 SetAndExpectMaxBitrate(capturer, 1000, 0, 1000); | 3428 SetAndExpectMaxBitrate(1000, 0, 1000); |
3424 SetAndExpectMaxBitrate(capturer, 1000, 800, 800); | 3429 SetAndExpectMaxBitrate(1000, 800, 800); |
3425 SetAndExpectMaxBitrate(capturer, 600, 800, 600); | 3430 SetAndExpectMaxBitrate(600, 800, 600); |
3426 SetAndExpectMaxBitrate(capturer, 0, 800, 800); | 3431 SetAndExpectMaxBitrate(0, 800, 800); |
3427 SetAndExpectMaxBitrate(capturer, 0, 0, default_encoder_bitrate); | 3432 SetAndExpectMaxBitrate(0, 0, default_encoder_bitrate); |
3428 | 3433 |
3429 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); | 3434 EXPECT_TRUE(channel_->SetVideoSend(last_ssrc_, true, nullptr, nullptr)); |
3430 } | 3435 } |
3431 | 3436 |
3432 TEST_F(WebRtcVideoChannel2Test, CannotSetMaxBitrateForNonexistentStream) { | 3437 TEST_F(WebRtcVideoChannel2Test, CannotSetMaxBitrateForNonexistentStream) { |
3433 webrtc::RtpParameters nonexistent_parameters = | 3438 webrtc::RtpParameters nonexistent_parameters = |
3434 channel_->GetRtpSendParameters(last_ssrc_); | 3439 channel_->GetRtpSendParameters(last_ssrc_); |
3435 EXPECT_EQ(0, nonexistent_parameters.encodings.size()); | 3440 EXPECT_EQ(0, nonexistent_parameters.encodings.size()); |
3436 | 3441 |
3437 nonexistent_parameters.encodings.push_back(webrtc::RtpEncodingParameters()); | 3442 nonexistent_parameters.encodings.push_back(webrtc::RtpEncodingParameters()); |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3765 EXPECT_FALSE(expected_streams[i].temporal_layer_thresholds_bps.empty()); | 3770 EXPECT_FALSE(expected_streams[i].temporal_layer_thresholds_bps.empty()); |
3766 EXPECT_EQ(expected_streams[i].temporal_layer_thresholds_bps, | 3771 EXPECT_EQ(expected_streams[i].temporal_layer_thresholds_bps, |
3767 video_streams[i].temporal_layer_thresholds_bps); | 3772 video_streams[i].temporal_layer_thresholds_bps); |
3768 | 3773 |
3769 if (i == num_streams - 1) { | 3774 if (i == num_streams - 1) { |
3770 total_max_bitrate_bps += video_streams[i].max_bitrate_bps; | 3775 total_max_bitrate_bps += video_streams[i].max_bitrate_bps; |
3771 } else { | 3776 } else { |
3772 total_max_bitrate_bps += video_streams[i].target_bitrate_bps; | 3777 total_max_bitrate_bps += video_streams[i].target_bitrate_bps; |
3773 } | 3778 } |
3774 } | 3779 } |
3775 cricket::VideoMediaInfo info; | 3780 // TODO - add GetStats test for this. |
3776 ASSERT_TRUE(channel_->GetStats(&info)); | 3781 // cricket::VideoMediaInfo info; |
3777 ASSERT_EQ(1u, info.senders.size()); | 3782 // ASSERT_TRUE(channel_->GetStats(&info)); |
3778 EXPECT_EQ(total_max_bitrate_bps, info.senders[0].preferred_bitrate); | 3783 // ASSERT_EQ(1u, info.senders.size()); |
| 3784 // EXPECT_EQ(total_max_bitrate_bps, info.senders[0].preferred_bitrate); |
3779 | 3785 |
3780 EXPECT_TRUE(channel_->SetVideoSend(ssrcs.front(), true, nullptr, nullptr)); | 3786 EXPECT_TRUE(channel_->SetVideoSend(ssrcs.front(), true, nullptr, nullptr)); |
3781 } | 3787 } |
3782 | 3788 |
3783 FakeVideoSendStream* AddSendStream() { | 3789 FakeVideoSendStream* AddSendStream() { |
3784 return AddSendStream(StreamParams::CreateLegacy(last_ssrc_++)); | 3790 return AddSendStream(StreamParams::CreateLegacy(last_ssrc_++)); |
3785 } | 3791 } |
3786 | 3792 |
3787 FakeVideoSendStream* AddSendStream(const StreamParams& sp) { | 3793 FakeVideoSendStream* AddSendStream(const StreamParams& sp) { |
3788 size_t num_streams = | 3794 size_t num_streams = |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3827 } | 3833 } |
3828 | 3834 |
3829 // Test that we normalize send codec format size in simulcast. | 3835 // Test that we normalize send codec format size in simulcast. |
3830 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWithOddSizeInSimulcast) { | 3836 TEST_F(WebRtcVideoChannel2SimulcastTest, SetSendCodecsWithOddSizeInSimulcast) { |
3831 cricket::VideoCodec codec(kVp8Codec270p); | 3837 cricket::VideoCodec codec(kVp8Codec270p); |
3832 codec.width += 1; | 3838 codec.width += 1; |
3833 codec.height += 1; | 3839 codec.height += 1; |
3834 VerifySimulcastSettings(codec, 2, 2); | 3840 VerifySimulcastSettings(codec, 2, 2); |
3835 } | 3841 } |
3836 } // namespace cricket | 3842 } // namespace cricket |
OLD | NEW |