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/time.h" | 10 #include "base/time/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/text_track_config.h" |
13 #include "media/base/video_decoder_config.h" | 14 #include "media/base/video_decoder_config.h" |
14 #include "media/base/video_util.h" | 15 #include "media/base/video_util.h" |
15 #include "media/mp4/box_definitions.h" | 16 #include "media/mp4/box_definitions.h" |
16 #include "media/mp4/box_reader.h" | 17 #include "media/mp4/box_reader.h" |
17 #include "media/mp4/es_descriptor.h" | 18 #include "media/mp4/es_descriptor.h" |
18 #include "media/mp4/rcheck.h" | 19 #include "media/mp4/rcheck.h" |
19 | 20 |
20 namespace media { | 21 namespace media { |
21 namespace mp4 { | 22 namespace mp4 { |
22 | 23 |
(...skipping 15 matching lines...) Expand all Loading... |
38 is_video_track_encrypted_(false) { | 39 is_video_track_encrypted_(false) { |
39 } | 40 } |
40 | 41 |
41 MP4StreamParser::~MP4StreamParser() {} | 42 MP4StreamParser::~MP4StreamParser() {} |
42 | 43 |
43 void MP4StreamParser::Init(const InitCB& init_cb, | 44 void MP4StreamParser::Init(const InitCB& init_cb, |
44 const NewConfigCB& config_cb, | 45 const NewConfigCB& config_cb, |
45 const NewBuffersCB& new_buffers_cb, | 46 const NewBuffersCB& new_buffers_cb, |
46 const NewTextBuffersCB& /* text_cb */ , | 47 const NewTextBuffersCB& /* text_cb */ , |
47 const NeedKeyCB& need_key_cb, | 48 const NeedKeyCB& need_key_cb, |
48 const AddTextTrackCB& /* add_text_track_cb */ , | |
49 const NewMediaSegmentCB& new_segment_cb, | 49 const NewMediaSegmentCB& new_segment_cb, |
50 const base::Closure& end_of_segment_cb, | 50 const base::Closure& end_of_segment_cb, |
51 const LogCB& log_cb) { | 51 const LogCB& log_cb) { |
52 DCHECK_EQ(state_, kWaitingForInit); | 52 DCHECK_EQ(state_, kWaitingForInit); |
53 DCHECK(init_cb_.is_null()); | 53 DCHECK(init_cb_.is_null()); |
54 DCHECK(!init_cb.is_null()); | 54 DCHECK(!init_cb.is_null()); |
55 DCHECK(!config_cb.is_null()); | 55 DCHECK(!config_cb.is_null()); |
56 DCHECK(!new_buffers_cb.is_null()); | 56 DCHECK(!new_buffers_cb.is_null()); |
57 DCHECK(!need_key_cb.is_null()); | 57 DCHECK(!need_key_cb.is_null()); |
58 DCHECK(!end_of_segment_cb.is_null()); | 58 DCHECK(!end_of_segment_cb.is_null()); |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 video_config.Initialize(kCodecH264, H264PROFILE_MAIN, VideoFrame::YV12, | 285 video_config.Initialize(kCodecH264, H264PROFILE_MAIN, VideoFrame::YV12, |
286 coded_size, visible_rect, natural_size, | 286 coded_size, visible_rect, natural_size, |
287 // No decoder-specific buffer needed for AVC; | 287 // No decoder-specific buffer needed for AVC; |
288 // SPS/PPS are embedded in the video stream | 288 // SPS/PPS are embedded in the video stream |
289 NULL, 0, is_video_track_encrypted_, true); | 289 NULL, 0, is_video_track_encrypted_, true); |
290 has_video_ = true; | 290 has_video_ = true; |
291 video_track_id_ = track->header.track_id; | 291 video_track_id_ = track->header.track_id; |
292 } | 292 } |
293 } | 293 } |
294 | 294 |
295 RCHECK(config_cb_.Run(audio_config, video_config)); | 295 RCHECK(config_cb_.Run(audio_config, video_config, TextTrackConfigMap())); |
296 | 296 |
297 base::TimeDelta duration; | 297 base::TimeDelta duration; |
298 if (moov_->extends.header.fragment_duration > 0) { | 298 if (moov_->extends.header.fragment_duration > 0) { |
299 duration = TimeDeltaFromRational(moov_->extends.header.fragment_duration, | 299 duration = TimeDeltaFromRational(moov_->extends.header.fragment_duration, |
300 moov_->header.timescale); | 300 moov_->header.timescale); |
301 } else if (moov_->header.duration > 0 && | 301 } else if (moov_->header.duration > 0 && |
302 moov_->header.duration != kuint64max) { | 302 moov_->header.duration != kuint64max) { |
303 duration = TimeDeltaFromRational(moov_->header.duration, | 303 duration = TimeDeltaFromRational(moov_->header.duration, |
304 moov_->header.timescale); | 304 moov_->header.timescale); |
305 } else { | 305 } else { |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
567 return !err; | 567 return !err; |
568 } | 568 } |
569 | 569 |
570 void MP4StreamParser::ChangeState(State new_state) { | 570 void MP4StreamParser::ChangeState(State new_state) { |
571 DVLOG(2) << "Changing state: " << new_state; | 571 DVLOG(2) << "Changing state: " << new_state; |
572 state_ = new_state; | 572 state_ = new_state; |
573 } | 573 } |
574 | 574 |
575 } // namespace mp4 | 575 } // namespace mp4 |
576 } // namespace media | 576 } // namespace media |
OLD | NEW |