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

Side by Side Diff: media/webm/webm_stream_parser.cc

Issue 10803019: Chrome-side implementation of media source timestamp offset (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase ToT Created 8 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
« no previous file with comments | « media/webm/webm_stream_parser.h ('k') | webkit/media/webmediaplayer_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/webm/webm_stream_parser.h" 5 #include "media/webm/webm_stream_parser.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "media/ffmpeg/ffmpeg_common.h" 9 #include "media/ffmpeg/ffmpeg_common.h"
10 #include "media/filters/ffmpeg_glue.h" 10 #include "media/filters/ffmpeg_glue.h"
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 waiting_for_buffers_(false) { 185 waiting_for_buffers_(false) {
186 } 186 }
187 187
188 WebMStreamParser::~WebMStreamParser() {} 188 WebMStreamParser::~WebMStreamParser() {}
189 189
190 void WebMStreamParser::Init(const InitCB& init_cb, 190 void WebMStreamParser::Init(const InitCB& init_cb,
191 const NewConfigCB& config_cb, 191 const NewConfigCB& config_cb,
192 const NewBuffersCB& audio_cb, 192 const NewBuffersCB& audio_cb,
193 const NewBuffersCB& video_cb, 193 const NewBuffersCB& video_cb,
194 const NeedKeyCB& need_key_cb, 194 const NeedKeyCB& need_key_cb,
195 const NewMediaSegmentCB& new_segment_cb) { 195 const NewMediaSegmentCB& new_segment_cb,
196 const base::Closure& end_of_segment_cb) {
196 DCHECK_EQ(state_, kWaitingForInit); 197 DCHECK_EQ(state_, kWaitingForInit);
197 DCHECK(init_cb_.is_null()); 198 DCHECK(init_cb_.is_null());
198 DCHECK(!init_cb.is_null()); 199 DCHECK(!init_cb.is_null());
199 DCHECK(!config_cb.is_null()); 200 DCHECK(!config_cb.is_null());
200 DCHECK(!audio_cb.is_null() || !video_cb.is_null()); 201 DCHECK(!audio_cb.is_null() || !video_cb.is_null());
201 DCHECK(!need_key_cb.is_null()); 202 DCHECK(!need_key_cb.is_null());
202 DCHECK(!new_segment_cb.is_null()); 203 DCHECK(!new_segment_cb.is_null());
204 DCHECK(!end_of_segment_cb.is_null());
203 205
204 ChangeState(kParsingHeaders); 206 ChangeState(kParsingHeaders);
205 init_cb_ = init_cb; 207 init_cb_ = init_cb;
206 config_cb_ = config_cb; 208 config_cb_ = config_cb;
207 audio_cb_ = audio_cb; 209 audio_cb_ = audio_cb;
208 video_cb_ = video_cb; 210 video_cb_ = video_cb;
209 need_key_cb_ = need_key_cb; 211 need_key_cb_ = need_key_cb;
210 new_segment_cb_ = new_segment_cb; 212 new_segment_cb_ = new_segment_cb;
213 end_of_segment_cb_ = end_of_segment_cb;
211 } 214 }
212 215
213 void WebMStreamParser::Flush() { 216 void WebMStreamParser::Flush() {
214 DCHECK_NE(state_, kWaitingForInit); 217 DCHECK_NE(state_, kWaitingForInit);
215 218
216 byte_queue_.Reset(); 219 byte_queue_.Reset();
217 220
218 if (state_ != kParsingClusters) 221 if (state_ != kParsingClusters)
219 return; 222 return;
220 223
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 } 412 }
410 413
411 int bytes_parsed = cluster_parser_->Parse(data, size); 414 int bytes_parsed = cluster_parser_->Parse(data, size);
412 415
413 if (bytes_parsed <= 0) 416 if (bytes_parsed <= 0)
414 return bytes_parsed; 417 return bytes_parsed;
415 418
416 const BufferQueue& audio_buffers = cluster_parser_->audio_buffers(); 419 const BufferQueue& audio_buffers = cluster_parser_->audio_buffers();
417 const BufferQueue& video_buffers = cluster_parser_->video_buffers(); 420 const BufferQueue& video_buffers = cluster_parser_->video_buffers();
418 base::TimeDelta cluster_start_time = cluster_parser_->cluster_start_time(); 421 base::TimeDelta cluster_start_time = cluster_parser_->cluster_start_time();
422 bool cluster_ended = cluster_parser_->cluster_ended();
419 423
420 if (waiting_for_buffers_ && cluster_start_time != kNoTimestamp()) { 424 if (waiting_for_buffers_ && cluster_start_time != kNoTimestamp()) {
421 new_segment_cb_.Run(cluster_start_time); 425 new_segment_cb_.Run(cluster_start_time);
422 waiting_for_buffers_ = false; 426 waiting_for_buffers_ = false;
423 } 427 }
424 428
425 if (!audio_buffers.empty() && !audio_cb_.Run(audio_buffers)) 429 if (!audio_buffers.empty() && !audio_cb_.Run(audio_buffers))
426 return -1; 430 return -1;
427 431
428 if (!video_buffers.empty() && !video_cb_.Run(video_buffers)) 432 if (!video_buffers.empty() && !video_cb_.Run(video_buffers))
429 return -1; 433 return -1;
430 434
435 if (cluster_ended)
436 end_of_segment_cb_.Run();
437
431 return bytes_parsed; 438 return bytes_parsed;
432 } 439 }
433 440
434 } // namespace media 441 } // namespace media
OLDNEW
« no previous file with comments | « media/webm/webm_stream_parser.h ('k') | webkit/media/webmediaplayer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698