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