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 1871 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1882 VideoCodecConfigObserver(VideoCodecType video_codec_type, | 1882 VideoCodecConfigObserver(VideoCodecType video_codec_type, |
1883 const char* codec_name) | 1883 const char* codec_name) |
1884 : SendTest(VideoSendStreamTest::kDefaultTimeoutMs), | 1884 : SendTest(VideoSendStreamTest::kDefaultTimeoutMs), |
1885 FakeEncoder(Clock::GetRealTimeClock()), | 1885 FakeEncoder(Clock::GetRealTimeClock()), |
1886 video_codec_type_(video_codec_type), | 1886 video_codec_type_(video_codec_type), |
1887 codec_name_(codec_name), | 1887 codec_name_(codec_name), |
1888 init_encode_event_(false, false), | 1888 init_encode_event_(false, false), |
1889 num_initializations_(0), | 1889 num_initializations_(0), |
1890 stream_(nullptr) { | 1890 stream_(nullptr) { |
1891 memset(&encoder_settings_, 0, sizeof(encoder_settings_)); | 1891 memset(&encoder_settings_, 0, sizeof(encoder_settings_)); |
| 1892 InitCodecSpecifics(); |
1892 } | 1893 } |
1893 | 1894 |
1894 private: | 1895 private: |
1895 class VideoStreamFactory | 1896 class VideoStreamFactory |
1896 : public VideoEncoderConfig::VideoStreamFactoryInterface { | 1897 : public VideoEncoderConfig::VideoStreamFactoryInterface { |
1897 public: | 1898 public: |
1898 VideoStreamFactory() {} | 1899 VideoStreamFactory() {} |
1899 | 1900 |
1900 private: | 1901 private: |
1901 std::vector<VideoStream> CreateEncoderStreams( | 1902 std::vector<VideoStream> CreateEncoderStreams( |
1902 int width, | 1903 int width, |
1903 int height, | 1904 int height, |
1904 const VideoEncoderConfig& encoder_config) override { | 1905 const VideoEncoderConfig& encoder_config) override { |
1905 std::vector<VideoStream> streams = | 1906 std::vector<VideoStream> streams = |
1906 test::CreateVideoStreams(width, height, encoder_config); | 1907 test::CreateVideoStreams(width, height, encoder_config); |
1907 for (size_t i = 0; i < streams.size(); ++i) { | 1908 for (size_t i = 0; i < streams.size(); ++i) { |
1908 streams[i].temporal_layer_thresholds_bps.resize( | 1909 streams[i].temporal_layer_thresholds_bps.resize( |
1909 kVideoCodecConfigObserverNumberOfTemporalLayers - 1); | 1910 kVideoCodecConfigObserverNumberOfTemporalLayers - 1); |
1910 } | 1911 } |
1911 return streams; | 1912 return streams; |
1912 } | 1913 } |
1913 }; | 1914 }; |
1914 | 1915 |
| 1916 void InitCodecSpecifics(); |
| 1917 |
1915 void ModifyVideoConfigs( | 1918 void ModifyVideoConfigs( |
1916 VideoSendStream::Config* send_config, | 1919 VideoSendStream::Config* send_config, |
1917 std::vector<VideoReceiveStream::Config>* receive_configs, | 1920 std::vector<VideoReceiveStream::Config>* receive_configs, |
1918 VideoEncoderConfig* encoder_config) override { | 1921 VideoEncoderConfig* encoder_config) override { |
1919 send_config->encoder_settings.encoder = this; | 1922 send_config->encoder_settings.encoder = this; |
1920 send_config->encoder_settings.payload_name = codec_name_; | 1923 send_config->encoder_settings.payload_name = codec_name_; |
1921 | 1924 |
1922 encoder_config->encoder_specific_settings = GetEncoderSpecificSettings(); | 1925 encoder_config->encoder_specific_settings = GetEncoderSpecificSettings(); |
1923 encoder_config->video_stream_factory = | 1926 encoder_config->video_stream_factory = |
1924 new rtc::RefCountedObject<VideoStreamFactory>(); | 1927 new rtc::RefCountedObject<VideoStreamFactory>(); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1969 | 1972 |
1970 T encoder_settings_; | 1973 T encoder_settings_; |
1971 const VideoCodecType video_codec_type_; | 1974 const VideoCodecType video_codec_type_; |
1972 const char* const codec_name_; | 1975 const char* const codec_name_; |
1973 rtc::Event init_encode_event_; | 1976 rtc::Event init_encode_event_; |
1974 size_t num_initializations_; | 1977 size_t num_initializations_; |
1975 VideoSendStream* stream_; | 1978 VideoSendStream* stream_; |
1976 VideoEncoderConfig encoder_config_; | 1979 VideoEncoderConfig encoder_config_; |
1977 }; | 1980 }; |
1978 | 1981 |
| 1982 template <typename T> |
| 1983 void VideoCodecConfigObserver<T>::InitCodecSpecifics() {} |
| 1984 |
| 1985 template <> |
| 1986 void VideoCodecConfigObserver<VideoCodecH264>::InitCodecSpecifics() { |
| 1987 encoder_settings_.packetization_mode = kH264PacketizationMode1; |
| 1988 } |
1979 template <> | 1989 template <> |
1980 void VideoCodecConfigObserver<VideoCodecH264>::VerifyCodecSpecifics( | 1990 void VideoCodecConfigObserver<VideoCodecH264>::VerifyCodecSpecifics( |
1981 const VideoCodec& config) const { | 1991 const VideoCodec& config) const { |
1982 EXPECT_EQ( | 1992 EXPECT_EQ( |
1983 0, memcmp(&config.H264(), &encoder_settings_, sizeof(encoder_settings_))); | 1993 0, memcmp(&config.H264(), &encoder_settings_, sizeof(encoder_settings_))); |
| 1994 // Check that packetization mode has propagated. |
| 1995 EXPECT_EQ(kH264PacketizationMode1, |
| 1996 config.codecSpecific.H264.packetization_mode); |
1984 } | 1997 } |
1985 | 1998 |
1986 template <> | 1999 template <> |
1987 rtc::scoped_refptr<VideoEncoderConfig::EncoderSpecificSettings> | 2000 rtc::scoped_refptr<VideoEncoderConfig::EncoderSpecificSettings> |
1988 VideoCodecConfigObserver<VideoCodecH264>::GetEncoderSpecificSettings() const { | 2001 VideoCodecConfigObserver<VideoCodecH264>::GetEncoderSpecificSettings() const { |
1989 return new rtc::RefCountedObject< | 2002 return new rtc::RefCountedObject< |
1990 VideoEncoderConfig::H264EncoderSpecificSettings>(encoder_settings_); | 2003 VideoEncoderConfig::H264EncoderSpecificSettings>(encoder_settings_); |
1991 } | 2004 } |
1992 | 2005 |
1993 template <> | 2006 template <> |
(...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2873 observation_complete_.Set(); | 2886 observation_complete_.Set(); |
2874 } | 2887 } |
2875 } | 2888 } |
2876 } test; | 2889 } test; |
2877 | 2890 |
2878 RunBaseTest(&test); | 2891 RunBaseTest(&test); |
2879 } | 2892 } |
2880 #endif // !defined(RTC_DISABLE_VP9) | 2893 #endif // !defined(RTC_DISABLE_VP9) |
2881 | 2894 |
2882 } // namespace webrtc | 2895 } // namespace webrtc |
OLD | NEW |