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 Call::Config call_config; | 63 CreateSenderCall(Call::Config(&event_log_)); |
64 CreateSenderCall(call_config); | |
65 | 64 |
66 test::NullTransport transport; | 65 test::NullTransport transport; |
67 CreateSendConfig(1, 0, &transport); | 66 CreateSendConfig(1, 0, &transport); |
68 CreateVideoStreams(); | 67 CreateVideoStreams(); |
69 video_send_stream_->Start(); | 68 video_send_stream_->Start(); |
70 video_send_stream_->Start(); | 69 video_send_stream_->Start(); |
71 DestroyStreams(); | 70 DestroyStreams(); |
72 } | 71 } |
73 | 72 |
74 TEST_F(VideoSendStreamTest, CanStopStoppedStream) { | 73 TEST_F(VideoSendStreamTest, CanStopStoppedStream) { |
75 Call::Config call_config; | 74 CreateSenderCall(Call::Config(&event_log_)); |
76 CreateSenderCall(call_config); | |
77 | 75 |
78 test::NullTransport transport; | 76 test::NullTransport transport; |
79 CreateSendConfig(1, 0, &transport); | 77 CreateSendConfig(1, 0, &transport); |
80 CreateVideoStreams(); | 78 CreateVideoStreams(); |
81 video_send_stream_->Stop(); | 79 video_send_stream_->Stop(); |
82 video_send_stream_->Stop(); | 80 video_send_stream_->Stop(); |
83 DestroyStreams(); | 81 DestroyStreams(); |
84 } | 82 } |
85 | 83 |
86 TEST_F(VideoSendStreamTest, SupportsCName) { | 84 TEST_F(VideoSendStreamTest, SupportsCName) { |
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
728 // Increase frame size for next encoded frame, in the context of the | 726 // Increase frame size for next encoded frame, in the context of the |
729 // encoder thread. | 727 // encoder thread. |
730 if (!use_fec_ && | 728 if (!use_fec_ && |
731 current_size_frame_.Value() < static_cast<int32_t>(stop_size_)) { | 729 current_size_frame_.Value() < static_cast<int32_t>(stop_size_)) { |
732 ++current_size_frame_; | 730 ++current_size_frame_; |
733 } | 731 } |
734 encoder_.SetFrameSize(static_cast<size_t>(current_size_frame_.Value())); | 732 encoder_.SetFrameSize(static_cast<size_t>(current_size_frame_.Value())); |
735 } | 733 } |
736 | 734 |
737 Call::Config GetSenderCallConfig() override { | 735 Call::Config GetSenderCallConfig() override { |
738 Call::Config config; | 736 Call::Config config(&event_log_); |
739 const int kMinBitrateBps = 30000; | 737 const int kMinBitrateBps = 30000; |
740 config.bitrate_config.min_bitrate_bps = kMinBitrateBps; | 738 config.bitrate_config.min_bitrate_bps = kMinBitrateBps; |
741 return config; | 739 return config; |
742 } | 740 } |
743 | 741 |
744 void ModifyVideoConfigs( | 742 void ModifyVideoConfigs( |
745 VideoSendStream::Config* send_config, | 743 VideoSendStream::Config* send_config, |
746 std::vector<VideoReceiveStream::Config>* receive_configs, | 744 std::vector<VideoReceiveStream::Config>* receive_configs, |
747 VideoEncoderConfig* encoder_config) override { | 745 VideoEncoderConfig* encoder_config) override { |
748 transport_adapter_.reset( | 746 transport_adapter_.reset( |
(...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1431 return 0; | 1429 return 0; |
1432 } | 1430 } |
1433 | 1431 |
1434 rtc::CriticalSection crit_; | 1432 rtc::CriticalSection crit_; |
1435 rtc::Event init_encode_called_; | 1433 rtc::Event init_encode_called_; |
1436 size_t number_of_initializations_ GUARDED_BY(&crit_); | 1434 size_t number_of_initializations_ GUARDED_BY(&crit_); |
1437 int last_initialized_frame_width_ GUARDED_BY(&crit_); | 1435 int last_initialized_frame_width_ GUARDED_BY(&crit_); |
1438 int last_initialized_frame_height_ GUARDED_BY(&crit_); | 1436 int last_initialized_frame_height_ GUARDED_BY(&crit_); |
1439 }; | 1437 }; |
1440 | 1438 |
1441 CreateSenderCall(Call::Config()); | 1439 CreateSenderCall(Call::Config(&event_log_)); |
1442 test::NullTransport transport; | 1440 test::NullTransport transport; |
1443 CreateSendConfig(1, 0, &transport); | 1441 CreateSendConfig(1, 0, &transport); |
1444 EncoderObserver encoder; | 1442 EncoderObserver encoder; |
1445 video_send_config_.encoder_settings.encoder = &encoder; | 1443 video_send_config_.encoder_settings.encoder = &encoder; |
1446 CreateVideoStreams(); | 1444 CreateVideoStreams(); |
1447 CreateFrameGeneratorCapturer(kDefaultFramerate, kDefaultWidth, | 1445 CreateFrameGeneratorCapturer(kDefaultFramerate, kDefaultWidth, |
1448 kDefaultHeight); | 1446 kDefaultHeight); |
1449 frame_generator_capturer_->Start(); | 1447 frame_generator_capturer_->Start(); |
1450 | 1448 |
1451 encoder.WaitForResolution(kDefaultWidth, kDefaultHeight); | 1449 encoder.WaitForResolution(kDefaultWidth, kDefaultHeight); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1487 return start_bitrate_changed_.Wait( | 1485 return start_bitrate_changed_.Wait( |
1488 VideoSendStreamTest::kDefaultTimeoutMs); | 1486 VideoSendStreamTest::kDefaultTimeoutMs); |
1489 } | 1487 } |
1490 | 1488 |
1491 private: | 1489 private: |
1492 rtc::CriticalSection crit_; | 1490 rtc::CriticalSection crit_; |
1493 rtc::Event start_bitrate_changed_; | 1491 rtc::Event start_bitrate_changed_; |
1494 int start_bitrate_kbps_ GUARDED_BY(crit_); | 1492 int start_bitrate_kbps_ GUARDED_BY(crit_); |
1495 }; | 1493 }; |
1496 | 1494 |
1497 CreateSenderCall(Call::Config()); | 1495 CreateSenderCall(Call::Config(&event_log_)); |
1498 | 1496 |
1499 test::NullTransport transport; | 1497 test::NullTransport transport; |
1500 CreateSendConfig(1, 0, &transport); | 1498 CreateSendConfig(1, 0, &transport); |
1501 | 1499 |
1502 Call::Config::BitrateConfig bitrate_config; | 1500 Call::Config::BitrateConfig bitrate_config; |
1503 bitrate_config.start_bitrate_bps = 2 * video_encoder_config_.max_bitrate_bps; | 1501 bitrate_config.start_bitrate_bps = 2 * video_encoder_config_.max_bitrate_bps; |
1504 sender_call_->SetBitrateConfig(bitrate_config); | 1502 sender_call_->SetBitrateConfig(bitrate_config); |
1505 | 1503 |
1506 StartBitrateObserver encoder; | 1504 StartBitrateObserver encoder; |
1507 video_send_config_.encoder_settings.encoder = &encoder; | 1505 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); | 1566 return bitrate_changed_.Wait(VideoSendStreamTest::kDefaultTimeoutMs); |
1569 } | 1567 } |
1570 | 1568 |
1571 private: | 1569 private: |
1572 rtc::CriticalSection crit_; | 1570 rtc::CriticalSection crit_; |
1573 rtc::Event encoder_init_; | 1571 rtc::Event encoder_init_; |
1574 rtc::Event bitrate_changed_; | 1572 rtc::Event bitrate_changed_; |
1575 int bitrate_kbps_ GUARDED_BY(crit_); | 1573 int bitrate_kbps_ GUARDED_BY(crit_); |
1576 }; | 1574 }; |
1577 | 1575 |
1578 CreateSenderCall(Call::Config()); | 1576 CreateSenderCall(Call::Config(&event_log_)); |
1579 | 1577 |
1580 test::NullTransport transport; | 1578 test::NullTransport transport; |
1581 CreateSendConfig(1, 0, &transport); | 1579 CreateSendConfig(1, 0, &transport); |
1582 | 1580 |
1583 StartStopBitrateObserver encoder; | 1581 StartStopBitrateObserver encoder; |
1584 video_send_config_.encoder_settings.encoder = &encoder; | 1582 video_send_config_.encoder_settings.encoder = &encoder; |
1585 video_send_config_.encoder_settings.internal_source = true; | 1583 video_send_config_.encoder_settings.internal_source = true; |
1586 | 1584 |
1587 CreateVideoStreams(); | 1585 CreateVideoStreams(); |
1588 | 1586 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1623 | 1621 |
1624 private: | 1622 private: |
1625 // Delivered output frames. | 1623 // Delivered output frames. |
1626 std::vector<VideoFrame> output_frames_; | 1624 std::vector<VideoFrame> output_frames_; |
1627 | 1625 |
1628 // Indicate an output frame has arrived. | 1626 // Indicate an output frame has arrived. |
1629 rtc::Event output_frame_event_; | 1627 rtc::Event output_frame_event_; |
1630 }; | 1628 }; |
1631 | 1629 |
1632 // Initialize send stream. | 1630 // Initialize send stream. |
1633 CreateSenderCall(Call::Config()); | 1631 CreateSenderCall(Call::Config(&event_log_)); |
1634 | 1632 |
1635 test::NullTransport transport; | 1633 test::NullTransport transport; |
1636 CreateSendConfig(1, 0, &transport); | 1634 CreateSendConfig(1, 0, &transport); |
1637 FrameObserver observer; | 1635 FrameObserver observer; |
1638 video_send_config_.pre_encode_callback = &observer; | 1636 video_send_config_.pre_encode_callback = &observer; |
1639 CreateVideoStreams(); | 1637 CreateVideoStreams(); |
1640 | 1638 |
1641 // Prepare five input frames. Send ordinary VideoFrame and texture frames | 1639 // Prepare five input frames. Send ordinary VideoFrame and texture frames |
1642 // alternatively. | 1640 // alternatively. |
1643 std::vector<VideoFrame> input_frames; | 1641 std::vector<VideoFrame> input_frames; |
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2262 | 2260 |
2263 void WaitForSetRates(uint32_t expected_bitrate) { | 2261 void WaitForSetRates(uint32_t expected_bitrate) { |
2264 EXPECT_TRUE( | 2262 EXPECT_TRUE( |
2265 bitrate_changed_event_.Wait(VideoSendStreamTest::kDefaultTimeoutMs)) | 2263 bitrate_changed_event_.Wait(VideoSendStreamTest::kDefaultTimeoutMs)) |
2266 << "Timed out while waiting encoder rate to be set."; | 2264 << "Timed out while waiting encoder rate to be set."; |
2267 rtc::CritScope lock(&crit_); | 2265 rtc::CritScope lock(&crit_); |
2268 EXPECT_EQ(expected_bitrate, target_bitrate_); | 2266 EXPECT_EQ(expected_bitrate, target_bitrate_); |
2269 } | 2267 } |
2270 | 2268 |
2271 Call::Config GetSenderCallConfig() override { | 2269 Call::Config GetSenderCallConfig() override { |
2272 Call::Config config; | 2270 Call::Config config(&event_log_); |
2273 config.bitrate_config.min_bitrate_bps = kMinBitrateKbps * 1000; | 2271 config.bitrate_config.min_bitrate_bps = kMinBitrateKbps * 1000; |
2274 config.bitrate_config.start_bitrate_bps = kStartBitrateKbps * 1000; | 2272 config.bitrate_config.start_bitrate_bps = kStartBitrateKbps * 1000; |
2275 config.bitrate_config.max_bitrate_bps = kMaxBitrateKbps * 1000; | 2273 config.bitrate_config.max_bitrate_bps = kMaxBitrateKbps * 1000; |
2276 return config; | 2274 return config; |
2277 } | 2275 } |
2278 | 2276 |
2279 class VideoStreamFactory | 2277 class VideoStreamFactory |
2280 : public VideoEncoderConfig::VideoStreamFactoryInterface { | 2278 : public VideoEncoderConfig::VideoStreamFactoryInterface { |
2281 public: | 2279 public: |
2282 explicit VideoStreamFactory(int min_bitrate_bps) | 2280 explicit VideoStreamFactory(int min_bitrate_bps) |
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2890 observation_complete_.Set(); | 2888 observation_complete_.Set(); |
2891 } | 2889 } |
2892 } | 2890 } |
2893 } test; | 2891 } test; |
2894 | 2892 |
2895 RunBaseTest(&test); | 2893 RunBaseTest(&test); |
2896 } | 2894 } |
2897 #endif // !defined(RTC_DISABLE_VP9) | 2895 #endif // !defined(RTC_DISABLE_VP9) |
2898 | 2896 |
2899 } // namespace webrtc | 2897 } // namespace webrtc |
OLD | NEW |