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 |
11 #include <cstring> | 11 #include <cstring> |
12 #include <limits> | 12 #include <limits> |
13 #include <memory> | 13 #include <map> |
| 14 #include <set> |
14 #include <utility> | 15 #include <utility> |
15 | 16 |
16 #include "webrtc/modules/video_coding/frame_object.h" | 17 #include "webrtc/modules/video_coding/frame_object.h" |
17 #include "webrtc/modules/video_coding/packet_buffer.h" | 18 #include "webrtc/modules/video_coding/packet_buffer.h" |
18 | 19 |
19 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
20 #include "webrtc/base/random.h" | 21 #include "webrtc/base/random.h" |
21 | 22 |
22 namespace webrtc { | 23 namespace webrtc { |
23 namespace video_coding { | 24 namespace video_coding { |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 | 438 |
438 frames_from_callback_.clear(); | 439 frames_from_callback_.clear(); |
439 | 440 |
440 // seq_num , kf, frst, lst | 441 // seq_num , kf, frst, lst |
441 InsertGeneric(seq_num , kT, kT , kF); | 442 InsertGeneric(seq_num , kT, kT , kF); |
442 InsertGeneric(seq_num + 1, kF, kF , kF); | 443 InsertGeneric(seq_num + 1, kF, kF , kF); |
443 InsertGeneric(seq_num + 2, kF, kF , kT); | 444 InsertGeneric(seq_num + 2, kF, kF , kT); |
444 EXPECT_EQ(1UL, frames_from_callback_.size()); | 445 EXPECT_EQ(1UL, frames_from_callback_.size()); |
445 } | 446 } |
446 | 447 |
447 TEST_F(TestPacketBuffer, Flush) { | 448 TEST_F(TestPacketBuffer, Clear) { |
448 uint16_t seq_num = Rand(); | 449 uint16_t seq_num = Rand(); |
449 | 450 |
450 // seq_num , kf, frst, lst | 451 // seq_num , kf, frst, lst |
451 InsertGeneric(seq_num , kT, kT , kF); | 452 InsertGeneric(seq_num , kT, kT , kF); |
452 InsertGeneric(seq_num + 1, kF, kF , kF); | 453 InsertGeneric(seq_num + 1, kF, kF , kF); |
453 InsertGeneric(seq_num + 2, kF, kF , kT); | 454 InsertGeneric(seq_num + 2, kF, kF , kT); |
454 EXPECT_EQ(1UL, frames_from_callback_.size()); | 455 EXPECT_EQ(1UL, frames_from_callback_.size()); |
455 | 456 |
456 packet_buffer_->Flush(); | 457 packet_buffer_->Clear(); |
457 | 458 |
458 // seq_num , kf, frst, lst | 459 // seq_num , kf, frst, lst |
459 InsertGeneric(seq_num + kStartSize , kT, kT , kF); | 460 InsertGeneric(seq_num + kStartSize , kT, kT , kF); |
460 InsertGeneric(seq_num + kStartSize + 1, kF, kF , kF); | 461 InsertGeneric(seq_num + kStartSize + 1, kF, kF , kF); |
461 InsertGeneric(seq_num + kStartSize + 2, kF, kF , kT); | 462 InsertGeneric(seq_num + kStartSize + 2, kF, kF , kT); |
462 EXPECT_EQ(2UL, frames_from_callback_.size()); | 463 EXPECT_EQ(2UL, frames_from_callback_.size()); |
463 } | 464 } |
464 | 465 |
465 TEST_F(TestPacketBuffer, InvalidateFrameByFlushing) { | 466 TEST_F(TestPacketBuffer, InvalidateFrameByClearing) { |
466 VCMPacket packet; | 467 VCMPacket packet; |
467 packet.codec = kVideoCodecGeneric; | 468 packet.codec = kVideoCodecGeneric; |
468 packet.frameType = kVideoFrameKey; | 469 packet.frameType = kVideoFrameKey; |
469 packet.isFirstPacket = kT; | 470 packet.isFirstPacket = kT; |
470 packet.markerBit = kT; | 471 packet.markerBit = kT; |
471 packet.seqNum = Rand(); | 472 packet.seqNum = Rand(); |
472 EXPECT_TRUE(packet_buffer_->InsertPacket(packet)); | 473 EXPECT_TRUE(packet_buffer_->InsertPacket(packet)); |
473 ASSERT_EQ(1UL, frames_from_callback_.size()); | 474 ASSERT_EQ(1UL, frames_from_callback_.size()); |
474 | 475 |
475 packet_buffer_->Flush(); | 476 packet_buffer_->Clear(); |
476 EXPECT_FALSE(frames_from_callback_.begin()->second->GetBitstream(nullptr)); | 477 EXPECT_FALSE(frames_from_callback_.begin()->second->GetBitstream(nullptr)); |
477 } | 478 } |
478 | 479 |
479 TEST_F(TestPacketBuffer, Vp8NoPictureId) { | 480 TEST_F(TestPacketBuffer, Vp8NoPictureId) { |
480 uint16_t seq_num = Rand(); | 481 uint16_t seq_num = Rand(); |
481 | 482 |
482 // seq_num , kf, frst, lst | 483 // seq_num , kf, frst, lst |
483 InsertVp8(seq_num , kT, kT , kF); | 484 InsertVp8(seq_num , kT, kT , kF); |
484 InsertVp8(seq_num + 1 , kF, kF , kF); | 485 InsertVp8(seq_num + 1 , kF, kF , kF); |
485 InsertVp8(seq_num + 2 , kF, kF , kT); | 486 InsertVp8(seq_num + 2 , kF, kF , kT); |
(...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1397 CheckReferencesVp9(pid + 5, 1, pid + 4); | 1398 CheckReferencesVp9(pid + 5, 1, pid + 4); |
1398 CheckReferencesVp9(pid + 6, 0, pid + 4); | 1399 CheckReferencesVp9(pid + 6, 0, pid + 4); |
1399 CheckReferencesVp9(pid + 6, 1, pid + 5); | 1400 CheckReferencesVp9(pid + 6, 1, pid + 5); |
1400 CheckReferencesVp9(pid + 7, 1, pid + 6); | 1401 CheckReferencesVp9(pid + 7, 1, pid + 6); |
1401 CheckReferencesVp9(pid + 8, 0, pid + 6); | 1402 CheckReferencesVp9(pid + 8, 0, pid + 6); |
1402 CheckReferencesVp9(pid + 8, 1, pid + 7); | 1403 CheckReferencesVp9(pid + 8, 1, pid + 7); |
1403 } | 1404 } |
1404 | 1405 |
1405 } // namespace video_coding | 1406 } // namespace video_coding |
1406 } // namespace webrtc | 1407 } // namespace webrtc |
OLD | NEW |