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/mpeg/mpeg_audio_stream_parser_base.h" | 5 #include "media/formats/mpeg/mpeg_audio_stream_parser_base.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "media/base/buffers.h" | 10 #include "media/base/buffers.h" |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 37 was_lf = true; | 37 was_lf = true; |
| 38 } else if (c != '\r' || last_c != '\n') { | 38 } else if (c != '\r' || last_c != '\n') { |
| 39 was_lf = false; | 39 was_lf = false; |
| 40 } | 40 } |
| 41 last_c = c; | 41 last_c = c; |
| 42 } | 42 } |
| 43 return -1; | 43 return -1; |
| 44 } | 44 } |
| 45 | 45 |
| 46 MPEGAudioStreamParserBase::MPEGAudioStreamParserBase(uint32 start_code_mask, | 46 MPEGAudioStreamParserBase::MPEGAudioStreamParserBase(uint32 start_code_mask, |
| 47 AudioCodec audio_codec) | 47 AudioCodec audio_codec, |
| 48 int codec_delay_in_frames) | |
| 48 : state_(UNINITIALIZED), | 49 : state_(UNINITIALIZED), |
| 49 in_media_segment_(false), | 50 in_media_segment_(false), |
| 50 start_code_mask_(start_code_mask), | 51 start_code_mask_(start_code_mask), |
| 51 audio_codec_(audio_codec) {} | 52 audio_codec_(audio_codec), |
| 53 codec_delay_in_frames_(codec_delay_in_frames) {} | |
| 52 | 54 |
| 53 MPEGAudioStreamParserBase::~MPEGAudioStreamParserBase() {} | 55 MPEGAudioStreamParserBase::~MPEGAudioStreamParserBase() {} |
| 54 | 56 |
| 55 void MPEGAudioStreamParserBase::Init(const InitCB& init_cb, | 57 void MPEGAudioStreamParserBase::Init(const InitCB& init_cb, |
| 56 const NewConfigCB& config_cb, | 58 const NewConfigCB& config_cb, |
| 57 const NewBuffersCB& new_buffers_cb, | 59 const NewBuffersCB& new_buffers_cb, |
| 58 bool ignore_text_tracks, | 60 bool ignore_text_tracks, |
| 59 const NeedKeyCB& need_key_cb, | 61 const NeedKeyCB& need_key_cb, |
| 60 const NewMediaSegmentCB& new_segment_cb, | 62 const NewMediaSegmentCB& new_segment_cb, |
| 61 const base::Closure& end_of_segment_cb, | 63 const base::Closure& end_of_segment_cb, |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 186 config_.channel_layout() != channel_layout)) { | 188 config_.channel_layout() != channel_layout)) { |
| 187 // Clear config data so that a config change is initiated. | 189 // Clear config data so that a config change is initiated. |
| 188 config_ = AudioDecoderConfig(); | 190 config_ = AudioDecoderConfig(); |
| 189 | 191 |
| 190 // Send all buffers associated with the previous config. | 192 // Send all buffers associated with the previous config. |
| 191 if (!buffers->empty() && !SendBuffers(buffers, true)) | 193 if (!buffers->empty() && !SendBuffers(buffers, true)) |
| 192 return -1; | 194 return -1; |
| 193 } | 195 } |
| 194 | 196 |
| 195 if (!config_.IsValidConfig()) { | 197 if (!config_.IsValidConfig()) { |
| 196 config_.Initialize(audio_codec_, kSampleFormatF32, channel_layout, | |
| 197 sample_rate, NULL, 0, false, false, | |
| 198 base::TimeDelta(), base::TimeDelta()); | |
| 199 | |
| 200 base::TimeDelta base_timestamp; | 198 base::TimeDelta base_timestamp; |
| 201 if (timestamp_helper_) | 199 if (timestamp_helper_) |
| 202 base_timestamp = timestamp_helper_->GetTimestamp(); | 200 base_timestamp = timestamp_helper_->GetTimestamp(); |
| 203 | 201 |
| 204 timestamp_helper_.reset(new AudioTimestampHelper(sample_rate)); | 202 timestamp_helper_.reset(new AudioTimestampHelper(sample_rate)); |
| 205 timestamp_helper_->SetBaseTimestamp(base_timestamp); | 203 timestamp_helper_->SetBaseTimestamp(base_timestamp); |
| 206 | 204 |
| 205 config_.Initialize( | |
| 206 audio_codec_, | |
| 207 kSampleFormatF32, | |
| 208 channel_layout, | |
| 209 sample_rate, | |
| 210 NULL, | |
| 211 0, | |
| 212 false, | |
| 213 false, | |
| 214 base::TimeDelta(), | |
| 215 timestamp_helper_->GetFrameDuration(codec_delay_in_frames_)); | |
|
DaleCurtis
2014/04/15 22:22:26
I'm wondering if we should just change codec_delay
acolwell GONE FROM CHROMIUM
2014/04/16 15:47:35
Yes. I think the coding_delay should be in frames
DaleCurtis
2014/04/16 18:22:22
Do you have a preference in naming? Keep codec_del
| |
| 216 | |
| 207 VideoDecoderConfig video_config; | 217 VideoDecoderConfig video_config; |
| 208 bool success = config_cb_.Run(config_, video_config, TextTrackConfigMap()); | 218 bool success = config_cb_.Run(config_, video_config, TextTrackConfigMap()); |
| 209 | 219 |
| 210 if (!init_cb_.is_null()) | 220 if (!init_cb_.is_null()) |
| 211 base::ResetAndReturn(&init_cb_).Run(success, kInfiniteDuration(), true); | 221 base::ResetAndReturn(&init_cb_).Run(success, kInfiniteDuration(), true); |
| 212 | 222 |
| 213 if (!success) | 223 if (!success) |
| 214 return -1; | 224 return -1; |
| 215 } | 225 } |
| 216 | 226 |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 391 if (end_of_segment) { | 401 if (end_of_segment) { |
| 392 in_media_segment_ = false; | 402 in_media_segment_ = false; |
| 393 end_of_segment_cb_.Run(); | 403 end_of_segment_cb_.Run(); |
| 394 } | 404 } |
| 395 | 405 |
| 396 timestamp_helper_->SetBaseTimestamp(base::TimeDelta()); | 406 timestamp_helper_->SetBaseTimestamp(base::TimeDelta()); |
| 397 return true; | 407 return true; |
| 398 } | 408 } |
| 399 | 409 |
| 400 } // namespace media | 410 } // namespace media |
| OLD | NEW |