Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(122)

Side by Side Diff: media/formats/mp4/track_run_iterator_unittest.cc

Issue 1235793005: Deprecate LogCB in favor of using MediaLog (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments and attempt to fix Android compilation Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/formats/mp4/track_run_iterator.cc ('k') | media/formats/mpeg/adts_stream_parser.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/logging.h" 6 #include "base/logging.h"
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/strings/string_split.h" 8 #include "base/strings/string_split.h"
9 #include "media/formats/mp4/box_definitions.h" 9 #include "media/formats/mp4/box_definitions.h"
10 #include "media/formats/mp4/rcheck.h" 10 #include "media/formats/mp4/rcheck.h"
(...skipping 28 matching lines...) Expand all
39 static const uint8 kCencSampleGroupKeyId[] = { 39 static const uint8 kCencSampleGroupKeyId[] = {
40 0x46, 0x72, 0x61, 0x67, 0x53, 0x61, 0x6d, 0x70, 40 0x46, 0x72, 0x61, 0x67, 0x53, 0x61, 0x6d, 0x70,
41 0x6c, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x4b 41 0x6c, 0x65, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x4b
42 }; 42 };
43 43
44 namespace media { 44 namespace media {
45 namespace mp4 { 45 namespace mp4 {
46 46
47 class TrackRunIteratorTest : public testing::Test { 47 class TrackRunIteratorTest : public testing::Test {
48 public: 48 public:
49 TrackRunIteratorTest() { 49 TrackRunIteratorTest() : media_log_(new MediaLog()) { CreateMovie(); }
50 CreateMovie();
51 }
52 50
53 protected: 51 protected:
54 Movie moov_; 52 Movie moov_;
55 LogCB log_cb_; 53 scoped_refptr<MediaLog> media_log_;
56 scoped_ptr<TrackRunIterator> iter_; 54 scoped_ptr<TrackRunIterator> iter_;
57 55
58 void CreateMovie() { 56 void CreateMovie() {
59 moov_.header.timescale = 1000; 57 moov_.header.timescale = 1000;
60 moov_.tracks.resize(3); 58 moov_.tracks.resize(3);
61 moov_.extends.tracks.resize(2); 59 moov_.extends.tracks.resize(2);
62 moov_.tracks[0].header.track_id = 1; 60 moov_.tracks[0].header.track_id = 1;
63 moov_.tracks[0].media.header.timescale = kAudioScale; 61 moov_.tracks[0].media.header.timescale = kAudioScale;
64 SampleDescription& desc1 = 62 SampleDescription& desc1 =
65 moov_.tracks[0].media.information.sample_table.description; 63 moov_.tracks[0].media.information.sample_table.description;
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 } 267 }
270 268
271 void SetAscending(std::vector<uint32>* vec) { 269 void SetAscending(std::vector<uint32>* vec) {
272 vec->resize(10); 270 vec->resize(10);
273 for (size_t i = 0; i < vec->size(); i++) 271 for (size_t i = 0; i < vec->size(); i++)
274 (*vec)[i] = i+1; 272 (*vec)[i] = i+1;
275 } 273 }
276 }; 274 };
277 275
278 TEST_F(TrackRunIteratorTest, NoRunsTest) { 276 TEST_F(TrackRunIteratorTest, NoRunsTest) {
279 iter_.reset(new TrackRunIterator(&moov_, log_cb_)); 277 iter_.reset(new TrackRunIterator(&moov_, media_log_));
280 ASSERT_TRUE(iter_->Init(MovieFragment())); 278 ASSERT_TRUE(iter_->Init(MovieFragment()));
281 EXPECT_FALSE(iter_->IsRunValid()); 279 EXPECT_FALSE(iter_->IsRunValid());
282 EXPECT_FALSE(iter_->IsSampleValid()); 280 EXPECT_FALSE(iter_->IsSampleValid());
283 } 281 }
284 282
285 TEST_F(TrackRunIteratorTest, BasicOperationTest) { 283 TEST_F(TrackRunIteratorTest, BasicOperationTest) {
286 iter_.reset(new TrackRunIterator(&moov_, log_cb_)); 284 iter_.reset(new TrackRunIterator(&moov_, media_log_));
287 MovieFragment moof = CreateFragment(); 285 MovieFragment moof = CreateFragment();
288 286
289 // Test that runs are sorted correctly, and that properties of the initial 287 // Test that runs are sorted correctly, and that properties of the initial
290 // sample of the first run are correct 288 // sample of the first run are correct
291 ASSERT_TRUE(iter_->Init(moof)); 289 ASSERT_TRUE(iter_->Init(moof));
292 EXPECT_TRUE(iter_->IsRunValid()); 290 EXPECT_TRUE(iter_->IsRunValid());
293 EXPECT_FALSE(iter_->is_encrypted()); 291 EXPECT_FALSE(iter_->is_encrypted());
294 EXPECT_EQ(iter_->track_id(), 1u); 292 EXPECT_EQ(iter_->track_id(), 1u);
295 EXPECT_EQ(iter_->sample_offset(), 100); 293 EXPECT_EQ(iter_->sample_offset(), 100);
296 EXPECT_EQ(iter_->sample_size(), 1); 294 EXPECT_EQ(iter_->sample_size(), 1);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 moof.tracks[0].header.default_sample_size, 331 moof.tracks[0].header.default_sample_size,
334 iter_->sample_offset()); 332 iter_->sample_offset());
335 iter_->AdvanceRun(); 333 iter_->AdvanceRun();
336 EXPECT_FALSE(iter_->IsRunValid()); 334 EXPECT_FALSE(iter_->IsRunValid());
337 } 335 }
338 336
339 TEST_F(TrackRunIteratorTest, TrackExtendsDefaultsTest) { 337 TEST_F(TrackRunIteratorTest, TrackExtendsDefaultsTest) {
340 moov_.extends.tracks[0].default_sample_duration = 50; 338 moov_.extends.tracks[0].default_sample_duration = 50;
341 moov_.extends.tracks[0].default_sample_size = 3; 339 moov_.extends.tracks[0].default_sample_size = 3;
342 moov_.extends.tracks[0].default_sample_flags = ToSampleFlags("UN"); 340 moov_.extends.tracks[0].default_sample_flags = ToSampleFlags("UN");
343 iter_.reset(new TrackRunIterator(&moov_, log_cb_)); 341 iter_.reset(new TrackRunIterator(&moov_, media_log_));
344 MovieFragment moof = CreateFragment(); 342 MovieFragment moof = CreateFragment();
345 moof.tracks[0].header.has_default_sample_flags = false; 343 moof.tracks[0].header.has_default_sample_flags = false;
346 moof.tracks[0].header.default_sample_size = 0; 344 moof.tracks[0].header.default_sample_size = 0;
347 moof.tracks[0].header.default_sample_duration = 0; 345 moof.tracks[0].header.default_sample_duration = 0;
348 moof.tracks[0].runs[0].sample_sizes.clear(); 346 moof.tracks[0].runs[0].sample_sizes.clear();
349 ASSERT_TRUE(iter_->Init(moof)); 347 ASSERT_TRUE(iter_->Init(moof));
350 iter_->AdvanceSample(); 348 iter_->AdvanceSample();
351 EXPECT_FALSE(iter_->is_keyframe()); 349 EXPECT_FALSE(iter_->is_keyframe());
352 EXPECT_EQ(iter_->sample_size(), 3); 350 EXPECT_EQ(iter_->sample_size(), 3);
353 EXPECT_EQ(iter_->sample_offset(), moof.tracks[0].runs[0].data_offset + 3); 351 EXPECT_EQ(iter_->sample_offset(), moof.tracks[0].runs[0].data_offset + 3);
354 EXPECT_EQ(iter_->duration(), TimeDeltaFromRational(50, kAudioScale)); 352 EXPECT_EQ(iter_->duration(), TimeDeltaFromRational(50, kAudioScale));
355 EXPECT_EQ(iter_->dts(), DecodeTimestampFromRational(50, kAudioScale)); 353 EXPECT_EQ(iter_->dts(), DecodeTimestampFromRational(50, kAudioScale));
356 } 354 }
357 355
358 TEST_F(TrackRunIteratorTest, FirstSampleFlagTest) { 356 TEST_F(TrackRunIteratorTest, FirstSampleFlagTest) {
359 // Ensure that keyframes are flagged correctly in the face of BMFF boxes which 357 // Ensure that keyframes are flagged correctly in the face of BMFF boxes which
360 // explicitly specify the flags for the first sample in a run and rely on 358 // explicitly specify the flags for the first sample in a run and rely on
361 // defaults for all subsequent samples 359 // defaults for all subsequent samples
362 iter_.reset(new TrackRunIterator(&moov_, log_cb_)); 360 iter_.reset(new TrackRunIterator(&moov_, media_log_));
363 MovieFragment moof = CreateFragment(); 361 MovieFragment moof = CreateFragment();
364 moof.tracks[1].header.has_default_sample_flags = true; 362 moof.tracks[1].header.has_default_sample_flags = true;
365 moof.tracks[1].header.default_sample_flags = ToSampleFlags("UN"); 363 moof.tracks[1].header.default_sample_flags = ToSampleFlags("UN");
366 SetFlagsOnSamples("US", &moof.tracks[1].runs[0]); 364 SetFlagsOnSamples("US", &moof.tracks[1].runs[0]);
367 365
368 ASSERT_TRUE(iter_->Init(moof)); 366 ASSERT_TRUE(iter_->Init(moof));
369 EXPECT_EQ("1 KR KR KR KR KR KR KR KR KR KR", KeyframeAndRAPInfo(iter_.get())); 367 EXPECT_EQ("1 KR KR KR KR KR KR KR KR KR KR", KeyframeAndRAPInfo(iter_.get()));
370 368
371 iter_->AdvanceRun(); 369 iter_->AdvanceRun();
372 EXPECT_EQ("2 KR P P P P P P P P P", KeyframeAndRAPInfo(iter_.get())); 370 EXPECT_EQ("2 KR P P P P P P P P P", KeyframeAndRAPInfo(iter_.get()));
373 } 371 }
374 372
375 // Verify that parsing fails if a reserved value is in the sample flags. 373 // Verify that parsing fails if a reserved value is in the sample flags.
376 TEST_F(TrackRunIteratorTest, SampleInfoTest_ReservedInSampleFlags) { 374 TEST_F(TrackRunIteratorTest, SampleInfoTest_ReservedInSampleFlags) {
377 iter_.reset(new TrackRunIterator(&moov_, log_cb_)); 375 iter_.reset(new TrackRunIterator(&moov_, media_log_));
378 MovieFragment moof = CreateFragment(); 376 MovieFragment moof = CreateFragment();
379 // Change the "depends on" field on one of the samples to a 377 // Change the "depends on" field on one of the samples to a
380 // reserved value. 378 // reserved value.
381 moof.tracks[1].runs[0].sample_flags[0] = ToSampleFlags("RS"); 379 moof.tracks[1].runs[0].sample_flags[0] = ToSampleFlags("RS");
382 ASSERT_FALSE(iter_->Init(moof)); 380 ASSERT_FALSE(iter_->Init(moof));
383 } 381 }
384 382
385 // Verify that parsing fails if a reserved value is in the default sample flags. 383 // Verify that parsing fails if a reserved value is in the default sample flags.
386 TEST_F(TrackRunIteratorTest, SampleInfoTest_ReservedInDefaultSampleFlags) { 384 TEST_F(TrackRunIteratorTest, SampleInfoTest_ReservedInDefaultSampleFlags) {
387 iter_.reset(new TrackRunIterator(&moov_, log_cb_)); 385 iter_.reset(new TrackRunIterator(&moov_, media_log_));
388 MovieFragment moof = CreateFragment(); 386 MovieFragment moof = CreateFragment();
389 // Set the default flag to contain a reserved "depends on" value. 387 // Set the default flag to contain a reserved "depends on" value.
390 moof.tracks[0].header.default_sample_flags = ToSampleFlags("RN"); 388 moof.tracks[0].header.default_sample_flags = ToSampleFlags("RN");
391 ASSERT_FALSE(iter_->Init(moof)); 389 ASSERT_FALSE(iter_->Init(moof));
392 } 390 }
393 391
394 TEST_F(TrackRunIteratorTest, ReorderingTest) { 392 TEST_F(TrackRunIteratorTest, ReorderingTest) {
395 // Test frame reordering and edit list support. The frames have the following 393 // Test frame reordering and edit list support. The frames have the following
396 // decode timestamps: 394 // decode timestamps:
397 // 395 //
398 // 0ms 40ms 120ms 240ms 396 // 0ms 40ms 120ms 240ms
399 // | 0 | 1 - | 2 - - | 397 // | 0 | 1 - | 2 - - |
400 // 398 //
401 // ...and these composition timestamps, after edit list adjustment: 399 // ...and these composition timestamps, after edit list adjustment:
402 // 400 //
403 // 0ms 40ms 160ms 240ms 401 // 0ms 40ms 160ms 240ms
404 // | 0 | 2 - - | 1 - | 402 // | 0 | 2 - - | 1 - |
405 403
406 // Create an edit list with one entry, with an initial start time of 80ms 404 // Create an edit list with one entry, with an initial start time of 80ms
407 // (that is, 2 / kVideoTimescale) and a duration of zero (which is treated as 405 // (that is, 2 / kVideoTimescale) and a duration of zero (which is treated as
408 // infinite according to 14496-12:2012). This will cause the first 80ms of the 406 // infinite according to 14496-12:2012). This will cause the first 80ms of the
409 // media timeline - which will be empty, due to CTS biasing - to be discarded. 407 // media timeline - which will be empty, due to CTS biasing - to be discarded.
410 iter_.reset(new TrackRunIterator(&moov_, log_cb_)); 408 iter_.reset(new TrackRunIterator(&moov_, media_log_));
411 EditListEntry entry; 409 EditListEntry entry;
412 entry.segment_duration = 0; 410 entry.segment_duration = 0;
413 entry.media_time = 2; 411 entry.media_time = 2;
414 entry.media_rate_integer = 1; 412 entry.media_rate_integer = 1;
415 entry.media_rate_fraction = 0; 413 entry.media_rate_fraction = 0;
416 moov_.tracks[1].edit.list.edits.push_back(entry); 414 moov_.tracks[1].edit.list.edits.push_back(entry);
417 415
418 // Add CTS offsets. Without bias, the CTS offsets for the first three frames 416 // Add CTS offsets. Without bias, the CTS offsets for the first three frames
419 // would simply be [0, 3, -2]. Since CTS offsets should be non-negative for 417 // would simply be [0, 3, -2]. Since CTS offsets should be non-negative for
420 // maximum compatibility, these values are biased up to [2, 5, 0], and the 418 // maximum compatibility, these values are biased up to [2, 5, 0], and the
(...skipping 16 matching lines...) Expand all
437 EXPECT_EQ(iter_->dts(), DecodeTimestampFromRational(1, kVideoScale)); 435 EXPECT_EQ(iter_->dts(), DecodeTimestampFromRational(1, kVideoScale));
438 EXPECT_EQ(iter_->cts(), TimeDeltaFromRational(4, kVideoScale)); 436 EXPECT_EQ(iter_->cts(), TimeDeltaFromRational(4, kVideoScale));
439 EXPECT_EQ(iter_->duration(), TimeDeltaFromRational(2, kVideoScale)); 437 EXPECT_EQ(iter_->duration(), TimeDeltaFromRational(2, kVideoScale));
440 iter_->AdvanceSample(); 438 iter_->AdvanceSample();
441 EXPECT_EQ(iter_->dts(), DecodeTimestampFromRational(3, kVideoScale)); 439 EXPECT_EQ(iter_->dts(), DecodeTimestampFromRational(3, kVideoScale));
442 EXPECT_EQ(iter_->cts(), TimeDeltaFromRational(1, kVideoScale)); 440 EXPECT_EQ(iter_->cts(), TimeDeltaFromRational(1, kVideoScale));
443 EXPECT_EQ(iter_->duration(), TimeDeltaFromRational(3, kVideoScale)); 441 EXPECT_EQ(iter_->duration(), TimeDeltaFromRational(3, kVideoScale));
444 } 442 }
445 443
446 TEST_F(TrackRunIteratorTest, IgnoreUnknownAuxInfoTest) { 444 TEST_F(TrackRunIteratorTest, IgnoreUnknownAuxInfoTest) {
447 iter_.reset(new TrackRunIterator(&moov_, log_cb_)); 445 iter_.reset(new TrackRunIterator(&moov_, media_log_));
448 MovieFragment moof = CreateFragment(); 446 MovieFragment moof = CreateFragment();
449 moof.tracks[1].auxiliary_offset.offsets.push_back(50); 447 moof.tracks[1].auxiliary_offset.offsets.push_back(50);
450 moof.tracks[1].auxiliary_size.default_sample_info_size = 2; 448 moof.tracks[1].auxiliary_size.default_sample_info_size = 2;
451 moof.tracks[1].auxiliary_size.sample_count = 2; 449 moof.tracks[1].auxiliary_size.sample_count = 2;
452 moof.tracks[1].runs[0].sample_count = 2; 450 moof.tracks[1].runs[0].sample_count = 2;
453 ASSERT_TRUE(iter_->Init(moof)); 451 ASSERT_TRUE(iter_->Init(moof));
454 iter_->AdvanceRun(); 452 iter_->AdvanceRun();
455 EXPECT_FALSE(iter_->AuxInfoNeedsToBeCached()); 453 EXPECT_FALSE(iter_->AuxInfoNeedsToBeCached());
456 } 454 }
457 455
458 TEST_F(TrackRunIteratorTest, DecryptConfigTest) { 456 TEST_F(TrackRunIteratorTest, DecryptConfigTest) {
459 AddEncryption(&moov_.tracks[1]); 457 AddEncryption(&moov_.tracks[1]);
460 iter_.reset(new TrackRunIterator(&moov_, log_cb_)); 458 iter_.reset(new TrackRunIterator(&moov_, media_log_));
461 459
462 MovieFragment moof = CreateFragment(); 460 MovieFragment moof = CreateFragment();
463 AddAuxInfoHeaders(50, &moof.tracks[1]); 461 AddAuxInfoHeaders(50, &moof.tracks[1]);
464 462
465 ASSERT_TRUE(iter_->Init(moof)); 463 ASSERT_TRUE(iter_->Init(moof));
466 464
467 // The run for track 2 will be first, since its aux info offset is the first 465 // The run for track 2 will be first, since its aux info offset is the first
468 // element in the file. 466 // element in the file.
469 EXPECT_EQ(iter_->track_id(), 2u); 467 EXPECT_EQ(iter_->track_id(), 2u);
470 EXPECT_TRUE(iter_->is_encrypted()); 468 EXPECT_TRUE(iter_->is_encrypted());
(...skipping 26 matching lines...) Expand all
497 MovieFragment moof = CreateFragment(); 495 MovieFragment moof = CreateFragment();
498 496
499 const SampleToGroupEntry kSampleToGroupTable[] = { 497 const SampleToGroupEntry kSampleToGroupTable[] = {
500 // Associated with the second entry in SampleGroupDescription Box. 498 // Associated with the second entry in SampleGroupDescription Box.
501 {1, SampleToGroupEntry::kFragmentGroupDescriptionIndexBase + 2}, 499 {1, SampleToGroupEntry::kFragmentGroupDescriptionIndexBase + 2},
502 // Associated with the first entry in SampleGroupDescription Box. 500 // Associated with the first entry in SampleGroupDescription Box.
503 {1, SampleToGroupEntry::kFragmentGroupDescriptionIndexBase + 1}}; 501 {1, SampleToGroupEntry::kFragmentGroupDescriptionIndexBase + 1}};
504 AddCencSampleGroup( 502 AddCencSampleGroup(
505 &moof.tracks[0], kSampleToGroupTable, arraysize(kSampleToGroupTable)); 503 &moof.tracks[0], kSampleToGroupTable, arraysize(kSampleToGroupTable));
506 504
507 iter_.reset(new TrackRunIterator(&moov_, log_cb_)); 505 iter_.reset(new TrackRunIterator(&moov_, media_log_));
508 ASSERT_TRUE(InitMoofWithArbitraryAuxInfo(&moof)); 506 ASSERT_TRUE(InitMoofWithArbitraryAuxInfo(&moof));
509 507
510 std::string cenc_sample_group_key_id( 508 std::string cenc_sample_group_key_id(
511 kCencSampleGroupKeyId, 509 kCencSampleGroupKeyId,
512 kCencSampleGroupKeyId + arraysize(kCencSampleGroupKeyId)); 510 kCencSampleGroupKeyId + arraysize(kCencSampleGroupKeyId));
513 // The first sample is encrypted and the second sample is unencrypted. 511 // The first sample is encrypted and the second sample is unencrypted.
514 EXPECT_TRUE(iter_->is_encrypted()); 512 EXPECT_TRUE(iter_->is_encrypted());
515 EXPECT_EQ(cenc_sample_group_key_id, iter_->GetDecryptConfig()->key_id()); 513 EXPECT_EQ(cenc_sample_group_key_id, iter_->GetDecryptConfig()->key_id());
516 iter_->AdvanceSample(); 514 iter_->AdvanceSample();
517 EXPECT_FALSE(iter_->is_encrypted()); 515 EXPECT_FALSE(iter_->is_encrypted());
518 } 516 }
519 517
520 TEST_F(TrackRunIteratorTest, CencSampleGroupWithTrackEncryptionBoxTest) { 518 TEST_F(TrackRunIteratorTest, CencSampleGroupWithTrackEncryptionBoxTest) {
521 // Add TrackEncryption Box. 519 // Add TrackEncryption Box.
522 AddEncryption(&moov_.tracks[0]); 520 AddEncryption(&moov_.tracks[0]);
523 521
524 MovieFragment moof = CreateFragment(); 522 MovieFragment moof = CreateFragment();
525 523
526 const SampleToGroupEntry kSampleToGroupTable[] = { 524 const SampleToGroupEntry kSampleToGroupTable[] = {
527 // Associated with the second entry in SampleGroupDescription Box. 525 // Associated with the second entry in SampleGroupDescription Box.
528 {2, SampleToGroupEntry::kFragmentGroupDescriptionIndexBase + 2}, 526 {2, SampleToGroupEntry::kFragmentGroupDescriptionIndexBase + 2},
529 // Associated with the default values specified in TrackEncryption Box. 527 // Associated with the default values specified in TrackEncryption Box.
530 {4, 0}, 528 {4, 0},
531 // Associated with the first entry in SampleGroupDescription Box. 529 // Associated with the first entry in SampleGroupDescription Box.
532 {3, SampleToGroupEntry::kFragmentGroupDescriptionIndexBase + 1}}; 530 {3, SampleToGroupEntry::kFragmentGroupDescriptionIndexBase + 1}};
533 AddCencSampleGroup( 531 AddCencSampleGroup(
534 &moof.tracks[0], kSampleToGroupTable, arraysize(kSampleToGroupTable)); 532 &moof.tracks[0], kSampleToGroupTable, arraysize(kSampleToGroupTable));
535 533
536 iter_.reset(new TrackRunIterator(&moov_, log_cb_)); 534 iter_.reset(new TrackRunIterator(&moov_, media_log_));
537 ASSERT_TRUE(InitMoofWithArbitraryAuxInfo(&moof)); 535 ASSERT_TRUE(InitMoofWithArbitraryAuxInfo(&moof));
538 536
539 std::string track_encryption_key_id(kKeyId, kKeyId + arraysize(kKeyId)); 537 std::string track_encryption_key_id(kKeyId, kKeyId + arraysize(kKeyId));
540 std::string cenc_sample_group_key_id( 538 std::string cenc_sample_group_key_id(
541 kCencSampleGroupKeyId, 539 kCencSampleGroupKeyId,
542 kCencSampleGroupKeyId + arraysize(kCencSampleGroupKeyId)); 540 kCencSampleGroupKeyId + arraysize(kCencSampleGroupKeyId));
543 541
544 for (size_t i = 0; i < kSampleToGroupTable[0].sample_count; ++i) { 542 for (size_t i = 0; i < kSampleToGroupTable[0].sample_count; ++i) {
545 EXPECT_TRUE(iter_->is_encrypted()); 543 EXPECT_TRUE(iter_->is_encrypted());
546 EXPECT_EQ(cenc_sample_group_key_id, iter_->GetDecryptConfig()->key_id()); 544 EXPECT_EQ(cenc_sample_group_key_id, iter_->GetDecryptConfig()->key_id());
(...skipping 14 matching lines...) Expand all
561 // The remaining samples should be associated with the default values 559 // The remaining samples should be associated with the default values
562 // specified in TrackEncryption Box. 560 // specified in TrackEncryption Box.
563 EXPECT_TRUE(iter_->is_encrypted()); 561 EXPECT_TRUE(iter_->is_encrypted());
564 EXPECT_EQ(track_encryption_key_id, iter_->GetDecryptConfig()->key_id()); 562 EXPECT_EQ(track_encryption_key_id, iter_->GetDecryptConfig()->key_id());
565 } 563 }
566 564
567 // It is legal for aux info blocks to be shared among multiple formats. 565 // It is legal for aux info blocks to be shared among multiple formats.
568 TEST_F(TrackRunIteratorTest, SharedAuxInfoTest) { 566 TEST_F(TrackRunIteratorTest, SharedAuxInfoTest) {
569 AddEncryption(&moov_.tracks[0]); 567 AddEncryption(&moov_.tracks[0]);
570 AddEncryption(&moov_.tracks[1]); 568 AddEncryption(&moov_.tracks[1]);
571 iter_.reset(new TrackRunIterator(&moov_, log_cb_)); 569 iter_.reset(new TrackRunIterator(&moov_, media_log_));
572 570
573 MovieFragment moof = CreateFragment(); 571 MovieFragment moof = CreateFragment();
574 moof.tracks[0].runs.resize(1); 572 moof.tracks[0].runs.resize(1);
575 AddAuxInfoHeaders(50, &moof.tracks[0]); 573 AddAuxInfoHeaders(50, &moof.tracks[0]);
576 AddAuxInfoHeaders(50, &moof.tracks[1]); 574 AddAuxInfoHeaders(50, &moof.tracks[1]);
577 moof.tracks[0].auxiliary_size.default_sample_info_size = 8; 575 moof.tracks[0].auxiliary_size.default_sample_info_size = 8;
578 576
579 ASSERT_TRUE(iter_->Init(moof)); 577 ASSERT_TRUE(iter_->Init(moof));
580 EXPECT_EQ(iter_->track_id(), 1u); 578 EXPECT_EQ(iter_->track_id(), 1u);
581 EXPECT_EQ(iter_->aux_info_offset(), 50); 579 EXPECT_EQ(iter_->aux_info_offset(), 50);
(...skipping 21 matching lines...) Expand all
603 // unreasonable behavior demonstrated here: 601 // unreasonable behavior demonstrated here:
604 // byte 50: track 2, run 1 aux info 602 // byte 50: track 2, run 1 aux info
605 // byte 100: track 1, run 1 data 603 // byte 100: track 1, run 1 data
606 // byte 200: track 2, run 1 data 604 // byte 200: track 2, run 1 data
607 // byte 201: track 1, run 2 aux info (*inside* track 2, run 1 data) 605 // byte 201: track 1, run 2 aux info (*inside* track 2, run 1 data)
608 // byte 10000: track 1, run 2 data 606 // byte 10000: track 1, run 2 data
609 // byte 20000: track 1, run 1 aux info 607 // byte 20000: track 1, run 1 aux info
610 TEST_F(TrackRunIteratorTest, UnexpectedOrderingTest) { 608 TEST_F(TrackRunIteratorTest, UnexpectedOrderingTest) {
611 AddEncryption(&moov_.tracks[0]); 609 AddEncryption(&moov_.tracks[0]);
612 AddEncryption(&moov_.tracks[1]); 610 AddEncryption(&moov_.tracks[1]);
613 iter_.reset(new TrackRunIterator(&moov_, log_cb_)); 611 iter_.reset(new TrackRunIterator(&moov_, media_log_));
614 612
615 MovieFragment moof = CreateFragment(); 613 MovieFragment moof = CreateFragment();
616 AddAuxInfoHeaders(20000, &moof.tracks[0]); 614 AddAuxInfoHeaders(20000, &moof.tracks[0]);
617 moof.tracks[0].auxiliary_offset.offsets.push_back(201); 615 moof.tracks[0].auxiliary_offset.offsets.push_back(201);
618 moof.tracks[0].auxiliary_size.sample_count += 2; 616 moof.tracks[0].auxiliary_size.sample_count += 2;
619 moof.tracks[0].auxiliary_size.default_sample_info_size = 8; 617 moof.tracks[0].auxiliary_size.default_sample_info_size = 8;
620 moof.tracks[0].runs[1].sample_count = 2; 618 moof.tracks[0].runs[1].sample_count = 2;
621 AddAuxInfoHeaders(50, &moof.tracks[1]); 619 AddAuxInfoHeaders(50, &moof.tracks[1]);
622 moof.tracks[1].runs[0].sample_sizes[0] = 5; 620 moof.tracks[1].runs[0].sample_sizes[0] = 5;
623 621
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 // that none of the samples should be random access points. If the 659 // that none of the samples should be random access points. If the
662 // kSampleIsNonSyncSample flag is NOT set though, the sample should be 660 // kSampleIsNonSyncSample flag is NOT set though, the sample should be
663 // considered a random access point. 661 // considered a random access point.
664 moov_.tracks[1].media.information.sample_table.sync_sample.is_present = true; 662 moov_.tracks[1].media.information.sample_table.sync_sample.is_present = true;
665 moov_.tracks[1].media.information.sample_table.sync_sample.entries.resize(0); 663 moov_.tracks[1].media.information.sample_table.sync_sample.entries.resize(0);
666 moof.tracks[1].runs.resize(1); 664 moof.tracks[1].runs.resize(1);
667 moof.tracks[1].runs[0].sample_count = 6; 665 moof.tracks[1].runs[0].sample_count = 6;
668 moof.tracks[1].runs[0].data_offset = 200; 666 moof.tracks[1].runs[0].data_offset = 200;
669 SetFlagsOnSamples("US UN OS ON NS NN", &moof.tracks[1].runs[0]); 667 SetFlagsOnSamples("US UN OS ON NS NN", &moof.tracks[1].runs[0]);
670 668
671 iter_.reset(new TrackRunIterator(&moov_, log_cb_)); 669 iter_.reset(new TrackRunIterator(&moov_, media_log_));
672 670
673 ASSERT_TRUE(iter_->Init(moof)); 671 ASSERT_TRUE(iter_->Init(moof));
674 EXPECT_TRUE(iter_->IsRunValid()); 672 EXPECT_TRUE(iter_->IsRunValid());
675 673
676 // Verify that all samples except for the ones that have the 674 // Verify that all samples except for the ones that have the
677 // kSampleIsNonSyncSample flag set are marked as random access points. 675 // kSampleIsNonSyncSample flag set are marked as random access points.
678 EXPECT_EQ("1 KR P PR P KR K", KeyframeAndRAPInfo(iter_.get())); 676 EXPECT_EQ("1 KR P PR P KR K", KeyframeAndRAPInfo(iter_.get()));
679 677
680 iter_->AdvanceRun(); 678 iter_->AdvanceRun();
681 679
682 // Verify that nothing is marked as a random access point. 680 // Verify that nothing is marked as a random access point.
683 EXPECT_EQ("2 KR P PR P KR K", KeyframeAndRAPInfo(iter_.get())); 681 EXPECT_EQ("2 KR P PR P KR K", KeyframeAndRAPInfo(iter_.get()));
684 } 682 }
685 683
686 684
687 } // namespace mp4 685 } // namespace mp4
688 } // namespace media 686 } // namespace media
OLDNEW
« no previous file with comments | « media/formats/mp4/track_run_iterator.cc ('k') | media/formats/mpeg/adts_stream_parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698