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 <algorithm> | 7 #include <algorithm> |
8 #include <deque> | 8 #include <deque> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/callback_helpers.h" | 11 #include "base/callback_helpers.h" |
12 #include "base/location.h" | 12 #include "base/location.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/message_loop_proxy.h" | 14 #include "base/message_loop_proxy.h" |
15 #include "base/string_util.h" | 15 #include "base/string_util.h" |
16 #include "media/base/audio_decoder_config.h" | 16 #include "media/base/audio_decoder_config.h" |
17 #include "media/base/stream_parser_buffer.h" | 17 #include "media/base/stream_parser_buffer.h" |
18 #include "media/base/video_decoder_config.h" | 18 #include "media/base/video_decoder_config.h" |
19 #if defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS) | 19 #if defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS) |
20 #include "media/mp4/es_descriptor.h" | |
20 #include "media/mp4/mp4_stream_parser.h" | 21 #include "media/mp4/mp4_stream_parser.h" |
21 #endif | 22 #endif |
22 #include "media/webm/webm_stream_parser.h" | 23 #include "media/webm/webm_stream_parser.h" |
23 | 24 |
24 using base::TimeDelta; | 25 using base::TimeDelta; |
25 | 26 |
26 namespace media { | 27 namespace media { |
27 | 28 |
28 struct CodecInfo { | 29 struct CodecInfo { |
29 const char* pattern; | 30 const char* pattern; |
(...skipping 22 matching lines...) Expand all Loading... | |
52 &kVorbisCodecInfo, | 53 &kVorbisCodecInfo, |
53 NULL | 54 NULL |
54 }; | 55 }; |
55 | 56 |
56 static StreamParser* BuildWebMParser(const std::vector<std::string>& codecs) { | 57 static StreamParser* BuildWebMParser(const std::vector<std::string>& codecs) { |
57 return new WebMStreamParser(); | 58 return new WebMStreamParser(); |
58 } | 59 } |
59 | 60 |
60 #if defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS) | 61 #if defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS) |
61 static const CodecInfo kH264CodecInfo = { "avc1.*", DemuxerStream::VIDEO }; | 62 static const CodecInfo kH264CodecInfo = { "avc1.*", DemuxerStream::VIDEO }; |
62 static const CodecInfo kAACCodecInfo = { "mp4a.40.*", DemuxerStream::AUDIO }; | 63 static const CodecInfo kMPEG4AACLCCodecInfo = { |
64 "mp4a.40.2", DemuxerStream::AUDIO }; | |
scherkus (not reviewing)
2013/01/08 23:51:08
move trailing }; to next line here + below
acolwell GONE FROM CHROMIUM
2013/01/16 17:35:09
Done.
| |
65 static const CodecInfo kMPEG4AACSBRCodecInfo = { | |
66 "mp4a.40.5", DemuxerStream::AUDIO }; | |
67 static const CodecInfo kMPEG2AACLCCodecInfo = { | |
68 "mp4a.67", DemuxerStream::AUDIO }; | |
63 | 69 |
64 static const CodecInfo* kVideoMP4Codecs[] = { | 70 static const CodecInfo* kVideoMP4Codecs[] = { |
65 &kH264CodecInfo, | 71 &kH264CodecInfo, |
66 &kAACCodecInfo, | 72 &kMPEG4AACLCCodecInfo, |
73 &kMPEG4AACSBRCodecInfo, | |
74 &kMPEG2AACLCCodecInfo, | |
67 NULL | 75 NULL |
68 }; | 76 }; |
69 | 77 |
70 static const CodecInfo* kAudioMP4Codecs[] = { | 78 static const CodecInfo* kAudioMP4Codecs[] = { |
71 &kAACCodecInfo, | 79 &kMPEG4AACLCCodecInfo, |
80 &kMPEG4AACSBRCodecInfo, | |
81 &kMPEG2AACLCCodecInfo, | |
72 NULL | 82 NULL |
73 }; | 83 }; |
74 | 84 |
75 // Mimetype codec string that indicates the content contains AAC SBR frames. | 85 // Mimetype codec string that indicates the content contains AAC SBR frames. |
76 static const char* kSBRCodecId = "mp4a.40.5"; | 86 static const char* kSBRCodecId = "mp4a.40.5"; |
77 | 87 |
78 static StreamParser* BuildMP4Parser(const std::vector<std::string>& codecs) { | 88 static StreamParser* BuildMP4Parser(const std::vector<std::string>& codecs) { |
89 std::set<int> audio_object_types; | |
79 bool has_sbr = false; | 90 bool has_sbr = false; |
80 for (size_t i = 0; i < codecs.size(); ++i) { | 91 for (size_t i = 0; i < codecs.size(); ++i) { |
92 if (MatchPattern(codecs[i], kMPEG2AACLCCodecInfo.pattern)) { | |
93 audio_object_types.insert(mp4::kISO_13818_7_AAC_LC); | |
94 } else { | |
95 audio_object_types.insert(mp4::kISO_14496_3); | |
96 } | |
97 | |
81 if (codecs[i] == kSBRCodecId) { | 98 if (codecs[i] == kSBRCodecId) { |
82 has_sbr = true; | 99 has_sbr = true; |
83 break; | 100 break; |
84 } | 101 } |
85 } | 102 } |
86 | 103 |
87 return new mp4::MP4StreamParser(has_sbr); | 104 return new mp4::MP4StreamParser(audio_object_types, has_sbr); |
88 } | 105 } |
89 #endif | 106 #endif |
90 | 107 |
91 static const SupportedTypeInfo kSupportedTypeInfo[] = { | 108 static const SupportedTypeInfo kSupportedTypeInfo[] = { |
92 { "video/webm", &BuildWebMParser, kVideoWebMCodecs }, | 109 { "video/webm", &BuildWebMParser, kVideoWebMCodecs }, |
93 { "audio/webm", &BuildWebMParser, kAudioWebMCodecs }, | 110 { "audio/webm", &BuildWebMParser, kAudioWebMCodecs }, |
94 #if defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS) | 111 #if defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS) |
95 { "video/mp4", &BuildMP4Parser, kVideoMP4Codecs }, | 112 { "video/mp4", &BuildMP4Parser, kVideoMP4Codecs }, |
96 { "audio/mp4", &BuildMP4Parser, kAudioMP4Codecs }, | 113 { "audio/mp4", &BuildMP4Parser, kAudioMP4Codecs }, |
97 #endif | 114 #endif |
(...skipping 1149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1247 | 1264 |
1248 Ranges<TimeDelta> ChunkDemuxer::GetBufferedRanges() const { | 1265 Ranges<TimeDelta> ChunkDemuxer::GetBufferedRanges() const { |
1249 if (audio_ && !video_) | 1266 if (audio_ && !video_) |
1250 return audio_->GetBufferedRanges(duration_); | 1267 return audio_->GetBufferedRanges(duration_); |
1251 else if (!audio_ && video_) | 1268 else if (!audio_ && video_) |
1252 return video_->GetBufferedRanges(duration_); | 1269 return video_->GetBufferedRanges(duration_); |
1253 return ComputeIntersection(); | 1270 return ComputeIntersection(); |
1254 } | 1271 } |
1255 | 1272 |
1256 } // namespace media | 1273 } // namespace media |
OLD | NEW |