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/base/video_util.h" | 14 #include "media/base/video_util.h" |
15 #include "media/mp4/box_definitions.h" | 15 #include "media/mp4/box_definitions.h" |
16 #include "media/mp4/box_reader.h" | 16 #include "media/mp4/box_reader.h" |
17 #include "media/mp4/es_descriptor.h" | 17 #include "media/mp4/es_descriptor.h" |
18 #include "media/mp4/rcheck.h" | 18 #include "media/mp4/rcheck.h" |
19 | 19 |
20 namespace media { | 20 namespace media { |
21 namespace mp4 { | 21 namespace mp4 { |
22 | 22 |
23 static const char kMp4InitDataType[] = "video/mp4"; | |
ddorwin
2012/10/27 00:08:26
// TODO: Figure this out appropriately once spec'd
xhwang
2012/10/27 00:50:14
Done.
| |
24 | |
23 MP4StreamParser::MP4StreamParser(bool has_sbr) | 25 MP4StreamParser::MP4StreamParser(bool has_sbr) |
24 : state_(kWaitingForInit), | 26 : state_(kWaitingForInit), |
25 moof_head_(0), | 27 moof_head_(0), |
26 mdat_tail_(0), | 28 mdat_tail_(0), |
27 has_audio_(false), | 29 has_audio_(false), |
28 has_video_(false), | 30 has_video_(false), |
29 audio_track_id_(0), | 31 audio_track_id_(0), |
30 video_track_id_(0), | 32 video_track_id_(0), |
31 has_sbr_(has_sbr) { | 33 has_sbr_(has_sbr) { |
32 } | 34 } |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
280 for (size_t i = 0; i < headers.size(); i++) | 282 for (size_t i = 0; i < headers.size(); i++) |
281 total_size += headers[i].raw_box.size(); | 283 total_size += headers[i].raw_box.size(); |
282 | 284 |
283 scoped_array<uint8> init_data(new uint8[total_size]); | 285 scoped_array<uint8> init_data(new uint8[total_size]); |
284 size_t pos = 0; | 286 size_t pos = 0; |
285 for (size_t i = 0; i < headers.size(); i++) { | 287 for (size_t i = 0; i < headers.size(); i++) { |
286 memcpy(&init_data.get()[pos], &headers[i].raw_box[0], | 288 memcpy(&init_data.get()[pos], &headers[i].raw_box[0], |
287 headers[i].raw_box.size()); | 289 headers[i].raw_box.size()); |
288 pos += headers[i].raw_box.size(); | 290 pos += headers[i].raw_box.size(); |
289 } | 291 } |
290 return need_key_cb_.Run(init_data.Pass(), total_size); | 292 return need_key_cb_.Run(kMp4InitDataType, init_data.Pass(), total_size); |
291 } | 293 } |
292 | 294 |
293 bool MP4StreamParser::PrepareAVCBuffer( | 295 bool MP4StreamParser::PrepareAVCBuffer( |
294 const AVCDecoderConfigurationRecord& avc_config, | 296 const AVCDecoderConfigurationRecord& avc_config, |
295 std::vector<uint8>* frame_buf, | 297 std::vector<uint8>* frame_buf, |
296 std::vector<SubsampleEntry>* subsamples) const { | 298 std::vector<SubsampleEntry>* subsamples) const { |
297 // Convert the AVC NALU length fields to Annex B headers, as expected by | 299 // Convert the AVC NALU length fields to Annex B headers, as expected by |
298 // decoding libraries. Since this may enlarge the size of the buffer, we also | 300 // decoding libraries. Since this may enlarge the size of the buffer, we also |
299 // update the clear byte count for each subsample if encryption is used to | 301 // update the clear byte count for each subsample if encryption is used to |
300 // account for the difference in size between the length prefix and Annex B | 302 // account for the difference in size between the length prefix and Annex B |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
496 return !err; | 498 return !err; |
497 } | 499 } |
498 | 500 |
499 void MP4StreamParser::ChangeState(State new_state) { | 501 void MP4StreamParser::ChangeState(State new_state) { |
500 DVLOG(2) << "Changing state: " << new_state; | 502 DVLOG(2) << "Changing state: " << new_state; |
501 state_ = new_state; | 503 state_ = new_state; |
502 } | 504 } |
503 | 505 |
504 } // namespace mp4 | 506 } // namespace mp4 |
505 } // namespace media | 507 } // namespace media |
OLD | NEW |