OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 Insert(seq_num, kKeyFrame, kFirst, kNotLast, sizeof(many_data), many)); | 367 Insert(seq_num, kKeyFrame, kFirst, kNotLast, sizeof(many_data), many)); |
368 EXPECT_TRUE(Insert(seq_num + 1, kDeltaFrame, kNotFirst, kNotLast, | 368 EXPECT_TRUE(Insert(seq_num + 1, kDeltaFrame, kNotFirst, kNotLast, |
369 sizeof(bitstream_data), bitstream)); | 369 sizeof(bitstream_data), bitstream)); |
370 EXPECT_TRUE(Insert(seq_num + 2, kDeltaFrame, kNotFirst, kNotLast, | 370 EXPECT_TRUE(Insert(seq_num + 2, kDeltaFrame, kNotFirst, kNotLast, |
371 sizeof(such_data), such)); | 371 sizeof(such_data), such)); |
372 EXPECT_TRUE(Insert(seq_num + 3, kDeltaFrame, kNotFirst, kLast, | 372 EXPECT_TRUE(Insert(seq_num + 3, kDeltaFrame, kNotFirst, kLast, |
373 sizeof(data_data), data)); | 373 sizeof(data_data), data)); |
374 | 374 |
375 ASSERT_EQ(1UL, frames_from_callback_.size()); | 375 ASSERT_EQ(1UL, frames_from_callback_.size()); |
376 CheckFrame(seq_num); | 376 CheckFrame(seq_num); |
| 377 EXPECT_EQ(frames_from_callback_[seq_num]->size(), sizeof(result)); |
377 EXPECT_TRUE(frames_from_callback_[seq_num]->GetBitstream(result)); | 378 EXPECT_TRUE(frames_from_callback_[seq_num]->GetBitstream(result)); |
378 EXPECT_EQ(memcmp(result, "many bitstream, such data", sizeof(result)), 0); | 379 EXPECT_EQ(memcmp(result, "many bitstream, such data", sizeof(result)), 0); |
379 } | 380 } |
380 | 381 |
| 382 TEST_F(TestPacketBuffer, GetBitstreamOneFrameFullBuffer) { |
| 383 uint8_t* data_arr[kStartSize]; |
| 384 uint8_t expected[kStartSize]; |
| 385 uint8_t result[kStartSize]; |
| 386 |
| 387 for (uint8_t i = 0; i < kStartSize; ++i) { |
| 388 data_arr[i] = new uint8_t(i); |
| 389 expected[i] = i; |
| 390 } |
| 391 |
| 392 EXPECT_TRUE(Insert(0, kKeyFrame, kFirst, kNotLast, 1, data_arr[0])); |
| 393 for (uint8_t i = 1; i < kStartSize - 1; ++i) |
| 394 EXPECT_TRUE(Insert(i, kKeyFrame, kNotFirst, kNotLast, 1, data_arr[i])); |
| 395 EXPECT_TRUE(Insert(kStartSize - 1, kKeyFrame, kNotFirst, kLast, 1, |
| 396 data_arr[kStartSize - 1])); |
| 397 |
| 398 ASSERT_EQ(1UL, frames_from_callback_.size()); |
| 399 CheckFrame(0); |
| 400 EXPECT_EQ(frames_from_callback_[0]->size(), static_cast<size_t>(kStartSize)); |
| 401 EXPECT_TRUE(frames_from_callback_[0]->GetBitstream(result)); |
| 402 EXPECT_EQ(memcmp(result, expected, kStartSize), 0); |
| 403 } |
| 404 |
| 405 TEST_F(TestPacketBuffer, GetBitstreamOneFrameFullBufferH264) { |
| 406 uint8_t* data_arr[kStartSize]; |
| 407 uint8_t expected[kStartSize]; |
| 408 uint8_t result[kStartSize]; |
| 409 |
| 410 for (uint8_t i = 0; i < kStartSize; ++i) { |
| 411 data_arr[i] = new uint8_t(i); |
| 412 expected[i] = i; |
| 413 } |
| 414 |
| 415 EXPECT_TRUE(InsertH264(0, kKeyFrame, kFirst, kNotLast, 1, 1, data_arr[0])); |
| 416 for (uint8_t i = 1; i < kStartSize - 1; ++i) { |
| 417 EXPECT_TRUE( |
| 418 InsertH264(i, kKeyFrame, kNotFirst, kNotLast, 1, 1, data_arr[i])); |
| 419 } |
| 420 EXPECT_TRUE(InsertH264(kStartSize - 1, kKeyFrame, kNotFirst, kLast, 1, 1, |
| 421 data_arr[kStartSize - 1])); |
| 422 |
| 423 ASSERT_EQ(1UL, frames_from_callback_.size()); |
| 424 CheckFrame(0); |
| 425 EXPECT_EQ(frames_from_callback_[0]->size(), static_cast<size_t>(kStartSize)); |
| 426 EXPECT_TRUE(frames_from_callback_[0]->GetBitstream(result)); |
| 427 EXPECT_EQ(memcmp(result, expected, kStartSize), 0); |
| 428 } |
| 429 |
381 TEST_F(TestPacketBuffer, GetBitstreamH264BufferPadding) { | 430 TEST_F(TestPacketBuffer, GetBitstreamH264BufferPadding) { |
382 uint16_t seq_num = Rand(); | 431 uint16_t seq_num = Rand(); |
383 uint8_t data_data[] = "some plain old data"; | 432 uint8_t data_data[] = "some plain old data"; |
384 uint8_t* data = new uint8_t[sizeof(data_data)]; | 433 uint8_t* data = new uint8_t[sizeof(data_data)]; |
385 memcpy(data, data_data, sizeof(data_data)); | 434 memcpy(data, data_data, sizeof(data_data)); |
386 | 435 |
387 // EncodedImage::kBufferPaddingBytesH264 is unknown at compile time. | 436 // EncodedImage::kBufferPaddingBytesH264 is unknown at compile time. |
388 std::unique_ptr<uint8_t[]> result( | 437 std::unique_ptr<uint8_t[]> result( |
389 new uint8_t[sizeof(data_data) + EncodedImage::kBufferPaddingBytesH264]); | 438 new uint8_t[sizeof(data_data) + EncodedImage::kBufferPaddingBytesH264]); |
390 | 439 |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 TEST_F(TestPacketBuffer, OneFrameFillBufferH264) { | 590 TEST_F(TestPacketBuffer, OneFrameFillBufferH264) { |
542 InsertH264(0, kKeyFrame, kFirst, kNotLast, 1000); | 591 InsertH264(0, kKeyFrame, kFirst, kNotLast, 1000); |
543 for (int i = 1; i < kStartSize - 1; ++i) | 592 for (int i = 1; i < kStartSize - 1; ++i) |
544 InsertH264(i, kKeyFrame, kNotFirst, kNotLast, 1000); | 593 InsertH264(i, kKeyFrame, kNotFirst, kNotLast, 1000); |
545 InsertH264(kStartSize - 1, kKeyFrame, kNotFirst, kLast, 1000); | 594 InsertH264(kStartSize - 1, kKeyFrame, kNotFirst, kLast, 1000); |
546 | 595 |
547 EXPECT_EQ(1UL, frames_from_callback_.size()); | 596 EXPECT_EQ(1UL, frames_from_callback_.size()); |
548 CheckFrame(0); | 597 CheckFrame(0); |
549 } | 598 } |
550 | 599 |
| 600 TEST_F(TestPacketBuffer, CreateFramesAfterFilledBufferH264) { |
| 601 InsertH264(kStartSize - 2, kKeyFrame, kFirst, kLast, 0); |
| 602 ASSERT_EQ(1UL, frames_from_callback_.size()); |
| 603 frames_from_callback_.clear(); |
| 604 |
| 605 InsertH264(kStartSize, kDeltaFrame, kFirst, kNotLast, 2000); |
| 606 for (int i = 1; i < kStartSize; ++i) |
| 607 InsertH264(kStartSize + i, kDeltaFrame, kNotFirst, kNotLast, 2000); |
| 608 InsertH264(kStartSize + kStartSize, kDeltaFrame, kNotFirst, kLast, 2000); |
| 609 ASSERT_EQ(0UL, frames_from_callback_.size()); |
| 610 |
| 611 InsertH264(kStartSize - 1, kKeyFrame, kFirst, kLast, 1000); |
| 612 ASSERT_EQ(2UL, frames_from_callback_.size()); |
| 613 CheckFrame(kStartSize - 1); |
| 614 CheckFrame(kStartSize); |
| 615 } |
| 616 |
551 TEST_F(TestPacketBuffer, OneFrameMaxSeqNumH264) { | 617 TEST_F(TestPacketBuffer, OneFrameMaxSeqNumH264) { |
552 InsertH264(65534, kKeyFrame, kFirst, kNotLast, 1000); | 618 InsertH264(65534, kKeyFrame, kFirst, kNotLast, 1000); |
553 InsertH264(65535, kKeyFrame, kNotFirst, kLast, 1000); | 619 InsertH264(65535, kKeyFrame, kNotFirst, kLast, 1000); |
554 | 620 |
555 EXPECT_EQ(1UL, frames_from_callback_.size()); | 621 EXPECT_EQ(1UL, frames_from_callback_.size()); |
556 CheckFrame(65534); | 622 CheckFrame(65534); |
557 } | 623 } |
558 | 624 |
559 TEST_F(TestPacketBuffer, ClearMissingPacketsOnKeyframeH264) { | 625 TEST_F(TestPacketBuffer, ClearMissingPacketsOnKeyframeH264) { |
560 InsertH264(0, kKeyFrame, kFirst, kLast, 1000); | 626 InsertH264(0, kKeyFrame, kFirst, kLast, 1000); |
(...skipping 18 matching lines...) Expand all Loading... |
579 | 645 |
580 ASSERT_EQ(1UL, frames_from_callback_.size()); | 646 ASSERT_EQ(1UL, frames_from_callback_.size()); |
581 packet_buffer_->PaddingReceived(1); | 647 packet_buffer_->PaddingReceived(1); |
582 ASSERT_EQ(2UL, frames_from_callback_.size()); | 648 ASSERT_EQ(2UL, frames_from_callback_.size()); |
583 CheckFrame(0); | 649 CheckFrame(0); |
584 CheckFrame(2); | 650 CheckFrame(2); |
585 } | 651 } |
586 | 652 |
587 } // namespace video_coding | 653 } // namespace video_coding |
588 } // namespace webrtc | 654 } // namespace webrtc |
OLD | NEW |