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 |
| 65 }; |
| 66 |
| 67 static const CodecInfo kMPEG4AACSBRCodecInfo = { |
| 68 "mp4a.40.5", DemuxerStream::AUDIO |
| 69 }; |
| 70 |
| 71 static const CodecInfo kMPEG2AACLCCodecInfo = { |
| 72 "mp4a.67", DemuxerStream::AUDIO |
| 73 }; |
63 | 74 |
64 static const CodecInfo* kVideoMP4Codecs[] = { | 75 static const CodecInfo* kVideoMP4Codecs[] = { |
65 &kH264CodecInfo, | 76 &kH264CodecInfo, |
66 &kAACCodecInfo, | 77 &kMPEG4AACLCCodecInfo, |
| 78 &kMPEG4AACSBRCodecInfo, |
| 79 &kMPEG2AACLCCodecInfo, |
67 NULL | 80 NULL |
68 }; | 81 }; |
69 | 82 |
70 static const CodecInfo* kAudioMP4Codecs[] = { | 83 static const CodecInfo* kAudioMP4Codecs[] = { |
71 &kAACCodecInfo, | 84 &kMPEG4AACLCCodecInfo, |
| 85 &kMPEG4AACSBRCodecInfo, |
| 86 &kMPEG2AACLCCodecInfo, |
72 NULL | 87 NULL |
73 }; | 88 }; |
74 | 89 |
75 // Mimetype codec string that indicates the content contains AAC SBR frames. | 90 // Mimetype codec string that indicates the content contains AAC SBR frames. |
76 static const char* kSBRCodecId = "mp4a.40.5"; | 91 static const char* kSBRCodecId = "mp4a.40.5"; |
77 | 92 |
78 static StreamParser* BuildMP4Parser(const std::vector<std::string>& codecs) { | 93 static StreamParser* BuildMP4Parser(const std::vector<std::string>& codecs) { |
| 94 std::set<int> audio_object_types; |
79 bool has_sbr = false; | 95 bool has_sbr = false; |
80 for (size_t i = 0; i < codecs.size(); ++i) { | 96 for (size_t i = 0; i < codecs.size(); ++i) { |
| 97 if (MatchPattern(codecs[i], kMPEG2AACLCCodecInfo.pattern)) { |
| 98 audio_object_types.insert(mp4::kISO_13818_7_AAC_LC); |
| 99 } else { |
| 100 audio_object_types.insert(mp4::kISO_14496_3); |
| 101 } |
| 102 |
81 if (codecs[i] == kSBRCodecId) { | 103 if (codecs[i] == kSBRCodecId) { |
82 has_sbr = true; | 104 has_sbr = true; |
83 break; | 105 break; |
84 } | 106 } |
85 } | 107 } |
86 | 108 |
87 return new mp4::MP4StreamParser(has_sbr); | 109 return new mp4::MP4StreamParser(audio_object_types, has_sbr); |
88 } | 110 } |
89 #endif | 111 #endif |
90 | 112 |
91 static const SupportedTypeInfo kSupportedTypeInfo[] = { | 113 static const SupportedTypeInfo kSupportedTypeInfo[] = { |
92 { "video/webm", &BuildWebMParser, kVideoWebMCodecs }, | 114 { "video/webm", &BuildWebMParser, kVideoWebMCodecs }, |
93 { "audio/webm", &BuildWebMParser, kAudioWebMCodecs }, | 115 { "audio/webm", &BuildWebMParser, kAudioWebMCodecs }, |
94 #if defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS) | 116 #if defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS) |
95 { "video/mp4", &BuildMP4Parser, kVideoMP4Codecs }, | 117 { "video/mp4", &BuildMP4Parser, kVideoMP4Codecs }, |
96 { "audio/mp4", &BuildMP4Parser, kAudioMP4Codecs }, | 118 { "audio/mp4", &BuildMP4Parser, kAudioMP4Codecs }, |
97 #endif | 119 #endif |
(...skipping 1149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1247 | 1269 |
1248 Ranges<TimeDelta> ChunkDemuxer::GetBufferedRanges() const { | 1270 Ranges<TimeDelta> ChunkDemuxer::GetBufferedRanges() const { |
1249 if (audio_ && !video_) | 1271 if (audio_ && !video_) |
1250 return audio_->GetBufferedRanges(duration_); | 1272 return audio_->GetBufferedRanges(duration_); |
1251 else if (!audio_ && video_) | 1273 else if (!audio_ && video_) |
1252 return video_->GetBufferedRanges(duration_); | 1274 return video_->GetBufferedRanges(duration_); |
1253 return ComputeIntersection(); | 1275 return ComputeIntersection(); |
1254 } | 1276 } |
1255 | 1277 |
1256 } // namespace media | 1278 } // namespace media |
OLD | NEW |