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/mp2t/es_parser_adts.h" | 5 #include "media/formats/mp2t/es_parser_adts.h" |
6 | 6 |
7 #include <list> | 7 #include <list> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 133 matching lines...) Loading... |
144 if (!UpdateAudioConfiguration(adts_frame.data)) | 144 if (!UpdateAudioConfiguration(adts_frame.data)) |
145 return false; | 145 return false; |
146 | 146 |
147 // Get the PTS & the duration of this access unit. | 147 // Get the PTS & the duration of this access unit. |
148 while (!pts_list_.empty() && | 148 while (!pts_list_.empty() && |
149 pts_list_.front().first <= adts_frame.queue_offset) { | 149 pts_list_.front().first <= adts_frame.queue_offset) { |
150 audio_timestamp_helper_->SetBaseTimestamp(pts_list_.front().second); | 150 audio_timestamp_helper_->SetBaseTimestamp(pts_list_.front().second); |
151 pts_list_.pop_front(); | 151 pts_list_.pop_front(); |
152 } | 152 } |
153 | 153 |
| 154 if (audio_timestamp_helper_->base_timestamp() == kNoTimestamp()) { |
| 155 DVLOG(1) << "Audio frame with unknown timestamp"; |
| 156 return false; |
| 157 } |
154 base::TimeDelta current_pts = audio_timestamp_helper_->GetTimestamp(); | 158 base::TimeDelta current_pts = audio_timestamp_helper_->GetTimestamp(); |
155 base::TimeDelta frame_duration = | 159 base::TimeDelta frame_duration = |
156 audio_timestamp_helper_->GetFrameDuration(kSamplesPerAACFrame); | 160 audio_timestamp_helper_->GetFrameDuration(kSamplesPerAACFrame); |
157 | 161 |
158 // Emit an audio frame. | 162 // Emit an audio frame. |
159 bool is_key_frame = true; | 163 bool is_key_frame = true; |
160 | 164 |
161 // TODO(wolenetz/acolwell): Validate and use a common cross-parser TrackId | 165 // TODO(wolenetz/acolwell): Validate and use a common cross-parser TrackId |
162 // type and allow multiple audio tracks. See https://crbug.com/341581. | 166 // type and allow multiple audio tracks. See https://crbug.com/341581. |
163 scoped_refptr<StreamParserBuffer> stream_parser_buffer = | 167 scoped_refptr<StreamParserBuffer> stream_parser_buffer = |
(...skipping 75 matching lines...) Loading... |
239 extra_data, | 243 extra_data, |
240 arraysize(extra_data), | 244 arraysize(extra_data), |
241 false); | 245 false); |
242 | 246 |
243 if (!audio_decoder_config.Matches(last_audio_decoder_config_)) { | 247 if (!audio_decoder_config.Matches(last_audio_decoder_config_)) { |
244 DVLOG(1) << "Sampling frequency: " << samples_per_second; | 248 DVLOG(1) << "Sampling frequency: " << samples_per_second; |
245 DVLOG(1) << "Extended sampling frequency: " << extended_samples_per_second; | 249 DVLOG(1) << "Extended sampling frequency: " << extended_samples_per_second; |
246 DVLOG(1) << "Channel config: " << channel_configuration; | 250 DVLOG(1) << "Channel config: " << channel_configuration; |
247 DVLOG(1) << "Adts profile: " << adts_profile; | 251 DVLOG(1) << "Adts profile: " << adts_profile; |
248 // Reset the timestamp helper to use a new time scale. | 252 // Reset the timestamp helper to use a new time scale. |
249 if (audio_timestamp_helper_) { | 253 if (audio_timestamp_helper_ && |
| 254 audio_timestamp_helper_->base_timestamp() != kNoTimestamp()) { |
250 base::TimeDelta base_timestamp = audio_timestamp_helper_->GetTimestamp(); | 255 base::TimeDelta base_timestamp = audio_timestamp_helper_->GetTimestamp(); |
251 audio_timestamp_helper_.reset( | 256 audio_timestamp_helper_.reset( |
252 new AudioTimestampHelper(samples_per_second)); | 257 new AudioTimestampHelper(samples_per_second)); |
253 audio_timestamp_helper_->SetBaseTimestamp(base_timestamp); | 258 audio_timestamp_helper_->SetBaseTimestamp(base_timestamp); |
254 } else { | 259 } else { |
255 audio_timestamp_helper_.reset( | 260 audio_timestamp_helper_.reset( |
256 new AudioTimestampHelper(samples_per_second)); | 261 new AudioTimestampHelper(samples_per_second)); |
257 } | 262 } |
258 // Audio config notification. | 263 // Audio config notification. |
259 last_audio_decoder_config_ = audio_decoder_config; | 264 last_audio_decoder_config_ = audio_decoder_config; |
260 new_audio_config_cb_.Run(audio_decoder_config); | 265 new_audio_config_cb_.Run(audio_decoder_config); |
261 } | 266 } |
262 | 267 |
263 return true; | 268 return true; |
264 } | 269 } |
265 | 270 |
266 } // namespace mp2t | 271 } // namespace mp2t |
267 } // namespace media | 272 } // namespace media |
OLD | NEW |