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/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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 138 | 138 |
| 139 // Look for every ADTS frame in the ES buffer. | 139 // Look for every ADTS frame in the ES buffer. |
| 140 AdtsFrame adts_frame; | 140 AdtsFrame adts_frame; |
| 141 while (LookForAdtsFrame(&adts_frame)) { | 141 while (LookForAdtsFrame(&adts_frame)) { |
| 142 // Update the audio configuration if needed. | 142 // Update the audio configuration if needed. |
| 143 DCHECK_GE(adts_frame.size, kADTSHeaderMinSize); | 143 DCHECK_GE(adts_frame.size, kADTSHeaderMinSize); |
| 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() && |
|
wolenetz
2014/07/15 19:57:42
I'm curious since I haven't looked through this co
damienv1
2014/07/15 21:26:59
How many PTS are in this list all depend on the st
wolenetz
2014/07/15 21:59:56
Acknowledged.
| |
| 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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 241 arraysize(extra_data), | 245 arraysize(extra_data), |
| 242 false); | 246 false); |
| 243 | 247 |
| 244 if (!audio_decoder_config.Matches(last_audio_decoder_config_)) { | 248 if (!audio_decoder_config.Matches(last_audio_decoder_config_)) { |
| 245 DVLOG(1) << "Sampling frequency: " << samples_per_second; | 249 DVLOG(1) << "Sampling frequency: " << samples_per_second; |
| 246 DVLOG(1) << "Extended sampling frequency: " << extended_samples_per_second; | 250 DVLOG(1) << "Extended sampling frequency: " << extended_samples_per_second; |
| 247 DVLOG(1) << "Channel config: " << channel_configuration; | 251 DVLOG(1) << "Channel config: " << channel_configuration; |
| 248 DVLOG(1) << "Adts profile: " << adts_profile; | 252 DVLOG(1) << "Adts profile: " << adts_profile; |
| 249 // Reset the timestamp helper to use a new time scale. | 253 // Reset the timestamp helper to use a new time scale. |
| 250 if (audio_timestamp_helper_) { | 254 if (audio_timestamp_helper_) { |
| 251 base::TimeDelta base_timestamp = audio_timestamp_helper_->GetTimestamp(); | 255 base::TimeDelta base_timestamp = audio_timestamp_helper_->GetTimestamp(); |
|
wolenetz
2014/07/15 19:57:42
What if base timestamp was not previously set? Is
damienv1
2014/07/15 21:26:59
Good catch. Thanks.
| |
| 252 audio_timestamp_helper_.reset( | 256 audio_timestamp_helper_.reset( |
| 253 new AudioTimestampHelper(samples_per_second)); | 257 new AudioTimestampHelper(samples_per_second)); |
| 254 audio_timestamp_helper_->SetBaseTimestamp(base_timestamp); | 258 audio_timestamp_helper_->SetBaseTimestamp(base_timestamp); |
| 255 } else { | 259 } else { |
| 256 audio_timestamp_helper_.reset( | 260 audio_timestamp_helper_.reset( |
| 257 new AudioTimestampHelper(samples_per_second)); | 261 new AudioTimestampHelper(samples_per_second)); |
| 258 } | 262 } |
| 259 // Audio config notification. | 263 // Audio config notification. |
| 260 last_audio_decoder_config_ = audio_decoder_config; | 264 last_audio_decoder_config_ = audio_decoder_config; |
| 261 new_audio_config_cb_.Run(audio_decoder_config); | 265 new_audio_config_cb_.Run(audio_decoder_config); |
| 262 } | 266 } |
| 263 | 267 |
| 264 return true; | 268 return true; |
| 265 } | 269 } |
| 266 | 270 |
| 267 } // namespace mp2t | 271 } // namespace mp2t |
| 268 } // namespace media | 272 } // namespace media |
| 269 | 273 |
| OLD | NEW |