| 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 1751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1762 | 1762 |
| 1763 void OnVideoStreamsCreated( | 1763 void OnVideoStreamsCreated( |
| 1764 VideoSendStream* send_stream, | 1764 VideoSendStream* send_stream, |
| 1765 const std::vector<VideoReceiveStream*>& receive_streams) override { | 1765 const std::vector<VideoReceiveStream*>& receive_streams) override { |
| 1766 stream_ = send_stream; | 1766 stream_ = send_stream; |
| 1767 } | 1767 } |
| 1768 | 1768 |
| 1769 int32_t InitEncode(const VideoCodec* config, | 1769 int32_t InitEncode(const VideoCodec* config, |
| 1770 int32_t number_of_cores, | 1770 int32_t number_of_cores, |
| 1771 size_t max_payload_size) override { | 1771 size_t max_payload_size) override { |
| 1772 if (num_initializations_ == 0) { | 1772 if (num_initializations_ < 2) { |
| 1773 // Verify default values. | 1773 // Verify default values. |
| 1774 EXPECT_EQ(kRealtimeVideo, config->mode); | 1774 EXPECT_EQ(kRealtimeVideo, config->mode); |
| 1775 } else { | 1775 } else { |
| 1776 // Verify that changed values are propagated. | 1776 // Verify that changed values are propagated. |
| 1777 EXPECT_EQ(kScreensharing, config->mode); | 1777 EXPECT_EQ(kScreensharing, config->mode); |
| 1778 } | 1778 } |
| 1779 ++num_initializations_; | 1779 ++num_initializations_; |
| 1780 init_encode_event_.Set(); | 1780 if (num_initializations_ > 1) { |
| 1781 // Skip the first two InitEncode events: one with QCIF resolution when |
| 1782 // the SendStream is created, the other with QVGA when the first frame |
| 1783 // is encoded. |
| 1784 init_encode_event_.Set(); |
| 1785 } |
| 1781 return FakeEncoder::InitEncode(config, number_of_cores, max_payload_size); | 1786 return FakeEncoder::InitEncode(config, number_of_cores, max_payload_size); |
| 1782 } | 1787 } |
| 1783 | 1788 |
| 1784 void PerformTest() override { | 1789 void PerformTest() override { |
| 1785 EXPECT_TRUE(init_encode_event_.Wait(kDefaultTimeoutMs)); | 1790 EXPECT_TRUE(init_encode_event_.Wait(kDefaultTimeoutMs)); |
| 1786 EXPECT_EQ(1u, num_initializations_) << "VideoEncoder not initialized."; | 1791 EXPECT_EQ(2u, num_initializations_) << "VideoEncoder not initialized."; |
| 1787 | 1792 |
| 1788 encoder_config_.content_type = VideoEncoderConfig::ContentType::kScreen; | 1793 encoder_config_.content_type = VideoEncoderConfig::ContentType::kScreen; |
| 1789 stream_->ReconfigureVideoEncoder(std::move(encoder_config_)); | 1794 stream_->ReconfigureVideoEncoder(std::move(encoder_config_)); |
| 1790 EXPECT_TRUE(init_encode_event_.Wait(kDefaultTimeoutMs)); | 1795 EXPECT_TRUE(init_encode_event_.Wait(kDefaultTimeoutMs)); |
| 1791 EXPECT_EQ(2u, num_initializations_) | 1796 EXPECT_EQ(3u, num_initializations_) |
| 1792 << "ReconfigureVideoEncoder did not reinitialize the encoder with " | 1797 << "ReconfigureVideoEncoder did not reinitialize the encoder with " |
| 1793 "new encoder settings."; | 1798 "new encoder settings."; |
| 1794 } | 1799 } |
| 1795 | 1800 |
| 1796 rtc::Event init_encode_event_; | 1801 rtc::Event init_encode_event_; |
| 1797 size_t num_initializations_; | 1802 size_t num_initializations_; |
| 1798 VideoSendStream* stream_; | 1803 VideoSendStream* stream_; |
| 1799 VideoEncoderConfig encoder_config_; | 1804 VideoEncoderConfig encoder_config_; |
| 1800 } test; | 1805 } test; |
| 1801 | 1806 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1858 const std::vector<VideoReceiveStream*>& receive_streams) override { | 1863 const std::vector<VideoReceiveStream*>& receive_streams) override { |
| 1859 stream_ = send_stream; | 1864 stream_ = send_stream; |
| 1860 } | 1865 } |
| 1861 | 1866 |
| 1862 int32_t InitEncode(const VideoCodec* config, | 1867 int32_t InitEncode(const VideoCodec* config, |
| 1863 int32_t number_of_cores, | 1868 int32_t number_of_cores, |
| 1864 size_t max_payload_size) override { | 1869 size_t max_payload_size) override { |
| 1865 EXPECT_EQ(video_codec_type_, config->codecType); | 1870 EXPECT_EQ(video_codec_type_, config->codecType); |
| 1866 VerifyCodecSpecifics(*config); | 1871 VerifyCodecSpecifics(*config); |
| 1867 ++num_initializations_; | 1872 ++num_initializations_; |
| 1868 init_encode_event_.Set(); | 1873 if (num_initializations_ > 1) { |
| 1874 // Skip the first two InitEncode events: one with QCIF resolution when |
| 1875 // the SendStream is created, the other with QVGA when the first frame is |
| 1876 // encoded. |
| 1877 init_encode_event_.Set(); |
| 1878 } |
| 1869 return FakeEncoder::InitEncode(config, number_of_cores, max_payload_size); | 1879 return FakeEncoder::InitEncode(config, number_of_cores, max_payload_size); |
| 1870 } | 1880 } |
| 1871 | 1881 |
| 1872 void VerifyCodecSpecifics(const VideoCodec& config) const; | 1882 void VerifyCodecSpecifics(const VideoCodec& config) const; |
| 1873 rtc::scoped_refptr<VideoEncoderConfig::EncoderSpecificSettings> | 1883 rtc::scoped_refptr<VideoEncoderConfig::EncoderSpecificSettings> |
| 1874 GetEncoderSpecificSettings() const; | 1884 GetEncoderSpecificSettings() const; |
| 1875 | 1885 |
| 1876 void PerformTest() override { | 1886 void PerformTest() override { |
| 1877 EXPECT_TRUE( | 1887 EXPECT_TRUE( |
| 1878 init_encode_event_.Wait(VideoSendStreamTest::kDefaultTimeoutMs)); | 1888 init_encode_event_.Wait(VideoSendStreamTest::kDefaultTimeoutMs)); |
| 1879 ASSERT_EQ(1u, num_initializations_) << "VideoEncoder not initialized."; | 1889 ASSERT_EQ(2u, num_initializations_) << "VideoEncoder not initialized."; |
| 1880 | 1890 |
| 1881 encoder_settings_.frameDroppingOn = true; | 1891 encoder_settings_.frameDroppingOn = true; |
| 1882 encoder_config_.encoder_specific_settings = GetEncoderSpecificSettings(); | 1892 encoder_config_.encoder_specific_settings = GetEncoderSpecificSettings(); |
| 1883 stream_->ReconfigureVideoEncoder(std::move(encoder_config_)); | 1893 stream_->ReconfigureVideoEncoder(std::move(encoder_config_)); |
| 1884 ASSERT_TRUE( | 1894 ASSERT_TRUE( |
| 1885 init_encode_event_.Wait(VideoSendStreamTest::kDefaultTimeoutMs)); | 1895 init_encode_event_.Wait(VideoSendStreamTest::kDefaultTimeoutMs)); |
| 1886 EXPECT_EQ(2u, num_initializations_) | 1896 EXPECT_EQ(3u, num_initializations_) |
| 1887 << "ReconfigureVideoEncoder did not reinitialize the encoder with " | 1897 << "ReconfigureVideoEncoder did not reinitialize the encoder with " |
| 1888 "new encoder settings."; | 1898 "new encoder settings."; |
| 1889 } | 1899 } |
| 1890 | 1900 |
| 1891 int32_t Encode(const VideoFrame& input_image, | 1901 int32_t Encode(const VideoFrame& input_image, |
| 1892 const CodecSpecificInfo* codec_specific_info, | 1902 const CodecSpecificInfo* codec_specific_info, |
| 1893 const std::vector<FrameType>* frame_types) override { | 1903 const std::vector<FrameType>* frame_types) override { |
| 1894 // Silently skip the encode, FakeEncoder::Encode doesn't produce VP8. | 1904 // Silently skip the encode, FakeEncoder::Encode doesn't produce VP8. |
| 1895 return 0; | 1905 return 0; |
| 1896 } | 1906 } |
| (...skipping 906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2803 observation_complete_.Set(); | 2813 observation_complete_.Set(); |
| 2804 } | 2814 } |
| 2805 } | 2815 } |
| 2806 } test; | 2816 } test; |
| 2807 | 2817 |
| 2808 RunBaseTest(&test); | 2818 RunBaseTest(&test); |
| 2809 } | 2819 } |
| 2810 #endif // !defined(RTC_DISABLE_VP9) | 2820 #endif // !defined(RTC_DISABLE_VP9) |
| 2811 | 2821 |
| 2812 } // namespace webrtc | 2822 } // namespace webrtc |
| OLD | NEW |