| 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_ |
| 308 ? EncryptionScheme::CIPHER_MODE_AES_CTR |
| 309 : EncryptionScheme::CIPHER_MODE_UNENCRYPTED); |
| 304 audio_config.Initialize(codec, sample_format, channel_layout, | 310 audio_config.Initialize(codec, sample_format, channel_layout, |
| 305 sample_per_second, extra_data, | 311 sample_per_second, extra_data, encryption_scheme, |
| 306 is_audio_track_encrypted_, base::TimeDelta(), 0); | 312 base::TimeDelta(), 0); |
| 307 has_audio_ = true; | 313 has_audio_ = true; |
| 308 audio_track_id_ = track->header.track_id; | 314 audio_track_id_ = track->header.track_id; |
| 309 } | 315 } |
| 310 if (track->media.handler.type == kVideo && !video_config.IsValidConfig()) { | 316 if (track->media.handler.type == kVideo && !video_config.IsValidConfig()) { |
| 311 RCHECK(!samp_descr.video_entries.empty()); | 317 RCHECK(!samp_descr.video_entries.empty()); |
| 312 if (desc_idx >= samp_descr.video_entries.size()) | 318 if (desc_idx >= samp_descr.video_entries.size()) |
| 313 desc_idx = 0; | 319 desc_idx = 0; |
| 314 const VideoSampleEntry& entry = samp_descr.video_entries[desc_idx]; | 320 const VideoSampleEntry& entry = samp_descr.video_entries[desc_idx]; |
| 315 | 321 |
| 316 if (!entry.IsFormatValid()) { | 322 if (!entry.IsFormatValid()) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 332 natural_size = | 338 natural_size = |
| 333 GetNaturalSize(visible_rect.size(), entry.pixel_aspect.h_spacing, | 339 GetNaturalSize(visible_rect.size(), entry.pixel_aspect.h_spacing, |
| 334 entry.pixel_aspect.v_spacing); | 340 entry.pixel_aspect.v_spacing); |
| 335 } else if (track->header.width && track->header.height) { | 341 } else if (track->header.width && track->header.height) { |
| 336 natural_size = | 342 natural_size = |
| 337 gfx::Size(track->header.width, track->header.height); | 343 gfx::Size(track->header.width, track->header.height); |
| 338 } | 344 } |
| 339 | 345 |
| 340 is_video_track_encrypted_ = entry.sinf.info.track_encryption.is_encrypted; | 346 is_video_track_encrypted_ = entry.sinf.info.track_encryption.is_encrypted; |
| 341 DVLOG(1) << "is_video_track_encrypted_: " << is_video_track_encrypted_; | 347 DVLOG(1) << "is_video_track_encrypted_: " << is_video_track_encrypted_; |
| 342 video_config.Initialize( | 348 EncryptionScheme scheme(is_video_track_encrypted_ |
| 343 entry.video_codec, entry.video_codec_profile, PIXEL_FORMAT_YV12, | 349 ? EncryptionScheme::CIPHER_MODE_AES_CTR |
| 344 COLOR_SPACE_HD_REC709, coded_size, visible_rect, natural_size, | 350 : EncryptionScheme::CIPHER_MODE_UNENCRYPTED); |
| 345 // No decoder-specific buffer needed for AVC; | 351 video_config.Initialize(entry.video_codec, entry.video_codec_profile, |
| 346 // SPS/PPS are embedded in the video stream | 352 PIXEL_FORMAT_YV12, COLOR_SPACE_HD_REC709, |
| 347 std::vector<uint8_t>(), is_video_track_encrypted_); | 353 coded_size, visible_rect, natural_size, |
| 354 // No decoder-specific buffer needed for AVC; |
| 355 // SPS/PPS are embedded in the video stream |
| 356 EmptyExtraData(), scheme); |
| 348 has_video_ = true; | 357 has_video_ = true; |
| 349 video_track_id_ = track->header.track_id; | 358 video_track_id_ = track->header.track_id; |
| 350 } | 359 } |
| 351 } | 360 } |
| 352 | 361 |
| 353 if (!moov_->pssh.empty()) | 362 if (!moov_->pssh.empty()) |
| 354 OnEncryptedMediaInitData(moov_->pssh); | 363 OnEncryptedMediaInitData(moov_->pssh); |
| 355 | 364 |
| 356 RCHECK(config_cb_.Run(audio_config, video_config, TextTrackConfigMap())); | 365 RCHECK(config_cb_.Run(audio_config, video_config, TextTrackConfigMap())); |
| 357 | 366 |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 656 runs.AdvanceSample(); | 665 runs.AdvanceSample(); |
| 657 } | 666 } |
| 658 runs.AdvanceRun(); | 667 runs.AdvanceRun(); |
| 659 } | 668 } |
| 660 | 669 |
| 661 return true; | 670 return true; |
| 662 } | 671 } |
| 663 | 672 |
| 664 } // namespace mp4 | 673 } // namespace mp4 |
| 665 } // namespace media | 674 } // namespace media |
| OLD | NEW |