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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 const auto generate_payload = [] (size_t payload_length_bytes) { | 74 const auto generate_payload = [] (size_t payload_length_bytes) { |
75 rtc::Buffer payload(payload_length_bytes); | 75 rtc::Buffer payload(payload_length_bytes); |
76 // Fill payload with increasing integers {0, 1, 2, ...}. | 76 // Fill payload with increasing integers {0, 1, 2, ...}. |
77 for (size_t i = 0; i < payload.size(); ++i) { | 77 for (size_t i = 0; i < payload.size(); ++i) { |
78 payload[i] = static_cast<uint8_t>(i); | 78 payload[i] = static_cast<uint8_t>(i); |
79 } | 79 } |
80 return payload; | 80 return payload; |
81 }; | 81 }; |
82 | 82 |
83 const auto results = decoder.ParsePayload( | 83 const auto results = decoder.ParsePayload( |
84 generate_payload(frame_length_bytes_ * num_frames_), 0, true); | 84 generate_payload(frame_length_bytes_ * num_frames_), 0); |
85 EXPECT_EQ(num_frames_, results.size()); | 85 EXPECT_EQ(num_frames_, results.size()); |
86 | 86 |
87 size_t frame_num = 0; | 87 size_t frame_num = 0; |
88 uint8_t payload_value = 0; | 88 uint8_t payload_value = 0; |
89 for (const auto& result : results) { | 89 for (const auto& result : results) { |
90 EXPECT_EQ(frame_length_samples * frame_num, result.timestamp); | 90 EXPECT_EQ(frame_length_samples * frame_num, result.timestamp); |
91 const LegacyEncodedAudioFrame* frame = | 91 const LegacyEncodedAudioFrame* frame = |
92 static_cast<const LegacyEncodedAudioFrame*>(result.frame.get()); | 92 static_cast<const LegacyEncodedAudioFrame*>(result.frame.get()); |
93 const rtc::Buffer& payload = frame->payload(); | 93 const rtc::Buffer& payload = frame->payload(); |
94 EXPECT_EQ(frame_length_bytes_, payload.size()); | 94 EXPECT_EQ(frame_length_bytes_, payload.size()); |
(...skipping 21 matching lines...) Expand all Loading... |
116 std::pair<int, int>(3, 30), | 116 std::pair<int, int>(3, 30), |
117 std::pair<int, int>(4, 30), | 117 std::pair<int, int>(4, 30), |
118 std::pair<int, int>(5, 30), | 118 std::pair<int, int>(5, 30), |
119 std::pair<int, int>(18, 30))); | 119 std::pair<int, int>(18, 30))); |
120 | 120 |
121 // Test too large payload size. | 121 // Test too large payload size. |
122 TEST(IlbcTest, SplitTooLargePayload) { | 122 TEST(IlbcTest, SplitTooLargePayload) { |
123 AudioDecoderIlbc decoder; | 123 AudioDecoderIlbc decoder; |
124 constexpr size_t kPayloadLengthBytes = 950; | 124 constexpr size_t kPayloadLengthBytes = 950; |
125 const auto results = | 125 const auto results = |
126 decoder.ParsePayload(rtc::Buffer(kPayloadLengthBytes), 0, true); | 126 decoder.ParsePayload(rtc::Buffer(kPayloadLengthBytes), 0); |
127 EXPECT_TRUE(results.empty()); | 127 EXPECT_TRUE(results.empty()); |
128 } | 128 } |
129 | 129 |
130 // Payload not an integer number of frames. | 130 // Payload not an integer number of frames. |
131 TEST(IlbcTest, SplitUnevenPayload) { | 131 TEST(IlbcTest, SplitUnevenPayload) { |
132 AudioDecoderIlbc decoder; | 132 AudioDecoderIlbc decoder; |
133 constexpr size_t kPayloadLengthBytes = 39; // Not an even number of frames. | 133 constexpr size_t kPayloadLengthBytes = 39; // Not an even number of frames. |
134 const auto results = | 134 const auto results = |
135 decoder.ParsePayload(rtc::Buffer(kPayloadLengthBytes), 0, true); | 135 decoder.ParsePayload(rtc::Buffer(kPayloadLengthBytes), 0); |
136 EXPECT_TRUE(results.empty()); | 136 EXPECT_TRUE(results.empty()); |
137 } | 137 } |
138 | 138 |
139 } // namespace webrtc | 139 } // namespace webrtc |
OLD | NEW |