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 | 10 |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
122 Vp8StreamInfo info; | 122 Vp8StreamInfo info; |
123 for (int tl = 0; tl < 3; ++tl) { | 123 for (int tl = 0; tl < 3; ++tl) { |
124 info.framerate_fps[tl] = FramerateFpsWithinTemporalLayer(tl); | 124 info.framerate_fps[tl] = FramerateFpsWithinTemporalLayer(tl); |
125 info.bitrate_kbps[tl] = BitrateKbpsWithinTemporalLayer(tl); | 125 info.bitrate_kbps[tl] = BitrateKbpsWithinTemporalLayer(tl); |
126 } | 126 } |
127 return info; | 127 return info; |
128 } | 128 } |
129 | 129 |
130 private: | 130 private: |
131 struct FrameData { | 131 struct FrameData { |
132 FrameData() {} | 132 FrameData() : payload_size(0) {} |
133 | 133 |
134 FrameData(size_t payload_size, const CodecSpecificInfo& codec_specific_info) | 134 FrameData(size_t payload_size, const CodecSpecificInfo& codec_specific_info) |
135 : payload_size(payload_size), | 135 : payload_size(payload_size), |
136 codec_specific_info(codec_specific_info) {} | 136 codec_specific_info(codec_specific_info) {} |
137 | 137 |
138 size_t payload_size; | 138 size_t payload_size; |
139 CodecSpecificInfo codec_specific_info; | 139 CodecSpecificInfo codec_specific_info; |
140 }; | 140 }; |
141 | 141 |
142 int64_t interval_ms() { | 142 int64_t interval_ms() { |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
292 AddFrame(); | 292 AddFrame(); |
293 ExpectIntraRequest(-1); | 293 ExpectIntraRequest(-1); |
294 AddFrame(); | 294 AddFrame(); |
295 | 295 |
296 EXPECT_EQ(-1, sender_->IntraFrameRequest(3)); | 296 EXPECT_EQ(-1, sender_->IntraFrameRequest(3)); |
297 ExpectIntraRequest(-1); | 297 ExpectIntraRequest(-1); |
298 AddFrame(); | 298 AddFrame(); |
299 } | 299 } |
300 | 300 |
301 TEST_F(TestVideoSenderWithMockEncoder, TestSetRate) { | 301 TEST_F(TestVideoSenderWithMockEncoder, TestSetRate) { |
302 // Let actual fps be half of max, so it can be distinguished from default. | |
303 const int64_t kActualFrameRate = settings_.maxFramerate / 2; | |
danilchap
2016/11/21 13:14:49
since it is not a time variable, may be revert to
sprang_webrtc
2016/11/21 13:21:50
Sure. And no, little consistency :(
I'd like to cl
| |
304 const int64_t kFrameIntervalMs = 1000 / kActualFrameRate; | |
302 const uint32_t new_bitrate_kbps = settings_.startBitrate + 300; | 305 const uint32_t new_bitrate_kbps = settings_.startBitrate + 300; |
306 | |
307 // Initial frame rate is taken from config, as we have no data yet. | |
303 BitrateAllocation new_rate_allocation = rate_allocator_->GetAllocation( | 308 BitrateAllocation new_rate_allocation = rate_allocator_->GetAllocation( |
304 new_bitrate_kbps * 1000, settings_.maxFramerate); | 309 new_bitrate_kbps * 1000, settings_.maxFramerate); |
305 EXPECT_CALL(encoder_, SetRateAllocation(new_rate_allocation, _)) | 310 EXPECT_CALL(encoder_, |
311 SetRateAllocation(new_rate_allocation, settings_.maxFramerate)) | |
306 .Times(1) | 312 .Times(1) |
307 .WillOnce(Return(0)); | 313 .WillOnce(Return(0)); |
308 sender_->SetChannelParameters(new_bitrate_kbps * 1000, 0, 200, | 314 sender_->SetChannelParameters(new_bitrate_kbps * 1000, 0, 200, |
309 rate_allocator_.get()); | 315 rate_allocator_.get()); |
310 AddFrame(); | 316 AddFrame(); |
317 clock_.AdvanceTimeMilliseconds(kFrameIntervalMs); | |
318 | |
319 // Add enough frames so that input frame rate will be updated. | |
320 const int kFramesToSend = | |
321 (VCMProcessTimer::kDefaultProcessIntervalMs / kFrameIntervalMs) + 1; | |
322 for (int i = 0; i < kFramesToSend; ++i) { | |
323 AddFrame(); | |
324 clock_.AdvanceTimeMilliseconds(kFrameIntervalMs); | |
325 } | |
326 | |
327 EXPECT_CALL(encoder_, | |
328 SetRateAllocation(new_rate_allocation, kActualFrameRate)) | |
329 .Times(1) | |
330 .WillOnce(Return(0)); | |
331 | |
332 sender_->Process(); | |
333 AddFrame(); | |
311 | 334 |
312 // Expect no call to encoder_.SetRates if the new bitrate is zero. | 335 // Expect no call to encoder_.SetRates if the new bitrate is zero. |
313 EXPECT_CALL(encoder_, SetRateAllocation(_, _)).Times(0); | 336 EXPECT_CALL(encoder_, SetRateAllocation(_, _)).Times(0); |
314 sender_->SetChannelParameters(0, 0, 200, rate_allocator_.get()); | 337 sender_->SetChannelParameters(0, 0, 200, rate_allocator_.get()); |
315 AddFrame(); | 338 AddFrame(); |
316 } | 339 } |
317 | 340 |
318 TEST_F(TestVideoSenderWithMockEncoder, TestIntraRequestsInternalCapture) { | 341 TEST_F(TestVideoSenderWithMockEncoder, TestIntraRequestsInternalCapture) { |
319 // De-register current external encoder. | 342 // De-register current external encoder. |
320 sender_->RegisterExternalEncoder(nullptr, kUnusedPayloadType, false); | 343 sender_->RegisterExternalEncoder(nullptr, kUnusedPayloadType, false); |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
544 } | 567 } |
545 { | 568 { |
546 // TODO(andresp): Find out why this fails with framerate = 7.5 | 569 // TODO(andresp): Find out why this fails with framerate = 7.5 |
547 Vp8StreamInfo expected = {{7.0, 7.0, 7.0}, {high_b, high_b, high_b}}; | 570 Vp8StreamInfo expected = {{7.0, 7.0, 7.0}, {high_b, high_b, high_b}}; |
548 EXPECT_THAT(SimulateWithFramerate(7.0), MatchesVp8StreamInfo(expected)); | 571 EXPECT_THAT(SimulateWithFramerate(7.0), MatchesVp8StreamInfo(expected)); |
549 } | 572 } |
550 } | 573 } |
551 } // namespace | 574 } // namespace |
552 } // namespace vcm | 575 } // namespace vcm |
553 } // namespace webrtc | 576 } // namespace webrtc |
OLD | NEW |