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

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

Issue 2571463002: Fix for video protection_bitrate in BWE with overhead. (Closed)
Patch Set: Response to comments Created 3 years, 10 months 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
« no previous file with comments | « webrtc/video/video_send_stream.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 3151 matching lines...) Expand 10 before | Expand all | Expand 10 after
3162 TEST_F(VideoSendStreamTest, 3162 TEST_F(VideoSendStreamTest,
3163 RequestSourceRotateIfVideoOrientationExtensionNotSupported) { 3163 RequestSourceRotateIfVideoOrientationExtensionNotSupported) {
3164 TestRequestSourceRotateVideo(false); 3164 TestRequestSourceRotateVideo(false);
3165 } 3165 }
3166 3166
3167 TEST_F(VideoSendStreamTest, 3167 TEST_F(VideoSendStreamTest,
3168 DoNotRequestsRotationIfVideoOrientationExtensionSupported) { 3168 DoNotRequestsRotationIfVideoOrientationExtensionSupported) {
3169 TestRequestSourceRotateVideo(true); 3169 TestRequestSourceRotateVideo(true);
3170 } 3170 }
3171 3171
3172 // Flaky on Win32 Release: http://crbug.com/webrtc/6886
3173 #if defined(WEBRTC_WIN)
3174 #define MAYBE_RemoveOverheadFromBandwidth DISABLED_RemoveOverheadFromBandwidth
3175 #else
3176 #define MAYBE_RemoveOverheadFromBandwidth RemoveOverheadFromBandwidth
3177 #endif
3178 // This test verifies that overhead is removed from the bandwidth estimate by 3172 // This test verifies that overhead is removed from the bandwidth estimate by
3179 // testing that the maximum possible target payload rate is smaller than the 3173 // testing that the maximum possible target payload rate is smaller than the
3180 // maximum bandwidth estimate by the overhead rate. 3174 // maximum bandwidth estimate by the overhead rate.
3181 TEST_F(VideoSendStreamTest, MAYBE_RemoveOverheadFromBandwidth) { 3175 TEST_F(VideoSendStreamTest, RemoveOverheadFromBandwidth) {
3182 test::ScopedFieldTrials override_field_trials( 3176 test::ScopedFieldTrials override_field_trials(
3183 "WebRTC-SendSideBwe-WithOverhead/Enabled/"); 3177 "WebRTC-SendSideBwe-WithOverhead/Enabled/");
3184 class RemoveOverheadFromBandwidthTest : public test::EndToEndTest, 3178 class RemoveOverheadFromBandwidthTest : public test::EndToEndTest,
3185 public test::FakeEncoder { 3179 public test::FakeEncoder {
3186 public: 3180 public:
3187 RemoveOverheadFromBandwidthTest() 3181 RemoveOverheadFromBandwidthTest()
3188 : EndToEndTest(test::CallTest::kDefaultTimeoutMs), 3182 : EndToEndTest(test::CallTest::kDefaultTimeoutMs),
3189 FakeEncoder(Clock::GetRealTimeClock()), 3183 FakeEncoder(Clock::GetRealTimeClock()),
3190 call_(nullptr), 3184 call_(nullptr),
3191 max_bitrate_kbps_(0) {} 3185 max_bitrate_bps_(0),
3186 first_packet_sent_(false),
3187 bitrate_changed_event_(false, false) {}
3192 3188
3193 int32_t SetRateAllocation(const BitrateAllocation& bitrate, 3189 int32_t SetRateAllocation(const BitrateAllocation& bitrate,
3194 uint32_t frameRate) override { 3190 uint32_t frameRate) override {
3195 rtc::CritScope lock(&crit_); 3191 rtc::CritScope lock(&crit_);
3196 if (max_bitrate_kbps_ < bitrate.get_sum_kbps()) 3192 // Wait for the first sent packet so that videosendstream knows
3197 max_bitrate_kbps_ = bitrate.get_sum_kbps(); 3193 // rtp_overhead.
3194 if (first_packet_sent_) {
3195 max_bitrate_bps_ = bitrate.get_sum_bps();
3196 bitrate_changed_event_.Set();
3197 }
3198 return FakeEncoder::SetRateAllocation(bitrate, frameRate); 3198 return FakeEncoder::SetRateAllocation(bitrate, frameRate);
3199 } 3199 }
3200 3200
3201 void OnCallsCreated(Call* sender_call, Call* receiver_call) override { 3201 void OnCallsCreated(Call* sender_call, Call* receiver_call) override {
3202 call_ = sender_call; 3202 call_ = sender_call;
3203 } 3203 }
3204 3204
3205 void ModifyVideoConfigs( 3205 void ModifyVideoConfigs(
3206 VideoSendStream::Config* send_config, 3206 VideoSendStream::Config* send_config,
3207 std::vector<VideoReceiveStream::Config>* receive_configs, 3207 std::vector<VideoReceiveStream::Config>* receive_configs,
3208 VideoEncoderConfig* encoder_config) override { 3208 VideoEncoderConfig* encoder_config) override {
3209 send_config->rtp.max_packet_size = 1200; 3209 send_config->rtp.max_packet_size = 1200;
3210 send_config->encoder_settings.encoder = this; 3210 send_config->encoder_settings.encoder = this;
3211 EXPECT_FALSE(send_config->rtp.extensions.empty()); 3211 EXPECT_FALSE(send_config->rtp.extensions.empty());
3212 } 3212 }
3213 3213
3214 Action OnSendRtp(const uint8_t* packet, size_t length) override {
3215 rtc::CritScope lock(&crit_);
3216 first_packet_sent_ = true;
3217 return SEND_PACKET;
3218 }
3219
3214 void PerformTest() override { 3220 void PerformTest() override {
3215 call_->OnTransportOverheadChanged(webrtc::MediaType::VIDEO, 20);
3216 Call::Config::BitrateConfig bitrate_config; 3221 Call::Config::BitrateConfig bitrate_config;
3217 constexpr int kStartBitrateBps = 50000; 3222 constexpr int kStartBitrateBps = 60000;
3218 constexpr int kMaxBitrateBps = 60000; 3223 constexpr int kMaxBitrateBps = 60000;
3224 constexpr int kMinBitrateBps = 10000;
3219 bitrate_config.start_bitrate_bps = kStartBitrateBps; 3225 bitrate_config.start_bitrate_bps = kStartBitrateBps;
3220 bitrate_config.max_bitrate_bps = kMaxBitrateBps; 3226 bitrate_config.max_bitrate_bps = kMaxBitrateBps;
3227 bitrate_config.min_bitrate_bps = kMinBitrateBps;
3221 call_->SetBitrateConfig(bitrate_config); 3228 call_->SetBitrateConfig(bitrate_config);
3229 call_->OnTransportOverheadChanged(webrtc::MediaType::VIDEO, 20);
3222 3230
3223 // At a bitrate of 60kbps with a packet size of 1200B video and an 3231 // At a bitrate of 60kbps with a packet size of 1200B video and an
3224 // overhead of 40B per packet video produces 2kbps overhead. 3232 // overhead of 40B per packet video produces 2240bps overhead.
3225 // So with a BWE should reach 58kbps but not 60kbps. 3233 // So the encoder BW should be set to 57760bps.
3226 Wait(); 3234 bitrate_changed_event_.Wait(VideoSendStreamTest::kDefaultTimeoutMs);
3227 { 3235 {
3228 rtc::CritScope lock(&crit_); 3236 rtc::CritScope lock(&crit_);
3229 EXPECT_EQ(58u, max_bitrate_kbps_); 3237 EXPECT_LE(57760u, max_bitrate_bps_);
3230 } 3238 }
3231 } 3239 }
3232 3240
3233 private: 3241 private:
3234 Call* call_; 3242 Call* call_;
3235 rtc::CriticalSection crit_; 3243 rtc::CriticalSection crit_;
3236 uint32_t max_bitrate_kbps_ GUARDED_BY(&crit_); 3244 uint32_t max_bitrate_bps_ GUARDED_BY(&crit_);
3245 bool first_packet_sent_ GUARDED_BY(&crit_);
3246 rtc::Event bitrate_changed_event_;
3237 } test; 3247 } test;
3238 3248
3239 RunBaseTest(&test); 3249 RunBaseTest(&test);
3240 } 3250 }
3241 3251
3242 } // namespace webrtc 3252 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/video/video_send_stream.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698