Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: media/formats/mp2t/es_parser_adts.cc

Issue 399433003: Mpeg2 TS - Fail when no valid timestamp in the ADTS parser. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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...) Expand 10 before | Expand all | Expand 10 after
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();
wolenetz 2014/08/14 18:46:29 nit: I prefer a blank line between } and non-}.
damienv1 2014/08/14 22:31:22 I usually put code in logical groups: here we real
wolenetz 2014/08/14 23:13:53 Acknowledged.
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 =
164 StreamParserBuffer::CopyFrom( 168 StreamParserBuffer::CopyFrom(
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 extra_data, 244 extra_data,
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_ &&
255 audio_timestamp_helper_->base_timestamp() != kNoTimestamp()) {
251 base::TimeDelta base_timestamp = audio_timestamp_helper_->GetTimestamp(); 256 base::TimeDelta base_timestamp = audio_timestamp_helper_->GetTimestamp();
252 audio_timestamp_helper_.reset( 257 audio_timestamp_helper_.reset(
253 new AudioTimestampHelper(samples_per_second)); 258 new AudioTimestampHelper(samples_per_second));
254 audio_timestamp_helper_->SetBaseTimestamp(base_timestamp); 259 audio_timestamp_helper_->SetBaseTimestamp(base_timestamp);
255 } else { 260 } else {
256 audio_timestamp_helper_.reset( 261 audio_timestamp_helper_.reset(
257 new AudioTimestampHelper(samples_per_second)); 262 new AudioTimestampHelper(samples_per_second));
258 } 263 }
259 // Audio config notification. 264 // Audio config notification.
260 last_audio_decoder_config_ = audio_decoder_config; 265 last_audio_decoder_config_ = audio_decoder_config;
261 new_audio_config_cb_.Run(audio_decoder_config); 266 new_audio_config_cb_.Run(audio_decoder_config);
262 } 267 }
263 268
264 return true; 269 return true;
265 } 270 }
266 271
267 } // namespace mp2t 272 } // namespace mp2t
268 } // namespace media 273 } // namespace media
269 274
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698