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

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: Created 8 years, 5 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 (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 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 257
258 cur += result; 258 cur += result;
259 cur_size -= result; 259 cur_size -= result;
260 bytes_parsed += result; 260 bytes_parsed += result;
261 } while (result > 0 && cur_size > 0); 261 } while (result > 0 && cur_size > 0);
262 262
263 byte_queue_.Pop(bytes_parsed); 263 byte_queue_.Pop(bytes_parsed);
264 return true; 264 return true;
265 } 265 }
266 266
267 void WebMStreamParser::SetTimestampOffset(base::TimeDelta offset) {
268 timestamp_offset_ = offset;
269 }
270
271 void WebMStreamParser::ClearTimestampOffset() {
272 SetTimestampOffset(base::TimeDelta());
273 }
274
267 void WebMStreamParser::ChangeState(State new_state) { 275 void WebMStreamParser::ChangeState(State new_state) {
268 DVLOG(1) << "ChangeState() : " << state_ << " -> " << new_state; 276 DVLOG(1) << "ChangeState() : " << state_ << " -> " << new_state;
269 state_ = new_state; 277 state_ = new_state;
270 } 278 }
271 279
272 int WebMStreamParser::ParseInfoAndTracks(const uint8* data, int size) { 280 int WebMStreamParser::ParseInfoAndTracks(const uint8* data, int size) {
273 DCHECK(data); 281 DCHECK(data);
274 DCHECK_GT(size, 0); 282 DCHECK_GT(size, 0);
275 283
276 const uint8* cur = data; 284 const uint8* cur = data;
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 if (!cluster_parser_.get()) 386 if (!cluster_parser_.get())
379 return -1; 387 return -1;
380 388
381 int id; 389 int id;
382 int64 element_size; 390 int64 element_size;
383 int result = WebMParseElementHeader(data, size, &id, &element_size); 391 int result = WebMParseElementHeader(data, size, &id, &element_size);
384 392
385 if (result <= 0) 393 if (result <= 0)
386 return result; 394 return result;
387 395
388 if (id == kWebMIdCluster) 396 if (id == kWebMIdCluster) {
389 waiting_for_buffers_ = true; 397 waiting_for_buffers_ = true;
390 398
399 // Wait until the beginning of a new cluster to set the buffer timestamp
400 // offset.
401 cluster_parser_->SetTimestampOffset(timestamp_offset_);
402 }
403
391 if (id == kWebMIdCues) { 404 if (id == kWebMIdCues) {
392 if (size < (result + element_size)) { 405 if (size < (result + element_size)) {
393 // We don't have the whole element yet. Signal we need more data. 406 // We don't have the whole element yet. Signal we need more data.
394 return 0; 407 return 0;
395 } 408 }
396 // Skip the element. 409 // Skip the element.
397 return result + element_size; 410 return result + element_size;
398 } 411 }
399 412
400 if (id == kWebMIdEBMLHeader) { 413 if (id == kWebMIdEBMLHeader) {
(...skipping 18 matching lines...) Expand all
419 if (!audio_buffers.empty() && !audio_cb_.Run(audio_buffers)) 432 if (!audio_buffers.empty() && !audio_cb_.Run(audio_buffers))
420 return -1; 433 return -1;
421 434
422 if (!video_buffers.empty() && !video_cb_.Run(video_buffers)) 435 if (!video_buffers.empty() && !video_cb_.Run(video_buffers))
423 return -1; 436 return -1;
424 437
425 return bytes_parsed; 438 return bytes_parsed;
426 } 439 }
427 440
428 } // namespace media 441 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698