OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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 #include <algorithm> // max | 10 #include <algorithm> // max |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 protected: | 53 protected: |
54 void TestNackRetransmission(uint32_t retransmit_ssrc, | 54 void TestNackRetransmission(uint32_t retransmit_ssrc, |
55 uint8_t retransmit_payload_type); | 55 uint8_t retransmit_payload_type); |
56 void TestPacketFragmentationSize(VideoFormat format, bool with_fec); | 56 void TestPacketFragmentationSize(VideoFormat format, bool with_fec); |
57 | 57 |
58 void TestVp9NonFlexMode(uint8_t num_temporal_layers, | 58 void TestVp9NonFlexMode(uint8_t num_temporal_layers, |
59 uint8_t num_spatial_layers); | 59 uint8_t num_spatial_layers); |
60 }; | 60 }; |
61 | 61 |
62 TEST_F(VideoSendStreamTest, CanStartStartedStream) { | 62 TEST_F(VideoSendStreamTest, CanStartStartedStream) { |
| 63 webrtc::RtcEventLogNullImpl event_log; |
63 Call::Config call_config; | 64 Call::Config call_config; |
| 65 call_config.event_log = &event_log; |
64 CreateSenderCall(call_config); | 66 CreateSenderCall(call_config); |
65 | 67 |
66 test::NullTransport transport; | 68 test::NullTransport transport; |
67 CreateSendConfig(1, 0, &transport); | 69 CreateSendConfig(1, 0, &transport); |
68 CreateVideoStreams(); | 70 CreateVideoStreams(); |
69 video_send_stream_->Start(); | 71 video_send_stream_->Start(); |
70 video_send_stream_->Start(); | 72 video_send_stream_->Start(); |
71 DestroyStreams(); | 73 DestroyStreams(); |
72 } | 74 } |
73 | 75 |
74 TEST_F(VideoSendStreamTest, CanStopStoppedStream) { | 76 TEST_F(VideoSendStreamTest, CanStopStoppedStream) { |
| 77 webrtc::RtcEventLogNullImpl event_log; |
75 Call::Config call_config; | 78 Call::Config call_config; |
| 79 call_config.event_log = &event_log; |
76 CreateSenderCall(call_config); | 80 CreateSenderCall(call_config); |
77 | 81 |
78 test::NullTransport transport; | 82 test::NullTransport transport; |
79 CreateSendConfig(1, 0, &transport); | 83 CreateSendConfig(1, 0, &transport); |
80 CreateVideoStreams(); | 84 CreateVideoStreams(); |
81 video_send_stream_->Stop(); | 85 video_send_stream_->Stop(); |
82 video_send_stream_->Stop(); | 86 video_send_stream_->Stop(); |
83 DestroyStreams(); | 87 DestroyStreams(); |
84 } | 88 } |
85 | 89 |
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
731 current_size_frame_.Value() < static_cast<int32_t>(stop_size_)) { | 735 current_size_frame_.Value() < static_cast<int32_t>(stop_size_)) { |
732 ++current_size_frame_; | 736 ++current_size_frame_; |
733 } | 737 } |
734 encoder_.SetFrameSize(static_cast<size_t>(current_size_frame_.Value())); | 738 encoder_.SetFrameSize(static_cast<size_t>(current_size_frame_.Value())); |
735 } | 739 } |
736 | 740 |
737 Call::Config GetSenderCallConfig() override { | 741 Call::Config GetSenderCallConfig() override { |
738 Call::Config config; | 742 Call::Config config; |
739 const int kMinBitrateBps = 30000; | 743 const int kMinBitrateBps = 30000; |
740 config.bitrate_config.min_bitrate_bps = kMinBitrateBps; | 744 config.bitrate_config.min_bitrate_bps = kMinBitrateBps; |
| 745 config.event_log = &event_log_; |
741 return config; | 746 return config; |
742 } | 747 } |
743 | 748 |
744 void ModifyVideoConfigs( | 749 void ModifyVideoConfigs( |
745 VideoSendStream::Config* send_config, | 750 VideoSendStream::Config* send_config, |
746 std::vector<VideoReceiveStream::Config>* receive_configs, | 751 std::vector<VideoReceiveStream::Config>* receive_configs, |
747 VideoEncoderConfig* encoder_config) override { | 752 VideoEncoderConfig* encoder_config) override { |
748 transport_adapter_.reset( | 753 transport_adapter_.reset( |
749 new internal::TransportAdapter(send_config->send_transport)); | 754 new internal::TransportAdapter(send_config->send_transport)); |
750 transport_adapter_->Enable(); | 755 transport_adapter_->Enable(); |
(...skipping 11 matching lines...) Expand all Loading... |
762 | 767 |
763 // Make sure there is at least one extension header, to make the RTP | 768 // Make sure there is at least one extension header, to make the RTP |
764 // header larger than the base length of 12 bytes. | 769 // header larger than the base length of 12 bytes. |
765 EXPECT_FALSE(send_config->rtp.extensions.empty()); | 770 EXPECT_FALSE(send_config->rtp.extensions.empty()); |
766 } | 771 } |
767 | 772 |
768 void PerformTest() override { | 773 void PerformTest() override { |
769 EXPECT_TRUE(Wait()) << "Timed out while observing incoming RTP packets."; | 774 EXPECT_TRUE(Wait()) << "Timed out while observing incoming RTP packets."; |
770 } | 775 } |
771 | 776 |
| 777 webrtc::RtcEventLogNullImpl event_log_; |
772 std::unique_ptr<internal::TransportAdapter> transport_adapter_; | 778 std::unique_ptr<internal::TransportAdapter> transport_adapter_; |
773 test::ConfigurableFrameSizeEncoder encoder_; | 779 test::ConfigurableFrameSizeEncoder encoder_; |
774 | 780 |
775 const size_t max_packet_size_; | 781 const size_t max_packet_size_; |
776 const size_t stop_size_; | 782 const size_t stop_size_; |
777 const bool test_generic_packetization_; | 783 const bool test_generic_packetization_; |
778 const bool use_fec_; | 784 const bool use_fec_; |
779 | 785 |
780 uint32_t packet_count_; | 786 uint32_t packet_count_; |
781 size_t accumulated_size_; | 787 size_t accumulated_size_; |
(...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1431 return 0; | 1437 return 0; |
1432 } | 1438 } |
1433 | 1439 |
1434 rtc::CriticalSection crit_; | 1440 rtc::CriticalSection crit_; |
1435 rtc::Event init_encode_called_; | 1441 rtc::Event init_encode_called_; |
1436 size_t number_of_initializations_ GUARDED_BY(&crit_); | 1442 size_t number_of_initializations_ GUARDED_BY(&crit_); |
1437 int last_initialized_frame_width_ GUARDED_BY(&crit_); | 1443 int last_initialized_frame_width_ GUARDED_BY(&crit_); |
1438 int last_initialized_frame_height_ GUARDED_BY(&crit_); | 1444 int last_initialized_frame_height_ GUARDED_BY(&crit_); |
1439 }; | 1445 }; |
1440 | 1446 |
1441 CreateSenderCall(Call::Config()); | 1447 webrtc::RtcEventLogNullImpl event_log; |
| 1448 Call::Config call_config; |
| 1449 call_config.event_log = &event_log; |
| 1450 CreateSenderCall(call_config); |
1442 test::NullTransport transport; | 1451 test::NullTransport transport; |
1443 CreateSendConfig(1, 0, &transport); | 1452 CreateSendConfig(1, 0, &transport); |
1444 EncoderObserver encoder; | 1453 EncoderObserver encoder; |
1445 video_send_config_.encoder_settings.encoder = &encoder; | 1454 video_send_config_.encoder_settings.encoder = &encoder; |
1446 CreateVideoStreams(); | 1455 CreateVideoStreams(); |
1447 CreateFrameGeneratorCapturer(kDefaultFramerate, kDefaultWidth, | 1456 CreateFrameGeneratorCapturer(kDefaultFramerate, kDefaultWidth, |
1448 kDefaultHeight); | 1457 kDefaultHeight); |
1449 frame_generator_capturer_->Start(); | 1458 frame_generator_capturer_->Start(); |
1450 | 1459 |
1451 encoder.WaitForResolution(kDefaultWidth, kDefaultHeight); | 1460 encoder.WaitForResolution(kDefaultWidth, kDefaultHeight); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1487 return start_bitrate_changed_.Wait( | 1496 return start_bitrate_changed_.Wait( |
1488 VideoSendStreamTest::kDefaultTimeoutMs); | 1497 VideoSendStreamTest::kDefaultTimeoutMs); |
1489 } | 1498 } |
1490 | 1499 |
1491 private: | 1500 private: |
1492 rtc::CriticalSection crit_; | 1501 rtc::CriticalSection crit_; |
1493 rtc::Event start_bitrate_changed_; | 1502 rtc::Event start_bitrate_changed_; |
1494 int start_bitrate_kbps_ GUARDED_BY(crit_); | 1503 int start_bitrate_kbps_ GUARDED_BY(crit_); |
1495 }; | 1504 }; |
1496 | 1505 |
1497 CreateSenderCall(Call::Config()); | 1506 webrtc::RtcEventLogNullImpl event_log; |
| 1507 Call::Config call_config; |
| 1508 call_config.event_log = &event_log; |
| 1509 CreateSenderCall(call_config); |
1498 | 1510 |
1499 test::NullTransport transport; | 1511 test::NullTransport transport; |
1500 CreateSendConfig(1, 0, &transport); | 1512 CreateSendConfig(1, 0, &transport); |
1501 | 1513 |
1502 Call::Config::BitrateConfig bitrate_config; | 1514 Call::Config::BitrateConfig bitrate_config; |
1503 bitrate_config.start_bitrate_bps = 2 * video_encoder_config_.max_bitrate_bps; | 1515 bitrate_config.start_bitrate_bps = 2 * video_encoder_config_.max_bitrate_bps; |
1504 sender_call_->SetBitrateConfig(bitrate_config); | 1516 sender_call_->SetBitrateConfig(bitrate_config); |
1505 | 1517 |
1506 StartBitrateObserver encoder; | 1518 StartBitrateObserver encoder; |
1507 video_send_config_.encoder_settings.encoder = &encoder; | 1519 video_send_config_.encoder_settings.encoder = &encoder; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1568 return bitrate_changed_.Wait(VideoSendStreamTest::kDefaultTimeoutMs); | 1580 return bitrate_changed_.Wait(VideoSendStreamTest::kDefaultTimeoutMs); |
1569 } | 1581 } |
1570 | 1582 |
1571 private: | 1583 private: |
1572 rtc::CriticalSection crit_; | 1584 rtc::CriticalSection crit_; |
1573 rtc::Event encoder_init_; | 1585 rtc::Event encoder_init_; |
1574 rtc::Event bitrate_changed_; | 1586 rtc::Event bitrate_changed_; |
1575 int bitrate_kbps_ GUARDED_BY(crit_); | 1587 int bitrate_kbps_ GUARDED_BY(crit_); |
1576 }; | 1588 }; |
1577 | 1589 |
1578 CreateSenderCall(Call::Config()); | 1590 webrtc::RtcEventLogNullImpl event_log; |
| 1591 Call::Config call_config; |
| 1592 call_config.event_log = &event_log; |
| 1593 CreateSenderCall(call_config); |
1579 | 1594 |
1580 test::NullTransport transport; | 1595 test::NullTransport transport; |
1581 CreateSendConfig(1, 0, &transport); | 1596 CreateSendConfig(1, 0, &transport); |
1582 | 1597 |
1583 StartStopBitrateObserver encoder; | 1598 StartStopBitrateObserver encoder; |
1584 video_send_config_.encoder_settings.encoder = &encoder; | 1599 video_send_config_.encoder_settings.encoder = &encoder; |
1585 video_send_config_.encoder_settings.internal_source = true; | 1600 video_send_config_.encoder_settings.internal_source = true; |
1586 | 1601 |
1587 CreateVideoStreams(); | 1602 CreateVideoStreams(); |
1588 | 1603 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1623 | 1638 |
1624 private: | 1639 private: |
1625 // Delivered output frames. | 1640 // Delivered output frames. |
1626 std::vector<VideoFrame> output_frames_; | 1641 std::vector<VideoFrame> output_frames_; |
1627 | 1642 |
1628 // Indicate an output frame has arrived. | 1643 // Indicate an output frame has arrived. |
1629 rtc::Event output_frame_event_; | 1644 rtc::Event output_frame_event_; |
1630 }; | 1645 }; |
1631 | 1646 |
1632 // Initialize send stream. | 1647 // Initialize send stream. |
1633 CreateSenderCall(Call::Config()); | 1648 webrtc::RtcEventLogNullImpl event_log; |
| 1649 Call::Config call_config; |
| 1650 call_config.event_log = &event_log; |
| 1651 CreateSenderCall(call_config); |
1634 | 1652 |
1635 test::NullTransport transport; | 1653 test::NullTransport transport; |
1636 CreateSendConfig(1, 0, &transport); | 1654 CreateSendConfig(1, 0, &transport); |
1637 FrameObserver observer; | 1655 FrameObserver observer; |
1638 video_send_config_.pre_encode_callback = &observer; | 1656 video_send_config_.pre_encode_callback = &observer; |
1639 CreateVideoStreams(); | 1657 CreateVideoStreams(); |
1640 | 1658 |
1641 // Prepare five input frames. Send ordinary VideoFrame and texture frames | 1659 // Prepare five input frames. Send ordinary VideoFrame and texture frames |
1642 // alternatively. | 1660 // alternatively. |
1643 std::vector<VideoFrame> input_frames; | 1661 std::vector<VideoFrame> input_frames; |
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2263 void WaitForSetRates(uint32_t expected_bitrate) { | 2281 void WaitForSetRates(uint32_t expected_bitrate) { |
2264 EXPECT_TRUE( | 2282 EXPECT_TRUE( |
2265 bitrate_changed_event_.Wait(VideoSendStreamTest::kDefaultTimeoutMs)) | 2283 bitrate_changed_event_.Wait(VideoSendStreamTest::kDefaultTimeoutMs)) |
2266 << "Timed out while waiting encoder rate to be set."; | 2284 << "Timed out while waiting encoder rate to be set."; |
2267 rtc::CritScope lock(&crit_); | 2285 rtc::CritScope lock(&crit_); |
2268 EXPECT_EQ(expected_bitrate, target_bitrate_); | 2286 EXPECT_EQ(expected_bitrate, target_bitrate_); |
2269 } | 2287 } |
2270 | 2288 |
2271 Call::Config GetSenderCallConfig() override { | 2289 Call::Config GetSenderCallConfig() override { |
2272 Call::Config config; | 2290 Call::Config config; |
| 2291 config.event_log = &event_log_; |
2273 config.bitrate_config.min_bitrate_bps = kMinBitrateKbps * 1000; | 2292 config.bitrate_config.min_bitrate_bps = kMinBitrateKbps * 1000; |
2274 config.bitrate_config.start_bitrate_bps = kStartBitrateKbps * 1000; | 2293 config.bitrate_config.start_bitrate_bps = kStartBitrateKbps * 1000; |
2275 config.bitrate_config.max_bitrate_bps = kMaxBitrateKbps * 1000; | 2294 config.bitrate_config.max_bitrate_bps = kMaxBitrateKbps * 1000; |
2276 return config; | 2295 return config; |
2277 } | 2296 } |
2278 | 2297 |
2279 class VideoStreamFactory | 2298 class VideoStreamFactory |
2280 : public VideoEncoderConfig::VideoStreamFactoryInterface { | 2299 : public VideoEncoderConfig::VideoStreamFactoryInterface { |
2281 public: | 2300 public: |
2282 explicit VideoStreamFactory(int min_bitrate_bps) | 2301 explicit VideoStreamFactory(int min_bitrate_bps) |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2344 send_stream_->ReconfigureVideoEncoder(encoder_config_.Copy()); | 2363 send_stream_->ReconfigureVideoEncoder(encoder_config_.Copy()); |
2345 ASSERT_TRUE( | 2364 ASSERT_TRUE( |
2346 init_encode_event_.Wait(VideoSendStreamTest::kDefaultTimeoutMs)); | 2365 init_encode_event_.Wait(VideoSendStreamTest::kDefaultTimeoutMs)); |
2347 EXPECT_EQ(4, num_initializations_) | 2366 EXPECT_EQ(4, num_initializations_) |
2348 << "Encoder should have been reconfigured with the new value."; | 2367 << "Encoder should have been reconfigured with the new value."; |
2349 // Expected target bitrate is the start bitrate set in the call to | 2368 // Expected target bitrate is the start bitrate set in the call to |
2350 // call_->SetBitrateConfig. | 2369 // call_->SetBitrateConfig. |
2351 WaitForSetRates(kIncreasedStartBitrateKbps); | 2370 WaitForSetRates(kIncreasedStartBitrateKbps); |
2352 } | 2371 } |
2353 | 2372 |
| 2373 webrtc::RtcEventLogNullImpl event_log_; |
2354 rtc::Event init_encode_event_; | 2374 rtc::Event init_encode_event_; |
2355 rtc::Event bitrate_changed_event_; | 2375 rtc::Event bitrate_changed_event_; |
2356 rtc::CriticalSection crit_; | 2376 rtc::CriticalSection crit_; |
2357 uint32_t target_bitrate_ GUARDED_BY(&crit_); | 2377 uint32_t target_bitrate_ GUARDED_BY(&crit_); |
2358 | 2378 |
2359 int num_initializations_; | 2379 int num_initializations_; |
2360 webrtc::Call* call_; | 2380 webrtc::Call* call_; |
2361 webrtc::VideoSendStream* send_stream_; | 2381 webrtc::VideoSendStream* send_stream_; |
2362 webrtc::VideoEncoderConfig encoder_config_; | 2382 webrtc::VideoEncoderConfig encoder_config_; |
2363 } test; | 2383 } test; |
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2890 observation_complete_.Set(); | 2910 observation_complete_.Set(); |
2891 } | 2911 } |
2892 } | 2912 } |
2893 } test; | 2913 } test; |
2894 | 2914 |
2895 RunBaseTest(&test); | 2915 RunBaseTest(&test); |
2896 } | 2916 } |
2897 #endif // !defined(RTC_DISABLE_VP9) | 2917 #endif // !defined(RTC_DISABLE_VP9) |
2898 | 2918 |
2899 } // namespace webrtc | 2919 } // namespace webrtc |
OLD | NEW |