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 1704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1715 std::vector<VideoReceiveStream::Config>* receive_configs, | 1715 std::vector<VideoReceiveStream::Config>* receive_configs, |
1716 VideoEncoderConfig* encoder_config) override { | 1716 VideoEncoderConfig* encoder_config) override { |
1717 send_config->encoder_settings.encoder = this; | 1717 send_config->encoder_settings.encoder = this; |
1718 send_config->encoder_settings.payload_name = codec_name_; | 1718 send_config->encoder_settings.payload_name = codec_name_; |
1719 | 1719 |
1720 for (size_t i = 0; i < encoder_config->streams.size(); ++i) { | 1720 for (size_t i = 0; i < encoder_config->streams.size(); ++i) { |
1721 encoder_config->streams[i].temporal_layer_thresholds_bps.resize( | 1721 encoder_config->streams[i].temporal_layer_thresholds_bps.resize( |
1722 kVideoCodecConfigObserverNumberOfTemporalLayers - 1); | 1722 kVideoCodecConfigObserverNumberOfTemporalLayers - 1); |
1723 } | 1723 } |
1724 | 1724 |
1725 encoder_config->encoder_specific_settings = &encoder_settings_; | 1725 encoder_config->encoder_specific_settings = GetEncoderSpecificSettings(); |
1726 encoder_config_ = encoder_config->Copy(); | 1726 encoder_config_ = encoder_config->Copy(); |
1727 } | 1727 } |
1728 | 1728 |
1729 void OnVideoStreamsCreated( | 1729 void OnVideoStreamsCreated( |
1730 VideoSendStream* send_stream, | 1730 VideoSendStream* send_stream, |
1731 const std::vector<VideoReceiveStream*>& receive_streams) override { | 1731 const std::vector<VideoReceiveStream*>& receive_streams) override { |
1732 stream_ = send_stream; | 1732 stream_ = send_stream; |
1733 } | 1733 } |
1734 | 1734 |
1735 int32_t InitEncode(const VideoCodec* config, | 1735 int32_t InitEncode(const VideoCodec* config, |
1736 int32_t number_of_cores, | 1736 int32_t number_of_cores, |
1737 size_t max_payload_size) override { | 1737 size_t max_payload_size) override { |
1738 EXPECT_EQ(video_codec_type_, config->codecType); | 1738 EXPECT_EQ(video_codec_type_, config->codecType); |
1739 VerifyCodecSpecifics(*config); | 1739 VerifyCodecSpecifics(*config); |
1740 ++num_initializations_; | 1740 ++num_initializations_; |
1741 init_encode_event_.Set(); | 1741 init_encode_event_.Set(); |
1742 return FakeEncoder::InitEncode(config, number_of_cores, max_payload_size); | 1742 return FakeEncoder::InitEncode(config, number_of_cores, max_payload_size); |
1743 } | 1743 } |
1744 | 1744 |
1745 void VerifyCodecSpecifics(const VideoCodec& config) const; | 1745 void VerifyCodecSpecifics(const VideoCodec& config) const; |
1746 rtc::scoped_refptr<VideoEncoderConfig::EncoderSpecificSettings> | |
1747 GetEncoderSpecificSettings() const; | |
1746 | 1748 |
1747 void PerformTest() override { | 1749 void PerformTest() override { |
1748 EXPECT_TRUE( | 1750 EXPECT_TRUE( |
1749 init_encode_event_.Wait(VideoSendStreamTest::kDefaultTimeoutMs)); | 1751 init_encode_event_.Wait(VideoSendStreamTest::kDefaultTimeoutMs)); |
1750 ASSERT_EQ(1u, num_initializations_) << "VideoEncoder not initialized."; | 1752 ASSERT_EQ(1u, num_initializations_) << "VideoEncoder not initialized."; |
1751 | 1753 |
1752 encoder_settings_.frameDroppingOn = true; | 1754 encoder_settings_.frameDroppingOn = true; |
pbos-webrtc
2016/09/16 18:52:35
I suspect you need to reconfigure encoder_specific
| |
1753 stream_->ReconfigureVideoEncoder(std::move(encoder_config_)); | 1755 stream_->ReconfigureVideoEncoder(std::move(encoder_config_)); |
1754 ASSERT_TRUE( | 1756 ASSERT_TRUE( |
1755 init_encode_event_.Wait(VideoSendStreamTest::kDefaultTimeoutMs)); | 1757 init_encode_event_.Wait(VideoSendStreamTest::kDefaultTimeoutMs)); |
1756 EXPECT_EQ(2u, num_initializations_) | 1758 EXPECT_EQ(2u, num_initializations_) |
1757 << "ReconfigureVideoEncoder did not reinitialize the encoder with " | 1759 << "ReconfigureVideoEncoder did not reinitialize the encoder with " |
1758 "new encoder settings."; | 1760 "new encoder settings."; |
1759 } | 1761 } |
1760 | 1762 |
1761 int32_t Encode(const VideoFrame& input_image, | 1763 int32_t Encode(const VideoFrame& input_image, |
1762 const CodecSpecificInfo* codec_specific_info, | 1764 const CodecSpecificInfo* codec_specific_info, |
(...skipping 10 matching lines...) Expand all Loading... | |
1773 VideoSendStream* stream_; | 1775 VideoSendStream* stream_; |
1774 VideoEncoderConfig encoder_config_; | 1776 VideoEncoderConfig encoder_config_; |
1775 }; | 1777 }; |
1776 | 1778 |
1777 template <> | 1779 template <> |
1778 void VideoCodecConfigObserver<VideoCodecH264>::VerifyCodecSpecifics( | 1780 void VideoCodecConfigObserver<VideoCodecH264>::VerifyCodecSpecifics( |
1779 const VideoCodec& config) const { | 1781 const VideoCodec& config) const { |
1780 EXPECT_EQ(0, memcmp(&config.codecSpecific.H264, &encoder_settings_, | 1782 EXPECT_EQ(0, memcmp(&config.codecSpecific.H264, &encoder_settings_, |
1781 sizeof(encoder_settings_))); | 1783 sizeof(encoder_settings_))); |
1782 } | 1784 } |
1785 | |
1786 template <> | |
1787 rtc::scoped_refptr<VideoEncoderConfig::EncoderSpecificSettings> | |
1788 VideoCodecConfigObserver<VideoCodecH264>::GetEncoderSpecificSettings() const { | |
1789 return new rtc::RefCountedObject< | |
1790 VideoEncoderConfig::H264EncoderSpecificSettings>(encoder_settings_); | |
1791 } | |
1792 | |
1783 template <> | 1793 template <> |
1784 void VideoCodecConfigObserver<VideoCodecVP8>::VerifyCodecSpecifics( | 1794 void VideoCodecConfigObserver<VideoCodecVP8>::VerifyCodecSpecifics( |
1785 const VideoCodec& config) const { | 1795 const VideoCodec& config) const { |
1786 // Check that the number of temporal layers has propagated properly to | 1796 // Check that the number of temporal layers has propagated properly to |
1787 // VideoCodec. | 1797 // VideoCodec. |
1788 EXPECT_EQ(kVideoCodecConfigObserverNumberOfTemporalLayers, | 1798 EXPECT_EQ(kVideoCodecConfigObserverNumberOfTemporalLayers, |
1789 config.codecSpecific.VP8.numberOfTemporalLayers); | 1799 config.codecSpecific.VP8.numberOfTemporalLayers); |
1790 | 1800 |
1791 for (unsigned char i = 0; i < config.numberOfSimulcastStreams; ++i) { | 1801 for (unsigned char i = 0; i < config.numberOfSimulcastStreams; ++i) { |
1792 EXPECT_EQ(kVideoCodecConfigObserverNumberOfTemporalLayers, | 1802 EXPECT_EQ(kVideoCodecConfigObserverNumberOfTemporalLayers, |
1793 config.simulcastStream[i].numberOfTemporalLayers); | 1803 config.simulcastStream[i].numberOfTemporalLayers); |
1794 } | 1804 } |
1795 | 1805 |
1796 // Set expected temporal layers as they should have been set when | 1806 // Set expected temporal layers as they should have been set when |
1797 // reconfiguring the encoder and not match the set config. | 1807 // reconfiguring the encoder and not match the set config. |
1798 VideoCodecVP8 encoder_settings = encoder_settings_; | 1808 VideoCodecVP8 encoder_settings = encoder_settings_; |
1799 encoder_settings.numberOfTemporalLayers = | 1809 encoder_settings.numberOfTemporalLayers = |
1800 kVideoCodecConfigObserverNumberOfTemporalLayers; | 1810 kVideoCodecConfigObserverNumberOfTemporalLayers; |
1801 EXPECT_EQ(0, memcmp(&config.codecSpecific.VP8, &encoder_settings, | 1811 EXPECT_EQ(0, memcmp(&config.codecSpecific.VP8, &encoder_settings, |
1802 sizeof(encoder_settings_))); | 1812 sizeof(encoder_settings_))); |
1803 } | 1813 } |
1814 | |
1815 template <> | |
1816 rtc::scoped_refptr<VideoEncoderConfig::EncoderSpecificSettings> | |
1817 VideoCodecConfigObserver<VideoCodecVP8>::GetEncoderSpecificSettings() const { | |
1818 return new rtc::RefCountedObject< | |
1819 VideoEncoderConfig::Vp8EncoderSpecificSettings>(encoder_settings_); | |
1820 } | |
1821 | |
1804 template <> | 1822 template <> |
1805 void VideoCodecConfigObserver<VideoCodecVP9>::VerifyCodecSpecifics( | 1823 void VideoCodecConfigObserver<VideoCodecVP9>::VerifyCodecSpecifics( |
1806 const VideoCodec& config) const { | 1824 const VideoCodec& config) const { |
1807 // Check that the number of temporal layers has propagated properly to | 1825 // Check that the number of temporal layers has propagated properly to |
1808 // VideoCodec. | 1826 // VideoCodec. |
1809 EXPECT_EQ(kVideoCodecConfigObserverNumberOfTemporalLayers, | 1827 EXPECT_EQ(kVideoCodecConfigObserverNumberOfTemporalLayers, |
1810 config.codecSpecific.VP9.numberOfTemporalLayers); | 1828 config.codecSpecific.VP9.numberOfTemporalLayers); |
1811 | 1829 |
1812 for (unsigned char i = 0; i < config.numberOfSimulcastStreams; ++i) { | 1830 for (unsigned char i = 0; i < config.numberOfSimulcastStreams; ++i) { |
1813 EXPECT_EQ(kVideoCodecConfigObserverNumberOfTemporalLayers, | 1831 EXPECT_EQ(kVideoCodecConfigObserverNumberOfTemporalLayers, |
1814 config.simulcastStream[i].numberOfTemporalLayers); | 1832 config.simulcastStream[i].numberOfTemporalLayers); |
1815 } | 1833 } |
1816 | 1834 |
1817 // Set expected temporal layers as they should have been set when | 1835 // Set expected temporal layers as they should have been set when |
1818 // reconfiguring the encoder and not match the set config. | 1836 // reconfiguring the encoder and not match the set config. |
1819 VideoCodecVP9 encoder_settings = encoder_settings_; | 1837 VideoCodecVP9 encoder_settings = encoder_settings_; |
1820 encoder_settings.numberOfTemporalLayers = | 1838 encoder_settings.numberOfTemporalLayers = |
1821 kVideoCodecConfigObserverNumberOfTemporalLayers; | 1839 kVideoCodecConfigObserverNumberOfTemporalLayers; |
1822 EXPECT_EQ(0, memcmp(&config.codecSpecific.VP9, &encoder_settings, | 1840 EXPECT_EQ(0, memcmp(&config.codecSpecific.VP9, &encoder_settings, |
1823 sizeof(encoder_settings_))); | 1841 sizeof(encoder_settings_))); |
1824 } | 1842 } |
1825 | 1843 |
1844 template <> | |
1845 rtc::scoped_refptr<VideoEncoderConfig::EncoderSpecificSettings> | |
1846 VideoCodecConfigObserver<VideoCodecVP9>::GetEncoderSpecificSettings() const { | |
1847 return new rtc::RefCountedObject< | |
1848 VideoEncoderConfig::Vp9EncoderSpecificSettings>(encoder_settings_); | |
1849 } | |
1850 | |
1826 TEST_F(VideoSendStreamTest, EncoderSetupPropagatesVp8Config) { | 1851 TEST_F(VideoSendStreamTest, EncoderSetupPropagatesVp8Config) { |
1827 VideoCodecConfigObserver<VideoCodecVP8> test(kVideoCodecVP8, "VP8"); | 1852 VideoCodecConfigObserver<VideoCodecVP8> test(kVideoCodecVP8, "VP8"); |
1828 RunBaseTest(&test); | 1853 RunBaseTest(&test); |
1829 } | 1854 } |
1830 | 1855 |
1831 TEST_F(VideoSendStreamTest, EncoderSetupPropagatesVp9Config) { | 1856 TEST_F(VideoSendStreamTest, EncoderSetupPropagatesVp9Config) { |
1832 VideoCodecConfigObserver<VideoCodecVP9> test(kVideoCodecVP9, "VP9"); | 1857 VideoCodecConfigObserver<VideoCodecVP9> test(kVideoCodecVP9, "VP9"); |
1833 RunBaseTest(&test); | 1858 RunBaseTest(&test); |
1834 } | 1859 } |
1835 | 1860 |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2179 | 2204 |
2180 virtual void InspectHeader(const RTPVideoHeaderVP9& vp9) = 0; | 2205 virtual void InspectHeader(const RTPVideoHeaderVP9& vp9) = 0; |
2181 | 2206 |
2182 private: | 2207 private: |
2183 const int kVp9PayloadType = 105; | 2208 const int kVp9PayloadType = 105; |
2184 | 2209 |
2185 void ModifyVideoConfigs( | 2210 void ModifyVideoConfigs( |
2186 VideoSendStream::Config* send_config, | 2211 VideoSendStream::Config* send_config, |
2187 std::vector<VideoReceiveStream::Config>* receive_configs, | 2212 std::vector<VideoReceiveStream::Config>* receive_configs, |
2188 VideoEncoderConfig* encoder_config) override { | 2213 VideoEncoderConfig* encoder_config) override { |
2189 encoder_config->encoder_specific_settings = &vp9_settings_; | |
2190 send_config->encoder_settings.encoder = vp9_encoder_.get(); | 2214 send_config->encoder_settings.encoder = vp9_encoder_.get(); |
2191 send_config->encoder_settings.payload_name = "VP9"; | 2215 send_config->encoder_settings.payload_name = "VP9"; |
2192 send_config->encoder_settings.payload_type = kVp9PayloadType; | 2216 send_config->encoder_settings.payload_type = kVp9PayloadType; |
2193 ModifyVideoConfigsHook(send_config, receive_configs, encoder_config); | 2217 ModifyVideoConfigsHook(send_config, receive_configs, encoder_config); |
2218 encoder_config->encoder_specific_settings = new rtc::RefCountedObject< | |
2219 VideoEncoderConfig::Vp9EncoderSpecificSettings>(vp9_settings_); | |
2194 EXPECT_EQ(1u, encoder_config->streams.size()); | 2220 EXPECT_EQ(1u, encoder_config->streams.size()); |
2195 encoder_config->streams[0].temporal_layer_thresholds_bps.resize( | 2221 encoder_config->streams[0].temporal_layer_thresholds_bps.resize( |
2196 vp9_settings_.numberOfTemporalLayers - 1); | 2222 vp9_settings_.numberOfTemporalLayers - 1); |
2197 encoder_config_ = encoder_config->Copy(); | 2223 encoder_config_ = encoder_config->Copy(); |
2198 } | 2224 } |
2199 | 2225 |
2200 void PerformTest() override { | 2226 void PerformTest() override { |
2201 EXPECT_TRUE(Wait()) << "Test timed out waiting for VP9 packet, num frames " | 2227 EXPECT_TRUE(Wait()) << "Test timed out waiting for VP9 packet, num frames " |
2202 << frames_sent_; | 2228 << frames_sent_; |
2203 } | 2229 } |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2566 observation_complete_.Set(); | 2592 observation_complete_.Set(); |
2567 } | 2593 } |
2568 } | 2594 } |
2569 } test; | 2595 } test; |
2570 | 2596 |
2571 RunBaseTest(&test); | 2597 RunBaseTest(&test); |
2572 } | 2598 } |
2573 #endif // !defined(RTC_DISABLE_VP9) | 2599 #endif // !defined(RTC_DISABLE_VP9) |
2574 | 2600 |
2575 } // namespace webrtc | 2601 } // namespace webrtc |
OLD | NEW |