Chromium Code Reviews| 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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 298 EXPECT_TRUE(Insert(seq_num + 3, kDeltaFrame, kFirst, kLast)); | 298 EXPECT_TRUE(Insert(seq_num + 3, kDeltaFrame, kFirst, kLast)); |
| 299 EXPECT_TRUE(Insert(seq_num + 2, kDeltaFrame, kFirst, kLast)); | 299 EXPECT_TRUE(Insert(seq_num + 2, kDeltaFrame, kFirst, kLast)); |
| 300 | 300 |
| 301 ASSERT_EQ(4UL, frames_from_callback_.size()); | 301 ASSERT_EQ(4UL, frames_from_callback_.size()); |
| 302 CheckFrame(seq_num); | 302 CheckFrame(seq_num); |
| 303 CheckFrame(seq_num + 1); | 303 CheckFrame(seq_num + 1); |
| 304 CheckFrame(seq_num + 2); | 304 CheckFrame(seq_num + 2); |
| 305 CheckFrame(seq_num + 3); | 305 CheckFrame(seq_num + 3); |
| 306 } | 306 } |
| 307 | 307 |
| 308 TEST_F(TestPacketBuffer, GetBitstreamFromFrame) { | 308 TEST_F(TestPacketBuffer, GetBitstream) { |
| 309 // "many bitstream, such data" with null termination. | 309 // "many bitstream, such data" with null termination. |
| 310 uint8_t many[] = {0x6d, 0x61, 0x6e, 0x79, 0x20}; | 310 uint8_t many[] = {0x6d, 0x61, 0x6e, 0x79, 0x20}; |
| 311 uint8_t bitstream[] = {0x62, 0x69, 0x74, 0x73, 0x74, 0x72, | 311 uint8_t bitstream[] = {0x62, 0x69, 0x74, 0x73, 0x74, 0x72, |
| 312 0x65, 0x61, 0x6d, 0x2c, 0x20}; | 312 0x65, 0x61, 0x6d, 0x2c, 0x20}; |
| 313 uint8_t such[] = {0x73, 0x75, 0x63, 0x68, 0x20}; | 313 uint8_t such[] = {0x73, 0x75, 0x63, 0x68, 0x20}; |
| 314 uint8_t data[] = {0x64, 0x61, 0x74, 0x61, 0x0}; | 314 uint8_t data[] = {0x64, 0x61, 0x74, 0x61, 0x0}; |
| 315 uint8_t | 315 uint8_t |
| 316 result[sizeof(many) + sizeof(bitstream) + sizeof(such) + sizeof(data)]; | 316 result[sizeof(many) + sizeof(bitstream) + sizeof(such) + sizeof(data)]; |
| 317 | 317 |
| 318 const uint16_t seq_num = Rand(); | 318 const uint16_t seq_num = Rand(); |
| 319 | 319 |
| 320 EXPECT_TRUE(Insert(seq_num, kKeyFrame, kFirst, kNotLast, sizeof(many), many)); | 320 EXPECT_TRUE(Insert(seq_num, kKeyFrame, kFirst, kNotLast, sizeof(many), many)); |
| 321 EXPECT_TRUE(Insert(seq_num + 1, kDeltaFrame, kNotFirst, kNotLast, | 321 EXPECT_TRUE(Insert(seq_num + 1, kDeltaFrame, kNotFirst, kNotLast, |
| 322 sizeof(bitstream), bitstream)); | 322 sizeof(bitstream), bitstream)); |
| 323 EXPECT_TRUE(Insert(seq_num + 2, kDeltaFrame, kNotFirst, kNotLast, | 323 EXPECT_TRUE(Insert(seq_num + 2, kDeltaFrame, kNotFirst, kNotLast, |
| 324 sizeof(such), such)); | 324 sizeof(such), such)); |
| 325 EXPECT_TRUE( | 325 EXPECT_TRUE( |
| 326 Insert(seq_num + 3, kDeltaFrame, kNotFirst, kLast, sizeof(data), data)); | 326 Insert(seq_num + 3, kDeltaFrame, kNotFirst, kLast, sizeof(data), data)); |
| 327 | 327 |
| 328 ASSERT_EQ(1UL, frames_from_callback_.size()); | 328 ASSERT_EQ(1UL, frames_from_callback_.size()); |
| 329 CheckFrame(seq_num); | 329 CheckFrame(seq_num); |
| 330 EXPECT_TRUE(frames_from_callback_[seq_num]->GetBitstream(result)); | 330 EXPECT_TRUE(frames_from_callback_[seq_num]->GetBitstream(result)); |
| 331 EXPECT_EQ(memcmp(result, "many bitstream, such data", sizeof(result)), 0); | 331 EXPECT_EQ(memcmp(result, "many bitstream, such data", sizeof(result)), 0); |
| 332 } | 332 } |
| 333 | 333 |
| 334 TEST_F(TestPacketBuffer, GetBitstreamH264BufferPadding) { | |
| 335 uint16_t seq_num = Rand(); | |
| 336 uint8_t doge[] = | |
| 337 " Y. _ " | |
| 338 " YiL .```. " | |
| 339 " Yii; .; .;;`. " | |
| 340 " YY;ii._ .;`.;;;; : " | |
| 341 " iiYYYYYYiiiii;;;;i` ;;::;;;; " | |
| 342 " _.;YYYYYYiiiiiiYYYii .;;. ;;; " | |
| 343 " .YYYYYYYYYYiiYYYYYYYYYYYYii;` ;;;; " | |
| 344 " .YYYYYYY$$YYiiYY$$$$iiiYYYYYY;.ii;`.. " | |
| 345 " :YYY$!. TYiiYY$$$$$YYYYYYYiiYYYYiYYii. " | |
| 346 " Y$MM$: :YYYYYY$!'``'4YYYYYiiiYYYYiiYY. " | |
| 347 " `. :MM$$b.,dYY$$Yii' :' :YYYYllYiiYYYiYY " | |
| 348 "_.._ :`4MM$!YYYYYYYYYii,.__.diii$$YYYYYYYYYYY " | |
| 349 ".,._ $b`P` '4$$$$$iiiiiiii$$$$YY$$$$$$YiY; " | |
| 350 " `,.`$: :$$$$$$$$$YYYYY$$$$$$$$$YYiiYYL " | |
| 351 " '`;$$. .;PPb$`.,.``T$$YY$$$$YYYYYYiiiYYU: " | |
| 352 " ;$P$;;: ;;;;i$y$'!Y$$$b;$$$Y$YY$$YYYiiiYYiYY " | |
| 353 " $Fi$$ .. ``:iii.`-':YYYYY$$YY$$$$$YYYiiYiYYY " | |
| 354 " :Y$$rb ```` `_..;;i;YYY$YY$$$$$$$YYYYYYYiYY: " | |
| 355 " :$$$$$i;;iiiiidYYYYYYYYYY$$$$$$YYYYYYYiiYYYY." | |
| 356 " `$$$$$$$YYYYYYYYYYYYY$$$$$$YYYYYYYYiiiYYYYYY" | |
| 357 " .i!$$$$$$YYYYYYYYY$$$$$$YYY$$YYiiiiiiYYYYYYY" | |
| 358 " :YYiii$$$$$$$YYYYYYY$$$$YY$$$$YYiiiiiYYYYYYi'"; | |
|
stefan-webrtc
2016/11/03 13:04:02
While it's fun, maybe it's not worth spending 10 l
| |
| 359 uint8_t result[sizeof(doge) + EncodedImage::kBufferPaddingBytesH264]; | |
| 360 | |
| 361 VCMPacket packet; | |
| 362 packet.seqNum = seq_num; | |
| 363 packet.codec = kVideoCodecH264; | |
| 364 packet.insertStartCode = true; | |
| 365 packet.video_header.codecHeader.H264.packetization_type = kH264SingleNalu; | |
| 366 packet.dataPtr = doge; | |
| 367 packet.sizeBytes = sizeof(doge); | |
| 368 packet.isFirstPacket = true; | |
| 369 packet.markerBit = true; | |
| 370 packet_buffer_->InsertPacket(packet); | |
| 371 | |
| 372 ASSERT_EQ(1UL, frames_from_callback_.size()); | |
| 373 EXPECT_EQ(frames_from_callback_[seq_num]->EncodedImage()._length, | |
| 374 sizeof(doge)); | |
| 375 EXPECT_EQ(frames_from_callback_[seq_num]->EncodedImage()._size, | |
| 376 sizeof(doge) + EncodedImage::kBufferPaddingBytesH264); | |
| 377 EXPECT_TRUE(frames_from_callback_[seq_num]->GetBitstream(result)); | |
| 378 EXPECT_EQ(memcmp(result, doge, sizeof(doge)), 0); | |
| 379 } | |
| 380 | |
| 334 TEST_F(TestPacketBuffer, FreeSlotsOnFrameDestruction) { | 381 TEST_F(TestPacketBuffer, FreeSlotsOnFrameDestruction) { |
| 335 const uint16_t seq_num = Rand(); | 382 const uint16_t seq_num = Rand(); |
| 336 | 383 |
| 337 EXPECT_TRUE(Insert(seq_num, kKeyFrame, kFirst, kNotLast)); | 384 EXPECT_TRUE(Insert(seq_num, kKeyFrame, kFirst, kNotLast)); |
| 338 EXPECT_TRUE(Insert(seq_num + 1, kDeltaFrame, kNotFirst, kNotLast)); | 385 EXPECT_TRUE(Insert(seq_num + 1, kDeltaFrame, kNotFirst, kNotLast)); |
| 339 EXPECT_TRUE(Insert(seq_num + 2, kDeltaFrame, kNotFirst, kLast)); | 386 EXPECT_TRUE(Insert(seq_num + 2, kDeltaFrame, kNotFirst, kLast)); |
| 340 EXPECT_EQ(1UL, frames_from_callback_.size()); | 387 EXPECT_EQ(1UL, frames_from_callback_.size()); |
| 341 CheckFrame(seq_num); | 388 CheckFrame(seq_num); |
| 342 | 389 |
| 343 frames_from_callback_.clear(); | 390 frames_from_callback_.clear(); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 375 | 422 |
| 376 EXPECT_TRUE(Insert(seq_num, kKeyFrame, kFirst, kLast)); | 423 EXPECT_TRUE(Insert(seq_num, kKeyFrame, kFirst, kLast)); |
| 377 ASSERT_EQ(1UL, frames_from_callback_.size()); | 424 ASSERT_EQ(1UL, frames_from_callback_.size()); |
| 378 | 425 |
| 379 packet_buffer_->Clear(); | 426 packet_buffer_->Clear(); |
| 380 EXPECT_FALSE(frames_from_callback_.begin()->second->GetBitstream(nullptr)); | 427 EXPECT_FALSE(frames_from_callback_.begin()->second->GetBitstream(nullptr)); |
| 381 } | 428 } |
| 382 | 429 |
| 383 } // namespace video_coding | 430 } // namespace video_coding |
| 384 } // namespace webrtc | 431 } // namespace webrtc |
| OLD | NEW |