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/mp4/mp4_stream_parser.h" | 5 #include "media/mp4/mp4_stream_parser.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/time.h" | 10 #include "base/time.h" |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 // It is not uncommon to find otherwise-valid files with incorrect sample | 189 // It is not uncommon to find otherwise-valid files with incorrect sample |
190 // description indices, so we fail gracefully in that case. | 190 // description indices, so we fail gracefully in that case. |
191 if (desc_idx >= samp_descr.audio_entries.size()) | 191 if (desc_idx >= samp_descr.audio_entries.size()) |
192 desc_idx = 0; | 192 desc_idx = 0; |
193 const AudioSampleEntry& entry = samp_descr.audio_entries[desc_idx]; | 193 const AudioSampleEntry& entry = samp_descr.audio_entries[desc_idx]; |
194 const AAC& aac = entry.esds.aac; | 194 const AAC& aac = entry.esds.aac; |
195 | 195 |
196 if (!(entry.format == FOURCC_MP4A || | 196 if (!(entry.format == FOURCC_MP4A || |
197 (entry.format == FOURCC_ENCA && | 197 (entry.format == FOURCC_ENCA && |
198 entry.sinf.format.format == FOURCC_MP4A))) { | 198 entry.sinf.format.format == FOURCC_MP4A))) { |
199 LOG(ERROR) << "Unsupported audio format."; | 199 MEDIA_LOG(log_cb_) << "Unsupported audio format 0x" |
| 200 << std::hex << entry.format << " in stsd box."; |
200 return false; | 201 return false; |
201 } | 202 } |
202 // Check if it is MPEG4 AAC defined in ISO 14496 Part 3. | 203 // Check if it is MPEG4 AAC defined in ISO 14496 Part 3. |
203 if (entry.esds.object_type != kISO_14496_3) { | 204 if (entry.esds.object_type != kISO_14496_3) { |
204 LOG(ERROR) << "Unsupported audio object type."; | 205 MEDIA_LOG(log_cb_) << "Unsupported audio object type 0x" << std::hex |
| 206 << static_cast<int>(entry.esds.object_type) |
| 207 << " in esds."; |
205 return false; | 208 return false; |
206 } | 209 } |
207 | 210 |
208 bool is_encrypted = entry.sinf.info.track_encryption.is_encrypted; | 211 bool is_encrypted = entry.sinf.info.track_encryption.is_encrypted; |
209 audio_config.Initialize(kCodecAAC, entry.samplesize, | 212 audio_config.Initialize(kCodecAAC, entry.samplesize, |
210 aac.channel_layout(), | 213 aac.channel_layout(), |
211 aac.GetOutputSamplesPerSecond(has_sbr_), | 214 aac.GetOutputSamplesPerSecond(has_sbr_), |
212 NULL, 0, is_encrypted, false); | 215 NULL, 0, is_encrypted, false); |
213 has_audio_ = true; | 216 has_audio_ = true; |
214 audio_track_id_ = track->header.track_id; | 217 audio_track_id_ = track->header.track_id; |
215 } | 218 } |
216 if (track->media.handler.type == kVideo && !video_config.IsValidConfig()) { | 219 if (track->media.handler.type == kVideo && !video_config.IsValidConfig()) { |
217 RCHECK(!samp_descr.video_entries.empty()); | 220 RCHECK(!samp_descr.video_entries.empty()); |
218 if (desc_idx >= samp_descr.video_entries.size()) | 221 if (desc_idx >= samp_descr.video_entries.size()) |
219 desc_idx = 0; | 222 desc_idx = 0; |
220 const VideoSampleEntry& entry = samp_descr.video_entries[desc_idx]; | 223 const VideoSampleEntry& entry = samp_descr.video_entries[desc_idx]; |
221 | 224 |
222 if (!(entry.format == FOURCC_AVC1 || | 225 if (!(entry.format == FOURCC_AVC1 || |
223 (entry.format == FOURCC_ENCV && | 226 (entry.format == FOURCC_ENCV && |
224 entry.sinf.format.format == FOURCC_AVC1))) { | 227 entry.sinf.format.format == FOURCC_AVC1))) { |
225 LOG(ERROR) << "Unsupported video format."; | 228 MEDIA_LOG(log_cb_) << "Unsupported video format 0x" |
| 229 << std::hex << entry.format << " in stsd box."; |
226 return false; | 230 return false; |
227 } | 231 } |
228 | 232 |
229 // TODO(strobe): Recover correct crop box | 233 // TODO(strobe): Recover correct crop box |
230 gfx::Size coded_size(entry.width, entry.height); | 234 gfx::Size coded_size(entry.width, entry.height); |
231 gfx::Rect visible_rect(coded_size); | 235 gfx::Rect visible_rect(coded_size); |
232 gfx::Size natural_size = GetNaturalSize(visible_rect.size(), | 236 gfx::Size natural_size = GetNaturalSize(visible_rect.size(), |
233 entry.pixel_aspect.h_spacing, | 237 entry.pixel_aspect.h_spacing, |
234 entry.pixel_aspect.v_spacing); | 238 entry.pixel_aspect.v_spacing); |
235 bool is_encrypted = entry.sinf.info.track_encryption.is_encrypted; | 239 bool is_encrypted = entry.sinf.info.track_encryption.is_encrypted; |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 return !err; | 507 return !err; |
504 } | 508 } |
505 | 509 |
506 void MP4StreamParser::ChangeState(State new_state) { | 510 void MP4StreamParser::ChangeState(State new_state) { |
507 DVLOG(2) << "Changing state: " << new_state; | 511 DVLOG(2) << "Changing state: " << new_state; |
508 state_ = new_state; | 512 state_ = new_state; |
509 } | 513 } |
510 | 514 |
511 } // namespace mp4 | 515 } // namespace mp4 |
512 } // namespace media | 516 } // namespace media |
OLD | NEW |