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

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

Issue 447963003: Introduce DecodeTimestamp class to make it easier to distiguish presentation and decode timestamps. (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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 emit_buffer_cb_(emit_buffer_cb), 120 emit_buffer_cb_(emit_buffer_cb),
121 sbr_in_mimetype_(sbr_in_mimetype), 121 sbr_in_mimetype_(sbr_in_mimetype),
122 es_queue_(new media::OffsetByteQueue()) { 122 es_queue_(new media::OffsetByteQueue()) {
123 } 123 }
124 124
125 EsParserAdts::~EsParserAdts() { 125 EsParserAdts::~EsParserAdts() {
126 } 126 }
127 127
128 bool EsParserAdts::Parse(const uint8* buf, int size, 128 bool EsParserAdts::Parse(const uint8* buf, int size,
129 base::TimeDelta pts, 129 base::TimeDelta pts,
130 base::TimeDelta dts) { 130 DecodeTimestamp dts) {
131 // The incoming PTS applies to the access unit that comes just after 131 // The incoming PTS applies to the access unit that comes just after
132 // the beginning of |buf|. 132 // the beginning of |buf|.
133 if (pts != kNoTimestamp()) 133 if (pts != kNoTimestamp())
134 pts_list_.push_back(EsPts(es_queue_->tail(), pts)); 134 pts_list_.push_back(EsPts(es_queue_->tail(), pts));
135 135
136 // Copy the input data to the ES buffer. 136 // Copy the input data to the ES buffer.
137 es_queue_->Push(buf, size); 137 es_queue_->Push(buf, size);
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;
(...skipping 18 matching lines...) Expand all
159 bool is_key_frame = true; 159 bool is_key_frame = true;
160 160
161 // TODO(wolenetz/acolwell): Validate and use a common cross-parser TrackId 161 // TODO(wolenetz/acolwell): Validate and use a common cross-parser TrackId
162 // type and allow multiple audio tracks. See https://crbug.com/341581. 162 // type and allow multiple audio tracks. See https://crbug.com/341581.
163 scoped_refptr<StreamParserBuffer> stream_parser_buffer = 163 scoped_refptr<StreamParserBuffer> stream_parser_buffer =
164 StreamParserBuffer::CopyFrom( 164 StreamParserBuffer::CopyFrom(
165 adts_frame.data, 165 adts_frame.data,
166 adts_frame.size, 166 adts_frame.size,
167 is_key_frame, 167 is_key_frame,
168 DemuxerStream::AUDIO, 0); 168 DemuxerStream::AUDIO, 0);
169 stream_parser_buffer->SetDecodeTimestamp(current_pts);
170 stream_parser_buffer->set_timestamp(current_pts); 169 stream_parser_buffer->set_timestamp(current_pts);
171 stream_parser_buffer->set_duration(frame_duration); 170 stream_parser_buffer->set_duration(frame_duration);
172 emit_buffer_cb_.Run(stream_parser_buffer); 171 emit_buffer_cb_.Run(stream_parser_buffer);
173 172
174 // Update the PTS of the next frame. 173 // Update the PTS of the next frame.
175 audio_timestamp_helper_->AddFrames(kSamplesPerAACFrame); 174 audio_timestamp_helper_->AddFrames(kSamplesPerAACFrame);
176 175
177 // Skip the current frame. 176 // Skip the current frame.
178 SkipAdtsFrame(adts_frame); 177 SkipAdtsFrame(adts_frame);
179 } 178 }
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 // Audio config notification. 258 // Audio config notification.
260 last_audio_decoder_config_ = audio_decoder_config; 259 last_audio_decoder_config_ = audio_decoder_config;
261 new_audio_config_cb_.Run(audio_decoder_config); 260 new_audio_config_cb_.Run(audio_decoder_config);
262 } 261 }
263 262
264 return true; 263 return true;
265 } 264 }
266 265
267 } // namespace mp2t 266 } // namespace mp2t
268 } // namespace media 267 } // namespace media
269
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698