| 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" |
| 11 #include "media/base/audio_decoder_config.h" | 11 #include "media/base/audio_decoder_config.h" |
| 12 #include "media/base/stream_parser_buffer.h" | 12 #include "media/base/stream_parser_buffer.h" |
| 13 #include "media/base/video_decoder_config.h" | 13 #include "media/base/video_decoder_config.h" |
| 14 #include "media/mp4/box_definitions.h" | 14 #include "media/mp4/box_definitions.h" |
| 15 #include "media/mp4/box_reader.h" | 15 #include "media/mp4/box_reader.h" |
| 16 #include "media/mp4/es_descriptor.h" | 16 #include "media/mp4/es_descriptor.h" |
| 17 #include "media/mp4/rcheck.h" | 17 #include "media/mp4/rcheck.h" |
| 18 | 18 |
| 19 namespace media { | 19 namespace media { |
| 20 namespace mp4 { | 20 namespace mp4 { |
| 21 | 21 |
| 22 MP4StreamParser::MP4StreamParser() | 22 MP4StreamParser::MP4StreamParser(bool has_sbr) |
| 23 : state_(kWaitingForInit), | 23 : state_(kWaitingForInit), |
| 24 moof_head_(0), | 24 moof_head_(0), |
| 25 mdat_tail_(0), | 25 mdat_tail_(0), |
| 26 has_audio_(false), | 26 has_audio_(false), |
| 27 has_video_(false), | 27 has_video_(false), |
| 28 audio_track_id_(0), | 28 audio_track_id_(0), |
| 29 video_track_id_(0) { | 29 video_track_id_(0), |
| 30 has_sbr_(has_sbr) { |
| 30 } | 31 } |
| 31 | 32 |
| 32 MP4StreamParser::~MP4StreamParser() {} | 33 MP4StreamParser::~MP4StreamParser() {} |
| 33 | 34 |
| 34 void MP4StreamParser::Init(const InitCB& init_cb, | 35 void MP4StreamParser::Init(const InitCB& init_cb, |
| 35 const NewConfigCB& config_cb, | 36 const NewConfigCB& config_cb, |
| 36 const NewBuffersCB& audio_cb, | 37 const NewBuffersCB& audio_cb, |
| 37 const NewBuffersCB& video_cb, | 38 const NewBuffersCB& video_cb, |
| 38 const NeedKeyCB& need_key_cb, | 39 const NeedKeyCB& need_key_cb, |
| 39 const NewMediaSegmentCB& new_segment_cb) { | 40 const NewMediaSegmentCB& new_segment_cb) { |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 | 181 |
| 181 // TODO(strobe): We accept all format values, pending clarification on | 182 // TODO(strobe): We accept all format values, pending clarification on |
| 182 // the formats used for encrypted media (http://crbug.com/132351). | 183 // the formats used for encrypted media (http://crbug.com/132351). |
| 183 // RCHECK(entry.format == FOURCC_MP4A || | 184 // RCHECK(entry.format == FOURCC_MP4A || |
| 184 // (entry.format == FOURCC_ENCA && | 185 // (entry.format == FOURCC_ENCA && |
| 185 // entry.sinf.format.format == FOURCC_MP4A)); | 186 // entry.sinf.format.format == FOURCC_MP4A)); |
| 186 | 187 |
| 187 // Check if it is MPEG4 AAC defined in ISO 14496 Part 3. | 188 // Check if it is MPEG4 AAC defined in ISO 14496 Part 3. |
| 188 RCHECK(entry.esds.object_type == kISO_14496_3); | 189 RCHECK(entry.esds.object_type == kISO_14496_3); |
| 189 audio_config.Initialize(kCodecAAC, entry.samplesize, | 190 audio_config.Initialize(kCodecAAC, entry.samplesize, |
| 190 aac.channel_layout(), aac.frequency(), | 191 aac.channel_layout(), |
| 192 aac.GetOutputSamplesPerSecond(has_sbr_), |
| 191 NULL, 0, false); | 193 NULL, 0, false); |
| 192 | |
| 193 has_audio_ = true; | 194 has_audio_ = true; |
| 194 audio_track_id_ = track->header.track_id; | 195 audio_track_id_ = track->header.track_id; |
| 195 } | 196 } |
| 196 if (track->media.handler.type == kVideo && !video_config.IsValidConfig()) { | 197 if (track->media.handler.type == kVideo && !video_config.IsValidConfig()) { |
| 197 RCHECK(!samp_descr.video_entries.empty()); | 198 RCHECK(!samp_descr.video_entries.empty()); |
| 198 if (static_cast<uint32>(desc_idx) >= samp_descr.video_entries.size()) | 199 if (static_cast<uint32>(desc_idx) >= samp_descr.video_entries.size()) |
| 199 desc_idx = 0; | 200 desc_idx = 0; |
| 200 const VideoSampleEntry& entry = samp_descr.video_entries[desc_idx]; | 201 const VideoSampleEntry& entry = samp_descr.video_entries[desc_idx]; |
| 201 | 202 |
| 202 // RCHECK(entry.format == FOURCC_AVC1 || | 203 // RCHECK(entry.format == FOURCC_AVC1 || |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 return true; | 366 return true; |
| 366 } | 367 } |
| 367 | 368 |
| 368 void MP4StreamParser::ChangeState(State new_state) { | 369 void MP4StreamParser::ChangeState(State new_state) { |
| 369 DVLOG(2) << "Changing state: " << new_state; | 370 DVLOG(2) << "Changing state: " << new_state; |
| 370 state_ = new_state; | 371 state_ = new_state; |
| 371 } | 372 } |
| 372 | 373 |
| 373 } // namespace mp4 | 374 } // namespace mp4 |
| 374 } // namespace media | 375 } // namespace media |
| OLD | NEW |