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

Side by Side Diff: media/webm/webm_cluster_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_cluster_parser.h ('k') | media/webm/webm_stream_parser.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_cluster_parser.h" 5 #include "media/webm/webm_cluster_parser.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/sys_byteorder.h" 8 #include "base/sys_byteorder.h"
9 #include "media/base/data_buffer.h" 9 #include "media/base/data_buffer.h"
10 #include "media/base/decrypt_config.h" 10 #include "media/base/decrypt_config.h"
(...skipping 25 matching lines...) Expand all
36 const uint8* video_encryption_key_id, 36 const uint8* video_encryption_key_id,
37 int video_encryption_key_id_size) 37 int video_encryption_key_id_size)
38 : timecode_multiplier_(timecode_scale / 1000.0), 38 : timecode_multiplier_(timecode_scale / 1000.0),
39 video_encryption_key_id_size_(video_encryption_key_id_size), 39 video_encryption_key_id_size_(video_encryption_key_id_size),
40 parser_(kWebMIdCluster, this), 40 parser_(kWebMIdCluster, this),
41 last_block_timecode_(-1), 41 last_block_timecode_(-1),
42 block_data_size_(-1), 42 block_data_size_(-1),
43 block_duration_(-1), 43 block_duration_(-1),
44 cluster_timecode_(-1), 44 cluster_timecode_(-1),
45 cluster_start_time_(kNoTimestamp()), 45 cluster_start_time_(kNoTimestamp()),
46 cluster_ended_(false),
46 audio_(audio_track_num), 47 audio_(audio_track_num),
47 video_(video_track_num) { 48 video_(video_track_num) {
48 CHECK_GE(video_encryption_key_id_size, 0); 49 CHECK_GE(video_encryption_key_id_size, 0);
49 if (video_encryption_key_id_size > 0) { 50 if (video_encryption_key_id_size > 0) {
50 video_encryption_key_id_.reset(new uint8[video_encryption_key_id_size]); 51 video_encryption_key_id_.reset(new uint8[video_encryption_key_id_size]);
51 memcpy(video_encryption_key_id_.get(), video_encryption_key_id, 52 memcpy(video_encryption_key_id_.get(), video_encryption_key_id,
52 video_encryption_key_id_size); 53 video_encryption_key_id_size);
53 } 54 }
54 } 55 }
55 56
56 WebMClusterParser::~WebMClusterParser() {} 57 WebMClusterParser::~WebMClusterParser() {}
57 58
58 void WebMClusterParser::Reset() { 59 void WebMClusterParser::Reset() {
59 last_block_timecode_ = -1; 60 last_block_timecode_ = -1;
60 cluster_timecode_ = -1; 61 cluster_timecode_ = -1;
61 cluster_start_time_ = kNoTimestamp(); 62 cluster_start_time_ = kNoTimestamp();
63 cluster_ended_ = false;
62 parser_.Reset(); 64 parser_.Reset();
63 audio_.Reset(); 65 audio_.Reset();
64 video_.Reset(); 66 video_.Reset();
65 } 67 }
66 68
67 int WebMClusterParser::Parse(const uint8* buf, int size) { 69 int WebMClusterParser::Parse(const uint8* buf, int size) {
68 audio_.Reset(); 70 audio_.Reset();
69 video_.Reset(); 71 video_.Reset();
70 72
71 int result = parser_.Parse(buf, size); 73 int result = parser_.Parse(buf, size);
72 74
73 if (result <= 0) 75 if (result <= 0) {
76 cluster_ended_ = false;
74 return result; 77 return result;
78 }
75 79
76 if (parser_.IsParsingComplete()) { 80 cluster_ended_ = parser_.IsParsingComplete();
81 if (cluster_ended_) {
77 // If there were no buffers in this cluster, set the cluster start time to 82 // If there were no buffers in this cluster, set the cluster start time to
78 // be the |cluster_timecode_|. 83 // be the |cluster_timecode_|.
79 if (cluster_start_time_ == kNoTimestamp()) { 84 if (cluster_start_time_ == kNoTimestamp()) {
80 DCHECK_GT(cluster_timecode_, -1); 85 DCHECK_GT(cluster_timecode_, -1);
81 cluster_start_time_ = base::TimeDelta::FromMicroseconds( 86 cluster_start_time_ = base::TimeDelta::FromMicroseconds(
82 cluster_timecode_ * timecode_multiplier_); 87 cluster_timecode_ * timecode_multiplier_);
83 } 88 }
84 89
85 // Reset the parser if we're done parsing so that 90 // Reset the parser if we're done parsing so that
86 // it is ready to accept another cluster on the next 91 // it is ready to accept another cluster on the next
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 286
282 buffers_.push_back(buffer); 287 buffers_.push_back(buffer);
283 return true; 288 return true;
284 } 289 }
285 290
286 void WebMClusterParser::Track::Reset() { 291 void WebMClusterParser::Track::Reset() {
287 buffers_.clear(); 292 buffers_.clear();
288 } 293 }
289 294
290 } // namespace media 295 } // namespace media
OLDNEW
« no previous file with comments | « media/webm/webm_cluster_parser.h ('k') | media/webm/webm_stream_parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698