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 3154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3165 TEST_F(VideoSendStreamTest, | 3165 TEST_F(VideoSendStreamTest, |
3166 RequestSourceRotateIfVideoOrientationExtensionNotSupported) { | 3166 RequestSourceRotateIfVideoOrientationExtensionNotSupported) { |
3167 TestRequestSourceRotateVideo(false); | 3167 TestRequestSourceRotateVideo(false); |
3168 } | 3168 } |
3169 | 3169 |
3170 TEST_F(VideoSendStreamTest, | 3170 TEST_F(VideoSendStreamTest, |
3171 DoNotRequestsRotationIfVideoOrientationExtensionSupported) { | 3171 DoNotRequestsRotationIfVideoOrientationExtensionSupported) { |
3172 TestRequestSourceRotateVideo(true); | 3172 TestRequestSourceRotateVideo(true); |
3173 } | 3173 } |
3174 | 3174 |
3175 // Flaky on Win32 Release: http://crbug.com/webrtc/6886 | |
3176 #if defined(WEBRTC_WIN) | |
3177 #define MAYBE_RemoveOverheadFromBandwidth DISABLED_RemoveOverheadFromBandwidth | |
3178 #else | |
3179 #define MAYBE_RemoveOverheadFromBandwidth RemoveOverheadFromBandwidth | |
3180 #endif | |
3181 // This test verifies that overhead is removed from the bandwidth estimate by | 3175 // This test verifies that overhead is removed from the bandwidth estimate by |
3182 // testing that the maximum possible target payload rate is smaller than the | 3176 // testing that the maximum possible target payload rate is smaller than the |
3183 // maximum bandwidth estimate by the overhead rate. | 3177 // maximum bandwidth estimate by the overhead rate. |
3184 TEST_F(VideoSendStreamTest, MAYBE_RemoveOverheadFromBandwidth) { | 3178 TEST_F(VideoSendStreamTest, RemoveOverheadFromBandwidth) { |
3185 test::ScopedFieldTrials override_field_trials( | 3179 test::ScopedFieldTrials override_field_trials( |
3186 "WebRTC-SendSideBwe-WithOverhead/Enabled/"); | 3180 "WebRTC-SendSideBwe-WithOverhead/Enabled/"); |
3187 class RemoveOverheadFromBandwidthTest : public test::EndToEndTest, | 3181 class RemoveOverheadFromBandwidthTest : public test::EndToEndTest, |
3188 public test::FakeEncoder { | 3182 public test::FakeEncoder { |
3189 public: | 3183 public: |
3190 RemoveOverheadFromBandwidthTest() | 3184 RemoveOverheadFromBandwidthTest() |
3191 : EndToEndTest(test::CallTest::kDefaultTimeoutMs), | 3185 : EndToEndTest(test::CallTest::kDefaultTimeoutMs), |
3192 FakeEncoder(Clock::GetRealTimeClock()), | 3186 FakeEncoder(Clock::GetRealTimeClock()), |
3193 call_(nullptr), | 3187 call_(nullptr), |
3194 max_bitrate_kbps_(0) {} | 3188 max_bitrate_bps_(0), |
3189 first_packet_send_(false), | |
3190 bitrate_changed_event_(false, false) {} | |
3195 | 3191 |
3196 int32_t SetRateAllocation(const BitrateAllocation& bitrate, | 3192 int32_t SetRateAllocation(const BitrateAllocation& bitrate, |
3197 uint32_t frameRate) override { | 3193 uint32_t frameRate) override { |
3198 rtc::CritScope lock(&crit_); | 3194 rtc::CritScope lock(&crit_); |
3199 if (max_bitrate_kbps_ < bitrate.get_sum_kbps()) | 3195 if (first_packet_send_) { |
3200 max_bitrate_kbps_ = bitrate.get_sum_kbps(); | 3196 max_bitrate_bps_ = bitrate.get_sum_bps(); |
3197 bitrate_changed_event_.Set(); | |
3198 } | |
3201 return FakeEncoder::SetRateAllocation(bitrate, frameRate); | 3199 return FakeEncoder::SetRateAllocation(bitrate, frameRate); |
3202 } | 3200 } |
3203 | 3201 |
3204 void OnCallsCreated(Call* sender_call, Call* receiver_call) override { | 3202 void OnCallsCreated(Call* sender_call, Call* receiver_call) override { |
3205 call_ = sender_call; | 3203 call_ = sender_call; |
3206 } | 3204 } |
3207 | 3205 |
3208 void ModifyVideoConfigs( | 3206 void ModifyVideoConfigs( |
3209 VideoSendStream::Config* send_config, | 3207 VideoSendStream::Config* send_config, |
3210 std::vector<VideoReceiveStream::Config>* receive_configs, | 3208 std::vector<VideoReceiveStream::Config>* receive_configs, |
3211 VideoEncoderConfig* encoder_config) override { | 3209 VideoEncoderConfig* encoder_config) override { |
3212 send_config->rtp.max_packet_size = 1200; | 3210 send_config->rtp.max_packet_size = 1200; |
3213 send_config->encoder_settings.encoder = this; | 3211 send_config->encoder_settings.encoder = this; |
3214 EXPECT_FALSE(send_config->rtp.extensions.empty()); | 3212 EXPECT_FALSE(send_config->rtp.extensions.empty()); |
3215 } | 3213 } |
3216 | 3214 |
3215 Action OnSendRtp(const uint8_t* packet, size_t length) override { | |
3216 rtc::CritScope lock(&crit_); | |
3217 // Wait for the first sent packet so that videosendstream know's | |
minyue-webrtc
2017/01/26 09:28:50
knows
And does this comment belong to line 3196
michaelt
2017/01/26 12:12:54
Yeap, it would fit better to 3196.
Moved it an fi
| |
3218 // rtp_overhead. | |
3219 first_packet_send_ = true; | |
3220 return SEND_PACKET; | |
3221 } | |
3222 | |
3217 void PerformTest() override { | 3223 void PerformTest() override { |
3218 call_->OnTransportOverheadChanged(webrtc::MediaType::VIDEO, 20); | 3224 call_->OnTransportOverheadChanged(webrtc::MediaType::VIDEO, 20); |
3219 Call::Config::BitrateConfig bitrate_config; | 3225 Call::Config::BitrateConfig bitrate_config; |
3220 constexpr int kStartBitrateBps = 50000; | 3226 constexpr int kStartBitrateBps = 60000; |
3221 constexpr int kMaxBitrateBps = 60000; | 3227 constexpr int kMaxBitrateBps = 60000; |
3228 constexpr int kMinBitrateBps = 10000; | |
3222 bitrate_config.start_bitrate_bps = kStartBitrateBps; | 3229 bitrate_config.start_bitrate_bps = kStartBitrateBps; |
3223 bitrate_config.max_bitrate_bps = kMaxBitrateBps; | 3230 bitrate_config.max_bitrate_bps = kMaxBitrateBps; |
3231 bitrate_config.min_bitrate_bps = kMinBitrateBps; | |
minyue-webrtc
2017/01/26 09:28:50
how did it work when no min was used.
michaelt
2017/01/26 12:12:54
When i see this right, then default min was used i
| |
3224 call_->SetBitrateConfig(bitrate_config); | 3232 call_->SetBitrateConfig(bitrate_config); |
3225 | 3233 |
3226 // At a bitrate of 60kbps with a packet size of 1200B video and an | 3234 // At a bitrate of 60kbps with a packet size of 1200B video and an |
3227 // overhead of 40B per packet video produces 2kbps overhead. | 3235 // overhead of 40B per packet video produces 2240bps overhead. |
3228 // So with a BWE should reach 58kbps but not 60kbps. | 3236 // So the encoder BW should be set to 57760bps. |
3229 Wait(); | 3237 bitrate_changed_event_.Wait(VideoSendStreamTest::kDefaultTimeoutMs); |
3230 { | 3238 { |
3231 rtc::CritScope lock(&crit_); | 3239 rtc::CritScope lock(&crit_); |
3232 EXPECT_EQ(58u, max_bitrate_kbps_); | 3240 EXPECT_EQ(57760u, max_bitrate_bps_); |
3233 } | 3241 } |
3234 } | 3242 } |
3235 | 3243 |
3236 private: | 3244 private: |
3237 Call* call_; | 3245 Call* call_; |
3238 rtc::CriticalSection crit_; | 3246 rtc::CriticalSection crit_; |
3239 uint32_t max_bitrate_kbps_ GUARDED_BY(&crit_); | 3247 uint32_t max_bitrate_bps_ GUARDED_BY(&crit_); |
3248 bool first_packet_send_ GUARDED_BY(&crit_); | |
minyue-webrtc
2017/01/26 09:28:50
send -> sent
michaelt
2017/01/26 12:12:54
Done.
| |
3249 rtc::Event bitrate_changed_event_; | |
3240 } test; | 3250 } test; |
3241 | 3251 |
3242 RunBaseTest(&test); | 3252 RunBaseTest(&test); |
3243 } | 3253 } |
3244 | 3254 |
3245 } // namespace webrtc | 3255 } // namespace webrtc |
OLD | NEW |