OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <algorithm> | 5 #include <algorithm> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/string_split.h" | 10 #include "base/strings/string_split.h" |
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 } | 535 } |
536 | 536 |
537 // Initializes the demuxer with data from 2 files with different | 537 // Initializes the demuxer with data from 2 files with different |
538 // decoder configurations. This is used to test the decoder config change | 538 // decoder configurations. This is used to test the decoder config change |
539 // logic. | 539 // logic. |
540 // | 540 // |
541 // bear-320x240.webm VideoDecoderConfig returns 320x240 for its natural_size() | 541 // bear-320x240.webm VideoDecoderConfig returns 320x240 for its natural_size() |
542 // bear-640x360.webm VideoDecoderConfig returns 640x360 for its natural_size() | 542 // bear-640x360.webm VideoDecoderConfig returns 640x360 for its natural_size() |
543 // The resulting video stream returns data from each file for the following | 543 // The resulting video stream returns data from each file for the following |
544 // time ranges. | 544 // time ranges. |
545 // bear-320x240.webm : [0-501) [801-2737) | 545 // bear-320x240.webm : [0-501) [801-2736) |
546 // bear-640x360.webm : [527-793) | 546 // bear-640x360.webm : [527-793) |
547 // | 547 // |
548 // bear-320x240.webm AudioDecoderConfig returns 3863 for its extra_data_size() | 548 // bear-320x240.webm AudioDecoderConfig returns 3863 for its extra_data_size() |
549 // bear-640x360.webm AudioDecoderConfig returns 3935 for its extra_data_size() | 549 // bear-640x360.webm AudioDecoderConfig returns 3935 for its extra_data_size() |
550 // The resulting audio stream returns data from each file for the following | 550 // The resulting audio stream returns data from each file for the following |
551 // time ranges. | 551 // time ranges. |
552 // bear-320x240.webm : [0-524) [779-2737) | 552 // bear-320x240.webm : [0-524) [779-2736) |
553 // bear-640x360.webm : [527-759) | 553 // bear-640x360.webm : [527-759) |
554 bool InitDemuxerWithConfigChangeData() { | 554 bool InitDemuxerWithConfigChangeData() { |
555 scoped_refptr<DecoderBuffer> bear1 = ReadTestDataFile("bear-320x240.webm"); | 555 scoped_refptr<DecoderBuffer> bear1 = ReadTestDataFile("bear-320x240.webm"); |
556 scoped_refptr<DecoderBuffer> bear2 = ReadTestDataFile("bear-640x360.webm"); | 556 scoped_refptr<DecoderBuffer> bear2 = ReadTestDataFile("bear-640x360.webm"); |
557 | 557 |
558 EXPECT_CALL(*this, DemuxerOpened()); | 558 EXPECT_CALL(*this, DemuxerOpened()); |
559 demuxer_->Initialize( | 559 demuxer_->Initialize( |
560 &host_, CreateInitDoneCB(base::TimeDelta::FromMilliseconds(2744), | 560 &host_, CreateInitDoneCB(base::TimeDelta::FromMilliseconds(2744), |
561 PIPELINE_OK), true); | 561 PIPELINE_OK), true); |
562 | 562 |
563 if (AddId(kSourceId, HAS_AUDIO | HAS_VIDEO) != ChunkDemuxer::kOk) | 563 if (AddId(kSourceId, HAS_AUDIO | HAS_VIDEO) != ChunkDemuxer::kOk) |
564 return false; | 564 return false; |
565 | 565 |
566 // Append the whole bear1 file. | 566 // Append the whole bear1 file. |
567 AppendData(bear1->data(), bear1->data_size()); | 567 AppendData(bear1->data(), bear1->data_size()); |
568 CheckExpectedRanges(kSourceId, "{ [0,2737) }"); | 568 // Last audio frame has timestamp 2721 and duration 24 (estimated from max |
| 569 // seen so far for audio track). |
| 570 // Last video frame has timestamp 2703 and duration 33 (from TrackEntry |
| 571 // DefaultDuration for video track). |
| 572 CheckExpectedRanges(kSourceId, "{ [0,2736) }"); |
569 | 573 |
570 // Append initialization segment for bear2. | 574 // Append initialization segment for bear2. |
571 // Note: Offsets here and below are derived from | 575 // Note: Offsets here and below are derived from |
572 // media/test/data/bear-640x360-manifest.js and | 576 // media/test/data/bear-640x360-manifest.js and |
573 // media/test/data/bear-320x240-manifest.js which were | 577 // media/test/data/bear-320x240-manifest.js which were |
574 // generated from media/test/data/bear-640x360.webm and | 578 // generated from media/test/data/bear-640x360.webm and |
575 // media/test/data/bear-320x240.webm respectively. | 579 // media/test/data/bear-320x240.webm respectively. |
576 AppendData(bear2->data(), 4340); | 580 AppendData(bear2->data(), 4340); |
577 | 581 |
578 // Append a media segment that goes from [0.527000, 1.014000). | 582 // Append a media segment that goes from [0.527000, 1.014000). |
579 AppendData(bear2->data() + 55290, 18785); | 583 AppendData(bear2->data() + 55290, 18785); |
580 CheckExpectedRanges(kSourceId, "{ [0,1028) [1201,2737) }"); | 584 CheckExpectedRanges(kSourceId, "{ [0,1027) [1201,2736) }"); |
581 | 585 |
582 // Append initialization segment for bear1 & fill gap with [779-1197) | 586 // Append initialization segment for bear1 & fill gap with [779-1197) |
583 // segment. | 587 // segment. |
584 AppendData(bear1->data(), 4370); | 588 AppendData(bear1->data(), 4370); |
585 AppendData(bear1->data() + 72737, 28183); | 589 AppendData(bear1->data() + 72737, 28183); |
586 CheckExpectedRanges(kSourceId, "{ [0,2737) }"); | 590 CheckExpectedRanges(kSourceId, "{ [0,2736) }"); |
587 | 591 |
588 MarkEndOfStream(PIPELINE_OK); | 592 MarkEndOfStream(PIPELINE_OK); |
589 return true; | 593 return true; |
590 } | 594 } |
591 | 595 |
592 void ShutdownDemuxer() { | 596 void ShutdownDemuxer() { |
593 if (demuxer_) { | 597 if (demuxer_) { |
594 demuxer_->Shutdown(); | 598 demuxer_->Shutdown(); |
595 message_loop_.RunUntilIdle(); | 599 message_loop_.RunUntilIdle(); |
596 } | 600 } |
(...skipping 2545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3142 // NOTE: we start at 175 here because the buffer at 125 was returned | 3146 // NOTE: we start at 175 here because the buffer at 125 was returned |
3143 // to the pending read initiated above. | 3147 // to the pending read initiated above. |
3144 CheckExpectedBuffers(text_stream, "175 225"); | 3148 CheckExpectedBuffers(text_stream, "175 225"); |
3145 | 3149 |
3146 // Verify that audio & video streams contiue to return expected values. | 3150 // Verify that audio & video streams contiue to return expected values. |
3147 CheckExpectedBuffers(audio_stream, "160 180"); | 3151 CheckExpectedBuffers(audio_stream, "160 180"); |
3148 CheckExpectedBuffers(video_stream, "180 210"); | 3152 CheckExpectedBuffers(video_stream, "180 210"); |
3149 } | 3153 } |
3150 | 3154 |
3151 } // namespace media | 3155 } // namespace media |
OLD | NEW |