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