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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 TEST_F(TestPacketBuffer, FrameSize) { | 138 TEST_F(TestPacketBuffer, FrameSize) { |
139 uint16_t seq_num = Rand(); | 139 uint16_t seq_num = Rand(); |
140 uint8_t data[] = {1, 2, 3, 4, 5}; | 140 uint8_t data[] = {1, 2, 3, 4, 5}; |
141 | 141 |
142 InsertPacket(seq_num, kKeyFrame, kFirst, kNotLast, 5, data); | 142 InsertPacket(seq_num, kKeyFrame, kFirst, kNotLast, 5, data); |
143 InsertPacket(seq_num + 1, kKeyFrame, kNotFirst, kNotLast, 5, data); | 143 InsertPacket(seq_num + 1, kKeyFrame, kNotFirst, kNotLast, 5, data); |
144 InsertPacket(seq_num + 2, kKeyFrame, kNotFirst, kNotLast, 5, data); | 144 InsertPacket(seq_num + 2, kKeyFrame, kNotFirst, kNotLast, 5, data); |
145 InsertPacket(seq_num + 3, kKeyFrame, kNotFirst, kLast, 5, data); | 145 InsertPacket(seq_num + 3, kKeyFrame, kNotFirst, kLast, 5, data); |
146 | 146 |
147 ASSERT_EQ(1UL, frames_from_callback_.size()); | 147 ASSERT_EQ(1UL, frames_from_callback_.size()); |
148 EXPECT_EQ(20UL, frames_from_callback_.begin()->second->size); | 148 EXPECT_EQ(20UL, frames_from_callback_.begin()->second->size()); |
149 } | 149 } |
150 | 150 |
151 TEST_F(TestPacketBuffer, ExpandBuffer) { | 151 TEST_F(TestPacketBuffer, ExpandBuffer) { |
152 uint16_t seq_num = Rand(); | 152 uint16_t seq_num = Rand(); |
153 | 153 |
154 for (int i = 0; i < kStartSize + 1; ++i) { | 154 for (int i = 0; i < kStartSize + 1; ++i) { |
155 InsertPacket(seq_num + i, kKeyFrame, kFirst, kLast); | 155 InsertPacket(seq_num + i, kKeyFrame, kFirst, kLast); |
156 } | 156 } |
157 } | 157 } |
158 | 158 |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 CheckFrame(seq_num + 3); | 279 CheckFrame(seq_num + 3); |
280 } | 280 } |
281 | 281 |
282 TEST_F(TestPacketBuffer, GetBitstreamFromFrame) { | 282 TEST_F(TestPacketBuffer, GetBitstreamFromFrame) { |
283 // "many bitstream, such data" with null termination. | 283 // "many bitstream, such data" with null termination. |
284 uint8_t many[] = {0x6d, 0x61, 0x6e, 0x79, 0x20}; | 284 uint8_t many[] = {0x6d, 0x61, 0x6e, 0x79, 0x20}; |
285 uint8_t bitstream[] = {0x62, 0x69, 0x74, 0x73, 0x74, 0x72, | 285 uint8_t bitstream[] = {0x62, 0x69, 0x74, 0x73, 0x74, 0x72, |
286 0x65, 0x61, 0x6d, 0x2c, 0x20}; | 286 0x65, 0x61, 0x6d, 0x2c, 0x20}; |
287 uint8_t such[] = {0x73, 0x75, 0x63, 0x68, 0x20}; | 287 uint8_t such[] = {0x73, 0x75, 0x63, 0x68, 0x20}; |
288 uint8_t data[] = {0x64, 0x61, 0x74, 0x61, 0x0}; | 288 uint8_t data[] = {0x64, 0x61, 0x74, 0x61, 0x0}; |
289 uint8_t | 289 const size_t total_size = |
290 result[sizeof(many) + sizeof(bitstream) + sizeof(such) + sizeof(data)]; | 290 sizeof(many) + sizeof(bitstream) + sizeof(such) + sizeof(data); |
291 | 291 |
292 uint16_t seq_num = Rand(); | 292 uint16_t seq_num = Rand(); |
293 | 293 |
294 InsertPacket(seq_num, kKeyFrame, kFirst, kNotLast, sizeof(many), many); | 294 InsertPacket(seq_num, kKeyFrame, kFirst, kNotLast, sizeof(many), many); |
295 InsertPacket(seq_num + 1, kDeltaFrame, kNotFirst, kNotLast, sizeof(bitstream), | 295 InsertPacket(seq_num + 1, kDeltaFrame, kNotFirst, kNotLast, sizeof(bitstream), |
296 bitstream); | 296 bitstream); |
297 InsertPacket(seq_num + 2, kDeltaFrame, kNotFirst, kNotLast, sizeof(such), | 297 InsertPacket(seq_num + 2, kDeltaFrame, kNotFirst, kNotLast, sizeof(such), |
298 such); | 298 such); |
299 InsertPacket(seq_num + 3, kDeltaFrame, kNotFirst, kLast, sizeof(data), data); | 299 InsertPacket(seq_num + 3, kDeltaFrame, kNotFirst, kLast, sizeof(data), data); |
300 | 300 |
301 ASSERT_EQ(1UL, frames_from_callback_.size()); | 301 ASSERT_EQ(1UL, frames_from_callback_.size()); |
302 CheckFrame(seq_num); | 302 CheckFrame(seq_num); |
303 EXPECT_TRUE(frames_from_callback_[seq_num]->GetBitstream(result)); | 303 EXPECT_EQ(frames_from_callback_[seq_num]->size(), total_size); |
304 EXPECT_EQ(memcmp(result, "many bitstream, such data", sizeof(result)), 0); | 304 EXPECT_EQ(memcmp(frames_from_callback_[seq_num]->EncodedImage()._buffer, |
| 305 "many bitstream, such data", total_size), 0); |
305 } | 306 } |
306 | 307 |
307 TEST_F(TestPacketBuffer, FreeSlotsOnFrameDestruction) { | 308 TEST_F(TestPacketBuffer, FreeSlotsOnFrameDestruction) { |
308 uint16_t seq_num = Rand(); | 309 uint16_t seq_num = Rand(); |
309 | 310 |
310 InsertPacket(seq_num, kKeyFrame, kFirst, kNotLast); | 311 InsertPacket(seq_num, kKeyFrame, kFirst, kNotLast); |
311 InsertPacket(seq_num + 1, kDeltaFrame, kNotFirst, kNotLast); | 312 InsertPacket(seq_num + 1, kDeltaFrame, kNotFirst, kNotLast); |
312 InsertPacket(seq_num + 2, kDeltaFrame, kNotFirst, kLast); | 313 InsertPacket(seq_num + 2, kDeltaFrame, kNotFirst, kLast); |
313 EXPECT_EQ(1UL, frames_from_callback_.size()); | 314 EXPECT_EQ(1UL, frames_from_callback_.size()); |
314 CheckFrame(seq_num); | 315 CheckFrame(seq_num); |
(...skipping 30 matching lines...) Expand all Loading... |
345 TEST_F(TestPacketBuffer, InvalidateFrameByClearing) { | 346 TEST_F(TestPacketBuffer, InvalidateFrameByClearing) { |
346 VCMPacket packet; | 347 VCMPacket packet; |
347 packet.frameType = kVideoFrameKey; | 348 packet.frameType = kVideoFrameKey; |
348 packet.isFirstPacket = true; | 349 packet.isFirstPacket = true; |
349 packet.markerBit = true; | 350 packet.markerBit = true; |
350 packet.seqNum = Rand(); | 351 packet.seqNum = Rand(); |
351 EXPECT_TRUE(packet_buffer_->InsertPacket(packet)); | 352 EXPECT_TRUE(packet_buffer_->InsertPacket(packet)); |
352 ASSERT_EQ(1UL, frames_from_callback_.size()); | 353 ASSERT_EQ(1UL, frames_from_callback_.size()); |
353 | 354 |
354 packet_buffer_->Clear(); | 355 packet_buffer_->Clear(); |
355 EXPECT_FALSE(frames_from_callback_.begin()->second->GetBitstream(nullptr)); | 356 EXPECT_EQ(frames_from_callback_.begin()->second->size(), 0U); |
356 } | 357 } |
357 | 358 |
358 } // namespace video_coding | 359 } // namespace video_coding |
359 } // namespace webrtc | 360 } // namespace webrtc |
OLD | NEW |