| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/mp4/mp4_stream_parser.h" | 5 #include "media/mp4/mp4_stream_parser.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/time.h" | 10 #include "base/time.h" |
| 11 #include "media/base/audio_decoder_config.h" | 11 #include "media/base/audio_decoder_config.h" |
| 12 #include "media/base/stream_parser_buffer.h" | 12 #include "media/base/stream_parser_buffer.h" |
| 13 #include "media/base/video_decoder_config.h" | 13 #include "media/base/video_decoder_config.h" |
| 14 #include "media/base/video_util.h" |
| 14 #include "media/mp4/box_definitions.h" | 15 #include "media/mp4/box_definitions.h" |
| 15 #include "media/mp4/box_reader.h" | 16 #include "media/mp4/box_reader.h" |
| 16 #include "media/mp4/es_descriptor.h" | 17 #include "media/mp4/es_descriptor.h" |
| 17 #include "media/mp4/rcheck.h" | 18 #include "media/mp4/rcheck.h" |
| 18 | 19 |
| 19 namespace media { | 20 namespace media { |
| 20 namespace mp4 { | 21 namespace mp4 { |
| 21 | 22 |
| 22 MP4StreamParser::MP4StreamParser(bool has_sbr) | 23 MP4StreamParser::MP4StreamParser(bool has_sbr) |
| 23 : state_(kWaitingForInit), | 24 : state_(kWaitingForInit), |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 | 213 |
| 213 if (!(entry.format == FOURCC_AVC1 || | 214 if (!(entry.format == FOURCC_AVC1 || |
| 214 (entry.format == FOURCC_ENCV && | 215 (entry.format == FOURCC_ENCV && |
| 215 entry.sinf.format.format == FOURCC_AVC1))) { | 216 entry.sinf.format.format == FOURCC_AVC1))) { |
| 216 LOG(ERROR) << "Unsupported video format."; | 217 LOG(ERROR) << "Unsupported video format."; |
| 217 return false; | 218 return false; |
| 218 } | 219 } |
| 219 RCHECK(EmitKeyNeeded(entry.sinf.info.track_encryption)); | 220 RCHECK(EmitKeyNeeded(entry.sinf.info.track_encryption)); |
| 220 | 221 |
| 221 // TODO(strobe): Recover correct crop box | 222 // TODO(strobe): Recover correct crop box |
| 223 gfx::Size coded_size(entry.width, entry.height); |
| 224 gfx::Rect visible_rect(coded_size); |
| 225 gfx::Size natural_size = GetNaturalSize(visible_rect.size(), |
| 226 entry.pixel_aspect.h_spacing, |
| 227 entry.pixel_aspect.v_spacing); |
| 222 video_config.Initialize(kCodecH264, H264PROFILE_MAIN, VideoFrame::YV12, | 228 video_config.Initialize(kCodecH264, H264PROFILE_MAIN, VideoFrame::YV12, |
| 223 gfx::Size(entry.width, entry.height), | 229 coded_size, visible_rect, natural_size, |
| 224 gfx::Rect(0, 0, entry.width, entry.height), | |
| 225 entry.pixel_aspect.h_spacing, | |
| 226 entry.pixel_aspect.v_spacing, | |
| 227 // No decoder-specific buffer needed for AVC; | 230 // No decoder-specific buffer needed for AVC; |
| 228 // SPS/PPS are embedded in the video stream | 231 // SPS/PPS are embedded in the video stream |
| 229 NULL, 0, false); | 232 NULL, 0, true); |
| 230 has_video_ = true; | 233 has_video_ = true; |
| 231 video_track_id_ = track->header.track_id; | 234 video_track_id_ = track->header.track_id; |
| 232 } | 235 } |
| 233 } | 236 } |
| 234 | 237 |
| 235 // TODO(strobe): For now, we avoid sending new configs on a new | 238 // TODO(strobe): For now, we avoid sending new configs on a new |
| 236 // reinitialization segment, and instead simply embed the updated parameter | 239 // reinitialization segment, and instead simply embed the updated parameter |
| 237 // sets into the video stream. The conditional should be removed when | 240 // sets into the video stream. The conditional should be removed when |
| 238 // http://crbug.com/122913 is fixed. (We detect whether we've already sent | 241 // http://crbug.com/122913 is fixed. (We detect whether we've already sent |
| 239 // configs by looking at init_cb_ instead of config_cb_, because init_cb_ | 242 // configs by looking at init_cb_ instead of config_cb_, because init_cb_ |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 return true; | 463 return true; |
| 461 } | 464 } |
| 462 | 465 |
| 463 void MP4StreamParser::ChangeState(State new_state) { | 466 void MP4StreamParser::ChangeState(State new_state) { |
| 464 DVLOG(2) << "Changing state: " << new_state; | 467 DVLOG(2) << "Changing state: " << new_state; |
| 465 state_ = new_state; | 468 state_ = new_state; |
| 466 } | 469 } |
| 467 | 470 |
| 468 } // namespace mp4 | 471 } // namespace mp4 |
| 469 } // namespace media | 472 } // namespace media |
| OLD | NEW |