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 <stddef.h> | 7 #include <stddef.h> |
8 #include <limits> | 8 #include <limits> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/callback_helpers.h" | 12 #include "base/callback_helpers.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
16 #include "media/base/audio_decoder_config.h" | 16 #include "media/base/audio_decoder_config.h" |
17 #include "media/base/encryption_scheme.h" | |
17 #include "media/base/stream_parser_buffer.h" | 18 #include "media/base/stream_parser_buffer.h" |
18 #include "media/base/text_track_config.h" | 19 #include "media/base/text_track_config.h" |
19 #include "media/base/timestamp_constants.h" | 20 #include "media/base/timestamp_constants.h" |
20 #include "media/base/video_decoder_config.h" | 21 #include "media/base/video_decoder_config.h" |
21 #include "media/base/video_util.h" | 22 #include "media/base/video_util.h" |
22 #include "media/formats/mp4/box_definitions.h" | 23 #include "media/formats/mp4/box_definitions.h" |
23 #include "media/formats/mp4/box_reader.h" | 24 #include "media/formats/mp4/box_reader.h" |
24 #include "media/formats/mp4/es_descriptor.h" | 25 #include "media/formats/mp4/es_descriptor.h" |
25 #include "media/formats/mp4/rcheck.h" | 26 #include "media/formats/mp4/rcheck.h" |
26 #include "media/formats/mpeg/adts_constants.h" | 27 #include "media/formats/mpeg/adts_constants.h" |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
294 sample_format = kSampleFormatS16; | 295 sample_format = kSampleFormatS16; |
295 } else if (entry.samplesize == 32) { | 296 } else if (entry.samplesize == 32) { |
296 sample_format = kSampleFormatS32; | 297 sample_format = kSampleFormatS32; |
297 } else { | 298 } else { |
298 LOG(ERROR) << "Unsupported sample size."; | 299 LOG(ERROR) << "Unsupported sample size."; |
299 return false; | 300 return false; |
300 } | 301 } |
301 | 302 |
302 is_audio_track_encrypted_ = entry.sinf.info.track_encryption.is_encrypted; | 303 is_audio_track_encrypted_ = entry.sinf.info.track_encryption.is_encrypted; |
303 DVLOG(1) << "is_audio_track_encrypted_: " << is_audio_track_encrypted_; | 304 DVLOG(1) << "is_audio_track_encrypted_: " << is_audio_track_encrypted_; |
304 audio_config.Initialize(codec, sample_format, channel_layout, | 305 audio_config.Initialize( |
305 sample_per_second, extra_data, | 306 codec, sample_format, channel_layout, sample_per_second, extra_data, |
306 is_audio_track_encrypted_, base::TimeDelta(), 0); | 307 EncryptionScheme(is_audio_track_encrypted_), base::TimeDelta(), 0); |
ddorwin
2016/03/01 02:17:42
For now, it's always CTR no pattern.
dougsteed
2016/03/02 18:07:53
Done.
| |
307 has_audio_ = true; | 308 has_audio_ = true; |
308 audio_track_id_ = track->header.track_id; | 309 audio_track_id_ = track->header.track_id; |
309 } | 310 } |
310 if (track->media.handler.type == kVideo && !video_config.IsValidConfig()) { | 311 if (track->media.handler.type == kVideo && !video_config.IsValidConfig()) { |
311 RCHECK(!samp_descr.video_entries.empty()); | 312 RCHECK(!samp_descr.video_entries.empty()); |
312 if (desc_idx >= samp_descr.video_entries.size()) | 313 if (desc_idx >= samp_descr.video_entries.size()) |
313 desc_idx = 0; | 314 desc_idx = 0; |
314 const VideoSampleEntry& entry = samp_descr.video_entries[desc_idx]; | 315 const VideoSampleEntry& entry = samp_descr.video_entries[desc_idx]; |
315 | 316 |
316 if (!entry.IsFormatValid()) { | 317 if (!entry.IsFormatValid()) { |
(...skipping 20 matching lines...) Expand all Loading... | |
337 gfx::Size(track->header.width, track->header.height); | 338 gfx::Size(track->header.width, track->header.height); |
338 } | 339 } |
339 | 340 |
340 is_video_track_encrypted_ = entry.sinf.info.track_encryption.is_encrypted; | 341 is_video_track_encrypted_ = entry.sinf.info.track_encryption.is_encrypted; |
341 DVLOG(1) << "is_video_track_encrypted_: " << is_video_track_encrypted_; | 342 DVLOG(1) << "is_video_track_encrypted_: " << is_video_track_encrypted_; |
342 video_config.Initialize( | 343 video_config.Initialize( |
343 entry.video_codec, entry.video_codec_profile, PIXEL_FORMAT_YV12, | 344 entry.video_codec, entry.video_codec_profile, PIXEL_FORMAT_YV12, |
344 COLOR_SPACE_HD_REC709, coded_size, visible_rect, natural_size, | 345 COLOR_SPACE_HD_REC709, coded_size, visible_rect, natural_size, |
345 // No decoder-specific buffer needed for AVC; | 346 // No decoder-specific buffer needed for AVC; |
346 // SPS/PPS are embedded in the video stream | 347 // SPS/PPS are embedded in the video stream |
347 std::vector<uint8_t>(), is_video_track_encrypted_); | 348 std::vector<uint8_t>(), EncryptionScheme(is_video_track_encrypted_)); |
ddorwin
2016/03/01 02:17:42
ditto
dougsteed
2016/03/02 18:07:53
Done.
| |
348 has_video_ = true; | 349 has_video_ = true; |
349 video_track_id_ = track->header.track_id; | 350 video_track_id_ = track->header.track_id; |
350 } | 351 } |
351 } | 352 } |
352 | 353 |
353 if (!moov_->pssh.empty()) | 354 if (!moov_->pssh.empty()) |
354 OnEncryptedMediaInitData(moov_->pssh); | 355 OnEncryptedMediaInitData(moov_->pssh); |
355 | 356 |
356 RCHECK(config_cb_.Run(audio_config, video_config, TextTrackConfigMap())); | 357 RCHECK(config_cb_.Run(audio_config, video_config, TextTrackConfigMap())); |
357 | 358 |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
656 runs.AdvanceSample(); | 657 runs.AdvanceSample(); |
657 } | 658 } |
658 runs.AdvanceRun(); | 659 runs.AdvanceRun(); |
659 } | 660 } |
660 | 661 |
661 return true; | 662 return true; |
662 } | 663 } |
663 | 664 |
664 } // namespace mp4 | 665 } // namespace mp4 |
665 } // namespace media | 666 } // namespace media |
OLD | NEW |