Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(254)

Side by Side Diff: webrtc/video/video_send_stream_tests.cc

Issue 2434073003: Extract bitrate allocation of spatial/temporal layers out of codec impl. (Closed)
Patch Set: Addressed comments. Moved VideoCodec creation to factory class. Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
1997 // VideoCodec. 1998 // VideoCodec.
1998 EXPECT_EQ(kVideoCodecConfigObserverNumberOfTemporalLayers, 1999 EXPECT_EQ(kVideoCodecConfigObserverNumberOfTemporalLayers,
1999 config.VP8().numberOfTemporalLayers); 2000 config.VP8().numberOfTemporalLayers);
2000 2001
2001 for (unsigned char i = 0; i < config.numberOfSimulcastStreams; ++i) { 2002 for (unsigned char i = 0; i < config.numberOfSimulcastStreams; ++i) {
2002 EXPECT_EQ(kVideoCodecConfigObserverNumberOfTemporalLayers, 2003 EXPECT_EQ(kVideoCodecConfigObserverNumberOfTemporalLayers,
2003 config.simulcastStream[i].numberOfTemporalLayers); 2004 config.simulcastStream[i].numberOfTemporalLayers);
2004 } 2005 }
2005 2006
2006 // Set expected temporal layers as they should have been set when 2007 // Set expected temporal layers as they should have been set when
2007 // reconfiguring the encoder and not match the set config. 2008 // reconfiguring the encoder and not match the set config. Also copy the
2009 // TemporalLayersFactory pointer that has been injected by ViEEncoder.
2008 VideoCodecVP8 encoder_settings = encoder_settings_; 2010 VideoCodecVP8 encoder_settings = encoder_settings_;
2009 encoder_settings.numberOfTemporalLayers = 2011 encoder_settings.numberOfTemporalLayers =
2010 kVideoCodecConfigObserverNumberOfTemporalLayers; 2012 kVideoCodecConfigObserverNumberOfTemporalLayers;
2013 encoder_settings.tl_factory = config.VP8().tl_factory;
2011 EXPECT_EQ( 2014 EXPECT_EQ(
2012 0, memcmp(&config.VP8(), &encoder_settings, sizeof(encoder_settings_))); 2015 0, memcmp(&config.VP8(), &encoder_settings, sizeof(encoder_settings_)));
2013 } 2016 }
2014 2017
2015 template <> 2018 template <>
2016 rtc::scoped_refptr<VideoEncoderConfig::EncoderSpecificSettings> 2019 rtc::scoped_refptr<VideoEncoderConfig::EncoderSpecificSettings>
2017 VideoCodecConfigObserver<VideoCodecVP8>::GetEncoderSpecificSettings() const { 2020 VideoCodecConfigObserver<VideoCodecVP8>::GetEncoderSpecificSettings() const {
2018 return new rtc::RefCountedObject< 2021 return new rtc::RefCountedObject<
2019 VideoEncoderConfig::Vp8EncoderSpecificSettings>(encoder_settings_); 2022 VideoEncoderConfig::Vp8EncoderSpecificSettings>(encoder_settings_);
2020 } 2023 }
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
2224 // has currently configured but in the span of the set max and min 2227 // has currently configured but in the span of the set max and min
2225 // bitrate. 2228 // bitrate.
2226 } 2229 }
2227 ++num_initializations_; 2230 ++num_initializations_;
2228 init_encode_event_.Set(); 2231 init_encode_event_.Set();
2229 2232
2230 return FakeEncoder::InitEncode(codecSettings, numberOfCores, 2233 return FakeEncoder::InitEncode(codecSettings, numberOfCores,
2231 maxPayloadSize); 2234 maxPayloadSize);
2232 } 2235 }
2233 2236
2234 int32_t SetRates(uint32_t newBitRate, uint32_t frameRate) override { 2237 int32_t SetRateAllocation(const BitrateAllocation& bitrate,
2238 uint32_t frameRate) override {
2235 { 2239 {
2236 rtc::CritScope lock(&crit_); 2240 rtc::CritScope lock(&crit_);
2237 if (target_bitrate_ == newBitRate) { 2241 if (target_bitrate_ == bitrate.get_sum_kbps()) {
2238 return FakeEncoder::SetRates(newBitRate, frameRate); 2242 return FakeEncoder::SetRateAllocation(bitrate, frameRate);
2239 } 2243 }
2240 target_bitrate_ = newBitRate; 2244 target_bitrate_ = bitrate.get_sum_kbps();
2241 } 2245 }
2242 bitrate_changed_event_.Set(); 2246 bitrate_changed_event_.Set();
2243 return FakeEncoder::SetRates(newBitRate, frameRate); 2247 return FakeEncoder::SetRateAllocation(bitrate, frameRate);
2244 } 2248 }
2245 2249
2246 void WaitForSetRates(uint32_t expected_bitrate) { 2250 void WaitForSetRates(uint32_t expected_bitrate) {
2247 EXPECT_TRUE( 2251 EXPECT_TRUE(
2248 bitrate_changed_event_.Wait(VideoSendStreamTest::kDefaultTimeoutMs)) 2252 bitrate_changed_event_.Wait(VideoSendStreamTest::kDefaultTimeoutMs))
2249 << "Timed out while waiting encoder rate to be set."; 2253 << "Timed out while waiting encoder rate to be set.";
2250 rtc::CritScope lock(&crit_); 2254 rtc::CritScope lock(&crit_);
2251 EXPECT_EQ(expected_bitrate, target_bitrate_); 2255 EXPECT_EQ(expected_bitrate, target_bitrate_);
2252 } 2256 }
2253 2257
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after
2873 observation_complete_.Set(); 2877 observation_complete_.Set();
2874 } 2878 }
2875 } 2879 }
2876 } test; 2880 } test;
2877 2881
2878 RunBaseTest(&test); 2882 RunBaseTest(&test);
2879 } 2883 }
2880 #endif // !defined(RTC_DISABLE_VP9) 2884 #endif // !defined(RTC_DISABLE_VP9)
2881 2885
2882 } // namespace webrtc 2886 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698