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> |
12 | 12 |
13 #include <list> | 13 #include <list> |
14 #include <memory> | 14 #include <memory> |
15 | 15 |
16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 17 #include "testing/gmock/include/gmock/gmock.h" |
17 #include "webrtc/modules/video_coding/frame_buffer.h" | 18 #include "webrtc/modules/video_coding/frame_buffer.h" |
18 #include "webrtc/modules/video_coding/jitter_buffer.h" | 19 #include "webrtc/modules/video_coding/jitter_buffer.h" |
19 #include "webrtc/modules/video_coding/media_opt_util.h" | 20 #include "webrtc/modules/video_coding/media_opt_util.h" |
20 #include "webrtc/modules/video_coding/packet.h" | 21 #include "webrtc/modules/video_coding/packet.h" |
21 #include "webrtc/modules/video_coding/test/stream_generator.h" | 22 #include "webrtc/modules/video_coding/test/stream_generator.h" |
22 #include "webrtc/modules/video_coding/test/test_util.h" | 23 #include "webrtc/modules/video_coding/test/test_util.h" |
23 #include "webrtc/system_wrappers/include/clock.h" | 24 #include "webrtc/system_wrappers/include/clock.h" |
| 25 #include "webrtc/system_wrappers/include/field_trial.h" |
24 #include "webrtc/system_wrappers/include/metrics.h" | 26 #include "webrtc/system_wrappers/include/metrics.h" |
| 27 #include "webrtc/test/field_trial.h" |
25 #include "webrtc/test/histogram.h" | 28 #include "webrtc/test/histogram.h" |
26 | 29 |
27 namespace webrtc { | 30 namespace webrtc { |
28 | 31 |
29 namespace { | 32 namespace { |
30 const uint32_t kProcessIntervalSec = 60; | 33 const uint32_t kProcessIntervalSec = 60; |
31 } // namespace | 34 } // namespace |
32 | 35 |
33 class Vp9SsMapTest : public ::testing::Test { | 36 class Vp9SsMapTest : public ::testing::Test { |
34 protected: | 37 protected: |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 | 181 |
179 packet_.codecSpecificHeader.codecHeader.VP9.gof_idx = 3; | 182 packet_.codecSpecificHeader.codecHeader.VP9.gof_idx = 3; |
180 EXPECT_TRUE(map_.UpdatePacket(&packet_)); | 183 EXPECT_TRUE(map_.UpdatePacket(&packet_)); |
181 EXPECT_EQ(2, packet_.codecSpecificHeader.codecHeader.VP9.temporal_idx); | 184 EXPECT_EQ(2, packet_.codecSpecificHeader.codecHeader.VP9.temporal_idx); |
182 EXPECT_FALSE(packet_.codecSpecificHeader.codecHeader.VP9.temporal_up_switch); | 185 EXPECT_FALSE(packet_.codecSpecificHeader.codecHeader.VP9.temporal_up_switch); |
183 EXPECT_EQ(2U, packet_.codecSpecificHeader.codecHeader.VP9.num_ref_pics); | 186 EXPECT_EQ(2U, packet_.codecSpecificHeader.codecHeader.VP9.num_ref_pics); |
184 EXPECT_EQ(1, packet_.codecSpecificHeader.codecHeader.VP9.pid_diff[0]); | 187 EXPECT_EQ(1, packet_.codecSpecificHeader.codecHeader.VP9.pid_diff[0]); |
185 EXPECT_EQ(2, packet_.codecSpecificHeader.codecHeader.VP9.pid_diff[1]); | 188 EXPECT_EQ(2, packet_.codecSpecificHeader.codecHeader.VP9.pid_diff[1]); |
186 } | 189 } |
187 | 190 |
188 class TestBasicJitterBuffer : public ::testing::Test { | 191 class ProcessThreadMock : public ProcessThread { |
| 192 public: |
| 193 MOCK_METHOD0(Start, void()); |
| 194 MOCK_METHOD0(Stop, void()); |
| 195 MOCK_METHOD1(WakeUp, void(Module* module)); |
| 196 MOCK_METHOD1(RegisterModule, void(Module* module)); |
| 197 MOCK_METHOD1(DeRegisterModule, void(Module* module)); |
| 198 void PostTask(rtc::scoped_ptr<ProcessTask> task) {} |
| 199 }; |
| 200 |
| 201 class TestBasicJitterBuffer : public ::testing::TestWithParam<std::string>, |
| 202 public NackSender, |
| 203 public KeyFrameRequestSender { |
| 204 public: |
| 205 void SendNack(const std::vector<uint16_t>& sequence_numbers) override { |
| 206 nack_sent_.insert(nack_sent_.end(), sequence_numbers.begin(), |
| 207 sequence_numbers.end()); |
| 208 } |
| 209 |
| 210 void RequestKeyFrame() override { ++keyframe_requests_; } |
| 211 |
| 212 ::testing::NiceMock<ProcessThreadMock> process_thread_mock_; |
| 213 std::vector<uint16_t> nack_sent_; |
| 214 int keyframe_requests_; |
| 215 |
189 protected: | 216 protected: |
| 217 TestBasicJitterBuffer() : scoped_field_trial_(GetParam()) {} |
190 virtual void SetUp() { | 218 virtual void SetUp() { |
191 clock_.reset(new SimulatedClock(0)); | 219 clock_.reset(new SimulatedClock(0)); |
192 jitter_buffer_.reset(new VCMJitterBuffer( | 220 jitter_buffer_.reset(new VCMJitterBuffer( |
193 clock_.get(), | 221 clock_.get(), |
194 std::unique_ptr<EventWrapper>(event_factory_.CreateEvent()))); | 222 std::unique_ptr<EventWrapper>(event_factory_.CreateEvent()), |
| 223 this, |
| 224 this)); |
195 jitter_buffer_->Start(); | 225 jitter_buffer_->Start(); |
196 seq_num_ = 1234; | 226 seq_num_ = 1234; |
197 timestamp_ = 0; | 227 timestamp_ = 0; |
198 size_ = 1400; | 228 size_ = 1400; |
199 // Data vector - 0, 0, 0x80, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0x80, 3.... | 229 // Data vector - 0, 0, 0x80, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0x80, 3.... |
200 data_[0] = 0; | 230 data_[0] = 0; |
201 data_[1] = 0; | 231 data_[1] = 0; |
202 data_[2] = 0x80; | 232 data_[2] = 0x80; |
203 int count = 3; | 233 int count = 3; |
204 for (unsigned int i = 3; i < sizeof(data_) - 3; ++i) { | 234 for (unsigned int i = 3; i < sizeof(data_) - 3; ++i) { |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 } | 301 } |
272 | 302 |
273 uint16_t seq_num_; | 303 uint16_t seq_num_; |
274 uint32_t timestamp_; | 304 uint32_t timestamp_; |
275 int size_; | 305 int size_; |
276 uint8_t data_[1500]; | 306 uint8_t data_[1500]; |
277 std::unique_ptr<VCMPacket> packet_; | 307 std::unique_ptr<VCMPacket> packet_; |
278 std::unique_ptr<SimulatedClock> clock_; | 308 std::unique_ptr<SimulatedClock> clock_; |
279 NullEventFactory event_factory_; | 309 NullEventFactory event_factory_; |
280 std::unique_ptr<VCMJitterBuffer> jitter_buffer_; | 310 std::unique_ptr<VCMJitterBuffer> jitter_buffer_; |
| 311 test::ScopedFieldTrials scoped_field_trial_; |
281 }; | 312 }; |
282 | 313 |
283 class TestRunningJitterBuffer : public ::testing::Test { | 314 INSTANTIATE_TEST_CASE_P( |
| 315 TestWithNackModule, |
| 316 TestBasicJitterBuffer, |
| 317 ::testing::Values("WebRTC-NewVideoJitterBuffer/Enabled/", |
| 318 "WebRTC-NewVideoJitterBuffer/Disabled/")); |
| 319 |
| 320 class TestRunningJitterBuffer : public ::testing::TestWithParam<std::string>, |
| 321 public NackSender, |
| 322 public KeyFrameRequestSender { |
| 323 public: |
| 324 void SendNack(const std::vector<uint16_t>& sequence_numbers) { |
| 325 nack_sent_.insert(nack_sent_.end(), sequence_numbers.begin(), |
| 326 sequence_numbers.end()); |
| 327 } |
| 328 |
| 329 void RequestKeyFrame() { ++keyframe_requests_; } |
| 330 |
| 331 ::testing::NiceMock<ProcessThreadMock> process_thread_mock_; |
| 332 std::vector<uint16_t> nack_sent_; |
| 333 int keyframe_requests_; |
| 334 |
284 protected: | 335 protected: |
285 enum { kDataBufferSize = 10 }; | 336 enum { kDataBufferSize = 10 }; |
286 | 337 |
287 virtual void SetUp() { | 338 virtual void SetUp() { |
288 clock_.reset(new SimulatedClock(0)); | 339 clock_.reset(new SimulatedClock(0)); |
289 max_nack_list_size_ = 150; | 340 max_nack_list_size_ = 150; |
290 oldest_packet_to_nack_ = 250; | 341 oldest_packet_to_nack_ = 250; |
291 jitter_buffer_ = new VCMJitterBuffer( | 342 jitter_buffer_ = new VCMJitterBuffer( |
292 clock_.get(), | 343 clock_.get(), |
293 std::unique_ptr<EventWrapper>(event_factory_.CreateEvent())); | 344 std::unique_ptr<EventWrapper>(event_factory_.CreateEvent()), |
| 345 this, this); |
294 stream_generator_ = new StreamGenerator(0, clock_->TimeInMilliseconds()); | 346 stream_generator_ = new StreamGenerator(0, clock_->TimeInMilliseconds()); |
295 jitter_buffer_->Start(); | 347 jitter_buffer_->Start(); |
296 jitter_buffer_->SetNackSettings(max_nack_list_size_, oldest_packet_to_nack_, | 348 jitter_buffer_->SetNackSettings(max_nack_list_size_, oldest_packet_to_nack_, |
297 0); | 349 0); |
298 memset(data_buffer_, 0, kDataBufferSize); | 350 memset(data_buffer_, 0, kDataBufferSize); |
299 } | 351 } |
300 | 352 |
301 virtual void TearDown() { | 353 virtual void TearDown() { |
302 jitter_buffer_->Stop(); | 354 jitter_buffer_->Stop(); |
303 delete stream_generator_; | 355 delete stream_generator_; |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 StreamGenerator* stream_generator_; | 435 StreamGenerator* stream_generator_; |
384 std::unique_ptr<SimulatedClock> clock_; | 436 std::unique_ptr<SimulatedClock> clock_; |
385 NullEventFactory event_factory_; | 437 NullEventFactory event_factory_; |
386 size_t max_nack_list_size_; | 438 size_t max_nack_list_size_; |
387 int oldest_packet_to_nack_; | 439 int oldest_packet_to_nack_; |
388 uint8_t data_buffer_[kDataBufferSize]; | 440 uint8_t data_buffer_[kDataBufferSize]; |
389 }; | 441 }; |
390 | 442 |
391 class TestJitterBufferNack : public TestRunningJitterBuffer { | 443 class TestJitterBufferNack : public TestRunningJitterBuffer { |
392 protected: | 444 protected: |
| 445 TestJitterBufferNack() : scoped_field_trial_(GetParam()) {} |
393 virtual void SetUp() { | 446 virtual void SetUp() { |
394 TestRunningJitterBuffer::SetUp(); | 447 TestRunningJitterBuffer::SetUp(); |
395 jitter_buffer_->SetNackMode(kNack, -1, -1); | 448 jitter_buffer_->SetNackMode(kNack, -1, -1); |
396 } | 449 } |
397 | 450 |
398 virtual void TearDown() { TestRunningJitterBuffer::TearDown(); } | 451 virtual void TearDown() { TestRunningJitterBuffer::TearDown(); } |
| 452 |
| 453 test::ScopedFieldTrials scoped_field_trial_; |
399 }; | 454 }; |
400 | 455 |
401 TEST_F(TestBasicJitterBuffer, StopRunning) { | 456 INSTANTIATE_TEST_CASE_P( |
| 457 TestWithNackModule, |
| 458 TestJitterBufferNack, |
| 459 ::testing::Values("WebRTC-NewVideoJitterBuffer/Enabled/", |
| 460 "WebRTC-NewVideoJitterBuffer/Disabled/")); |
| 461 |
| 462 TEST_P(TestBasicJitterBuffer, StopRunning) { |
402 jitter_buffer_->Stop(); | 463 jitter_buffer_->Stop(); |
403 EXPECT_TRUE(NULL == DecodeCompleteFrame()); | 464 EXPECT_TRUE(NULL == DecodeCompleteFrame()); |
404 EXPECT_TRUE(NULL == DecodeIncompleteFrame()); | 465 EXPECT_TRUE(NULL == DecodeIncompleteFrame()); |
405 jitter_buffer_->Start(); | 466 jitter_buffer_->Start(); |
406 // Allow selective errors. | 467 // Allow selective errors. |
407 jitter_buffer_->SetDecodeErrorMode(kSelectiveErrors); | 468 jitter_buffer_->SetDecodeErrorMode(kSelectiveErrors); |
408 | 469 |
409 // No packets inserted. | 470 // No packets inserted. |
410 EXPECT_TRUE(NULL == DecodeCompleteFrame()); | 471 EXPECT_TRUE(NULL == DecodeCompleteFrame()); |
411 EXPECT_TRUE(NULL == DecodeIncompleteFrame()); | 472 EXPECT_TRUE(NULL == DecodeIncompleteFrame()); |
412 | 473 |
413 // Allow decoding with errors. | 474 // Allow decoding with errors. |
414 jitter_buffer_->SetDecodeErrorMode(kWithErrors); | 475 jitter_buffer_->SetDecodeErrorMode(kWithErrors); |
415 | 476 |
416 // No packets inserted. | 477 // No packets inserted. |
417 EXPECT_TRUE(NULL == DecodeCompleteFrame()); | 478 EXPECT_TRUE(NULL == DecodeCompleteFrame()); |
418 EXPECT_TRUE(NULL == DecodeIncompleteFrame()); | 479 EXPECT_TRUE(NULL == DecodeIncompleteFrame()); |
419 } | 480 } |
420 | 481 |
421 TEST_F(TestBasicJitterBuffer, SinglePacketFrame) { | 482 TEST_P(TestBasicJitterBuffer, SinglePacketFrame) { |
422 // Always start with a complete key frame when not allowing errors. | 483 // Always start with a complete key frame when not allowing errors. |
423 jitter_buffer_->SetDecodeErrorMode(kNoErrors); | 484 jitter_buffer_->SetDecodeErrorMode(kNoErrors); |
424 packet_->frameType = kVideoFrameKey; | 485 packet_->frameType = kVideoFrameKey; |
425 packet_->isFirstPacket = true; | 486 packet_->isFirstPacket = true; |
426 packet_->markerBit = true; | 487 packet_->markerBit = true; |
427 packet_->timestamp += 123 * 90; | 488 packet_->timestamp += 123 * 90; |
428 | 489 |
429 // Insert the packet to the jitter buffer and get a frame. | 490 // Insert the packet to the jitter buffer and get a frame. |
430 bool retransmitted = false; | 491 bool retransmitted = false; |
431 EXPECT_EQ(kCompleteSession, | 492 EXPECT_EQ(kCompleteSession, |
432 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 493 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
433 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); | 494 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); |
434 CheckOutFrame(frame_out, size_, false); | 495 CheckOutFrame(frame_out, size_, false); |
435 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); | 496 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); |
436 jitter_buffer_->ReleaseFrame(frame_out); | 497 jitter_buffer_->ReleaseFrame(frame_out); |
437 } | 498 } |
438 | 499 |
439 TEST_F(TestBasicJitterBuffer, VerifyHistogramStats) { | 500 TEST_P(TestBasicJitterBuffer, VerifyHistogramStats) { |
440 test::ClearHistograms(); | 501 test::ClearHistograms(); |
441 // Always start with a complete key frame when not allowing errors. | 502 // Always start with a complete key frame when not allowing errors. |
442 jitter_buffer_->SetDecodeErrorMode(kNoErrors); | 503 jitter_buffer_->SetDecodeErrorMode(kNoErrors); |
443 packet_->frameType = kVideoFrameKey; | 504 packet_->frameType = kVideoFrameKey; |
444 packet_->isFirstPacket = true; | 505 packet_->isFirstPacket = true; |
445 packet_->markerBit = true; | 506 packet_->markerBit = true; |
446 packet_->timestamp += 123 * 90; | 507 packet_->timestamp += 123 * 90; |
447 | 508 |
448 // Insert single packet frame to the jitter buffer and get a frame. | 509 // Insert single packet frame to the jitter buffer and get a frame. |
449 bool retransmitted = false; | 510 bool retransmitted = false; |
(...skipping 21 matching lines...) Expand all Loading... |
471 EXPECT_EQ( | 532 EXPECT_EQ( |
472 1, test::NumHistogramSamples("WebRTC.Video.DiscardedPacketsInPercent")); | 533 1, test::NumHistogramSamples("WebRTC.Video.DiscardedPacketsInPercent")); |
473 EXPECT_EQ( | 534 EXPECT_EQ( |
474 1, test::NumHistogramSamples("WebRTC.Video.DuplicatedPacketsInPercent")); | 535 1, test::NumHistogramSamples("WebRTC.Video.DuplicatedPacketsInPercent")); |
475 EXPECT_EQ(1, test::NumHistogramSamples( | 536 EXPECT_EQ(1, test::NumHistogramSamples( |
476 "WebRTC.Video.CompleteFramesReceivedPerSecond")); | 537 "WebRTC.Video.CompleteFramesReceivedPerSecond")); |
477 EXPECT_EQ( | 538 EXPECT_EQ( |
478 1, test::NumHistogramSamples("WebRTC.Video.KeyFramesReceivedInPermille")); | 539 1, test::NumHistogramSamples("WebRTC.Video.KeyFramesReceivedInPermille")); |
479 } | 540 } |
480 | 541 |
481 TEST_F(TestBasicJitterBuffer, DualPacketFrame) { | 542 TEST_P(TestBasicJitterBuffer, DualPacketFrame) { |
482 packet_->frameType = kVideoFrameKey; | 543 packet_->frameType = kVideoFrameKey; |
483 packet_->isFirstPacket = true; | 544 packet_->isFirstPacket = true; |
484 packet_->markerBit = false; | 545 packet_->markerBit = false; |
485 | 546 |
486 bool retransmitted = false; | 547 bool retransmitted = false; |
487 EXPECT_EQ(kIncomplete, | 548 EXPECT_EQ(kIncomplete, |
488 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 549 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
489 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); | 550 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); |
490 // Should not be complete. | 551 // Should not be complete. |
491 EXPECT_TRUE(frame_out == NULL); | 552 EXPECT_TRUE(frame_out == NULL); |
492 | 553 |
493 ++seq_num_; | 554 ++seq_num_; |
494 packet_->isFirstPacket = false; | 555 packet_->isFirstPacket = false; |
495 packet_->markerBit = true; | 556 packet_->markerBit = true; |
496 packet_->seqNum = seq_num_; | 557 packet_->seqNum = seq_num_; |
497 | 558 |
498 EXPECT_EQ(kCompleteSession, | 559 EXPECT_EQ(kCompleteSession, |
499 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 560 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
500 | 561 |
501 frame_out = DecodeCompleteFrame(); | 562 frame_out = DecodeCompleteFrame(); |
502 CheckOutFrame(frame_out, 2 * size_, false); | 563 CheckOutFrame(frame_out, 2 * size_, false); |
503 | 564 |
504 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); | 565 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); |
505 jitter_buffer_->ReleaseFrame(frame_out); | 566 jitter_buffer_->ReleaseFrame(frame_out); |
506 } | 567 } |
507 | 568 |
508 TEST_F(TestBasicJitterBuffer, 100PacketKeyFrame) { | 569 TEST_P(TestBasicJitterBuffer, 100PacketKeyFrame) { |
509 packet_->frameType = kVideoFrameKey; | 570 packet_->frameType = kVideoFrameKey; |
510 packet_->isFirstPacket = true; | 571 packet_->isFirstPacket = true; |
511 packet_->markerBit = false; | 572 packet_->markerBit = false; |
512 | 573 |
513 bool retransmitted = false; | 574 bool retransmitted = false; |
514 EXPECT_EQ(kIncomplete, | 575 EXPECT_EQ(kIncomplete, |
515 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 576 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
516 | 577 |
517 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); | 578 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); |
518 | 579 |
(...skipping 22 matching lines...) Expand all Loading... |
541 EXPECT_EQ(kCompleteSession, | 602 EXPECT_EQ(kCompleteSession, |
542 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 603 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
543 | 604 |
544 frame_out = DecodeCompleteFrame(); | 605 frame_out = DecodeCompleteFrame(); |
545 | 606 |
546 CheckOutFrame(frame_out, 100 * size_, false); | 607 CheckOutFrame(frame_out, 100 * size_, false); |
547 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); | 608 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); |
548 jitter_buffer_->ReleaseFrame(frame_out); | 609 jitter_buffer_->ReleaseFrame(frame_out); |
549 } | 610 } |
550 | 611 |
551 TEST_F(TestBasicJitterBuffer, 100PacketDeltaFrame) { | 612 TEST_P(TestBasicJitterBuffer, 100PacketDeltaFrame) { |
552 // Always start with a complete key frame. | 613 // Always start with a complete key frame. |
553 packet_->frameType = kVideoFrameKey; | 614 packet_->frameType = kVideoFrameKey; |
554 packet_->isFirstPacket = true; | 615 packet_->isFirstPacket = true; |
555 packet_->markerBit = true; | 616 packet_->markerBit = true; |
556 | 617 |
557 bool retransmitted = false; | 618 bool retransmitted = false; |
558 EXPECT_EQ(kCompleteSession, | 619 EXPECT_EQ(kCompleteSession, |
559 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 620 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
560 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); | 621 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); |
561 EXPECT_FALSE(frame_out == NULL); | 622 EXPECT_FALSE(frame_out == NULL); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
597 EXPECT_EQ(kCompleteSession, | 658 EXPECT_EQ(kCompleteSession, |
598 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 659 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
599 | 660 |
600 frame_out = DecodeCompleteFrame(); | 661 frame_out = DecodeCompleteFrame(); |
601 | 662 |
602 CheckOutFrame(frame_out, 100 * size_, false); | 663 CheckOutFrame(frame_out, 100 * size_, false); |
603 EXPECT_EQ(kVideoFrameDelta, frame_out->FrameType()); | 664 EXPECT_EQ(kVideoFrameDelta, frame_out->FrameType()); |
604 jitter_buffer_->ReleaseFrame(frame_out); | 665 jitter_buffer_->ReleaseFrame(frame_out); |
605 } | 666 } |
606 | 667 |
607 TEST_F(TestBasicJitterBuffer, PacketReorderingReverseOrder) { | 668 TEST_P(TestBasicJitterBuffer, PacketReorderingReverseOrder) { |
608 // Insert the "first" packet last. | 669 // Insert the "first" packet last. |
609 seq_num_ += 100; | 670 seq_num_ += 100; |
610 packet_->frameType = kVideoFrameKey; | 671 packet_->frameType = kVideoFrameKey; |
611 packet_->isFirstPacket = false; | 672 packet_->isFirstPacket = false; |
612 packet_->markerBit = true; | 673 packet_->markerBit = true; |
613 packet_->seqNum = seq_num_; | 674 packet_->seqNum = seq_num_; |
614 packet_->timestamp = timestamp_; | 675 packet_->timestamp = timestamp_; |
615 | 676 |
616 bool retransmitted = false; | 677 bool retransmitted = false; |
617 EXPECT_EQ(kIncomplete, | 678 EXPECT_EQ(kIncomplete, |
(...skipping 26 matching lines...) Expand all Loading... |
644 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 705 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
645 | 706 |
646 frame_out = DecodeCompleteFrame(); | 707 frame_out = DecodeCompleteFrame(); |
647 | 708 |
648 CheckOutFrame(frame_out, 100 * size_, false); | 709 CheckOutFrame(frame_out, 100 * size_, false); |
649 | 710 |
650 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); | 711 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); |
651 jitter_buffer_->ReleaseFrame(frame_out); | 712 jitter_buffer_->ReleaseFrame(frame_out); |
652 } | 713 } |
653 | 714 |
654 TEST_F(TestBasicJitterBuffer, FrameReordering2Frames2PacketsEach) { | 715 TEST_P(TestBasicJitterBuffer, FrameReordering2Frames2PacketsEach) { |
655 packet_->frameType = kVideoFrameDelta; | 716 packet_->frameType = kVideoFrameDelta; |
656 packet_->isFirstPacket = true; | 717 packet_->isFirstPacket = true; |
657 packet_->markerBit = false; | 718 packet_->markerBit = false; |
658 | 719 |
659 bool retransmitted = false; | 720 bool retransmitted = false; |
660 EXPECT_EQ(kIncomplete, | 721 EXPECT_EQ(kIncomplete, |
661 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 722 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
662 | 723 |
663 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); | 724 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); |
664 | 725 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
704 CheckOutFrame(frame_out, 2 * size_, false); | 765 CheckOutFrame(frame_out, 2 * size_, false); |
705 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); | 766 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); |
706 jitter_buffer_->ReleaseFrame(frame_out); | 767 jitter_buffer_->ReleaseFrame(frame_out); |
707 | 768 |
708 frame_out = DecodeCompleteFrame(); | 769 frame_out = DecodeCompleteFrame(); |
709 CheckOutFrame(frame_out, 2 * size_, false); | 770 CheckOutFrame(frame_out, 2 * size_, false); |
710 EXPECT_EQ(kVideoFrameDelta, frame_out->FrameType()); | 771 EXPECT_EQ(kVideoFrameDelta, frame_out->FrameType()); |
711 jitter_buffer_->ReleaseFrame(frame_out); | 772 jitter_buffer_->ReleaseFrame(frame_out); |
712 } | 773 } |
713 | 774 |
714 TEST_F(TestBasicJitterBuffer, TestReorderingWithPadding) { | 775 TEST_P(TestBasicJitterBuffer, TestReorderingWithPadding) { |
715 packet_->frameType = kVideoFrameKey; | 776 packet_->frameType = kVideoFrameKey; |
716 packet_->isFirstPacket = true; | 777 packet_->isFirstPacket = true; |
717 packet_->markerBit = true; | 778 packet_->markerBit = true; |
718 | 779 |
719 // Send in an initial good packet/frame (Frame A) to start things off. | 780 // Send in an initial good packet/frame (Frame A) to start things off. |
720 bool retransmitted = false; | 781 bool retransmitted = false; |
721 EXPECT_EQ(kCompleteSession, | 782 EXPECT_EQ(kCompleteSession, |
722 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 783 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
723 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); | 784 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); |
724 EXPECT_TRUE(frame_out != NULL); | 785 EXPECT_TRUE(frame_out != NULL); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
761 empty_packet.seqNum += 1; | 822 empty_packet.seqNum += 1; |
762 EXPECT_EQ(kOldPacket, | 823 EXPECT_EQ(kOldPacket, |
763 jitter_buffer_->InsertPacket(empty_packet, &retransmitted)); | 824 jitter_buffer_->InsertPacket(empty_packet, &retransmitted)); |
764 | 825 |
765 // But now Frame C should be ready! | 826 // But now Frame C should be ready! |
766 frame_out = DecodeCompleteFrame(); | 827 frame_out = DecodeCompleteFrame(); |
767 EXPECT_TRUE(frame_out != NULL); | 828 EXPECT_TRUE(frame_out != NULL); |
768 jitter_buffer_->ReleaseFrame(frame_out); | 829 jitter_buffer_->ReleaseFrame(frame_out); |
769 } | 830 } |
770 | 831 |
771 TEST_F(TestBasicJitterBuffer, DuplicatePackets) { | 832 TEST_P(TestBasicJitterBuffer, DuplicatePackets) { |
772 packet_->frameType = kVideoFrameKey; | 833 packet_->frameType = kVideoFrameKey; |
773 packet_->isFirstPacket = true; | 834 packet_->isFirstPacket = true; |
774 packet_->markerBit = false; | 835 packet_->markerBit = false; |
775 packet_->seqNum = seq_num_; | 836 packet_->seqNum = seq_num_; |
776 packet_->timestamp = timestamp_; | 837 packet_->timestamp = timestamp_; |
777 EXPECT_EQ(0, jitter_buffer_->num_packets()); | 838 EXPECT_EQ(0, jitter_buffer_->num_packets()); |
778 EXPECT_EQ(0, jitter_buffer_->num_duplicated_packets()); | 839 EXPECT_EQ(0, jitter_buffer_->num_duplicated_packets()); |
779 | 840 |
780 bool retransmitted = false; | 841 bool retransmitted = false; |
781 EXPECT_EQ(kIncomplete, | 842 EXPECT_EQ(kIncomplete, |
(...skipping 22 matching lines...) Expand all Loading... |
804 frame_out = DecodeCompleteFrame(); | 865 frame_out = DecodeCompleteFrame(); |
805 ASSERT_TRUE(frame_out != NULL); | 866 ASSERT_TRUE(frame_out != NULL); |
806 CheckOutFrame(frame_out, 2 * size_, false); | 867 CheckOutFrame(frame_out, 2 * size_, false); |
807 | 868 |
808 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); | 869 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); |
809 EXPECT_EQ(3, jitter_buffer_->num_packets()); | 870 EXPECT_EQ(3, jitter_buffer_->num_packets()); |
810 EXPECT_EQ(1, jitter_buffer_->num_duplicated_packets()); | 871 EXPECT_EQ(1, jitter_buffer_->num_duplicated_packets()); |
811 jitter_buffer_->ReleaseFrame(frame_out); | 872 jitter_buffer_->ReleaseFrame(frame_out); |
812 } | 873 } |
813 | 874 |
814 TEST_F(TestBasicJitterBuffer, DuplicatePreviousDeltaFramePacket) { | 875 TEST_P(TestBasicJitterBuffer, DuplicatePreviousDeltaFramePacket) { |
815 packet_->frameType = kVideoFrameKey; | 876 packet_->frameType = kVideoFrameKey; |
816 packet_->isFirstPacket = true; | 877 packet_->isFirstPacket = true; |
817 packet_->markerBit = true; | 878 packet_->markerBit = true; |
818 packet_->seqNum = seq_num_; | 879 packet_->seqNum = seq_num_; |
819 packet_->timestamp = timestamp_; | 880 packet_->timestamp = timestamp_; |
820 jitter_buffer_->SetDecodeErrorMode(kNoErrors); | 881 jitter_buffer_->SetDecodeErrorMode(kNoErrors); |
821 EXPECT_EQ(0, jitter_buffer_->num_packets()); | 882 EXPECT_EQ(0, jitter_buffer_->num_packets()); |
822 EXPECT_EQ(0, jitter_buffer_->num_duplicated_packets()); | 883 EXPECT_EQ(0, jitter_buffer_->num_duplicated_packets()); |
823 | 884 |
824 bool retransmitted = false; | 885 bool retransmitted = false; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
856 // Should be able to decode 3 delta frames, key frame already decoded. | 917 // Should be able to decode 3 delta frames, key frame already decoded. |
857 for (size_t i = 0; i < 3; ++i) { | 918 for (size_t i = 0; i < 3; ++i) { |
858 frame_out = DecodeCompleteFrame(); | 919 frame_out = DecodeCompleteFrame(); |
859 ASSERT_TRUE(frame_out != NULL); | 920 ASSERT_TRUE(frame_out != NULL); |
860 CheckOutFrame(frame_out, size_, false); | 921 CheckOutFrame(frame_out, size_, false); |
861 EXPECT_EQ(kVideoFrameDelta, frame_out->FrameType()); | 922 EXPECT_EQ(kVideoFrameDelta, frame_out->FrameType()); |
862 jitter_buffer_->ReleaseFrame(frame_out); | 923 jitter_buffer_->ReleaseFrame(frame_out); |
863 } | 924 } |
864 } | 925 } |
865 | 926 |
866 TEST_F(TestBasicJitterBuffer, TestSkipForwardVp9) { | 927 TEST_P(TestBasicJitterBuffer, TestSkipForwardVp9) { |
867 // Verify that JB skips forward to next base layer frame. | 928 // Verify that JB skips forward to next base layer frame. |
868 // ------------------------------------------------- | 929 // ------------------------------------------------- |
869 // | 65485 | 65486 | 65487 | 65488 | 65489 | ... | 930 // | 65485 | 65486 | 65487 | 65488 | 65489 | ... |
870 // | pid:5 | pid:6 | pid:7 | pid:8 | pid:9 | ... | 931 // | pid:5 | pid:6 | pid:7 | pid:8 | pid:9 | ... |
871 // | tid:0 | tid:2 | tid:1 | tid:2 | tid:0 | ... | 932 // | tid:0 | tid:2 | tid:1 | tid:2 | tid:0 | ... |
872 // | ss | x | x | x | | | 933 // | ss | x | x | x | | |
873 // ------------------------------------------------- | 934 // ------------------------------------------------- |
874 // |<----------tl0idx:200--------->|<---tl0idx:201--- | 935 // |<----------tl0idx:200--------->|<---tl0idx:201--- |
875 | 936 |
876 bool re = false; | 937 bool re = false; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
909 EXPECT_EQ(1000U, frame_out->TimeStamp()); | 970 EXPECT_EQ(1000U, frame_out->TimeStamp()); |
910 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); | 971 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); |
911 jitter_buffer_->ReleaseFrame(frame_out); | 972 jitter_buffer_->ReleaseFrame(frame_out); |
912 | 973 |
913 frame_out = DecodeCompleteFrame(); | 974 frame_out = DecodeCompleteFrame(); |
914 EXPECT_EQ(13000U, frame_out->TimeStamp()); | 975 EXPECT_EQ(13000U, frame_out->TimeStamp()); |
915 EXPECT_EQ(kVideoFrameDelta, frame_out->FrameType()); | 976 EXPECT_EQ(kVideoFrameDelta, frame_out->FrameType()); |
916 jitter_buffer_->ReleaseFrame(frame_out); | 977 jitter_buffer_->ReleaseFrame(frame_out); |
917 } | 978 } |
918 | 979 |
919 TEST_F(TestBasicJitterBuffer, ReorderedVp9SsData_3TlLayers) { | 980 TEST_P(TestBasicJitterBuffer, ReorderedVp9SsData_3TlLayers) { |
920 // Verify that frames are updated with SS data when SS packet is reordered. | 981 // Verify that frames are updated with SS data when SS packet is reordered. |
921 // -------------------------------- | 982 // -------------------------------- |
922 // | 65486 | 65487 | 65485 |... | 983 // | 65486 | 65487 | 65485 |... |
923 // | pid:6 | pid:7 | pid:5 |... | 984 // | pid:6 | pid:7 | pid:5 |... |
924 // | tid:2 | tid:1 | tid:0 |... | 985 // | tid:2 | tid:1 | tid:0 |... |
925 // | | | ss | | 986 // | | | ss | |
926 // -------------------------------- | 987 // -------------------------------- |
927 // |<--------tl0idx:200--------->| | 988 // |<--------tl0idx:200--------->| |
928 | 989 |
929 bool re = false; | 990 bool re = false; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
983 jitter_buffer_->ReleaseFrame(frame_out); | 1044 jitter_buffer_->ReleaseFrame(frame_out); |
984 | 1045 |
985 frame_out = DecodeCompleteFrame(); | 1046 frame_out = DecodeCompleteFrame(); |
986 EXPECT_EQ(9000U, frame_out->TimeStamp()); | 1047 EXPECT_EQ(9000U, frame_out->TimeStamp()); |
987 EXPECT_EQ(kVideoFrameDelta, frame_out->FrameType()); | 1048 EXPECT_EQ(kVideoFrameDelta, frame_out->FrameType()); |
988 EXPECT_EQ(1, frame_out->CodecSpecific()->codecSpecific.VP9.temporal_idx); | 1049 EXPECT_EQ(1, frame_out->CodecSpecific()->codecSpecific.VP9.temporal_idx); |
989 EXPECT_TRUE(frame_out->CodecSpecific()->codecSpecific.VP9.temporal_up_switch); | 1050 EXPECT_TRUE(frame_out->CodecSpecific()->codecSpecific.VP9.temporal_up_switch); |
990 jitter_buffer_->ReleaseFrame(frame_out); | 1051 jitter_buffer_->ReleaseFrame(frame_out); |
991 } | 1052 } |
992 | 1053 |
993 TEST_F(TestBasicJitterBuffer, ReorderedVp9SsData_2Tl2SLayers) { | 1054 TEST_P(TestBasicJitterBuffer, ReorderedVp9SsData_2Tl2SLayers) { |
994 // Verify that frames are updated with SS data when SS packet is reordered. | 1055 // Verify that frames are updated with SS data when SS packet is reordered. |
995 // ----------------------------------------- | 1056 // ----------------------------------------- |
996 // | 65486 | 65487 | 65485 | 65484 |... | 1057 // | 65486 | 65487 | 65485 | 65484 |... |
997 // | pid:6 | pid:6 | pid:5 | pid:5 |... | 1058 // | pid:6 | pid:6 | pid:5 | pid:5 |... |
998 // | tid:1 | tid:1 | tid:0 | tid:0 |... | 1059 // | tid:1 | tid:1 | tid:0 | tid:0 |... |
999 // | sid:0 | sid:1 | sid:1 | sid:0 |... | 1060 // | sid:0 | sid:1 | sid:1 | sid:0 |... |
1000 // | t:6000 | t:6000 | t:3000 | t:3000 | | 1061 // | t:6000 | t:6000 | t:3000 | t:3000 | |
1001 // | | | | ss | | 1062 // | | | | ss | |
1002 // ----------------------------------------- | 1063 // ----------------------------------------- |
1003 // |<-----------tl0idx:200------------>| | 1064 // |<-----------tl0idx:200------------>| |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1067 jitter_buffer_->ReleaseFrame(frame_out); | 1128 jitter_buffer_->ReleaseFrame(frame_out); |
1068 | 1129 |
1069 frame_out = DecodeCompleteFrame(); | 1130 frame_out = DecodeCompleteFrame(); |
1070 EXPECT_EQ(6000U, frame_out->TimeStamp()); | 1131 EXPECT_EQ(6000U, frame_out->TimeStamp()); |
1071 EXPECT_EQ(kVideoFrameDelta, frame_out->FrameType()); | 1132 EXPECT_EQ(kVideoFrameDelta, frame_out->FrameType()); |
1072 EXPECT_EQ(1, frame_out->CodecSpecific()->codecSpecific.VP9.temporal_idx); | 1133 EXPECT_EQ(1, frame_out->CodecSpecific()->codecSpecific.VP9.temporal_idx); |
1073 EXPECT_TRUE(frame_out->CodecSpecific()->codecSpecific.VP9.temporal_up_switch); | 1134 EXPECT_TRUE(frame_out->CodecSpecific()->codecSpecific.VP9.temporal_up_switch); |
1074 jitter_buffer_->ReleaseFrame(frame_out); | 1135 jitter_buffer_->ReleaseFrame(frame_out); |
1075 } | 1136 } |
1076 | 1137 |
1077 TEST_F(TestBasicJitterBuffer, H264InsertStartCode) { | 1138 TEST_P(TestBasicJitterBuffer, H264InsertStartCode) { |
1078 packet_->frameType = kVideoFrameKey; | 1139 packet_->frameType = kVideoFrameKey; |
1079 packet_->isFirstPacket = true; | 1140 packet_->isFirstPacket = true; |
1080 packet_->markerBit = false; | 1141 packet_->markerBit = false; |
1081 packet_->seqNum = seq_num_; | 1142 packet_->seqNum = seq_num_; |
1082 packet_->timestamp = timestamp_; | 1143 packet_->timestamp = timestamp_; |
1083 packet_->insertStartCode = true; | 1144 packet_->insertStartCode = true; |
1084 | 1145 |
1085 bool retransmitted = false; | 1146 bool retransmitted = false; |
1086 EXPECT_EQ(kIncomplete, | 1147 EXPECT_EQ(kIncomplete, |
1087 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1148 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
(...skipping 11 matching lines...) Expand all Loading... |
1099 EXPECT_EQ(kCompleteSession, | 1160 EXPECT_EQ(kCompleteSession, |
1100 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1161 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
1101 | 1162 |
1102 frame_out = DecodeCompleteFrame(); | 1163 frame_out = DecodeCompleteFrame(); |
1103 CheckOutFrame(frame_out, size_ * 2 + 4 * 2, true); | 1164 CheckOutFrame(frame_out, size_ * 2 + 4 * 2, true); |
1104 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); | 1165 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); |
1105 jitter_buffer_->ReleaseFrame(frame_out); | 1166 jitter_buffer_->ReleaseFrame(frame_out); |
1106 } | 1167 } |
1107 | 1168 |
1108 // Test threshold conditions of decodable state. | 1169 // Test threshold conditions of decodable state. |
1109 TEST_F(TestBasicJitterBuffer, PacketLossWithSelectiveErrorsThresholdCheck) { | 1170 TEST_P(TestBasicJitterBuffer, PacketLossWithSelectiveErrorsThresholdCheck) { |
1110 jitter_buffer_->SetDecodeErrorMode(kSelectiveErrors); | 1171 jitter_buffer_->SetDecodeErrorMode(kSelectiveErrors); |
1111 // Always start with a key frame. Use 10 packets to test Decodable State | 1172 // Always start with a key frame. Use 10 packets to test Decodable State |
1112 // boundaries. | 1173 // boundaries. |
1113 packet_->frameType = kVideoFrameKey; | 1174 packet_->frameType = kVideoFrameKey; |
1114 packet_->isFirstPacket = true; | 1175 packet_->isFirstPacket = true; |
1115 packet_->markerBit = false; | 1176 packet_->markerBit = false; |
1116 packet_->seqNum = seq_num_; | 1177 packet_->seqNum = seq_num_; |
1117 packet_->timestamp = timestamp_; | 1178 packet_->timestamp = timestamp_; |
1118 | 1179 |
1119 bool retransmitted = false; | 1180 bool retransmitted = false; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1185 CheckOutFrame(frame_out, 9 * size_, false); | 1246 CheckOutFrame(frame_out, 9 * size_, false); |
1186 EXPECT_EQ(kVideoFrameDelta, frame_out->FrameType()); | 1247 EXPECT_EQ(kVideoFrameDelta, frame_out->FrameType()); |
1187 jitter_buffer_->ReleaseFrame(frame_out); | 1248 jitter_buffer_->ReleaseFrame(frame_out); |
1188 | 1249 |
1189 packet_->markerBit = true; | 1250 packet_->markerBit = true; |
1190 packet_->seqNum++; | 1251 packet_->seqNum++; |
1191 EXPECT_EQ(kOldPacket, jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1252 EXPECT_EQ(kOldPacket, jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
1192 } | 1253 } |
1193 | 1254 |
1194 // Make sure first packet is present before a frame can be decoded. | 1255 // Make sure first packet is present before a frame can be decoded. |
1195 TEST_F(TestBasicJitterBuffer, PacketLossWithSelectiveErrorsIncompleteKey) { | 1256 TEST_P(TestBasicJitterBuffer, PacketLossWithSelectiveErrorsIncompleteKey) { |
1196 jitter_buffer_->SetDecodeErrorMode(kSelectiveErrors); | 1257 jitter_buffer_->SetDecodeErrorMode(kSelectiveErrors); |
1197 // Always start with a key frame. | 1258 // Always start with a key frame. |
1198 packet_->frameType = kVideoFrameKey; | 1259 packet_->frameType = kVideoFrameKey; |
1199 packet_->isFirstPacket = true; | 1260 packet_->isFirstPacket = true; |
1200 packet_->markerBit = true; | 1261 packet_->markerBit = true; |
1201 packet_->seqNum = seq_num_; | 1262 packet_->seqNum = seq_num_; |
1202 packet_->timestamp = timestamp_; | 1263 packet_->timestamp = timestamp_; |
1203 | 1264 |
1204 bool retransmitted = false; | 1265 bool retransmitted = false; |
1205 EXPECT_EQ(kCompleteSession, | 1266 EXPECT_EQ(kCompleteSession, |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1249 packet_->seqNum++; | 1310 packet_->seqNum++; |
1250 EXPECT_EQ(kCompleteSession, | 1311 EXPECT_EQ(kCompleteSession, |
1251 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1312 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
1252 frame_out = DecodeCompleteFrame(); | 1313 frame_out = DecodeCompleteFrame(); |
1253 CheckOutFrame(frame_out, 6 * size_, false); | 1314 CheckOutFrame(frame_out, 6 * size_, false); |
1254 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); | 1315 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); |
1255 jitter_buffer_->ReleaseFrame(frame_out); | 1316 jitter_buffer_->ReleaseFrame(frame_out); |
1256 } | 1317 } |
1257 | 1318 |
1258 // Make sure first packet is present before a frame can be decoded. | 1319 // Make sure first packet is present before a frame can be decoded. |
1259 TEST_F(TestBasicJitterBuffer, PacketLossWithSelectiveErrorsMissingFirstPacket) { | 1320 TEST_P(TestBasicJitterBuffer, PacketLossWithSelectiveErrorsMissingFirstPacket) { |
1260 jitter_buffer_->SetDecodeErrorMode(kSelectiveErrors); | 1321 jitter_buffer_->SetDecodeErrorMode(kSelectiveErrors); |
1261 // Always start with a key frame. | 1322 // Always start with a key frame. |
1262 packet_->frameType = kVideoFrameKey; | 1323 packet_->frameType = kVideoFrameKey; |
1263 packet_->isFirstPacket = true; | 1324 packet_->isFirstPacket = true; |
1264 packet_->markerBit = true; | 1325 packet_->markerBit = true; |
1265 packet_->seqNum = seq_num_; | 1326 packet_->seqNum = seq_num_; |
1266 packet_->timestamp = timestamp_; | 1327 packet_->timestamp = timestamp_; |
1267 | 1328 |
1268 bool retransmitted = false; | 1329 bool retransmitted = false; |
1269 EXPECT_EQ(kCompleteSession, | 1330 EXPECT_EQ(kCompleteSession, |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1311 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1372 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
1312 EXPECT_FALSE(jitter_buffer_->NextCompleteTimestamp(0, ×tamp)); | 1373 EXPECT_FALSE(jitter_buffer_->NextCompleteTimestamp(0, ×tamp)); |
1313 EXPECT_TRUE(jitter_buffer_->NextMaybeIncompleteTimestamp(×tamp)); | 1374 EXPECT_TRUE(jitter_buffer_->NextMaybeIncompleteTimestamp(×tamp)); |
1314 | 1375 |
1315 frame_out = DecodeIncompleteFrame(); | 1376 frame_out = DecodeIncompleteFrame(); |
1316 CheckOutFrame(frame_out, 7 * size_, false); | 1377 CheckOutFrame(frame_out, 7 * size_, false); |
1317 EXPECT_EQ(kVideoFrameDelta, frame_out->FrameType()); | 1378 EXPECT_EQ(kVideoFrameDelta, frame_out->FrameType()); |
1318 jitter_buffer_->ReleaseFrame(frame_out); | 1379 jitter_buffer_->ReleaseFrame(frame_out); |
1319 } | 1380 } |
1320 | 1381 |
1321 TEST_F(TestBasicJitterBuffer, DiscontinuousStreamWhenDecodingWithErrors) { | 1382 TEST_P(TestBasicJitterBuffer, DiscontinuousStreamWhenDecodingWithErrors) { |
1322 // Will use one packet per frame. | 1383 // Will use one packet per frame. |
1323 jitter_buffer_->SetDecodeErrorMode(kWithErrors); | 1384 jitter_buffer_->SetDecodeErrorMode(kWithErrors); |
1324 packet_->frameType = kVideoFrameKey; | 1385 packet_->frameType = kVideoFrameKey; |
1325 packet_->isFirstPacket = true; | 1386 packet_->isFirstPacket = true; |
1326 packet_->markerBit = true; | 1387 packet_->markerBit = true; |
1327 packet_->seqNum = seq_num_; | 1388 packet_->seqNum = seq_num_; |
1328 packet_->timestamp = timestamp_; | 1389 packet_->timestamp = timestamp_; |
1329 bool retransmitted = false; | 1390 bool retransmitted = false; |
1330 EXPECT_EQ(kCompleteSession, | 1391 EXPECT_EQ(kCompleteSession, |
1331 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1392 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
(...skipping 22 matching lines...) Expand all Loading... |
1354 packet_->markerBit = false; | 1415 packet_->markerBit = false; |
1355 packet_->seqNum = seq_num_; | 1416 packet_->seqNum = seq_num_; |
1356 packet_->timestamp = timestamp_; | 1417 packet_->timestamp = timestamp_; |
1357 EXPECT_EQ(kDecodableSession, | 1418 EXPECT_EQ(kDecodableSession, |
1358 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1419 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
1359 EXPECT_FALSE(jitter_buffer_->NextCompleteTimestamp(0, &next_timestamp)); | 1420 EXPECT_FALSE(jitter_buffer_->NextCompleteTimestamp(0, &next_timestamp)); |
1360 EXPECT_TRUE(jitter_buffer_->NextMaybeIncompleteTimestamp(&next_timestamp)); | 1421 EXPECT_TRUE(jitter_buffer_->NextMaybeIncompleteTimestamp(&next_timestamp)); |
1361 EXPECT_EQ(packet_->timestamp - 33 * 90, next_timestamp); | 1422 EXPECT_EQ(packet_->timestamp - 33 * 90, next_timestamp); |
1362 } | 1423 } |
1363 | 1424 |
1364 TEST_F(TestBasicJitterBuffer, PacketLoss) { | 1425 TEST_P(TestBasicJitterBuffer, PacketLoss) { |
1365 // Verify missing packets statistics and not decodable packets statistics. | 1426 // Verify missing packets statistics and not decodable packets statistics. |
1366 // Insert 10 frames consisting of 4 packets and remove one from all of them. | 1427 // Insert 10 frames consisting of 4 packets and remove one from all of them. |
1367 // The last packet is an empty (non-media) packet. | 1428 // The last packet is an empty (non-media) packet. |
1368 | 1429 |
1369 // Select a start seqNum which triggers a difficult wrap situation | 1430 // Select a start seqNum which triggers a difficult wrap situation |
1370 // The JB will only output (incomplete)frames if the next one has started | 1431 // The JB will only output (incomplete)frames if the next one has started |
1371 // to arrive. Start by inserting one frame (key). | 1432 // to arrive. Start by inserting one frame (key). |
1372 jitter_buffer_->SetDecodeErrorMode(kWithErrors); | 1433 jitter_buffer_->SetDecodeErrorMode(kWithErrors); |
1373 seq_num_ = 0xffff - 4; | 1434 seq_num_ = 0xffff - 4; |
1374 seq_num_++; | 1435 seq_num_++; |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1455 EXPECT_EQ(kOldPacket, jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1516 EXPECT_EQ(kOldPacket, jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
1456 | 1517 |
1457 EXPECT_EQ(3, jitter_buffer_->num_discarded_packets()); | 1518 EXPECT_EQ(3, jitter_buffer_->num_discarded_packets()); |
1458 | 1519 |
1459 jitter_buffer_->Flush(); | 1520 jitter_buffer_->Flush(); |
1460 | 1521 |
1461 // This statistic shouldn't be reset by a flush. | 1522 // This statistic shouldn't be reset by a flush. |
1462 EXPECT_EQ(3, jitter_buffer_->num_discarded_packets()); | 1523 EXPECT_EQ(3, jitter_buffer_->num_discarded_packets()); |
1463 } | 1524 } |
1464 | 1525 |
1465 TEST_F(TestBasicJitterBuffer, DeltaFrame100PacketsWithSeqNumWrap) { | 1526 TEST_P(TestBasicJitterBuffer, DeltaFrame100PacketsWithSeqNumWrap) { |
1466 seq_num_ = 0xfff0; | 1527 seq_num_ = 0xfff0; |
1467 packet_->frameType = kVideoFrameKey; | 1528 packet_->frameType = kVideoFrameKey; |
1468 packet_->isFirstPacket = true; | 1529 packet_->isFirstPacket = true; |
1469 packet_->markerBit = false; | 1530 packet_->markerBit = false; |
1470 packet_->seqNum = seq_num_; | 1531 packet_->seqNum = seq_num_; |
1471 packet_->timestamp = timestamp_; | 1532 packet_->timestamp = timestamp_; |
1472 | 1533 |
1473 bool retransmitted = false; | 1534 bool retransmitted = false; |
1474 EXPECT_EQ(kIncomplete, | 1535 EXPECT_EQ(kIncomplete, |
1475 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1536 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
(...skipping 28 matching lines...) Expand all Loading... |
1504 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1565 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
1505 | 1566 |
1506 frame_out = DecodeCompleteFrame(); | 1567 frame_out = DecodeCompleteFrame(); |
1507 | 1568 |
1508 CheckOutFrame(frame_out, 100 * size_, false); | 1569 CheckOutFrame(frame_out, 100 * size_, false); |
1509 | 1570 |
1510 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); | 1571 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); |
1511 jitter_buffer_->ReleaseFrame(frame_out); | 1572 jitter_buffer_->ReleaseFrame(frame_out); |
1512 } | 1573 } |
1513 | 1574 |
1514 TEST_F(TestBasicJitterBuffer, PacketReorderingReverseWithNegSeqNumWrap) { | 1575 TEST_P(TestBasicJitterBuffer, PacketReorderingReverseWithNegSeqNumWrap) { |
1515 // Insert "first" packet last seqnum. | 1576 // Insert "first" packet last seqnum. |
1516 seq_num_ = 10; | 1577 seq_num_ = 10; |
1517 packet_->frameType = kVideoFrameKey; | 1578 packet_->frameType = kVideoFrameKey; |
1518 packet_->isFirstPacket = false; | 1579 packet_->isFirstPacket = false; |
1519 packet_->markerBit = true; | 1580 packet_->markerBit = true; |
1520 packet_->seqNum = seq_num_; | 1581 packet_->seqNum = seq_num_; |
1521 | 1582 |
1522 bool retransmitted = false; | 1583 bool retransmitted = false; |
1523 EXPECT_EQ(kIncomplete, | 1584 EXPECT_EQ(kIncomplete, |
1524 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1585 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
(...skipping 28 matching lines...) Expand all Loading... |
1553 | 1614 |
1554 EXPECT_EQ(kCompleteSession, | 1615 EXPECT_EQ(kCompleteSession, |
1555 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1616 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
1556 | 1617 |
1557 frame_out = DecodeCompleteFrame(); | 1618 frame_out = DecodeCompleteFrame(); |
1558 CheckOutFrame(frame_out, 100 * size_, false); | 1619 CheckOutFrame(frame_out, 100 * size_, false); |
1559 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); | 1620 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); |
1560 jitter_buffer_->ReleaseFrame(frame_out); | 1621 jitter_buffer_->ReleaseFrame(frame_out); |
1561 } | 1622 } |
1562 | 1623 |
1563 TEST_F(TestBasicJitterBuffer, TestInsertOldFrame) { | 1624 TEST_P(TestBasicJitterBuffer, TestInsertOldFrame) { |
1564 // ------- ------- | 1625 // ------- ------- |
1565 // | 2 | | 1 | | 1626 // | 2 | | 1 | |
1566 // ------- ------- | 1627 // ------- ------- |
1567 // t = 3000 t = 2000 | 1628 // t = 3000 t = 2000 |
1568 seq_num_ = 2; | 1629 seq_num_ = 2; |
1569 timestamp_ = 3000; | 1630 timestamp_ = 3000; |
1570 packet_->frameType = kVideoFrameKey; | 1631 packet_->frameType = kVideoFrameKey; |
1571 packet_->isFirstPacket = true; | 1632 packet_->isFirstPacket = true; |
1572 packet_->markerBit = true; | 1633 packet_->markerBit = true; |
1573 packet_->timestamp = timestamp_; | 1634 packet_->timestamp = timestamp_; |
(...skipping 13 matching lines...) Expand all Loading... |
1587 timestamp_ = 2000; | 1648 timestamp_ = 2000; |
1588 packet_->frameType = kVideoFrameDelta; | 1649 packet_->frameType = kVideoFrameDelta; |
1589 packet_->isFirstPacket = true; | 1650 packet_->isFirstPacket = true; |
1590 packet_->markerBit = true; | 1651 packet_->markerBit = true; |
1591 packet_->seqNum = seq_num_; | 1652 packet_->seqNum = seq_num_; |
1592 packet_->timestamp = timestamp_; | 1653 packet_->timestamp = timestamp_; |
1593 | 1654 |
1594 EXPECT_EQ(kOldPacket, jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1655 EXPECT_EQ(kOldPacket, jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
1595 } | 1656 } |
1596 | 1657 |
1597 TEST_F(TestBasicJitterBuffer, TestInsertOldFrameWithSeqNumWrap) { | 1658 TEST_P(TestBasicJitterBuffer, TestInsertOldFrameWithSeqNumWrap) { |
1598 // ------- ------- | 1659 // ------- ------- |
1599 // | 2 | | 1 | | 1660 // | 2 | | 1 | |
1600 // ------- ------- | 1661 // ------- ------- |
1601 // t = 3000 t = 0xffffff00 | 1662 // t = 3000 t = 0xffffff00 |
1602 | 1663 |
1603 seq_num_ = 2; | 1664 seq_num_ = 2; |
1604 timestamp_ = 3000; | 1665 timestamp_ = 3000; |
1605 packet_->frameType = kVideoFrameKey; | 1666 packet_->frameType = kVideoFrameKey; |
1606 packet_->isFirstPacket = true; | 1667 packet_->isFirstPacket = true; |
1607 packet_->markerBit = true; | 1668 packet_->markerBit = true; |
(...skipping 18 matching lines...) Expand all Loading... |
1626 packet_->frameType = kVideoFrameDelta; | 1687 packet_->frameType = kVideoFrameDelta; |
1627 packet_->isFirstPacket = true; | 1688 packet_->isFirstPacket = true; |
1628 packet_->markerBit = true; | 1689 packet_->markerBit = true; |
1629 packet_->seqNum = seq_num_; | 1690 packet_->seqNum = seq_num_; |
1630 packet_->timestamp = timestamp_; | 1691 packet_->timestamp = timestamp_; |
1631 | 1692 |
1632 // This timestamp is old. | 1693 // This timestamp is old. |
1633 EXPECT_EQ(kOldPacket, jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1694 EXPECT_EQ(kOldPacket, jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
1634 } | 1695 } |
1635 | 1696 |
1636 TEST_F(TestBasicJitterBuffer, TimestampWrap) { | 1697 TEST_P(TestBasicJitterBuffer, TimestampWrap) { |
1637 // --------------- --------------- | 1698 // --------------- --------------- |
1638 // | 1 | 2 | | 3 | 4 | | 1699 // | 1 | 2 | | 3 | 4 | |
1639 // --------------- --------------- | 1700 // --------------- --------------- |
1640 // t = 0xffffff00 t = 33*90 | 1701 // t = 0xffffff00 t = 33*90 |
1641 | 1702 |
1642 timestamp_ = 0xffffff00; | 1703 timestamp_ = 0xffffff00; |
1643 packet_->frameType = kVideoFrameKey; | 1704 packet_->frameType = kVideoFrameKey; |
1644 packet_->isFirstPacket = true; | 1705 packet_->isFirstPacket = true; |
1645 packet_->markerBit = false; | 1706 packet_->markerBit = false; |
1646 packet_->seqNum = seq_num_; | 1707 packet_->seqNum = seq_num_; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1686 | 1747 |
1687 EXPECT_EQ(kCompleteSession, | 1748 EXPECT_EQ(kCompleteSession, |
1688 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1749 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
1689 | 1750 |
1690 frame_out = DecodeCompleteFrame(); | 1751 frame_out = DecodeCompleteFrame(); |
1691 CheckOutFrame(frame_out, 2 * size_, false); | 1752 CheckOutFrame(frame_out, 2 * size_, false); |
1692 EXPECT_EQ(kVideoFrameDelta, frame_out->FrameType()); | 1753 EXPECT_EQ(kVideoFrameDelta, frame_out->FrameType()); |
1693 jitter_buffer_->ReleaseFrame(frame_out); | 1754 jitter_buffer_->ReleaseFrame(frame_out); |
1694 } | 1755 } |
1695 | 1756 |
1696 TEST_F(TestBasicJitterBuffer, 2FrameWithTimestampWrap) { | 1757 TEST_P(TestBasicJitterBuffer, 2FrameWithTimestampWrap) { |
1697 // ------- ------- | 1758 // ------- ------- |
1698 // | 1 | | 2 | | 1759 // | 1 | | 2 | |
1699 // ------- ------- | 1760 // ------- ------- |
1700 // t = 0xffffff00 t = 2700 | 1761 // t = 0xffffff00 t = 2700 |
1701 | 1762 |
1702 timestamp_ = 0xffffff00; | 1763 timestamp_ = 0xffffff00; |
1703 packet_->frameType = kVideoFrameKey; | 1764 packet_->frameType = kVideoFrameKey; |
1704 packet_->isFirstPacket = true; | 1765 packet_->isFirstPacket = true; |
1705 packet_->markerBit = true; | 1766 packet_->markerBit = true; |
1706 packet_->timestamp = timestamp_; | 1767 packet_->timestamp = timestamp_; |
(...skipping 21 matching lines...) Expand all Loading... |
1728 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); | 1789 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); |
1729 jitter_buffer_->ReleaseFrame(frame_out); | 1790 jitter_buffer_->ReleaseFrame(frame_out); |
1730 | 1791 |
1731 VCMEncodedFrame* frame_out2 = DecodeCompleteFrame(); | 1792 VCMEncodedFrame* frame_out2 = DecodeCompleteFrame(); |
1732 EXPECT_EQ(2700u, frame_out2->TimeStamp()); | 1793 EXPECT_EQ(2700u, frame_out2->TimeStamp()); |
1733 CheckOutFrame(frame_out2, size_, false); | 1794 CheckOutFrame(frame_out2, size_, false); |
1734 EXPECT_EQ(kVideoFrameDelta, frame_out2->FrameType()); | 1795 EXPECT_EQ(kVideoFrameDelta, frame_out2->FrameType()); |
1735 jitter_buffer_->ReleaseFrame(frame_out2); | 1796 jitter_buffer_->ReleaseFrame(frame_out2); |
1736 } | 1797 } |
1737 | 1798 |
1738 TEST_F(TestBasicJitterBuffer, Insert2FramesReOrderedWithTimestampWrap) { | 1799 TEST_P(TestBasicJitterBuffer, Insert2FramesReOrderedWithTimestampWrap) { |
1739 // ------- ------- | 1800 // ------- ------- |
1740 // | 2 | | 1 | | 1801 // | 2 | | 1 | |
1741 // ------- ------- | 1802 // ------- ------- |
1742 // t = 2700 t = 0xffffff00 | 1803 // t = 2700 t = 0xffffff00 |
1743 | 1804 |
1744 seq_num_ = 2; | 1805 seq_num_ = 2; |
1745 timestamp_ = 2700; | 1806 timestamp_ = 2700; |
1746 packet_->frameType = kVideoFrameDelta; | 1807 packet_->frameType = kVideoFrameDelta; |
1747 packet_->isFirstPacket = true; | 1808 packet_->isFirstPacket = true; |
1748 packet_->markerBit = true; | 1809 packet_->markerBit = true; |
(...skipping 22 matching lines...) Expand all Loading... |
1771 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); | 1832 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); |
1772 jitter_buffer_->ReleaseFrame(frame_out); | 1833 jitter_buffer_->ReleaseFrame(frame_out); |
1773 | 1834 |
1774 VCMEncodedFrame* frame_out2 = DecodeCompleteFrame(); | 1835 VCMEncodedFrame* frame_out2 = DecodeCompleteFrame(); |
1775 EXPECT_EQ(2700u, frame_out2->TimeStamp()); | 1836 EXPECT_EQ(2700u, frame_out2->TimeStamp()); |
1776 CheckOutFrame(frame_out2, size_, false); | 1837 CheckOutFrame(frame_out2, size_, false); |
1777 EXPECT_EQ(kVideoFrameDelta, frame_out2->FrameType()); | 1838 EXPECT_EQ(kVideoFrameDelta, frame_out2->FrameType()); |
1778 jitter_buffer_->ReleaseFrame(frame_out2); | 1839 jitter_buffer_->ReleaseFrame(frame_out2); |
1779 } | 1840 } |
1780 | 1841 |
1781 TEST_F(TestBasicJitterBuffer, DeltaFrameWithMoreThanMaxNumberOfPackets) { | 1842 TEST_P(TestBasicJitterBuffer, DeltaFrameWithMoreThanMaxNumberOfPackets) { |
1782 int loop = 0; | 1843 int loop = 0; |
1783 bool firstPacket = true; | 1844 bool firstPacket = true; |
1784 bool retransmitted = false; | 1845 bool retransmitted = false; |
1785 // Insert kMaxPacketsInJitterBuffer into frame. | 1846 // Insert kMaxPacketsInJitterBuffer into frame. |
1786 do { | 1847 do { |
1787 seq_num_++; | 1848 seq_num_++; |
1788 packet_->isFirstPacket = false; | 1849 packet_->isFirstPacket = false; |
1789 packet_->markerBit = false; | 1850 packet_->markerBit = false; |
1790 packet_->seqNum = seq_num_; | 1851 packet_->seqNum = seq_num_; |
1791 | 1852 |
(...skipping 14 matching lines...) Expand all Loading... |
1806 seq_num_++; | 1867 seq_num_++; |
1807 packet_->isFirstPacket = false; | 1868 packet_->isFirstPacket = false; |
1808 packet_->markerBit = true; | 1869 packet_->markerBit = true; |
1809 packet_->seqNum = seq_num_; | 1870 packet_->seqNum = seq_num_; |
1810 | 1871 |
1811 // Insert the packet -> frame recycled. | 1872 // Insert the packet -> frame recycled. |
1812 EXPECT_EQ(kSizeError, jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1873 EXPECT_EQ(kSizeError, jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
1813 EXPECT_TRUE(NULL == DecodeCompleteFrame()); | 1874 EXPECT_TRUE(NULL == DecodeCompleteFrame()); |
1814 } | 1875 } |
1815 | 1876 |
1816 TEST_F(TestBasicJitterBuffer, ExceedNumOfFrameWithSeqNumWrap) { | 1877 TEST_P(TestBasicJitterBuffer, ExceedNumOfFrameWithSeqNumWrap) { |
1817 // TEST fill JB with more than max number of frame (50 delta frames + | 1878 // TEST fill JB with more than max number of frame (50 delta frames + |
1818 // 51 key frames) with wrap in seq_num_ | 1879 // 51 key frames) with wrap in seq_num_ |
1819 // | 1880 // |
1820 // -------------------------------------------------------------- | 1881 // -------------------------------------------------------------- |
1821 // | 65485 | 65486 | 65487 | .... | 65535 | 0 | 1 | 2 | .....| 50 | | 1882 // | 65485 | 65486 | 65487 | .... | 65535 | 0 | 1 | 2 | .....| 50 | |
1822 // -------------------------------------------------------------- | 1883 // -------------------------------------------------------------- |
1823 // |<-----------delta frames------------->|<------key frames----->| | 1884 // |<-----------delta frames------------->|<------key frames----->| |
1824 | 1885 |
1825 // Make sure the jitter doesn't request a keyframe after too much non- | 1886 // Make sure the jitter doesn't request a keyframe after too much non- |
1826 // decodable frames. | 1887 // decodable frames. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1866 EXPECT_EQ(kFlushIndicator, | 1927 EXPECT_EQ(kFlushIndicator, |
1867 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1928 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
1868 | 1929 |
1869 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); | 1930 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); |
1870 EXPECT_EQ(first_key_frame_timestamp, frame_out->TimeStamp()); | 1931 EXPECT_EQ(first_key_frame_timestamp, frame_out->TimeStamp()); |
1871 CheckOutFrame(frame_out, size_, false); | 1932 CheckOutFrame(frame_out, size_, false); |
1872 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); | 1933 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); |
1873 jitter_buffer_->ReleaseFrame(frame_out); | 1934 jitter_buffer_->ReleaseFrame(frame_out); |
1874 } | 1935 } |
1875 | 1936 |
1876 TEST_F(TestBasicJitterBuffer, EmptyLastFrame) { | 1937 TEST_P(TestBasicJitterBuffer, EmptyLastFrame) { |
1877 jitter_buffer_->SetDecodeErrorMode(kWithErrors); | 1938 jitter_buffer_->SetDecodeErrorMode(kWithErrors); |
1878 seq_num_ = 3; | 1939 seq_num_ = 3; |
1879 // Insert one empty packet per frame, should never return the last timestamp | 1940 // Insert one empty packet per frame, should never return the last timestamp |
1880 // inserted. Only return empty frames in the presence of subsequent frames. | 1941 // inserted. Only return empty frames in the presence of subsequent frames. |
1881 int maxSize = 1000; | 1942 int maxSize = 1000; |
1882 bool retransmitted = false; | 1943 bool retransmitted = false; |
1883 for (int i = 0; i < maxSize + 10; i++) { | 1944 for (int i = 0; i < maxSize + 10; i++) { |
1884 timestamp_ += 33 * 90; | 1945 timestamp_ += 33 * 90; |
1885 seq_num_++; | 1946 seq_num_++; |
1886 packet_->isFirstPacket = false; | 1947 packet_->isFirstPacket = false; |
1887 packet_->markerBit = false; | 1948 packet_->markerBit = false; |
1888 packet_->seqNum = seq_num_; | 1949 packet_->seqNum = seq_num_; |
1889 packet_->timestamp = timestamp_; | 1950 packet_->timestamp = timestamp_; |
1890 packet_->frameType = kEmptyFrame; | 1951 packet_->frameType = kEmptyFrame; |
1891 | 1952 |
1892 EXPECT_EQ(kNoError, jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1953 EXPECT_EQ(kNoError, jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
1893 VCMEncodedFrame* testFrame = DecodeIncompleteFrame(); | 1954 VCMEncodedFrame* testFrame = DecodeIncompleteFrame(); |
1894 // Timestamp should never be the last TS inserted. | 1955 // Timestamp should never be the last TS inserted. |
1895 if (testFrame != NULL) { | 1956 if (testFrame != NULL) { |
1896 EXPECT_TRUE(testFrame->TimeStamp() < timestamp_); | 1957 EXPECT_TRUE(testFrame->TimeStamp() < timestamp_); |
1897 jitter_buffer_->ReleaseFrame(testFrame); | 1958 jitter_buffer_->ReleaseFrame(testFrame); |
1898 } | 1959 } |
1899 } | 1960 } |
1900 } | 1961 } |
1901 | 1962 |
1902 TEST_F(TestBasicJitterBuffer, H264IncompleteNalu) { | 1963 TEST_P(TestBasicJitterBuffer, H264IncompleteNalu) { |
1903 jitter_buffer_->SetNackMode(kNoNack, -1, -1); | 1964 jitter_buffer_->SetNackMode(kNoNack, -1, -1); |
1904 jitter_buffer_->SetDecodeErrorMode(kWithErrors); | 1965 jitter_buffer_->SetDecodeErrorMode(kWithErrors); |
1905 ++seq_num_; | 1966 ++seq_num_; |
1906 timestamp_ += 33 * 90; | 1967 timestamp_ += 33 * 90; |
1907 int insertedLength = 0; | 1968 int insertedLength = 0; |
1908 packet_->seqNum = seq_num_; | 1969 packet_->seqNum = seq_num_; |
1909 packet_->timestamp = timestamp_; | 1970 packet_->timestamp = timestamp_; |
1910 packet_->frameType = kVideoFrameKey; | 1971 packet_->frameType = kVideoFrameKey; |
1911 packet_->isFirstPacket = true; | 1972 packet_->isFirstPacket = true; |
1912 packet_->completeNALU = kNaluStart; | 1973 packet_->completeNALU = kNaluStart; |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2073 emptypacket.markerBit = true; | 2134 emptypacket.markerBit = true; |
2074 EXPECT_EQ(kCompleteSession, | 2135 EXPECT_EQ(kCompleteSession, |
2075 jitter_buffer_->InsertPacket(emptypacket, &retransmitted)); | 2136 jitter_buffer_->InsertPacket(emptypacket, &retransmitted)); |
2076 | 2137 |
2077 frame_out = DecodeCompleteFrame(); | 2138 frame_out = DecodeCompleteFrame(); |
2078 // Only last NALU is complete | 2139 // Only last NALU is complete |
2079 CheckOutFrame(frame_out, packet_->sizeBytes, false); | 2140 CheckOutFrame(frame_out, packet_->sizeBytes, false); |
2080 jitter_buffer_->ReleaseFrame(frame_out); | 2141 jitter_buffer_->ReleaseFrame(frame_out); |
2081 } | 2142 } |
2082 | 2143 |
2083 TEST_F(TestBasicJitterBuffer, NextFrameWhenIncomplete) { | 2144 TEST_P(TestBasicJitterBuffer, NextFrameWhenIncomplete) { |
2084 // Test that a we cannot get incomplete frames from the JB if we haven't | 2145 // Test that a we cannot get incomplete frames from the JB if we haven't |
2085 // received the marker bit, unless we have received a packet from a later | 2146 // received the marker bit, unless we have received a packet from a later |
2086 // timestamp. | 2147 // timestamp. |
2087 jitter_buffer_->SetDecodeErrorMode(kWithErrors); | 2148 jitter_buffer_->SetDecodeErrorMode(kWithErrors); |
2088 // Start with a complete key frame - insert and decode. | 2149 // Start with a complete key frame - insert and decode. |
2089 packet_->frameType = kVideoFrameKey; | 2150 packet_->frameType = kVideoFrameKey; |
2090 packet_->isFirstPacket = true; | 2151 packet_->isFirstPacket = true; |
2091 packet_->markerBit = true; | 2152 packet_->markerBit = true; |
2092 bool retransmitted = false; | 2153 bool retransmitted = false; |
2093 | 2154 |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2250 stream_generator_->GenerateFrame(kVideoFrameDelta, 2, 0, | 2311 stream_generator_->GenerateFrame(kVideoFrameDelta, 2, 0, |
2251 clock_->TimeInMilliseconds()); | 2312 clock_->TimeInMilliseconds()); |
2252 EXPECT_EQ(kIncomplete, InsertPacketAndPop(1)); | 2313 EXPECT_EQ(kIncomplete, InsertPacketAndPop(1)); |
2253 EXPECT_EQ(kCompleteSession, InsertPacketAndPop(1)); | 2314 EXPECT_EQ(kCompleteSession, InsertPacketAndPop(1)); |
2254 EXPECT_FALSE(DecodeCompleteFrame()); | 2315 EXPECT_FALSE(DecodeCompleteFrame()); |
2255 EXPECT_EQ(kCompleteSession, InsertPacketAndPop(0)); | 2316 EXPECT_EQ(kCompleteSession, InsertPacketAndPop(0)); |
2256 EXPECT_TRUE(DecodeCompleteFrame()); | 2317 EXPECT_TRUE(DecodeCompleteFrame()); |
2257 EXPECT_TRUE(DecodeCompleteFrame()); | 2318 EXPECT_TRUE(DecodeCompleteFrame()); |
2258 } | 2319 } |
2259 | 2320 |
2260 TEST_F(TestJitterBufferNack, EmptyPackets) { | 2321 TEST_P(TestJitterBufferNack, EmptyPackets) { |
2261 // Make sure empty packets doesn't clog the jitter buffer. | 2322 // Make sure empty packets doesn't clog the jitter buffer. |
2262 jitter_buffer_->SetNackMode(kNack, media_optimization::kLowRttNackMs, -1); | 2323 jitter_buffer_->SetNackMode(kNack, media_optimization::kLowRttNackMs, -1); |
2263 EXPECT_GE(InsertFrames(kMaxNumberOfFrames, kEmptyFrame), kNoError); | 2324 EXPECT_GE(InsertFrames(kMaxNumberOfFrames, kEmptyFrame), kNoError); |
2264 InsertFrame(kVideoFrameKey); | 2325 InsertFrame(kVideoFrameKey); |
2265 EXPECT_TRUE(DecodeCompleteFrame()); | 2326 EXPECT_TRUE(DecodeCompleteFrame()); |
2266 } | 2327 } |
2267 | 2328 |
2268 TEST_F(TestJitterBufferNack, NackTooOldPackets) { | 2329 TEST_P(TestJitterBufferNack, NackTooOldPackets) { |
2269 // Insert a key frame and decode it. | 2330 // Insert a key frame and decode it. |
2270 EXPECT_GE(InsertFrame(kVideoFrameKey), kNoError); | 2331 EXPECT_GE(InsertFrame(kVideoFrameKey), kNoError); |
2271 EXPECT_TRUE(DecodeCompleteFrame()); | 2332 EXPECT_TRUE(DecodeCompleteFrame()); |
2272 | 2333 |
2273 // Drop one frame and insert |kNackHistoryLength| to trigger NACKing a too | 2334 // Drop one frame and insert |kNackHistoryLength| to trigger NACKing a too |
2274 // old packet. | 2335 // old packet. |
2275 DropFrame(1); | 2336 DropFrame(1); |
2276 // Insert a frame which should trigger a recycle until the next key frame. | 2337 // Insert a frame which should trigger a recycle until the next key frame. |
2277 EXPECT_EQ(kFlushIndicator, | 2338 EXPECT_EQ(kFlushIndicator, |
2278 InsertFrames(oldest_packet_to_nack_ + 1, kVideoFrameDelta)); | 2339 InsertFrames(oldest_packet_to_nack_ + 1, kVideoFrameDelta)); |
(...skipping 12 matching lines...) Expand all Loading... |
2291 EXPECT_FALSE(DecodeIncompleteFrame()); | 2352 EXPECT_FALSE(DecodeIncompleteFrame()); |
2292 | 2353 |
2293 // The next complete continuous frame isn't a key frame, but we're waiting | 2354 // The next complete continuous frame isn't a key frame, but we're waiting |
2294 // for one. | 2355 // for one. |
2295 EXPECT_FALSE(DecodeCompleteFrame()); | 2356 EXPECT_FALSE(DecodeCompleteFrame()); |
2296 EXPECT_GE(InsertFrame(kVideoFrameKey), kNoError); | 2357 EXPECT_GE(InsertFrame(kVideoFrameKey), kNoError); |
2297 // Skipping ahead to the key frame. | 2358 // Skipping ahead to the key frame. |
2298 EXPECT_TRUE(DecodeCompleteFrame()); | 2359 EXPECT_TRUE(DecodeCompleteFrame()); |
2299 } | 2360 } |
2300 | 2361 |
2301 TEST_F(TestJitterBufferNack, NackLargeJitterBuffer) { | 2362 TEST_P(TestJitterBufferNack, NackLargeJitterBuffer) { |
2302 // Insert a key frame and decode it. | 2363 // Insert a key frame and decode it. |
2303 EXPECT_GE(InsertFrame(kVideoFrameKey), kNoError); | 2364 EXPECT_GE(InsertFrame(kVideoFrameKey), kNoError); |
2304 EXPECT_TRUE(DecodeCompleteFrame()); | 2365 EXPECT_TRUE(DecodeCompleteFrame()); |
2305 | 2366 |
2306 // Insert a frame which should trigger a recycle until the next key frame. | 2367 // Insert a frame which should trigger a recycle until the next key frame. |
2307 EXPECT_GE(InsertFrames(oldest_packet_to_nack_, kVideoFrameDelta), kNoError); | 2368 EXPECT_GE(InsertFrames(oldest_packet_to_nack_, kVideoFrameDelta), kNoError); |
2308 | 2369 |
2309 bool request_key_frame = false; | 2370 bool request_key_frame = false; |
2310 std::vector<uint16_t> nack_list = | 2371 std::vector<uint16_t> nack_list = |
2311 jitter_buffer_->GetNackList(&request_key_frame); | 2372 jitter_buffer_->GetNackList(&request_key_frame); |
2312 // Verify that the jitter buffer does not request a key frame. | 2373 // Verify that the jitter buffer does not request a key frame. |
2313 EXPECT_FALSE(request_key_frame); | 2374 EXPECT_FALSE(request_key_frame); |
2314 // Verify that no packets are NACKed. | 2375 // Verify that no packets are NACKed. |
2315 EXPECT_EQ(0u, nack_list.size()); | 2376 EXPECT_EQ(0u, nack_list.size()); |
2316 // Verify that we can decode the next frame. | 2377 // Verify that we can decode the next frame. |
2317 EXPECT_TRUE(DecodeCompleteFrame()); | 2378 EXPECT_TRUE(DecodeCompleteFrame()); |
2318 } | 2379 } |
2319 | 2380 |
2320 TEST_F(TestJitterBufferNack, NackListFull) { | 2381 TEST_P(TestJitterBufferNack, NackListFull) { |
2321 // Insert a key frame and decode it. | 2382 // Insert a key frame and decode it. |
2322 EXPECT_GE(InsertFrame(kVideoFrameKey), kNoError); | 2383 EXPECT_GE(InsertFrame(kVideoFrameKey), kNoError); |
2323 EXPECT_TRUE(DecodeCompleteFrame()); | 2384 EXPECT_TRUE(DecodeCompleteFrame()); |
2324 | 2385 |
2325 // Generate and drop |kNackHistoryLength| packets to fill the NACK list. | 2386 // Generate and drop |kNackHistoryLength| packets to fill the NACK list. |
2326 DropFrame(max_nack_list_size_ + 1); | 2387 DropFrame(max_nack_list_size_ + 1); |
2327 // Insert a frame which should trigger a recycle until the next key frame. | 2388 // Insert a frame which should trigger a recycle until the next key frame. |
2328 EXPECT_EQ(kFlushIndicator, InsertFrame(kVideoFrameDelta)); | 2389 EXPECT_EQ(kFlushIndicator, InsertFrame(kVideoFrameDelta)); |
2329 EXPECT_FALSE(DecodeCompleteFrame()); | 2390 EXPECT_FALSE(DecodeCompleteFrame()); |
2330 | 2391 |
(...skipping 12 matching lines...) Expand all Loading... |
2343 EXPECT_TRUE(request_key_frame); | 2404 EXPECT_TRUE(request_key_frame); |
2344 // The next complete continuous frame isn't a key frame, but we're waiting | 2405 // The next complete continuous frame isn't a key frame, but we're waiting |
2345 // for one. | 2406 // for one. |
2346 EXPECT_FALSE(DecodeCompleteFrame()); | 2407 EXPECT_FALSE(DecodeCompleteFrame()); |
2347 EXPECT_FALSE(DecodeIncompleteFrame()); | 2408 EXPECT_FALSE(DecodeIncompleteFrame()); |
2348 EXPECT_GE(InsertFrame(kVideoFrameKey), kNoError); | 2409 EXPECT_GE(InsertFrame(kVideoFrameKey), kNoError); |
2349 // Skipping ahead to the key frame. | 2410 // Skipping ahead to the key frame. |
2350 EXPECT_TRUE(DecodeCompleteFrame()); | 2411 EXPECT_TRUE(DecodeCompleteFrame()); |
2351 } | 2412 } |
2352 | 2413 |
2353 TEST_F(TestJitterBufferNack, NoNackListReturnedBeforeFirstDecode) { | 2414 TEST_P(TestJitterBufferNack, NoNackListReturnedBeforeFirstDecode) { |
2354 DropFrame(10); | 2415 DropFrame(10); |
2355 // Insert a frame and try to generate a NACK list. Shouldn't get one. | 2416 // Insert a frame and try to generate a NACK list. Shouldn't get one. |
2356 EXPECT_GE(InsertFrame(kVideoFrameDelta), kNoError); | 2417 EXPECT_GE(InsertFrame(kVideoFrameDelta), kNoError); |
2357 bool request_key_frame = false; | 2418 bool request_key_frame = false; |
2358 std::vector<uint16_t> nack_list = | 2419 std::vector<uint16_t> nack_list = |
2359 jitter_buffer_->GetNackList(&request_key_frame); | 2420 jitter_buffer_->GetNackList(&request_key_frame); |
2360 // No list generated, and a key frame request is signaled. | 2421 // No list generated, and a key frame request is signaled. |
2361 EXPECT_EQ(0u, nack_list.size()); | 2422 EXPECT_EQ(0u, nack_list.size()); |
2362 EXPECT_TRUE(request_key_frame); | 2423 EXPECT_TRUE(request_key_frame); |
2363 } | 2424 } |
2364 | 2425 |
2365 TEST_F(TestJitterBufferNack, NackListBuiltBeforeFirstDecode) { | 2426 TEST_P(TestJitterBufferNack, NackListBuiltBeforeFirstDecode) { |
2366 stream_generator_->Init(0, clock_->TimeInMilliseconds()); | 2427 stream_generator_->Init(0, clock_->TimeInMilliseconds()); |
2367 InsertFrame(kVideoFrameKey); | 2428 InsertFrame(kVideoFrameKey); |
2368 stream_generator_->GenerateFrame(kVideoFrameDelta, 2, 0, | 2429 stream_generator_->GenerateFrame(kVideoFrameDelta, 2, 0, |
2369 clock_->TimeInMilliseconds()); | 2430 clock_->TimeInMilliseconds()); |
2370 stream_generator_->NextPacket(NULL); // Drop packet. | 2431 stream_generator_->NextPacket(NULL); // Drop packet. |
2371 EXPECT_EQ(kIncomplete, InsertPacketAndPop(0)); | 2432 EXPECT_EQ(kIncomplete, InsertPacketAndPop(0)); |
2372 EXPECT_TRUE(DecodeCompleteFrame()); | 2433 EXPECT_TRUE(DecodeCompleteFrame()); |
2373 bool extended = false; | 2434 bool extended = false; |
2374 std::vector<uint16_t> nack_list = jitter_buffer_->GetNackList(&extended); | 2435 std::vector<uint16_t> nack_list = jitter_buffer_->GetNackList(&extended); |
2375 EXPECT_EQ(1u, nack_list.size()); | 2436 if (field_trial::FindFullName("WebRTC-NewVideoJitterBuffer") == "Enabled") |
| 2437 EXPECT_EQ(1u, nack_sent_.size()); |
| 2438 else |
| 2439 EXPECT_EQ(1u, nack_list.size()); |
2376 } | 2440 } |
2377 | 2441 |
2378 TEST_F(TestJitterBufferNack, VerifyRetransmittedFlag) { | 2442 TEST_P(TestJitterBufferNack, VerifyRetransmittedFlag) { |
2379 stream_generator_->Init(0, clock_->TimeInMilliseconds()); | 2443 stream_generator_->Init(0, clock_->TimeInMilliseconds()); |
2380 stream_generator_->GenerateFrame(kVideoFrameKey, 3, 0, | 2444 stream_generator_->GenerateFrame(kVideoFrameKey, 3, 0, |
2381 clock_->TimeInMilliseconds()); | 2445 clock_->TimeInMilliseconds()); |
2382 VCMPacket packet; | 2446 VCMPacket packet; |
2383 stream_generator_->PopPacket(&packet, 0); | 2447 stream_generator_->PopPacket(&packet, 0); |
2384 bool retransmitted = false; | 2448 bool retransmitted = false; |
2385 EXPECT_EQ(kIncomplete, jitter_buffer_->InsertPacket(packet, &retransmitted)); | 2449 EXPECT_EQ(kIncomplete, jitter_buffer_->InsertPacket(packet, &retransmitted)); |
2386 EXPECT_FALSE(retransmitted); | 2450 EXPECT_FALSE(retransmitted); |
2387 // Drop second packet. | 2451 // Drop second packet. |
2388 stream_generator_->PopPacket(&packet, 1); | 2452 stream_generator_->PopPacket(&packet, 1); |
2389 EXPECT_EQ(kIncomplete, jitter_buffer_->InsertPacket(packet, &retransmitted)); | 2453 EXPECT_EQ(kIncomplete, jitter_buffer_->InsertPacket(packet, &retransmitted)); |
2390 EXPECT_FALSE(retransmitted); | 2454 EXPECT_FALSE(retransmitted); |
2391 EXPECT_FALSE(DecodeCompleteFrame()); | 2455 EXPECT_FALSE(DecodeCompleteFrame()); |
2392 bool extended = false; | 2456 bool extended = false; |
2393 std::vector<uint16_t> nack_list = jitter_buffer_->GetNackList(&extended); | 2457 std::vector<uint16_t> nack_list = jitter_buffer_->GetNackList(&extended); |
2394 EXPECT_EQ(1u, nack_list.size()); | 2458 uint16_t seq_num; |
| 2459 if (field_trial::FindFullName("WebRTC-NewVideoJitterBuffer") == "Enabled") { |
| 2460 EXPECT_EQ(1u, nack_sent_.size()); |
| 2461 seq_num = nack_sent_[0]; |
| 2462 } else { |
| 2463 EXPECT_EQ(1u, nack_list.size()); |
| 2464 seq_num = nack_list[0]; |
| 2465 } |
2395 stream_generator_->PopPacket(&packet, 0); | 2466 stream_generator_->PopPacket(&packet, 0); |
2396 EXPECT_EQ(packet.seqNum, nack_list[0]); | 2467 EXPECT_EQ(packet.seqNum, seq_num); |
2397 EXPECT_EQ(kCompleteSession, | 2468 EXPECT_EQ(kCompleteSession, |
2398 jitter_buffer_->InsertPacket(packet, &retransmitted)); | 2469 jitter_buffer_->InsertPacket(packet, &retransmitted)); |
2399 EXPECT_TRUE(retransmitted); | 2470 EXPECT_TRUE(retransmitted); |
2400 EXPECT_TRUE(DecodeCompleteFrame()); | 2471 EXPECT_TRUE(DecodeCompleteFrame()); |
2401 } | 2472 } |
2402 | 2473 |
2403 TEST_F(TestJitterBufferNack, UseNackToRecoverFirstKeyFrame) { | 2474 TEST_P(TestJitterBufferNack, UseNackToRecoverFirstKeyFrame) { |
2404 stream_generator_->Init(0, clock_->TimeInMilliseconds()); | 2475 stream_generator_->Init(0, clock_->TimeInMilliseconds()); |
2405 stream_generator_->GenerateFrame(kVideoFrameKey, 3, 0, | 2476 stream_generator_->GenerateFrame(kVideoFrameKey, 3, 0, |
2406 clock_->TimeInMilliseconds()); | 2477 clock_->TimeInMilliseconds()); |
2407 EXPECT_EQ(kIncomplete, InsertPacketAndPop(0)); | 2478 EXPECT_EQ(kIncomplete, InsertPacketAndPop(0)); |
2408 // Drop second packet. | 2479 // Drop second packet. |
2409 EXPECT_EQ(kIncomplete, InsertPacketAndPop(1)); | 2480 EXPECT_EQ(kIncomplete, InsertPacketAndPop(1)); |
2410 EXPECT_FALSE(DecodeCompleteFrame()); | 2481 EXPECT_FALSE(DecodeCompleteFrame()); |
2411 bool extended = false; | 2482 bool extended = false; |
2412 std::vector<uint16_t> nack_list = jitter_buffer_->GetNackList(&extended); | 2483 std::vector<uint16_t> nack_list = jitter_buffer_->GetNackList(&extended); |
2413 EXPECT_EQ(1u, nack_list.size()); | 2484 uint16_t seq_num; |
| 2485 if (field_trial::FindFullName("WebRTC-NewVideoJitterBuffer") == "Enabled") { |
| 2486 ASSERT_EQ(1u, nack_sent_.size()); |
| 2487 seq_num = nack_sent_[0]; |
| 2488 } else { |
| 2489 ASSERT_EQ(1u, nack_list.size()); |
| 2490 seq_num = nack_list[0]; |
| 2491 } |
2414 VCMPacket packet; | 2492 VCMPacket packet; |
2415 stream_generator_->GetPacket(&packet, 0); | 2493 stream_generator_->GetPacket(&packet, 0); |
2416 EXPECT_EQ(packet.seqNum, nack_list[0]); | 2494 EXPECT_EQ(packet.seqNum, seq_num); |
2417 } | 2495 } |
2418 | 2496 |
2419 TEST_F(TestJitterBufferNack, UseNackToRecoverFirstKeyFrameSecondInQueue) { | 2497 TEST_P(TestJitterBufferNack, UseNackToRecoverFirstKeyFrameSecondInQueue) { |
2420 VCMPacket packet; | 2498 VCMPacket packet; |
2421 stream_generator_->Init(0, clock_->TimeInMilliseconds()); | 2499 stream_generator_->Init(0, clock_->TimeInMilliseconds()); |
2422 // First frame is delta. | 2500 // First frame is delta. |
2423 stream_generator_->GenerateFrame(kVideoFrameDelta, 3, 0, | 2501 stream_generator_->GenerateFrame(kVideoFrameDelta, 3, 0, |
2424 clock_->TimeInMilliseconds()); | 2502 clock_->TimeInMilliseconds()); |
2425 EXPECT_EQ(kIncomplete, InsertPacketAndPop(0)); | 2503 EXPECT_EQ(kIncomplete, InsertPacketAndPop(0)); |
2426 // Drop second packet in frame. | 2504 // Drop second packet in frame. |
2427 ASSERT_TRUE(stream_generator_->PopPacket(&packet, 0)); | 2505 ASSERT_TRUE(stream_generator_->PopPacket(&packet, 0)); |
2428 EXPECT_EQ(kIncomplete, InsertPacketAndPop(0)); | 2506 EXPECT_EQ(kIncomplete, InsertPacketAndPop(0)); |
2429 // Second frame is key. | 2507 // Second frame is key. |
2430 stream_generator_->GenerateFrame(kVideoFrameKey, 3, 0, | 2508 stream_generator_->GenerateFrame(kVideoFrameKey, 3, 0, |
2431 clock_->TimeInMilliseconds() + 10); | 2509 clock_->TimeInMilliseconds() + 10); |
2432 EXPECT_EQ(kIncomplete, InsertPacketAndPop(0)); | 2510 EXPECT_EQ(kIncomplete, InsertPacketAndPop(0)); |
2433 // Drop second packet in frame. | 2511 // Drop second packet in frame. |
2434 EXPECT_EQ(kIncomplete, InsertPacketAndPop(1)); | 2512 EXPECT_EQ(kIncomplete, InsertPacketAndPop(1)); |
2435 EXPECT_FALSE(DecodeCompleteFrame()); | 2513 EXPECT_FALSE(DecodeCompleteFrame()); |
2436 bool extended = false; | 2514 bool extended = false; |
2437 std::vector<uint16_t> nack_list = jitter_buffer_->GetNackList(&extended); | 2515 std::vector<uint16_t> nack_list = jitter_buffer_->GetNackList(&extended); |
2438 EXPECT_EQ(1u, nack_list.size()); | 2516 uint16_t seq_num; |
| 2517 if (field_trial::FindFullName("WebRTC-NewVideoJitterBuffer") == "Enabled") { |
| 2518 ASSERT_EQ(2u, nack_sent_.size()); |
| 2519 seq_num = nack_sent_[1]; |
| 2520 } else { |
| 2521 ASSERT_EQ(1u, nack_list.size()); |
| 2522 seq_num = nack_list[0]; |
| 2523 } |
2439 stream_generator_->GetPacket(&packet, 0); | 2524 stream_generator_->GetPacket(&packet, 0); |
2440 EXPECT_EQ(packet.seqNum, nack_list[0]); | 2525 EXPECT_EQ(packet.seqNum, seq_num); |
2441 } | 2526 } |
2442 | 2527 |
2443 TEST_F(TestJitterBufferNack, NormalOperation) { | 2528 TEST_P(TestJitterBufferNack, NormalOperation) { |
2444 EXPECT_EQ(kNack, jitter_buffer_->nack_mode()); | 2529 EXPECT_EQ(kNack, jitter_buffer_->nack_mode()); |
2445 jitter_buffer_->SetDecodeErrorMode(kWithErrors); | 2530 jitter_buffer_->SetDecodeErrorMode(kWithErrors); |
2446 | 2531 |
2447 EXPECT_GE(InsertFrame(kVideoFrameKey), kNoError); | 2532 EXPECT_GE(InsertFrame(kVideoFrameKey), kNoError); |
2448 EXPECT_TRUE(DecodeIncompleteFrame()); | 2533 EXPECT_TRUE(DecodeIncompleteFrame()); |
2449 | 2534 |
2450 // ---------------------------------------------------------------- | 2535 // ---------------------------------------------------------------- |
2451 // | 1 | 2 | .. | 8 | 9 | x | 11 | 12 | .. | 19 | x | 21 | .. | 100 | | 2536 // | 1 | 2 | .. | 8 | 9 | x | 11 | 12 | .. | 19 | x | 21 | .. | 100 | |
2452 // ---------------------------------------------------------------- | 2537 // ---------------------------------------------------------------- |
2453 stream_generator_->GenerateFrame(kVideoFrameKey, 100, 0, | 2538 stream_generator_->GenerateFrame(kVideoFrameKey, 100, 0, |
2454 clock_->TimeInMilliseconds()); | 2539 clock_->TimeInMilliseconds()); |
2455 clock_->AdvanceTimeMilliseconds(kDefaultFramePeriodMs); | 2540 clock_->AdvanceTimeMilliseconds(kDefaultFramePeriodMs); |
2456 EXPECT_EQ(kDecodableSession, InsertPacketAndPop(0)); | 2541 EXPECT_EQ(kDecodableSession, InsertPacketAndPop(0)); |
2457 // Verify that the frame is incomplete. | 2542 // Verify that the frame is incomplete. |
2458 EXPECT_FALSE(DecodeCompleteFrame()); | 2543 EXPECT_FALSE(DecodeCompleteFrame()); |
2459 while (stream_generator_->PacketsRemaining() > 1) { | 2544 while (stream_generator_->PacketsRemaining() > 1) { |
2460 if (stream_generator_->NextSequenceNumber() % 10 != 0) { | 2545 if (stream_generator_->NextSequenceNumber() % 10 != 0) { |
2461 EXPECT_EQ(kDecodableSession, InsertPacketAndPop(0)); | 2546 EXPECT_EQ(kDecodableSession, InsertPacketAndPop(0)); |
2462 } else { | 2547 } else { |
2463 stream_generator_->NextPacket(NULL); // Drop packet | 2548 stream_generator_->NextPacket(NULL); // Drop packet |
2464 } | 2549 } |
2465 } | 2550 } |
2466 EXPECT_EQ(kDecodableSession, InsertPacketAndPop(0)); | 2551 EXPECT_EQ(kDecodableSession, InsertPacketAndPop(0)); |
2467 EXPECT_EQ(0, stream_generator_->PacketsRemaining()); | 2552 EXPECT_EQ(0, stream_generator_->PacketsRemaining()); |
2468 EXPECT_FALSE(DecodeCompleteFrame()); | 2553 EXPECT_FALSE(DecodeCompleteFrame()); |
2469 EXPECT_FALSE(DecodeIncompleteFrame()); | 2554 EXPECT_FALSE(DecodeIncompleteFrame()); |
2470 bool request_key_frame = false; | 2555 bool request_key_frame = false; |
| 2556 |
| 2557 // Verify the NACK list. |
2471 std::vector<uint16_t> nack_list = | 2558 std::vector<uint16_t> nack_list = |
2472 jitter_buffer_->GetNackList(&request_key_frame); | 2559 jitter_buffer_->GetNackList(&request_key_frame); |
2473 // Verify the NACK list. | |
2474 const size_t kExpectedNackSize = 9; | 2560 const size_t kExpectedNackSize = 9; |
2475 ASSERT_EQ(kExpectedNackSize, nack_list.size()); | 2561 if (field_trial::FindFullName("WebRTC-NewVideoJitterBuffer") == "Enabled") |
| 2562 ASSERT_EQ(kExpectedNackSize, nack_sent_.size()); |
| 2563 else |
| 2564 ASSERT_EQ(kExpectedNackSize, nack_list.size()); |
2476 for (size_t i = 0; i < nack_list.size(); ++i) | 2565 for (size_t i = 0; i < nack_list.size(); ++i) |
2477 EXPECT_EQ((1 + i) * 10, nack_list[i]); | 2566 EXPECT_EQ((1 + i) * 10, nack_list[i]); |
2478 } | 2567 } |
2479 | 2568 |
2480 TEST_F(TestJitterBufferNack, NormalOperationWrap) { | 2569 TEST_P(TestJitterBufferNack, NormalOperationWrap) { |
2481 bool request_key_frame = false; | 2570 bool request_key_frame = false; |
2482 // ------- ------------------------------------------------------------ | 2571 // ------- ------------------------------------------------------------ |
2483 // | 65532 | | 65533 | 65534 | 65535 | x | 1 | .. | 9 | x | 11 |.....| 96 | | 2572 // | 65532 | | 65533 | 65534 | 65535 | x | 1 | .. | 9 | x | 11 |.....| 96 | |
2484 // ------- ------------------------------------------------------------ | 2573 // ------- ------------------------------------------------------------ |
2485 stream_generator_->Init(65532, clock_->TimeInMilliseconds()); | 2574 stream_generator_->Init(65532, clock_->TimeInMilliseconds()); |
2486 InsertFrame(kVideoFrameKey); | 2575 InsertFrame(kVideoFrameKey); |
2487 EXPECT_FALSE(request_key_frame); | 2576 EXPECT_FALSE(request_key_frame); |
2488 EXPECT_TRUE(DecodeCompleteFrame()); | 2577 EXPECT_TRUE(DecodeCompleteFrame()); |
2489 stream_generator_->GenerateFrame(kVideoFrameDelta, 100, 0, | 2578 stream_generator_->GenerateFrame(kVideoFrameDelta, 100, 0, |
2490 clock_->TimeInMilliseconds()); | 2579 clock_->TimeInMilliseconds()); |
2491 EXPECT_EQ(kIncomplete, InsertPacketAndPop(0)); | 2580 EXPECT_EQ(kIncomplete, InsertPacketAndPop(0)); |
2492 while (stream_generator_->PacketsRemaining() > 1) { | 2581 while (stream_generator_->PacketsRemaining() > 1) { |
2493 if (stream_generator_->NextSequenceNumber() % 10 != 0) { | 2582 if (stream_generator_->NextSequenceNumber() % 10 != 0) { |
2494 EXPECT_EQ(kIncomplete, InsertPacketAndPop(0)); | 2583 EXPECT_EQ(kIncomplete, InsertPacketAndPop(0)); |
2495 EXPECT_FALSE(request_key_frame); | 2584 EXPECT_FALSE(request_key_frame); |
2496 } else { | 2585 } else { |
2497 stream_generator_->NextPacket(NULL); // Drop packet | 2586 stream_generator_->NextPacket(NULL); // Drop packet |
2498 } | 2587 } |
2499 } | 2588 } |
2500 EXPECT_EQ(kIncomplete, InsertPacketAndPop(0)); | 2589 EXPECT_EQ(kIncomplete, InsertPacketAndPop(0)); |
2501 EXPECT_FALSE(request_key_frame); | 2590 EXPECT_FALSE(request_key_frame); |
2502 EXPECT_EQ(0, stream_generator_->PacketsRemaining()); | 2591 EXPECT_EQ(0, stream_generator_->PacketsRemaining()); |
2503 EXPECT_FALSE(DecodeCompleteFrame()); | 2592 EXPECT_FALSE(DecodeCompleteFrame()); |
2504 EXPECT_FALSE(DecodeCompleteFrame()); | 2593 EXPECT_FALSE(DecodeCompleteFrame()); |
2505 bool extended = false; | 2594 bool extended = false; |
2506 std::vector<uint16_t> nack_list = jitter_buffer_->GetNackList(&extended); | 2595 std::vector<uint16_t> nack_list = jitter_buffer_->GetNackList(&extended); |
2507 // Verify the NACK list. | 2596 // Verify the NACK list. |
2508 const size_t kExpectedNackSize = 10; | 2597 const size_t kExpectedNackSize = 10; |
2509 ASSERT_EQ(kExpectedNackSize, nack_list.size()); | 2598 if (field_trial::FindFullName("WebRTC-NewVideoJitterBuffer") == "Enabled") { |
2510 for (size_t i = 0; i < nack_list.size(); ++i) | 2599 ASSERT_EQ(kExpectedNackSize, nack_sent_.size()); |
2511 EXPECT_EQ(i * 10, nack_list[i]); | 2600 for (size_t i = 0; i < nack_sent_.size(); ++i) |
| 2601 EXPECT_EQ(i * 10, nack_sent_[i]); |
| 2602 } else { |
| 2603 ASSERT_EQ(kExpectedNackSize, nack_list.size()); |
| 2604 for (size_t i = 0; i < nack_list.size(); ++i) |
| 2605 EXPECT_EQ(i * 10, nack_list[i]); |
| 2606 } |
2512 } | 2607 } |
2513 | 2608 |
2514 TEST_F(TestJitterBufferNack, NormalOperationWrap2) { | 2609 TEST_P(TestJitterBufferNack, NormalOperationWrap2) { |
2515 bool request_key_frame = false; | 2610 bool request_key_frame = false; |
2516 // ----------------------------------- | 2611 // ----------------------------------- |
2517 // | 65532 | 65533 | 65534 | x | 0 | 1 | | 2612 // | 65532 | 65533 | 65534 | x | 0 | 1 | |
2518 // ----------------------------------- | 2613 // ----------------------------------- |
2519 stream_generator_->Init(65532, clock_->TimeInMilliseconds()); | 2614 stream_generator_->Init(65532, clock_->TimeInMilliseconds()); |
2520 InsertFrame(kVideoFrameKey); | 2615 InsertFrame(kVideoFrameKey); |
2521 EXPECT_FALSE(request_key_frame); | 2616 EXPECT_FALSE(request_key_frame); |
2522 EXPECT_TRUE(DecodeCompleteFrame()); | 2617 EXPECT_TRUE(DecodeCompleteFrame()); |
2523 stream_generator_->GenerateFrame(kVideoFrameDelta, 1, 0, | 2618 stream_generator_->GenerateFrame(kVideoFrameDelta, 1, 0, |
2524 clock_->TimeInMilliseconds()); | 2619 clock_->TimeInMilliseconds()); |
2525 clock_->AdvanceTimeMilliseconds(kDefaultFramePeriodMs); | 2620 clock_->AdvanceTimeMilliseconds(kDefaultFramePeriodMs); |
2526 for (int i = 0; i < 5; ++i) { | 2621 for (int i = 0; i < 5; ++i) { |
2527 if (stream_generator_->NextSequenceNumber() != 65535) { | 2622 if (stream_generator_->NextSequenceNumber() != 65535) { |
2528 EXPECT_EQ(kCompleteSession, InsertPacketAndPop(0)); | 2623 EXPECT_EQ(kCompleteSession, InsertPacketAndPop(0)); |
2529 EXPECT_FALSE(request_key_frame); | 2624 EXPECT_FALSE(request_key_frame); |
2530 } else { | 2625 } else { |
2531 stream_generator_->NextPacket(NULL); // Drop packet | 2626 stream_generator_->NextPacket(NULL); // Drop packet |
2532 } | 2627 } |
2533 stream_generator_->GenerateFrame(kVideoFrameDelta, 1, 0, | 2628 stream_generator_->GenerateFrame(kVideoFrameDelta, 1, 0, |
2534 clock_->TimeInMilliseconds()); | 2629 clock_->TimeInMilliseconds()); |
2535 clock_->AdvanceTimeMilliseconds(kDefaultFramePeriodMs); | 2630 clock_->AdvanceTimeMilliseconds(kDefaultFramePeriodMs); |
2536 } | 2631 } |
2537 EXPECT_EQ(kCompleteSession, InsertPacketAndPop(0)); | 2632 EXPECT_EQ(kCompleteSession, InsertPacketAndPop(0)); |
2538 EXPECT_FALSE(request_key_frame); | 2633 EXPECT_FALSE(request_key_frame); |
2539 bool extended = false; | 2634 bool extended = false; |
2540 std::vector<uint16_t> nack_list = jitter_buffer_->GetNackList(&extended); | 2635 std::vector<uint16_t> nack_list = jitter_buffer_->GetNackList(&extended); |
2541 // Verify the NACK list. | 2636 // Verify the NACK list. |
2542 ASSERT_EQ(1u, nack_list.size()); | 2637 if (field_trial::FindFullName("WebRTC-NewVideoJitterBuffer") == "Enabled") { |
2543 EXPECT_EQ(65535, nack_list[0]); | 2638 ASSERT_EQ(1u, nack_sent_.size()); |
| 2639 EXPECT_EQ(65535, nack_sent_[0]); |
| 2640 } else { |
| 2641 ASSERT_EQ(1u, nack_list.size()); |
| 2642 EXPECT_EQ(65535, nack_list[0]); |
| 2643 } |
2544 } | 2644 } |
2545 | 2645 |
2546 TEST_F(TestJitterBufferNack, ResetByFutureKeyFrameDoesntError) { | 2646 TEST_P(TestJitterBufferNack, ResetByFutureKeyFrameDoesntError) { |
2547 stream_generator_->Init(0, clock_->TimeInMilliseconds()); | 2647 stream_generator_->Init(0, clock_->TimeInMilliseconds()); |
2548 InsertFrame(kVideoFrameKey); | 2648 InsertFrame(kVideoFrameKey); |
2549 EXPECT_TRUE(DecodeCompleteFrame()); | 2649 EXPECT_TRUE(DecodeCompleteFrame()); |
2550 bool extended = false; | 2650 bool extended = false; |
2551 std::vector<uint16_t> nack_list = jitter_buffer_->GetNackList(&extended); | 2651 std::vector<uint16_t> nack_list = jitter_buffer_->GetNackList(&extended); |
2552 EXPECT_EQ(0u, nack_list.size()); | 2652 EXPECT_EQ(0u, nack_list.size()); |
2553 | 2653 |
2554 // Far-into-the-future video frame, could be caused by resetting the encoder | 2654 // Far-into-the-future video frame, could be caused by resetting the encoder |
2555 // or otherwise restarting. This should not fail when error when the packet is | 2655 // or otherwise restarting. This should not fail when error when the packet is |
2556 // a keyframe, even if all of the nack list needs to be flushed. | 2656 // a keyframe, even if all of the nack list needs to be flushed. |
2557 stream_generator_->Init(10000, clock_->TimeInMilliseconds()); | 2657 stream_generator_->Init(10000, clock_->TimeInMilliseconds()); |
2558 clock_->AdvanceTimeMilliseconds(kDefaultFramePeriodMs); | 2658 clock_->AdvanceTimeMilliseconds(kDefaultFramePeriodMs); |
2559 InsertFrame(kVideoFrameKey); | 2659 InsertFrame(kVideoFrameKey); |
2560 EXPECT_TRUE(DecodeCompleteFrame()); | 2660 EXPECT_TRUE(DecodeCompleteFrame()); |
2561 nack_list = jitter_buffer_->GetNackList(&extended); | 2661 nack_list = jitter_buffer_->GetNackList(&extended); |
2562 EXPECT_EQ(0u, nack_list.size()); | 2662 EXPECT_EQ(0u, nack_list.size()); |
2563 | 2663 |
2564 // Stream should be decodable from this point. | 2664 // Stream should be decodable from this point. |
2565 clock_->AdvanceTimeMilliseconds(kDefaultFramePeriodMs); | 2665 clock_->AdvanceTimeMilliseconds(kDefaultFramePeriodMs); |
2566 InsertFrame(kVideoFrameDelta); | 2666 InsertFrame(kVideoFrameDelta); |
2567 EXPECT_TRUE(DecodeCompleteFrame()); | 2667 EXPECT_TRUE(DecodeCompleteFrame()); |
2568 nack_list = jitter_buffer_->GetNackList(&extended); | 2668 nack_list = jitter_buffer_->GetNackList(&extended); |
2569 EXPECT_EQ(0u, nack_list.size()); | 2669 EXPECT_EQ(0u, nack_list.size()); |
2570 } | 2670 } |
2571 | 2671 |
2572 } // namespace webrtc | 2672 } // namespace webrtc |
OLD | NEW |