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) |
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_(codec_delay) {} |
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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 config_.channel_layout() != channel_layout)) { | 194 config_.channel_layout() != channel_layout)) { |
193 // Clear config data so that a config change is initiated. | 195 // Clear config data so that a config change is initiated. |
194 config_ = AudioDecoderConfig(); | 196 config_ = AudioDecoderConfig(); |
195 | 197 |
196 // Send all buffers associated with the previous config. | 198 // Send all buffers associated with the previous config. |
197 if (!buffers->empty() && !SendBuffers(buffers, true)) | 199 if (!buffers->empty() && !SendBuffers(buffers, true)) |
198 return -1; | 200 return -1; |
199 } | 201 } |
200 | 202 |
201 if (!config_.IsValidConfig()) { | 203 if (!config_.IsValidConfig()) { |
202 config_.Initialize(audio_codec_, kSampleFormatF32, channel_layout, | 204 config_.Initialize(audio_codec_, |
203 sample_rate, NULL, 0, false, false, | 205 kSampleFormatF32, |
204 base::TimeDelta(), base::TimeDelta()); | 206 channel_layout, |
| 207 sample_rate, |
| 208 NULL, |
| 209 0, |
| 210 false, |
| 211 false, |
| 212 base::TimeDelta(), |
| 213 codec_delay_); |
205 | 214 |
206 base::TimeDelta base_timestamp; | 215 base::TimeDelta base_timestamp; |
207 if (timestamp_helper_) | 216 if (timestamp_helper_) |
208 base_timestamp = timestamp_helper_->GetTimestamp(); | 217 base_timestamp = timestamp_helper_->GetTimestamp(); |
209 | 218 |
210 timestamp_helper_.reset(new AudioTimestampHelper(sample_rate)); | 219 timestamp_helper_.reset(new AudioTimestampHelper(sample_rate)); |
211 timestamp_helper_->SetBaseTimestamp(base_timestamp); | 220 timestamp_helper_->SetBaseTimestamp(base_timestamp); |
212 | 221 |
213 VideoDecoderConfig video_config; | 222 VideoDecoderConfig video_config; |
214 bool success = config_cb_.Run(config_, video_config, TextTrackConfigMap()); | 223 bool success = config_cb_.Run(config_, video_config, TextTrackConfigMap()); |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 if (end_of_segment) { | 410 if (end_of_segment) { |
402 in_media_segment_ = false; | 411 in_media_segment_ = false; |
403 end_of_segment_cb_.Run(); | 412 end_of_segment_cb_.Run(); |
404 } | 413 } |
405 | 414 |
406 timestamp_helper_->SetBaseTimestamp(base::TimeDelta()); | 415 timestamp_helper_->SetBaseTimestamp(base::TimeDelta()); |
407 return true; | 416 return true; |
408 } | 417 } |
409 | 418 |
410 } // namespace media | 419 } // namespace media |
OLD | NEW |