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

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

Issue 2517243005: Remove overhead from video bitrate. (Closed)
Patch Set: Add Test and field trial. Created 4 years 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 18 matching lines...) Expand all
29 #include "webrtc/system_wrappers/include/sleep.h" 29 #include "webrtc/system_wrappers/include/sleep.h"
30 #include "webrtc/test/call_test.h" 30 #include "webrtc/test/call_test.h"
31 #include "webrtc/test/configurable_frame_size_encoder.h" 31 #include "webrtc/test/configurable_frame_size_encoder.h"
32 #include "webrtc/test/fake_texture_frame.h" 32 #include "webrtc/test/fake_texture_frame.h"
33 #include "webrtc/test/frame_generator.h" 33 #include "webrtc/test/frame_generator.h"
34 #include "webrtc/test/frame_utils.h" 34 #include "webrtc/test/frame_utils.h"
35 #include "webrtc/test/gtest.h" 35 #include "webrtc/test/gtest.h"
36 #include "webrtc/test/null_transport.h" 36 #include "webrtc/test/null_transport.h"
37 #include "webrtc/test/rtcp_packet_parser.h" 37 #include "webrtc/test/rtcp_packet_parser.h"
38 #include "webrtc/test/testsupport/perf_test.h" 38 #include "webrtc/test/testsupport/perf_test.h"
39 #include "webrtc/test/field_trial.h"
39 40
40 #include "webrtc/video/send_statistics_proxy.h" 41 #include "webrtc/video/send_statistics_proxy.h"
41 #include "webrtc/video/transport_adapter.h" 42 #include "webrtc/video/transport_adapter.h"
42 #include "webrtc/video_frame.h" 43 #include "webrtc/video_frame.h"
43 #include "webrtc/video_send_stream.h" 44 #include "webrtc/video_send_stream.h"
44 45
45 namespace webrtc { 46 namespace webrtc {
46 47
47 enum VideoFormat { kGeneric, kVP8, }; 48 enum VideoFormat { kGeneric, kVP8, };
48 49
(...skipping 3118 matching lines...) Expand 10 before | Expand all | Expand 10 after
3167 TEST_F(VideoSendStreamTest, 3168 TEST_F(VideoSendStreamTest,
3168 RequestSourceRotateIfVideoOrientationExtensionNotSupported) { 3169 RequestSourceRotateIfVideoOrientationExtensionNotSupported) {
3169 TestRequestSourceRotateVideo(false); 3170 TestRequestSourceRotateVideo(false);
3170 } 3171 }
3171 3172
3172 TEST_F(VideoSendStreamTest, 3173 TEST_F(VideoSendStreamTest,
3173 DoNotRequestsRotationIfVideoOrientationExtensionSupported) { 3174 DoNotRequestsRotationIfVideoOrientationExtensionSupported) {
3174 TestRequestSourceRotateVideo(true); 3175 TestRequestSourceRotateVideo(true);
3175 } 3176 }
3176 3177
3178 TEST_F(VideoSendStreamTest, RemoveOverheadFromBandwith) {
minyue-webrtc 2016/11/24 10:09:49 Add comment that "This test verifies that overhead
minyue-webrtc 2016/11/24 10:09:49 Bandwi"d"th
michaelt 2016/11/24 14:38:53 Done.
michaelt 2016/11/24 14:38:53 Done.
3179 class RemoveOverheadFromBandwithTest : public test::EndToEndTest,
3180 public test::FakeEncoder {
3181 public:
3182 RemoveOverheadFromBandwithTest()
3183 : EndToEndTest(test::CallTest::kDefaultTimeoutMs),
3184 FakeEncoder(Clock::GetRealTimeClock()),
3185 call_(nullptr),
3186 reached_bitrate_event_(false, false),
3187 target_bitrate_kbps_(0) {}
3188
3189 int32_t SetRateAllocation(const BitrateAllocation& bitrate,
3190 uint32_t frameRate) override {
3191 {
3192 rtc::CritScope lock(&crit_);
3193 if (target_bitrate_kbps_ > bitrate.get_sum_kbps()) {
minyue-webrtc 2016/11/24 10:09:49 prefer if (bitrate.get_sum_kbps() >= target_bitr
michaelt 2016/11/24 14:38:53 Changed the impl. to wait for Max.
3194 return FakeEncoder::SetRateAllocation(bitrate, frameRate);
3195 }
3196 }
3197 reached_bitrate_event_.Set();
3198 return FakeEncoder::SetRateAllocation(bitrate, frameRate);
3199 }
3200
3201 bool WaitForBitrate(int bitrate_bps) {
3202 {
3203 rtc::CritScope lock(&crit_);
3204 target_bitrate_kbps_ = bitrate_bps / 1000;
3205 }
3206 return reached_bitrate_event_.Wait(1000 * 5);
minyue-webrtc 2016/11/24 10:09:49 why 1000 * 5?
michaelt 2016/11/24 14:38:53 Changed the impl. to wait for Max.
3207 }
3208
3209 void OnCallsCreated(Call* sender_call, Call* receiver_call) override {
3210 call_ = sender_call;
3211 }
3212
3213 void ModifyVideoConfigs(
3214 VideoSendStream::Config* send_config,
3215 std::vector<VideoReceiveStream::Config>* receive_configs,
3216 VideoEncoderConfig* encoder_config) override {
3217 send_config->rtp.max_packet_size = 1200;
3218 send_config->encoder_settings.encoder = this;
3219 EXPECT_FALSE(send_config->rtp.extensions.empty());
3220 }
3221
3222 void PerformTest() override {
3223 call_->OnTransportOverheadChanged(webrtc::MediaType::VIDEO, 20);
3224 Call::Config::BitrateConfig bitrate_config;
3225 constexpr int kStartBitrateBps = 50000;
3226 constexpr int kMaxBitrateBps = 60000;
3227 bitrate_config.start_bitrate_bps = kStartBitrateBps;
3228 bitrate_config.max_bitrate_bps = kMaxBitrateBps;
3229
3230 test::ScopedFieldTrials override_field_trials_(
3231 "WebRTC-SendSideBwe-WithOverhead/Enabled/");
3232 call_->SetBitrateConfig(bitrate_config);
3233
3234 // At a bitrate of 60kbps with a packet size of 1200B video and a overhead
minyue-webrtc 2016/11/24 10:09:49 a overhead -> an overhead
michaelt 2016/11/24 14:38:53 Done.
3235 // of 40B per packet video produces 2kbps overhead.
3236 // So with a BWE should reach 58kbps but not 60kbps.
3237 EXPECT_TRUE(WaitForBitrate(kMaxBitrateBps - 2000));
3238 EXPECT_FALSE(WaitForBitrate(kMaxBitrateBps));
minyue-webrtc 2016/11/24 10:09:49 should test FALSE on kMaxBitrateBps - 1999 But I
michaelt 2016/11/24 14:38:53 Done.
3239 }
3240
3241 private:
3242 Call* call_;
3243 rtc::Event reached_bitrate_event_;
3244 rtc::CriticalSection crit_;
3245 uint32_t target_bitrate_kbps_;
3246 } test;
3247
3248 RunBaseTest(&test);
3249 }
3250
3177 } // namespace webrtc 3251 } // namespace webrtc
OLDNEW
« webrtc/video/video_send_stream.cc ('K') | « webrtc/video/video_send_stream.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698