| 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 "media/filters/chunk_demuxer.h" | 5 #include "media/filters/chunk_demuxer.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 610 | 610 |
| 611 if (blocks[i].duration) { | 611 if (blocks[i].duration) { |
| 612 if (blocks[i].track_number == kVideoTrackNum || | 612 if (blocks[i].track_number == kVideoTrackNum || |
| 613 blocks[i].track_number == kAlternateVideoTrackNum) { | 613 blocks[i].track_number == kAlternateVideoTrackNum) { |
| 614 AddVideoBlockGroup(&cb, | 614 AddVideoBlockGroup(&cb, |
| 615 blocks[i].track_number, blocks[i].timestamp_in_ms, | 615 blocks[i].track_number, blocks[i].timestamp_in_ms, |
| 616 blocks[i].duration, blocks[i].flags); | 616 blocks[i].duration, blocks[i].flags); |
| 617 } else { | 617 } else { |
| 618 cb.AddBlockGroup(blocks[i].track_number, blocks[i].timestamp_in_ms, | 618 cb.AddBlockGroup(blocks[i].track_number, blocks[i].timestamp_in_ms, |
| 619 blocks[i].duration, blocks[i].flags, | 619 blocks[i].duration, blocks[i].flags, |
| 620 &data[0], data.size()); | 620 blocks[i].flags & kWebMFlagKeyframe, &data[0], |
| 621 data.size()); |
| 621 } | 622 } |
| 622 } else { | 623 } else { |
| 623 cb.AddSimpleBlock(blocks[i].track_number, blocks[i].timestamp_in_ms, | 624 cb.AddSimpleBlock(blocks[i].track_number, blocks[i].timestamp_in_ms, |
| 624 blocks[i].flags, | 625 blocks[i].flags, |
| 625 &data[0], data.size()); | 626 &data[0], data.size()); |
| 626 } | 627 } |
| 627 } | 628 } |
| 628 | 629 |
| 629 return unknown_size ? cb.FinishWithUnknownSize() : cb.Finish(); | 630 return unknown_size ? cb.FinishWithUnknownSize() : cb.Finish(); |
| 630 } | 631 } |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1003 | 1004 |
| 1004 void AddVideoBlockGroup(ClusterBuilder* cb, | 1005 void AddVideoBlockGroup(ClusterBuilder* cb, |
| 1005 int track_num, | 1006 int track_num, |
| 1006 int64_t timecode, | 1007 int64_t timecode, |
| 1007 int duration, | 1008 int duration, |
| 1008 int flags) { | 1009 int flags) { |
| 1009 const uint8_t* data = | 1010 const uint8_t* data = |
| 1010 (flags & kWebMFlagKeyframe) != 0 ? kVP8Keyframe : kVP8Interframe; | 1011 (flags & kWebMFlagKeyframe) != 0 ? kVP8Keyframe : kVP8Interframe; |
| 1011 int size = (flags & kWebMFlagKeyframe) != 0 ? sizeof(kVP8Keyframe) : | 1012 int size = (flags & kWebMFlagKeyframe) != 0 ? sizeof(kVP8Keyframe) : |
| 1012 sizeof(kVP8Interframe); | 1013 sizeof(kVP8Interframe); |
| 1013 cb->AddBlockGroup(track_num, timecode, duration, flags, data, size); | 1014 cb->AddBlockGroup(track_num, timecode, duration, flags, |
| 1015 flags & kWebMFlagKeyframe, data, size); |
| 1014 } | 1016 } |
| 1015 | 1017 |
| 1016 std::unique_ptr<Cluster> GenerateCluster(int first_audio_timecode, | 1018 std::unique_ptr<Cluster> GenerateCluster(int first_audio_timecode, |
| 1017 int first_video_timecode, | 1019 int first_video_timecode, |
| 1018 int block_count) { | 1020 int block_count) { |
| 1019 return GenerateCluster(first_audio_timecode, first_video_timecode, | 1021 return GenerateCluster(first_audio_timecode, first_video_timecode, |
| 1020 block_count, false); | 1022 block_count, false); |
| 1021 } | 1023 } |
| 1022 std::unique_ptr<Cluster> GenerateCluster(int first_audio_timecode, | 1024 std::unique_ptr<Cluster> GenerateCluster(int first_audio_timecode, |
| 1023 int first_video_timecode, | 1025 int first_video_timecode, |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1089 cb.AddSimpleBlock(track_number, timecode, kWebMFlagKeyframe, | 1091 cb.AddSimpleBlock(track_number, timecode, kWebMFlagKeyframe, |
| 1090 &data[0], data.size()); | 1092 &data[0], data.size()); |
| 1091 timecode += block_duration; | 1093 timecode += block_duration; |
| 1092 } | 1094 } |
| 1093 | 1095 |
| 1094 if (track_number == kVideoTrackNum) { | 1096 if (track_number == kVideoTrackNum) { |
| 1095 AddVideoBlockGroup(&cb, track_number, timecode, block_duration, | 1097 AddVideoBlockGroup(&cb, track_number, timecode, block_duration, |
| 1096 kWebMFlagKeyframe); | 1098 kWebMFlagKeyframe); |
| 1097 } else { | 1099 } else { |
| 1098 cb.AddBlockGroup(track_number, timecode, block_duration, | 1100 cb.AddBlockGroup(track_number, timecode, block_duration, |
| 1099 kWebMFlagKeyframe, &data[0], data.size()); | 1101 kWebMFlagKeyframe, static_cast<bool>(kWebMFlagKeyframe), |
| 1102 &data[0], data.size()); |
| 1100 } | 1103 } |
| 1101 | 1104 |
| 1102 return cb.Finish(); | 1105 return cb.Finish(); |
| 1103 } | 1106 } |
| 1104 | 1107 |
| 1105 void Read(DemuxerStream::Type type, const DemuxerStream::ReadCB& read_cb) { | 1108 void Read(DemuxerStream::Type type, const DemuxerStream::ReadCB& read_cb) { |
| 1106 demuxer_->GetStream(type)->Read(read_cb); | 1109 demuxer_->GetStream(type)->Read(read_cb); |
| 1107 message_loop_.RunUntilIdle(); | 1110 message_loop_.RunUntilIdle(); |
| 1108 } | 1111 } |
| 1109 | 1112 |
| (...skipping 3566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4676 cluster->size() - video_start); | 4679 cluster->size() - video_start); |
| 4677 | 4680 |
| 4678 CheckExpectedRanges(DemuxerStream::AUDIO, "{ [30,90) }"); | 4681 CheckExpectedRanges(DemuxerStream::AUDIO, "{ [30,90) }"); |
| 4679 CheckExpectedRanges(DemuxerStream::VIDEO, "{ [0,91) }"); | 4682 CheckExpectedRanges(DemuxerStream::VIDEO, "{ [0,91) }"); |
| 4680 CheckExpectedRanges("{ [30,90) }"); | 4683 CheckExpectedRanges("{ [30,90) }"); |
| 4681 CheckExpectedBuffers(audio_stream, "30K 40K 50K 60K 70K 80K"); | 4684 CheckExpectedBuffers(audio_stream, "30K 40K 50K 60K 70K 80K"); |
| 4682 CheckExpectedBuffers(video_stream, "71K 81"); | 4685 CheckExpectedBuffers(video_stream, "71K 81"); |
| 4683 } | 4686 } |
| 4684 | 4687 |
| 4685 } // namespace media | 4688 } // namespace media |
| OLD | NEW |