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 1529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1540 bitrate_kbps_(0) {} | 1540 bitrate_kbps_(0) {} |
1541 int32_t InitEncode(const VideoCodec* config, | 1541 int32_t InitEncode(const VideoCodec* config, |
1542 int32_t number_of_cores, | 1542 int32_t number_of_cores, |
1543 size_t max_payload_size) override { | 1543 size_t max_payload_size) override { |
1544 rtc::CritScope lock(&crit_); | 1544 rtc::CritScope lock(&crit_); |
1545 bitrate_kbps_ = config->startBitrate; | 1545 bitrate_kbps_ = config->startBitrate; |
1546 encoder_init_.Set(); | 1546 encoder_init_.Set(); |
1547 return FakeEncoder::InitEncode(config, number_of_cores, max_payload_size); | 1547 return FakeEncoder::InitEncode(config, number_of_cores, max_payload_size); |
1548 } | 1548 } |
1549 | 1549 |
1550 int32_t SetRates(uint32_t new_target_bitrate, uint32_t framerate) override { | 1550 int32_t SetRateAllocation(const BitrateAllocation& bitrate, |
| 1551 uint32_t framerate) override { |
1551 rtc::CritScope lock(&crit_); | 1552 rtc::CritScope lock(&crit_); |
1552 bitrate_kbps_ = new_target_bitrate; | 1553 bitrate_kbps_ = bitrate.get_sum_kbps(); |
1553 bitrate_changed_.Set(); | 1554 bitrate_changed_.Set(); |
1554 return FakeEncoder::SetRates(new_target_bitrate, framerate); | 1555 return FakeEncoder::SetRateAllocation(bitrate, framerate); |
1555 } | 1556 } |
1556 | 1557 |
1557 int GetBitrateKbps() const { | 1558 int GetBitrateKbps() const { |
1558 rtc::CritScope lock(&crit_); | 1559 rtc::CritScope lock(&crit_); |
1559 return bitrate_kbps_; | 1560 return bitrate_kbps_; |
1560 } | 1561 } |
1561 | 1562 |
1562 bool WaitForEncoderInit() { | 1563 bool WaitForEncoderInit() { |
1563 return encoder_init_.Wait(VideoSendStreamTest::kDefaultTimeoutMs); | 1564 return encoder_init_.Wait(VideoSendStreamTest::kDefaultTimeoutMs); |
1564 } | 1565 } |
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2010 // VideoCodec. | 2011 // VideoCodec. |
2011 EXPECT_EQ(kVideoCodecConfigObserverNumberOfTemporalLayers, | 2012 EXPECT_EQ(kVideoCodecConfigObserverNumberOfTemporalLayers, |
2012 config.codecSpecific.VP8.numberOfTemporalLayers); | 2013 config.codecSpecific.VP8.numberOfTemporalLayers); |
2013 | 2014 |
2014 for (unsigned char i = 0; i < config.numberOfSimulcastStreams; ++i) { | 2015 for (unsigned char i = 0; i < config.numberOfSimulcastStreams; ++i) { |
2015 EXPECT_EQ(kVideoCodecConfigObserverNumberOfTemporalLayers, | 2016 EXPECT_EQ(kVideoCodecConfigObserverNumberOfTemporalLayers, |
2016 config.simulcastStream[i].numberOfTemporalLayers); | 2017 config.simulcastStream[i].numberOfTemporalLayers); |
2017 } | 2018 } |
2018 | 2019 |
2019 // Set expected temporal layers as they should have been set when | 2020 // Set expected temporal layers as they should have been set when |
2020 // reconfiguring the encoder and not match the set config. | 2021 // reconfiguring the encoder and not match the set config. Also copy the |
| 2022 // TemporalLayersFactory pointer that has been injected by ViEEncoder. |
2021 VideoCodecVP8 encoder_settings = encoder_settings_; | 2023 VideoCodecVP8 encoder_settings = encoder_settings_; |
2022 encoder_settings.numberOfTemporalLayers = | 2024 encoder_settings.numberOfTemporalLayers = |
2023 kVideoCodecConfigObserverNumberOfTemporalLayers; | 2025 kVideoCodecConfigObserverNumberOfTemporalLayers; |
| 2026 encoder_settings.tl_factory = config.codecSpecific.VP8.tl_factory; |
2024 EXPECT_EQ(0, memcmp(&config.codecSpecific.VP8, &encoder_settings, | 2027 EXPECT_EQ(0, memcmp(&config.codecSpecific.VP8, &encoder_settings, |
2025 sizeof(encoder_settings_))); | 2028 sizeof(encoder_settings_))); |
2026 } | 2029 } |
2027 | 2030 |
2028 template <> | 2031 template <> |
2029 rtc::scoped_refptr<VideoEncoderConfig::EncoderSpecificSettings> | 2032 rtc::scoped_refptr<VideoEncoderConfig::EncoderSpecificSettings> |
2030 VideoCodecConfigObserver<VideoCodecVP8>::GetEncoderSpecificSettings() const { | 2033 VideoCodecConfigObserver<VideoCodecVP8>::GetEncoderSpecificSettings() const { |
2031 return new rtc::RefCountedObject< | 2034 return new rtc::RefCountedObject< |
2032 VideoEncoderConfig::Vp8EncoderSpecificSettings>(encoder_settings_); | 2035 VideoEncoderConfig::Vp8EncoderSpecificSettings>(encoder_settings_); |
2033 } | 2036 } |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2239 // bitrate. | 2242 // bitrate. |
2240 } | 2243 } |
2241 ++num_initializations_; | 2244 ++num_initializations_; |
2242 if (num_initializations_ > 1) { | 2245 if (num_initializations_ > 1) { |
2243 init_encode_event_.Set(); | 2246 init_encode_event_.Set(); |
2244 } | 2247 } |
2245 return FakeEncoder::InitEncode(codecSettings, numberOfCores, | 2248 return FakeEncoder::InitEncode(codecSettings, numberOfCores, |
2246 maxPayloadSize); | 2249 maxPayloadSize); |
2247 } | 2250 } |
2248 | 2251 |
2249 int32_t SetRates(uint32_t newBitRate, uint32_t frameRate) override { | 2252 int32_t SetRateAllocation(const BitrateAllocation& bitrate, |
| 2253 uint32_t frameRate) override { |
2250 { | 2254 { |
2251 rtc::CritScope lock(&crit_); | 2255 rtc::CritScope lock(&crit_); |
2252 if (target_bitrate_ == newBitRate) { | 2256 if (target_bitrate_ == bitrate.get_sum_kbps()) { |
2253 return FakeEncoder::SetRates(newBitRate, frameRate); | 2257 return FakeEncoder::SetRateAllocation(bitrate, frameRate); |
2254 } | 2258 } |
2255 target_bitrate_ = newBitRate; | 2259 target_bitrate_ = bitrate.get_sum_kbps(); |
2256 } | 2260 } |
2257 bitrate_changed_event_.Set(); | 2261 bitrate_changed_event_.Set(); |
2258 return FakeEncoder::SetRates(newBitRate, frameRate); | 2262 return FakeEncoder::SetRateAllocation(bitrate, frameRate); |
2259 } | 2263 } |
2260 | 2264 |
2261 void WaitForSetRates(uint32_t expected_bitrate) { | 2265 void WaitForSetRates(uint32_t expected_bitrate) { |
2262 EXPECT_TRUE( | 2266 EXPECT_TRUE( |
2263 bitrate_changed_event_.Wait(VideoSendStreamTest::kDefaultTimeoutMs)) | 2267 bitrate_changed_event_.Wait(VideoSendStreamTest::kDefaultTimeoutMs)) |
2264 << "Timed out while waiting encoder rate to be set."; | 2268 << "Timed out while waiting encoder rate to be set."; |
2265 rtc::CritScope lock(&crit_); | 2269 rtc::CritScope lock(&crit_); |
2266 EXPECT_EQ(expected_bitrate, target_bitrate_); | 2270 EXPECT_EQ(expected_bitrate, target_bitrate_); |
2267 } | 2271 } |
2268 | 2272 |
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2888 observation_complete_.Set(); | 2892 observation_complete_.Set(); |
2889 } | 2893 } |
2890 } | 2894 } |
2891 } test; | 2895 } test; |
2892 | 2896 |
2893 RunBaseTest(&test); | 2897 RunBaseTest(&test); |
2894 } | 2898 } |
2895 #endif // !defined(RTC_DISABLE_VP9) | 2899 #endif // !defined(RTC_DISABLE_VP9) |
2896 | 2900 |
2897 } // namespace webrtc | 2901 } // namespace webrtc |
OLD | NEW |