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