OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2011 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 |
11 #include <string.h> | 11 #include <string.h> |
12 | 12 |
13 #include <list> | 13 #include <list> |
| 14 #include <memory> |
14 | 15 |
15 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
16 #include "webrtc/modules/video_coding/frame_buffer.h" | 17 #include "webrtc/modules/video_coding/frame_buffer.h" |
17 #include "webrtc/modules/video_coding/jitter_buffer.h" | 18 #include "webrtc/modules/video_coding/jitter_buffer.h" |
18 #include "webrtc/modules/video_coding/media_opt_util.h" | 19 #include "webrtc/modules/video_coding/media_opt_util.h" |
19 #include "webrtc/modules/video_coding/packet.h" | 20 #include "webrtc/modules/video_coding/packet.h" |
20 #include "webrtc/modules/video_coding/test/stream_generator.h" | 21 #include "webrtc/modules/video_coding/test/stream_generator.h" |
21 #include "webrtc/modules/video_coding/test/test_util.h" | 22 #include "webrtc/modules/video_coding/test/test_util.h" |
22 #include "webrtc/system_wrappers/include/clock.h" | 23 #include "webrtc/system_wrappers/include/clock.h" |
23 #include "webrtc/system_wrappers/include/metrics.h" | 24 #include "webrtc/system_wrappers/include/metrics.h" |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 EXPECT_EQ(1, packet_.codecSpecificHeader.codecHeader.VP9.pid_diff[0]); | 184 EXPECT_EQ(1, packet_.codecSpecificHeader.codecHeader.VP9.pid_diff[0]); |
184 EXPECT_EQ(2, packet_.codecSpecificHeader.codecHeader.VP9.pid_diff[1]); | 185 EXPECT_EQ(2, packet_.codecSpecificHeader.codecHeader.VP9.pid_diff[1]); |
185 } | 186 } |
186 | 187 |
187 class TestBasicJitterBuffer : public ::testing::Test { | 188 class TestBasicJitterBuffer : public ::testing::Test { |
188 protected: | 189 protected: |
189 virtual void SetUp() { | 190 virtual void SetUp() { |
190 clock_.reset(new SimulatedClock(0)); | 191 clock_.reset(new SimulatedClock(0)); |
191 jitter_buffer_.reset(new VCMJitterBuffer( | 192 jitter_buffer_.reset(new VCMJitterBuffer( |
192 clock_.get(), | 193 clock_.get(), |
193 rtc::scoped_ptr<EventWrapper>(event_factory_.CreateEvent()))); | 194 std::unique_ptr<EventWrapper>(event_factory_.CreateEvent()))); |
194 jitter_buffer_->Start(); | 195 jitter_buffer_->Start(); |
195 seq_num_ = 1234; | 196 seq_num_ = 1234; |
196 timestamp_ = 0; | 197 timestamp_ = 0; |
197 size_ = 1400; | 198 size_ = 1400; |
198 // Data vector - 0, 0, 0x80, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0x80, 3.... | 199 // Data vector - 0, 0, 0x80, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0x80, 3.... |
199 data_[0] = 0; | 200 data_[0] = 0; |
200 data_[1] = 0; | 201 data_[1] = 0; |
201 data_[2] = 0x80; | 202 data_[2] = 0x80; |
202 int count = 3; | 203 int count = 3; |
203 for (unsigned int i = 3; i < sizeof(data_) - 3; ++i) { | 204 for (unsigned int i = 3; i < sizeof(data_) - 3; ++i) { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 count = 3; | 267 count = 3; |
267 } | 268 } |
268 } | 269 } |
269 } | 270 } |
270 } | 271 } |
271 | 272 |
272 uint16_t seq_num_; | 273 uint16_t seq_num_; |
273 uint32_t timestamp_; | 274 uint32_t timestamp_; |
274 int size_; | 275 int size_; |
275 uint8_t data_[1500]; | 276 uint8_t data_[1500]; |
276 rtc::scoped_ptr<VCMPacket> packet_; | 277 std::unique_ptr<VCMPacket> packet_; |
277 rtc::scoped_ptr<SimulatedClock> clock_; | 278 std::unique_ptr<SimulatedClock> clock_; |
278 NullEventFactory event_factory_; | 279 NullEventFactory event_factory_; |
279 rtc::scoped_ptr<VCMJitterBuffer> jitter_buffer_; | 280 std::unique_ptr<VCMJitterBuffer> jitter_buffer_; |
280 }; | 281 }; |
281 | 282 |
282 class TestRunningJitterBuffer : public ::testing::Test { | 283 class TestRunningJitterBuffer : public ::testing::Test { |
283 protected: | 284 protected: |
284 enum { kDataBufferSize = 10 }; | 285 enum { kDataBufferSize = 10 }; |
285 | 286 |
286 virtual void SetUp() { | 287 virtual void SetUp() { |
287 clock_.reset(new SimulatedClock(0)); | 288 clock_.reset(new SimulatedClock(0)); |
288 max_nack_list_size_ = 150; | 289 max_nack_list_size_ = 150; |
289 oldest_packet_to_nack_ = 250; | 290 oldest_packet_to_nack_ = 250; |
290 jitter_buffer_ = new VCMJitterBuffer( | 291 jitter_buffer_ = new VCMJitterBuffer( |
291 clock_.get(), | 292 clock_.get(), |
292 rtc::scoped_ptr<EventWrapper>(event_factory_.CreateEvent())); | 293 std::unique_ptr<EventWrapper>(event_factory_.CreateEvent())); |
293 stream_generator_ = new StreamGenerator(0, clock_->TimeInMilliseconds()); | 294 stream_generator_ = new StreamGenerator(0, clock_->TimeInMilliseconds()); |
294 jitter_buffer_->Start(); | 295 jitter_buffer_->Start(); |
295 jitter_buffer_->SetNackSettings(max_nack_list_size_, oldest_packet_to_nack_, | 296 jitter_buffer_->SetNackSettings(max_nack_list_size_, oldest_packet_to_nack_, |
296 0); | 297 0); |
297 memset(data_buffer_, 0, kDataBufferSize); | 298 memset(data_buffer_, 0, kDataBufferSize); |
298 } | 299 } |
299 | 300 |
300 virtual void TearDown() { | 301 virtual void TearDown() { |
301 jitter_buffer_->Stop(); | 302 jitter_buffer_->Stop(); |
302 delete stream_generator_; | 303 delete stream_generator_; |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 if (!found_frame) | 374 if (!found_frame) |
374 return false; | 375 return false; |
375 VCMEncodedFrame* frame = jitter_buffer_->ExtractAndSetDecode(timestamp); | 376 VCMEncodedFrame* frame = jitter_buffer_->ExtractAndSetDecode(timestamp); |
376 bool ret = (frame != NULL); | 377 bool ret = (frame != NULL); |
377 jitter_buffer_->ReleaseFrame(frame); | 378 jitter_buffer_->ReleaseFrame(frame); |
378 return ret; | 379 return ret; |
379 } | 380 } |
380 | 381 |
381 VCMJitterBuffer* jitter_buffer_; | 382 VCMJitterBuffer* jitter_buffer_; |
382 StreamGenerator* stream_generator_; | 383 StreamGenerator* stream_generator_; |
383 rtc::scoped_ptr<SimulatedClock> clock_; | 384 std::unique_ptr<SimulatedClock> clock_; |
384 NullEventFactory event_factory_; | 385 NullEventFactory event_factory_; |
385 size_t max_nack_list_size_; | 386 size_t max_nack_list_size_; |
386 int oldest_packet_to_nack_; | 387 int oldest_packet_to_nack_; |
387 uint8_t data_buffer_[kDataBufferSize]; | 388 uint8_t data_buffer_[kDataBufferSize]; |
388 }; | 389 }; |
389 | 390 |
390 class TestJitterBufferNack : public TestRunningJitterBuffer { | 391 class TestJitterBufferNack : public TestRunningJitterBuffer { |
391 protected: | 392 protected: |
392 virtual void SetUp() { | 393 virtual void SetUp() { |
393 TestRunningJitterBuffer::SetUp(); | 394 TestRunningJitterBuffer::SetUp(); |
(...skipping 2168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2562 | 2563 |
2563 // Stream should be decodable from this point. | 2564 // Stream should be decodable from this point. |
2564 clock_->AdvanceTimeMilliseconds(kDefaultFramePeriodMs); | 2565 clock_->AdvanceTimeMilliseconds(kDefaultFramePeriodMs); |
2565 InsertFrame(kVideoFrameDelta); | 2566 InsertFrame(kVideoFrameDelta); |
2566 EXPECT_TRUE(DecodeCompleteFrame()); | 2567 EXPECT_TRUE(DecodeCompleteFrame()); |
2567 nack_list = jitter_buffer_->GetNackList(&extended); | 2568 nack_list = jitter_buffer_->GetNackList(&extended); |
2568 EXPECT_EQ(0u, nack_list.size()); | 2569 EXPECT_EQ(0u, nack_list.size()); |
2569 } | 2570 } |
2570 | 2571 |
2571 } // namespace webrtc | 2572 } // namespace webrtc |
OLD | NEW |