OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/formats/mp4/mp4_stream_parser.h" | 5 #include "media/formats/mp4/mp4_stream_parser.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
12 #include "media/base/audio_decoder_config.h" | 12 #include "media/base/audio_decoder_config.h" |
13 #include "media/base/encryption_scheme.h" | |
13 #include "media/base/stream_parser_buffer.h" | 14 #include "media/base/stream_parser_buffer.h" |
14 #include "media/base/text_track_config.h" | 15 #include "media/base/text_track_config.h" |
15 #include "media/base/timestamp_constants.h" | 16 #include "media/base/timestamp_constants.h" |
16 #include "media/base/video_decoder_config.h" | 17 #include "media/base/video_decoder_config.h" |
17 #include "media/base/video_util.h" | 18 #include "media/base/video_util.h" |
18 #include "media/formats/mp4/box_definitions.h" | 19 #include "media/formats/mp4/box_definitions.h" |
19 #include "media/formats/mp4/box_reader.h" | 20 #include "media/formats/mp4/box_reader.h" |
20 #include "media/formats/mp4/es_descriptor.h" | 21 #include "media/formats/mp4/es_descriptor.h" |
21 #include "media/formats/mp4/rcheck.h" | 22 #include "media/formats/mp4/rcheck.h" |
22 #include "media/formats/mpeg/adts_constants.h" | 23 #include "media/formats/mpeg/adts_constants.h" |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
261 sample_format = kSampleFormatS16; | 262 sample_format = kSampleFormatS16; |
262 } else if (entry.samplesize == 32) { | 263 } else if (entry.samplesize == 32) { |
263 sample_format = kSampleFormatS32; | 264 sample_format = kSampleFormatS32; |
264 } else { | 265 } else { |
265 LOG(ERROR) << "Unsupported sample size."; | 266 LOG(ERROR) << "Unsupported sample size."; |
266 return false; | 267 return false; |
267 } | 268 } |
268 | 269 |
269 is_audio_track_encrypted_ = entry.sinf.info.track_encryption.is_encrypted; | 270 is_audio_track_encrypted_ = entry.sinf.info.track_encryption.is_encrypted; |
270 DVLOG(1) << "is_audio_track_encrypted_: " << is_audio_track_encrypted_; | 271 DVLOG(1) << "is_audio_track_encrypted_: " << is_audio_track_encrypted_; |
271 audio_config.Initialize(codec, sample_format, channel_layout, | 272 audio_config.Initialize( |
272 sample_per_second, extra_data, | 273 codec, sample_format, channel_layout, sample_per_second, extra_data, |
273 is_audio_track_encrypted_, base::TimeDelta(), 0); | 274 EncryptionScheme(is_audio_track_encrypted_), base::TimeDelta(), 0); |
ddorwin
2015/12/10 18:36:02
Perhaps we should have a member documenting the en
dougsteed
2015/12/14 21:19:02
I figured we could do that when we added support f
| |
274 has_audio_ = true; | 275 has_audio_ = true; |
275 audio_track_id_ = track->header.track_id; | 276 audio_track_id_ = track->header.track_id; |
276 } | 277 } |
277 if (track->media.handler.type == kVideo && !video_config.IsValidConfig()) { | 278 if (track->media.handler.type == kVideo && !video_config.IsValidConfig()) { |
278 RCHECK(!samp_descr.video_entries.empty()); | 279 RCHECK(!samp_descr.video_entries.empty()); |
279 if (desc_idx >= samp_descr.video_entries.size()) | 280 if (desc_idx >= samp_descr.video_entries.size()) |
280 desc_idx = 0; | 281 desc_idx = 0; |
281 const VideoSampleEntry& entry = samp_descr.video_entries[desc_idx]; | 282 const VideoSampleEntry& entry = samp_descr.video_entries[desc_idx]; |
282 | 283 |
283 if (!entry.IsFormatValid()) { | 284 if (!entry.IsFormatValid()) { |
(...skipping 20 matching lines...) Expand all Loading... | |
304 gfx::Size(track->header.width, track->header.height); | 305 gfx::Size(track->header.width, track->header.height); |
305 } | 306 } |
306 | 307 |
307 is_video_track_encrypted_ = entry.sinf.info.track_encryption.is_encrypted; | 308 is_video_track_encrypted_ = entry.sinf.info.track_encryption.is_encrypted; |
308 DVLOG(1) << "is_video_track_encrypted_: " << is_video_track_encrypted_; | 309 DVLOG(1) << "is_video_track_encrypted_: " << is_video_track_encrypted_; |
309 video_config.Initialize( | 310 video_config.Initialize( |
310 entry.video_codec, entry.video_codec_profile, PIXEL_FORMAT_YV12, | 311 entry.video_codec, entry.video_codec_profile, PIXEL_FORMAT_YV12, |
311 COLOR_SPACE_HD_REC709, coded_size, visible_rect, natural_size, | 312 COLOR_SPACE_HD_REC709, coded_size, visible_rect, natural_size, |
312 // No decoder-specific buffer needed for AVC; | 313 // No decoder-specific buffer needed for AVC; |
313 // SPS/PPS are embedded in the video stream | 314 // SPS/PPS are embedded in the video stream |
314 std::vector<uint8_t>(), is_video_track_encrypted_); | 315 std::vector<uint8_t>(), EncryptionScheme(is_video_track_encrypted_)); |
ddorwin
2015/12/10 18:36:02
ditto
dougsteed
2015/12/14 21:19:02
See above comment. (Default is appropriately AES-C
| |
315 has_video_ = true; | 316 has_video_ = true; |
316 video_track_id_ = track->header.track_id; | 317 video_track_id_ = track->header.track_id; |
317 } | 318 } |
318 } | 319 } |
319 | 320 |
320 RCHECK(config_cb_.Run(audio_config, video_config, TextTrackConfigMap())); | 321 RCHECK(config_cb_.Run(audio_config, video_config, TextTrackConfigMap())); |
321 | 322 |
322 StreamParser::InitParameters params(kInfiniteDuration()); | 323 StreamParser::InitParameters params(kInfiniteDuration()); |
323 if (moov_->extends.header.fragment_duration > 0) { | 324 if (moov_->extends.header.fragment_duration > 0) { |
324 params.duration = TimeDeltaFromRational( | 325 params.duration = TimeDeltaFromRational( |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
622 runs.AdvanceSample(); | 623 runs.AdvanceSample(); |
623 } | 624 } |
624 runs.AdvanceRun(); | 625 runs.AdvanceRun(); |
625 } | 626 } |
626 | 627 |
627 return true; | 628 return true; |
628 } | 629 } |
629 | 630 |
630 } // namespace mp4 | 631 } // namespace mp4 |
631 } // namespace media | 632 } // namespace media |
OLD | NEW |