OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 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 <vector> | 11 #include <vector> |
12 | 12 |
13 #include "testing/gmock/include/gmock/gmock.h" | 13 #include "testing/gmock/include/gmock/gmock.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
15 #include "webrtc/modules/rtp_rtcp/source/rtp_format_vp9.h" | 15 #include "webrtc/modules/rtp_rtcp/source/rtp_format_vp9.h" |
16 #include "webrtc/typedefs.h" | 16 #include "webrtc/typedefs.h" |
17 | 17 |
18 namespace webrtc { | 18 namespace webrtc { |
19 namespace { | 19 namespace { |
20 void VerifyHeader(const RTPVideoHeaderVP9& expected, | 20 void VerifyHeader(const RTPVideoHeaderVP9& expected, |
21 const RTPVideoHeaderVP9& actual) { | 21 const RTPVideoHeaderVP9& actual) { |
22 EXPECT_EQ(expected.inter_layer_predicted, actual.inter_layer_predicted); | 22 EXPECT_EQ(expected.inter_layer_predicted, actual.inter_layer_predicted); |
23 EXPECT_EQ(expected.inter_pic_predicted, actual.inter_pic_predicted); | 23 EXPECT_EQ(expected.inter_pic_predicted, actual.inter_pic_predicted); |
24 EXPECT_EQ(expected.flexible_mode, actual.flexible_mode); | 24 EXPECT_EQ(expected.flexible_mode, actual.flexible_mode); |
25 EXPECT_EQ(expected.beginning_of_frame, actual.beginning_of_frame); | 25 EXPECT_EQ(expected.beginning_of_frame, actual.beginning_of_frame); |
26 EXPECT_EQ(expected.end_of_frame, actual.end_of_frame); | 26 EXPECT_EQ(expected.end_of_frame, actual.end_of_frame); |
27 EXPECT_EQ(expected.ss_data_available, actual.ss_data_available); | 27 EXPECT_EQ(expected.ss_data_available, actual.ss_data_available); |
28 EXPECT_EQ(expected.picture_id, actual.picture_id); | 28 EXPECT_EQ(expected.picture_id, actual.picture_id); |
29 EXPECT_EQ(expected.max_picture_id, actual.max_picture_id); | 29 EXPECT_EQ(expected.max_picture_id, actual.max_picture_id); |
30 EXPECT_EQ(expected.temporal_idx == kNoTemporalIdx ? 0 : expected.temporal_idx, | 30 EXPECT_EQ(expected.temporal_idx, actual.temporal_idx); |
31 actual.temporal_idx); | |
32 EXPECT_EQ(expected.spatial_idx == kNoSpatialIdx ? 0 : expected.spatial_idx, | 31 EXPECT_EQ(expected.spatial_idx == kNoSpatialIdx ? 0 : expected.spatial_idx, |
33 actual.spatial_idx); | 32 actual.spatial_idx); |
34 EXPECT_EQ(expected.gof_idx, actual.gof_idx); | 33 EXPECT_EQ(expected.gof_idx, actual.gof_idx); |
35 EXPECT_EQ(expected.tl0_pic_idx, actual.tl0_pic_idx); | 34 EXPECT_EQ(expected.tl0_pic_idx, actual.tl0_pic_idx); |
36 EXPECT_EQ(expected.temporal_up_switch, actual.temporal_up_switch); | 35 EXPECT_EQ(expected.temporal_up_switch, actual.temporal_up_switch); |
37 | 36 |
38 EXPECT_EQ(expected.num_ref_pics, actual.num_ref_pics); | 37 EXPECT_EQ(expected.num_ref_pics, actual.num_ref_pics); |
39 for (uint8_t i = 0; i < expected.num_ref_pics; ++i) { | 38 for (uint8_t i = 0; i < expected.num_ref_pics; ++i) { |
40 EXPECT_EQ(expected.pid_diff[i], actual.pid_diff[i]); | 39 EXPECT_EQ(expected.pid_diff[i], actual.pid_diff[i]); |
41 EXPECT_EQ(expected.ref_picture_id[i], actual.ref_picture_id[i]); | 40 EXPECT_EQ(expected.ref_picture_id[i], actual.ref_picture_id[i]); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 // +-+-+-+-+-+-+-+-+ | 120 // +-+-+-+-+-+-+-+-+ |
122 // V: | SS | | 121 // V: | SS | |
123 // | .. | | 122 // | .. | |
124 // +-+-+-+-+-+-+-+-+ | 123 // +-+-+-+-+-+-+-+-+ |
125 | 124 |
126 class RtpPacketizerVp9Test : public ::testing::Test { | 125 class RtpPacketizerVp9Test : public ::testing::Test { |
127 protected: | 126 protected: |
128 RtpPacketizerVp9Test() {} | 127 RtpPacketizerVp9Test() {} |
129 virtual void SetUp() { | 128 virtual void SetUp() { |
130 expected_.InitRTPVideoHeaderVP9(); | 129 expected_.InitRTPVideoHeaderVP9(); |
131 // Always input one layer frame at a time. | |
132 expected_.beginning_of_frame = true; | |
133 expected_.end_of_frame = true; | |
134 } | 130 } |
135 | 131 |
136 rtc::scoped_ptr<uint8_t[]> packet_; | 132 rtc::scoped_ptr<uint8_t[]> packet_; |
137 rtc::scoped_ptr<uint8_t[]> payload_; | 133 rtc::scoped_ptr<uint8_t[]> payload_; |
138 size_t payload_size_; | 134 size_t payload_size_; |
139 size_t payload_pos_; | 135 size_t payload_pos_; |
140 RTPVideoHeaderVP9 expected_; | 136 RTPVideoHeaderVP9 expected_; |
141 rtc::scoped_ptr<RtpPacketizerVp9> packetizer_; | 137 rtc::scoped_ptr<RtpPacketizerVp9> packetizer_; |
142 | 138 |
143 void Init(size_t payload_size, size_t packet_size) { | 139 void Init(size_t payload_size, size_t packet_size) { |
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
655 } | 651 } |
656 | 652 |
657 TEST_F(RtpDepacketizerVp9Test, ParseFailsForTooShortBufferToFitPayload) { | 653 TEST_F(RtpDepacketizerVp9Test, ParseFailsForTooShortBufferToFitPayload) { |
658 const uint8_t kHeaderLength = 1; | 654 const uint8_t kHeaderLength = 1; |
659 uint8_t packet[kHeaderLength] = {0}; | 655 uint8_t packet[kHeaderLength] = {0}; |
660 RtpDepacketizer::ParsedPayload parsed; | 656 RtpDepacketizer::ParsedPayload parsed; |
661 EXPECT_FALSE(depacketizer_->Parse(&parsed, packet, sizeof(packet))); | 657 EXPECT_FALSE(depacketizer_->Parse(&parsed, packet, sizeof(packet))); |
662 } | 658 } |
663 | 659 |
664 } // namespace webrtc | 660 } // namespace webrtc |
OLD | NEW |