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" |
| 18 #include "media/base/media_util.h" |
17 #include "media/base/stream_parser_buffer.h" | 19 #include "media/base/stream_parser_buffer.h" |
18 #include "media/base/text_track_config.h" | 20 #include "media/base/text_track_config.h" |
19 #include "media/base/timestamp_constants.h" | 21 #include "media/base/timestamp_constants.h" |
20 #include "media/base/video_decoder_config.h" | 22 #include "media/base/video_decoder_config.h" |
21 #include "media/base/video_util.h" | 23 #include "media/base/video_util.h" |
22 #include "media/formats/mp4/box_definitions.h" | 24 #include "media/formats/mp4/box_definitions.h" |
23 #include "media/formats/mp4/box_reader.h" | 25 #include "media/formats/mp4/box_reader.h" |
24 #include "media/formats/mp4/es_descriptor.h" | 26 #include "media/formats/mp4/es_descriptor.h" |
25 #include "media/formats/mp4/rcheck.h" | 27 #include "media/formats/mp4/rcheck.h" |
26 #include "media/formats/mpeg/adts_constants.h" | 28 #include "media/formats/mpeg/adts_constants.h" |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 sample_format = kSampleFormatS16; | 296 sample_format = kSampleFormatS16; |
295 } else if (entry.samplesize == 32) { | 297 } else if (entry.samplesize == 32) { |
296 sample_format = kSampleFormatS32; | 298 sample_format = kSampleFormatS32; |
297 } else { | 299 } else { |
298 LOG(ERROR) << "Unsupported sample size."; | 300 LOG(ERROR) << "Unsupported sample size."; |
299 return false; | 301 return false; |
300 } | 302 } |
301 | 303 |
302 is_audio_track_encrypted_ = entry.sinf.info.track_encryption.is_encrypted; | 304 is_audio_track_encrypted_ = entry.sinf.info.track_encryption.is_encrypted; |
303 DVLOG(1) << "is_audio_track_encrypted_: " << is_audio_track_encrypted_; | 305 DVLOG(1) << "is_audio_track_encrypted_: " << is_audio_track_encrypted_; |
| 306 EncryptionScheme encryption_scheme( |
| 307 is_audio_track_encrypted_ ? EncryptionScheme::kCipherModeAesCtr |
| 308 : EncryptionScheme::kCipherModeUnencrypted); |
304 audio_config.Initialize(codec, sample_format, channel_layout, | 309 audio_config.Initialize(codec, sample_format, channel_layout, |
305 sample_per_second, extra_data, | 310 sample_per_second, extra_data, encryption_scheme, |
306 is_audio_track_encrypted_, base::TimeDelta(), 0); | 311 base::TimeDelta(), 0); |
307 has_audio_ = true; | 312 has_audio_ = true; |
308 audio_track_id_ = track->header.track_id; | 313 audio_track_id_ = track->header.track_id; |
309 } | 314 } |
310 if (track->media.handler.type == kVideo && !video_config.IsValidConfig()) { | 315 if (track->media.handler.type == kVideo && !video_config.IsValidConfig()) { |
311 RCHECK(!samp_descr.video_entries.empty()); | 316 RCHECK(!samp_descr.video_entries.empty()); |
312 if (desc_idx >= samp_descr.video_entries.size()) | 317 if (desc_idx >= samp_descr.video_entries.size()) |
313 desc_idx = 0; | 318 desc_idx = 0; |
314 const VideoSampleEntry& entry = samp_descr.video_entries[desc_idx]; | 319 const VideoSampleEntry& entry = samp_descr.video_entries[desc_idx]; |
315 | 320 |
316 if (!entry.IsFormatValid()) { | 321 if (!entry.IsFormatValid()) { |
(...skipping 15 matching lines...) Expand all Loading... |
332 natural_size = | 337 natural_size = |
333 GetNaturalSize(visible_rect.size(), entry.pixel_aspect.h_spacing, | 338 GetNaturalSize(visible_rect.size(), entry.pixel_aspect.h_spacing, |
334 entry.pixel_aspect.v_spacing); | 339 entry.pixel_aspect.v_spacing); |
335 } else if (track->header.width && track->header.height) { | 340 } else if (track->header.width && track->header.height) { |
336 natural_size = | 341 natural_size = |
337 gfx::Size(track->header.width, track->header.height); | 342 gfx::Size(track->header.width, track->header.height); |
338 } | 343 } |
339 | 344 |
340 is_video_track_encrypted_ = entry.sinf.info.track_encryption.is_encrypted; | 345 is_video_track_encrypted_ = entry.sinf.info.track_encryption.is_encrypted; |
341 DVLOG(1) << "is_video_track_encrypted_: " << is_video_track_encrypted_; | 346 DVLOG(1) << "is_video_track_encrypted_: " << is_video_track_encrypted_; |
342 video_config.Initialize( | 347 EncryptionScheme scheme(is_video_track_encrypted_ |
343 entry.video_codec, entry.video_codec_profile, PIXEL_FORMAT_YV12, | 348 ? EncryptionScheme::kCipherModeAesCtr |
344 COLOR_SPACE_HD_REC709, coded_size, visible_rect, natural_size, | 349 : EncryptionScheme::kCipherModeUnencrypted); |
345 // No decoder-specific buffer needed for AVC; | 350 video_config.Initialize(entry.video_codec, entry.video_codec_profile, |
346 // SPS/PPS are embedded in the video stream | 351 PIXEL_FORMAT_YV12, COLOR_SPACE_HD_REC709, |
347 std::vector<uint8_t>(), is_video_track_encrypted_); | 352 coded_size, visible_rect, natural_size, |
| 353 // No decoder-specific buffer needed for AVC; |
| 354 // SPS/PPS are embedded in the video stream |
| 355 EmptyExtraData(), scheme); |
348 has_video_ = true; | 356 has_video_ = true; |
349 video_track_id_ = track->header.track_id; | 357 video_track_id_ = track->header.track_id; |
350 } | 358 } |
351 } | 359 } |
352 | 360 |
353 if (!moov_->pssh.empty()) | 361 if (!moov_->pssh.empty()) |
354 OnEncryptedMediaInitData(moov_->pssh); | 362 OnEncryptedMediaInitData(moov_->pssh); |
355 | 363 |
356 RCHECK(config_cb_.Run(audio_config, video_config, TextTrackConfigMap())); | 364 RCHECK(config_cb_.Run(audio_config, video_config, TextTrackConfigMap())); |
357 | 365 |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
656 runs.AdvanceSample(); | 664 runs.AdvanceSample(); |
657 } | 665 } |
658 runs.AdvanceRun(); | 666 runs.AdvanceRun(); |
659 } | 667 } |
660 | 668 |
661 return true; | 669 return true; |
662 } | 670 } |
663 | 671 |
664 } // namespace mp4 | 672 } // namespace mp4 |
665 } // namespace media | 673 } // namespace media |
OLD | NEW |