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 1910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1921 VideoCodecConfigObserver(VideoCodecType video_codec_type, | 1921 VideoCodecConfigObserver(VideoCodecType video_codec_type, |
1922 const char* codec_name) | 1922 const char* codec_name) |
1923 : SendTest(VideoSendStreamTest::kDefaultTimeoutMs), | 1923 : SendTest(VideoSendStreamTest::kDefaultTimeoutMs), |
1924 FakeEncoder(Clock::GetRealTimeClock()), | 1924 FakeEncoder(Clock::GetRealTimeClock()), |
1925 video_codec_type_(video_codec_type), | 1925 video_codec_type_(video_codec_type), |
1926 codec_name_(codec_name), | 1926 codec_name_(codec_name), |
1927 init_encode_event_(false, false), | 1927 init_encode_event_(false, false), |
1928 num_initializations_(0), | 1928 num_initializations_(0), |
1929 stream_(nullptr) { | 1929 stream_(nullptr) { |
1930 memset(&encoder_settings_, 0, sizeof(encoder_settings_)); | 1930 memset(&encoder_settings_, 0, sizeof(encoder_settings_)); |
| 1931 InitCodecSpecifics(); |
1931 } | 1932 } |
1932 | 1933 |
1933 private: | 1934 private: |
1934 class VideoStreamFactory | 1935 class VideoStreamFactory |
1935 : public VideoEncoderConfig::VideoStreamFactoryInterface { | 1936 : public VideoEncoderConfig::VideoStreamFactoryInterface { |
1936 public: | 1937 public: |
1937 VideoStreamFactory() {} | 1938 VideoStreamFactory() {} |
1938 | 1939 |
1939 private: | 1940 private: |
1940 std::vector<VideoStream> CreateEncoderStreams( | 1941 std::vector<VideoStream> CreateEncoderStreams( |
1941 int width, | 1942 int width, |
1942 int height, | 1943 int height, |
1943 const VideoEncoderConfig& encoder_config) override { | 1944 const VideoEncoderConfig& encoder_config) override { |
1944 std::vector<VideoStream> streams = | 1945 std::vector<VideoStream> streams = |
1945 test::CreateVideoStreams(width, height, encoder_config); | 1946 test::CreateVideoStreams(width, height, encoder_config); |
1946 for (size_t i = 0; i < streams.size(); ++i) { | 1947 for (size_t i = 0; i < streams.size(); ++i) { |
1947 streams[i].temporal_layer_thresholds_bps.resize( | 1948 streams[i].temporal_layer_thresholds_bps.resize( |
1948 kVideoCodecConfigObserverNumberOfTemporalLayers - 1); | 1949 kVideoCodecConfigObserverNumberOfTemporalLayers - 1); |
1949 } | 1950 } |
1950 return streams; | 1951 return streams; |
1951 } | 1952 } |
1952 }; | 1953 }; |
1953 | 1954 |
| 1955 void InitCodecSpecifics(); |
| 1956 |
1954 void ModifyVideoConfigs( | 1957 void ModifyVideoConfigs( |
1955 VideoSendStream::Config* send_config, | 1958 VideoSendStream::Config* send_config, |
1956 std::vector<VideoReceiveStream::Config>* receive_configs, | 1959 std::vector<VideoReceiveStream::Config>* receive_configs, |
1957 VideoEncoderConfig* encoder_config) override { | 1960 VideoEncoderConfig* encoder_config) override { |
1958 send_config->encoder_settings.encoder = this; | 1961 send_config->encoder_settings.encoder = this; |
1959 send_config->encoder_settings.payload_name = codec_name_; | 1962 send_config->encoder_settings.payload_name = codec_name_; |
1960 | 1963 |
1961 encoder_config->encoder_specific_settings = GetEncoderSpecificSettings(); | 1964 encoder_config->encoder_specific_settings = GetEncoderSpecificSettings(); |
1962 encoder_config->video_stream_factory = | 1965 encoder_config->video_stream_factory = |
1963 new rtc::RefCountedObject<VideoStreamFactory>(); | 1966 new rtc::RefCountedObject<VideoStreamFactory>(); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2008 | 2011 |
2009 T encoder_settings_; | 2012 T encoder_settings_; |
2010 const VideoCodecType video_codec_type_; | 2013 const VideoCodecType video_codec_type_; |
2011 const char* const codec_name_; | 2014 const char* const codec_name_; |
2012 rtc::Event init_encode_event_; | 2015 rtc::Event init_encode_event_; |
2013 size_t num_initializations_; | 2016 size_t num_initializations_; |
2014 VideoSendStream* stream_; | 2017 VideoSendStream* stream_; |
2015 VideoEncoderConfig encoder_config_; | 2018 VideoEncoderConfig encoder_config_; |
2016 }; | 2019 }; |
2017 | 2020 |
| 2021 template <typename T> |
| 2022 void VideoCodecConfigObserver<T>::InitCodecSpecifics() {} |
| 2023 |
| 2024 template <> |
| 2025 void VideoCodecConfigObserver<VideoCodecH264>::InitCodecSpecifics() { |
| 2026 encoder_settings_.packetization_mode = kH264PacketizationMode1; |
| 2027 } |
2018 template <> | 2028 template <> |
2019 void VideoCodecConfigObserver<VideoCodecH264>::VerifyCodecSpecifics( | 2029 void VideoCodecConfigObserver<VideoCodecH264>::VerifyCodecSpecifics( |
2020 const VideoCodec& config) const { | 2030 const VideoCodec& config) const { |
2021 EXPECT_EQ( | 2031 EXPECT_EQ( |
2022 0, memcmp(&config.H264(), &encoder_settings_, sizeof(encoder_settings_))); | 2032 0, memcmp(&config.H264(), &encoder_settings_, sizeof(encoder_settings_))); |
| 2033 // Check that packetization mode has propagated. |
| 2034 EXPECT_EQ(kH264PacketizationMode1, |
| 2035 config.codecSpecific.H264.packetization_mode); |
2023 } | 2036 } |
2024 | 2037 |
2025 template <> | 2038 template <> |
2026 rtc::scoped_refptr<VideoEncoderConfig::EncoderSpecificSettings> | 2039 rtc::scoped_refptr<VideoEncoderConfig::EncoderSpecificSettings> |
2027 VideoCodecConfigObserver<VideoCodecH264>::GetEncoderSpecificSettings() const { | 2040 VideoCodecConfigObserver<VideoCodecH264>::GetEncoderSpecificSettings() const { |
2028 return new rtc::RefCountedObject< | 2041 return new rtc::RefCountedObject< |
2029 VideoEncoderConfig::H264EncoderSpecificSettings>(encoder_settings_); | 2042 VideoEncoderConfig::H264EncoderSpecificSettings>(encoder_settings_); |
2030 } | 2043 } |
2031 | 2044 |
2032 template <> | 2045 template <> |
(...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2943 RequestSourceRotateIfVideoOrientationExtensionNotSupported) { | 2956 RequestSourceRotateIfVideoOrientationExtensionNotSupported) { |
2944 TestRequestSourceRotateVideo(false); | 2957 TestRequestSourceRotateVideo(false); |
2945 } | 2958 } |
2946 | 2959 |
2947 TEST_F(VideoSendStreamTest, | 2960 TEST_F(VideoSendStreamTest, |
2948 DoNotRequestsRotationIfVideoOrientationExtensionSupported) { | 2961 DoNotRequestsRotationIfVideoOrientationExtensionSupported) { |
2949 TestRequestSourceRotateVideo(true); | 2962 TestRequestSourceRotateVideo(true); |
2950 } | 2963 } |
2951 | 2964 |
2952 } // namespace webrtc | 2965 } // namespace webrtc |
OLD | NEW |