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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 uint8_t retransmit_payload_type); | 57 uint8_t retransmit_payload_type); |
58 void TestPacketFragmentationSize(VideoFormat format, bool with_fec); | 58 void TestPacketFragmentationSize(VideoFormat format, bool with_fec); |
59 | 59 |
60 void TestVp9NonFlexMode(uint8_t num_temporal_layers, | 60 void TestVp9NonFlexMode(uint8_t num_temporal_layers, |
61 uint8_t num_spatial_layers); | 61 uint8_t num_spatial_layers); |
62 | 62 |
63 void TestRequestSourceRotateVideo(bool support_orientation_ext); | 63 void TestRequestSourceRotateVideo(bool support_orientation_ext); |
64 }; | 64 }; |
65 | 65 |
66 TEST_F(VideoSendStreamTest, CanStartStartedStream) { | 66 TEST_F(VideoSendStreamTest, CanStartStartedStream) { |
67 CreateSenderCall(Call::Config(&event_log_)); | 67 CreateSenderCall(Call::Config(event_log_.get())); |
68 | 68 |
69 test::NullTransport transport; | 69 test::NullTransport transport; |
70 CreateSendConfig(1, 0, 0, &transport); | 70 CreateSendConfig(1, 0, 0, &transport); |
71 CreateVideoStreams(); | 71 CreateVideoStreams(); |
72 video_send_stream_->Start(); | 72 video_send_stream_->Start(); |
73 video_send_stream_->Start(); | 73 video_send_stream_->Start(); |
74 DestroyStreams(); | 74 DestroyStreams(); |
75 } | 75 } |
76 | 76 |
77 TEST_F(VideoSendStreamTest, CanStopStoppedStream) { | 77 TEST_F(VideoSendStreamTest, CanStopStoppedStream) { |
78 CreateSenderCall(Call::Config(&event_log_)); | 78 CreateSenderCall(Call::Config(event_log_.get())); |
79 | 79 |
80 test::NullTransport transport; | 80 test::NullTransport transport; |
81 CreateSendConfig(1, 0, 0, &transport); | 81 CreateSendConfig(1, 0, 0, &transport); |
82 CreateVideoStreams(); | 82 CreateVideoStreams(); |
83 video_send_stream_->Stop(); | 83 video_send_stream_->Stop(); |
84 video_send_stream_->Stop(); | 84 video_send_stream_->Stop(); |
85 DestroyStreams(); | 85 DestroyStreams(); |
86 } | 86 } |
87 | 87 |
88 TEST_F(VideoSendStreamTest, SupportsCName) { | 88 TEST_F(VideoSendStreamTest, SupportsCName) { |
(...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
914 // Increase frame size for next encoded frame, in the context of the | 914 // Increase frame size for next encoded frame, in the context of the |
915 // encoder thread. | 915 // encoder thread. |
916 if (!use_fec_ && | 916 if (!use_fec_ && |
917 current_size_frame_.Value() < static_cast<int32_t>(stop_size_)) { | 917 current_size_frame_.Value() < static_cast<int32_t>(stop_size_)) { |
918 ++current_size_frame_; | 918 ++current_size_frame_; |
919 } | 919 } |
920 encoder_.SetFrameSize(static_cast<size_t>(current_size_frame_.Value())); | 920 encoder_.SetFrameSize(static_cast<size_t>(current_size_frame_.Value())); |
921 } | 921 } |
922 | 922 |
923 Call::Config GetSenderCallConfig() override { | 923 Call::Config GetSenderCallConfig() override { |
924 Call::Config config(&event_log_); | 924 Call::Config config(event_log_.get()); |
925 const int kMinBitrateBps = 30000; | 925 const int kMinBitrateBps = 30000; |
926 config.bitrate_config.min_bitrate_bps = kMinBitrateBps; | 926 config.bitrate_config.min_bitrate_bps = kMinBitrateBps; |
927 return config; | 927 return config; |
928 } | 928 } |
929 | 929 |
930 void ModifyVideoConfigs( | 930 void ModifyVideoConfigs( |
931 VideoSendStream::Config* send_config, | 931 VideoSendStream::Config* send_config, |
932 std::vector<VideoReceiveStream::Config>* receive_configs, | 932 std::vector<VideoReceiveStream::Config>* receive_configs, |
933 VideoEncoderConfig* encoder_config) override { | 933 VideoEncoderConfig* encoder_config) override { |
934 transport_adapter_.reset( | 934 transport_adapter_.reset( |
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1705 return 0; | 1705 return 0; |
1706 } | 1706 } |
1707 | 1707 |
1708 rtc::CriticalSection crit_; | 1708 rtc::CriticalSection crit_; |
1709 rtc::Event init_encode_called_; | 1709 rtc::Event init_encode_called_; |
1710 size_t number_of_initializations_ GUARDED_BY(&crit_); | 1710 size_t number_of_initializations_ GUARDED_BY(&crit_); |
1711 int last_initialized_frame_width_ GUARDED_BY(&crit_); | 1711 int last_initialized_frame_width_ GUARDED_BY(&crit_); |
1712 int last_initialized_frame_height_ GUARDED_BY(&crit_); | 1712 int last_initialized_frame_height_ GUARDED_BY(&crit_); |
1713 }; | 1713 }; |
1714 | 1714 |
1715 CreateSenderCall(Call::Config(&event_log_)); | 1715 CreateSenderCall(Call::Config(event_log_.get())); |
1716 test::NullTransport transport; | 1716 test::NullTransport transport; |
1717 CreateSendConfig(1, 0, 0, &transport); | 1717 CreateSendConfig(1, 0, 0, &transport); |
1718 EncoderObserver encoder; | 1718 EncoderObserver encoder; |
1719 video_send_config_.encoder_settings.encoder = &encoder; | 1719 video_send_config_.encoder_settings.encoder = &encoder; |
1720 CreateVideoStreams(); | 1720 CreateVideoStreams(); |
1721 CreateFrameGeneratorCapturer(kDefaultFramerate, kDefaultWidth, | 1721 CreateFrameGeneratorCapturer(kDefaultFramerate, kDefaultWidth, |
1722 kDefaultHeight); | 1722 kDefaultHeight); |
1723 frame_generator_capturer_->Start(); | 1723 frame_generator_capturer_->Start(); |
1724 | 1724 |
1725 encoder.WaitForResolution(kDefaultWidth, kDefaultHeight); | 1725 encoder.WaitForResolution(kDefaultWidth, kDefaultHeight); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1761 return start_bitrate_changed_.Wait( | 1761 return start_bitrate_changed_.Wait( |
1762 VideoSendStreamTest::kDefaultTimeoutMs); | 1762 VideoSendStreamTest::kDefaultTimeoutMs); |
1763 } | 1763 } |
1764 | 1764 |
1765 private: | 1765 private: |
1766 rtc::CriticalSection crit_; | 1766 rtc::CriticalSection crit_; |
1767 rtc::Event start_bitrate_changed_; | 1767 rtc::Event start_bitrate_changed_; |
1768 int start_bitrate_kbps_ GUARDED_BY(crit_); | 1768 int start_bitrate_kbps_ GUARDED_BY(crit_); |
1769 }; | 1769 }; |
1770 | 1770 |
1771 CreateSenderCall(Call::Config(&event_log_)); | 1771 CreateSenderCall(Call::Config(event_log_.get())); |
1772 | 1772 |
1773 test::NullTransport transport; | 1773 test::NullTransport transport; |
1774 CreateSendConfig(1, 0, 0, &transport); | 1774 CreateSendConfig(1, 0, 0, &transport); |
1775 | 1775 |
1776 Call::Config::BitrateConfig bitrate_config; | 1776 Call::Config::BitrateConfig bitrate_config; |
1777 bitrate_config.start_bitrate_bps = 2 * video_encoder_config_.max_bitrate_bps; | 1777 bitrate_config.start_bitrate_bps = 2 * video_encoder_config_.max_bitrate_bps; |
1778 sender_call_->SetBitrateConfig(bitrate_config); | 1778 sender_call_->SetBitrateConfig(bitrate_config); |
1779 | 1779 |
1780 StartBitrateObserver encoder; | 1780 StartBitrateObserver encoder; |
1781 video_send_config_.encoder_settings.encoder = &encoder; | 1781 video_send_config_.encoder_settings.encoder = &encoder; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1851 return false; | 1851 return false; |
1852 } | 1852 } |
1853 | 1853 |
1854 private: | 1854 private: |
1855 rtc::CriticalSection crit_; | 1855 rtc::CriticalSection crit_; |
1856 rtc::Event encoder_init_; | 1856 rtc::Event encoder_init_; |
1857 rtc::Event bitrate_changed_; | 1857 rtc::Event bitrate_changed_; |
1858 rtc::Optional<int> bitrate_kbps_ GUARDED_BY(crit_); | 1858 rtc::Optional<int> bitrate_kbps_ GUARDED_BY(crit_); |
1859 }; | 1859 }; |
1860 | 1860 |
1861 CreateSenderCall(Call::Config(&event_log_)); | 1861 CreateSenderCall(Call::Config(event_log_.get())); |
1862 | 1862 |
1863 test::NullTransport transport; | 1863 test::NullTransport transport; |
1864 CreateSendConfig(1, 0, 0, &transport); | 1864 CreateSendConfig(1, 0, 0, &transport); |
1865 | 1865 |
1866 sender_call_->SignalChannelNetworkState(MediaType::VIDEO, kNetworkUp); | 1866 sender_call_->SignalChannelNetworkState(MediaType::VIDEO, kNetworkUp); |
1867 | 1867 |
1868 StartStopBitrateObserver encoder; | 1868 StartStopBitrateObserver encoder; |
1869 video_send_config_.encoder_settings.encoder = &encoder; | 1869 video_send_config_.encoder_settings.encoder = &encoder; |
1870 video_send_config_.encoder_settings.internal_source = true; | 1870 video_send_config_.encoder_settings.internal_source = true; |
1871 | 1871 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1907 | 1907 |
1908 private: | 1908 private: |
1909 // Delivered output frames. | 1909 // Delivered output frames. |
1910 std::vector<VideoFrame> output_frames_; | 1910 std::vector<VideoFrame> output_frames_; |
1911 | 1911 |
1912 // Indicate an output frame has arrived. | 1912 // Indicate an output frame has arrived. |
1913 rtc::Event output_frame_event_; | 1913 rtc::Event output_frame_event_; |
1914 }; | 1914 }; |
1915 | 1915 |
1916 // Initialize send stream. | 1916 // Initialize send stream. |
1917 CreateSenderCall(Call::Config(&event_log_)); | 1917 CreateSenderCall(Call::Config(event_log_.get())); |
1918 | 1918 |
1919 test::NullTransport transport; | 1919 test::NullTransport transport; |
1920 CreateSendConfig(1, 0, 0, &transport); | 1920 CreateSendConfig(1, 0, 0, &transport); |
1921 FrameObserver observer; | 1921 FrameObserver observer; |
1922 video_send_config_.pre_encode_callback = &observer; | 1922 video_send_config_.pre_encode_callback = &observer; |
1923 CreateVideoStreams(); | 1923 CreateVideoStreams(); |
1924 | 1924 |
1925 // Prepare five input frames. Send ordinary VideoFrame and texture frames | 1925 // Prepare five input frames. Send ordinary VideoFrame and texture frames |
1926 // alternatively. | 1926 // alternatively. |
1927 std::vector<VideoFrame> input_frames; | 1927 std::vector<VideoFrame> input_frames; |
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2539 | 2539 |
2540 void WaitForSetRates(uint32_t expected_bitrate) { | 2540 void WaitForSetRates(uint32_t expected_bitrate) { |
2541 EXPECT_TRUE( | 2541 EXPECT_TRUE( |
2542 bitrate_changed_event_.Wait(VideoSendStreamTest::kDefaultTimeoutMs)) | 2542 bitrate_changed_event_.Wait(VideoSendStreamTest::kDefaultTimeoutMs)) |
2543 << "Timed out while waiting encoder rate to be set."; | 2543 << "Timed out while waiting encoder rate to be set."; |
2544 rtc::CritScope lock(&crit_); | 2544 rtc::CritScope lock(&crit_); |
2545 EXPECT_EQ(expected_bitrate, target_bitrate_); | 2545 EXPECT_EQ(expected_bitrate, target_bitrate_); |
2546 } | 2546 } |
2547 | 2547 |
2548 Call::Config GetSenderCallConfig() override { | 2548 Call::Config GetSenderCallConfig() override { |
2549 Call::Config config(&event_log_); | 2549 Call::Config config(event_log_.get()); |
2550 config.bitrate_config.min_bitrate_bps = kMinBitrateKbps * 1000; | 2550 config.bitrate_config.min_bitrate_bps = kMinBitrateKbps * 1000; |
2551 config.bitrate_config.start_bitrate_bps = kStartBitrateKbps * 1000; | 2551 config.bitrate_config.start_bitrate_bps = kStartBitrateKbps * 1000; |
2552 config.bitrate_config.max_bitrate_bps = kMaxBitrateKbps * 1000; | 2552 config.bitrate_config.max_bitrate_bps = kMaxBitrateKbps * 1000; |
2553 return config; | 2553 return config; |
2554 } | 2554 } |
2555 | 2555 |
2556 class VideoStreamFactory | 2556 class VideoStreamFactory |
2557 : public VideoEncoderConfig::VideoStreamFactoryInterface { | 2557 : public VideoEncoderConfig::VideoStreamFactoryInterface { |
2558 public: | 2558 public: |
2559 explicit VideoStreamFactory(int min_bitrate_bps) | 2559 explicit VideoStreamFactory(int min_bitrate_bps) |
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3181 } | 3181 } |
3182 } | 3182 } |
3183 } test; | 3183 } test; |
3184 | 3184 |
3185 RunBaseTest(&test); | 3185 RunBaseTest(&test); |
3186 } | 3186 } |
3187 #endif // !defined(RTC_DISABLE_VP9) | 3187 #endif // !defined(RTC_DISABLE_VP9) |
3188 | 3188 |
3189 void VideoSendStreamTest::TestRequestSourceRotateVideo( | 3189 void VideoSendStreamTest::TestRequestSourceRotateVideo( |
3190 bool support_orientation_ext) { | 3190 bool support_orientation_ext) { |
3191 CreateSenderCall(Call::Config(&event_log_)); | 3191 CreateSenderCall(Call::Config(event_log_.get())); |
3192 | 3192 |
3193 test::NullTransport transport; | 3193 test::NullTransport transport; |
3194 CreateSendConfig(1, 0, 0, &transport); | 3194 CreateSendConfig(1, 0, 0, &transport); |
3195 video_send_config_.rtp.extensions.clear(); | 3195 video_send_config_.rtp.extensions.clear(); |
3196 if (support_orientation_ext) { | 3196 if (support_orientation_ext) { |
3197 video_send_config_.rtp.extensions.push_back( | 3197 video_send_config_.rtp.extensions.push_back( |
3198 RtpExtension(RtpExtension::kVideoRotationUri, 1)); | 3198 RtpExtension(RtpExtension::kVideoRotationUri, 1)); |
3199 } | 3199 } |
3200 | 3200 |
3201 CreateVideoStreams(); | 3201 CreateVideoStreams(); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3293 rtc::CriticalSection crit_; | 3293 rtc::CriticalSection crit_; |
3294 uint32_t max_bitrate_bps_ GUARDED_BY(&crit_); | 3294 uint32_t max_bitrate_bps_ GUARDED_BY(&crit_); |
3295 bool first_packet_sent_ GUARDED_BY(&crit_); | 3295 bool first_packet_sent_ GUARDED_BY(&crit_); |
3296 rtc::Event bitrate_changed_event_; | 3296 rtc::Event bitrate_changed_event_; |
3297 } test; | 3297 } test; |
3298 | 3298 |
3299 RunBaseTest(&test); | 3299 RunBaseTest(&test); |
3300 } | 3300 } |
3301 | 3301 |
3302 } // namespace webrtc | 3302 } // namespace webrtc |
OLD | NEW |