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

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: 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_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 "media/base/data_buffer.h" 8 #include "media/base/data_buffer.h"
9 #include "media/base/decrypt_config.h" 9 #include "media/base/decrypt_config.h"
10 #include "media/webm/webm_constants.h" 10 #include "media/webm/webm_constants.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 // call. 68 // call.
69 parser_.Reset(); 69 parser_.Reset();
70 70
71 last_block_timecode_ = -1; 71 last_block_timecode_ = -1;
72 cluster_timecode_ = -1; 72 cluster_timecode_ = -1;
73 } 73 }
74 74
75 return result; 75 return result;
76 } 76 }
77 77
78 void WebMClusterParser::SetTimestampOffset(base::TimeDelta offset) {
79 timestamp_offset_ = offset;
80 }
81
82 void WebMClusterParser::ClearTimestampOffset() {
83 SetTimestampOffset(base::TimeDelta());
84 }
85
78 WebMParserClient* WebMClusterParser::OnListStart(int id) { 86 WebMParserClient* WebMClusterParser::OnListStart(int id) {
79 if (id == kWebMIdCluster) { 87 if (id == kWebMIdCluster) {
80 cluster_timecode_ = -1; 88 cluster_timecode_ = -1;
81 cluster_start_time_ = kNoTimestamp(); 89 cluster_start_time_ = kNoTimestamp();
82 } else if (id == kWebMIdBlockGroup) { 90 } else if (id == kWebMIdBlockGroup) {
83 block_data_.reset(); 91 block_data_.reset();
84 block_data_size_ = -1; 92 block_data_size_ = -1;
85 block_duration_ = -1; 93 block_duration_ = -1;
86 } 94 }
87 95
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 } 192 }
185 193
186 if (last_block_timecode_ != -1 && timecode < last_block_timecode_) { 194 if (last_block_timecode_ != -1 && timecode < last_block_timecode_) {
187 DVLOG(1) << "Got a block with a timecode before the previous block."; 195 DVLOG(1) << "Got a block with a timecode before the previous block.";
188 return false; 196 return false;
189 } 197 }
190 198
191 last_block_timecode_ = timecode; 199 last_block_timecode_ = timecode;
192 200
193 base::TimeDelta timestamp = base::TimeDelta::FromMicroseconds( 201 base::TimeDelta timestamp = base::TimeDelta::FromMicroseconds(
194 (cluster_timecode_ + timecode) * timecode_multiplier_); 202 (cluster_timecode_ + timecode) * timecode_multiplier_) +
203 timestamp_offset_;
195 204
196 // The first bit of the flags is set when the block contains only keyframes. 205 // The first bit of the flags is set when the block contains only keyframes.
197 // http://www.matroska.org/technical/specs/index.html 206 // http://www.matroska.org/technical/specs/index.html
198 bool is_keyframe = (flags & 0x80) != 0; 207 bool is_keyframe = (flags & 0x80) != 0;
199 scoped_refptr<StreamParserBuffer> buffer = 208 scoped_refptr<StreamParserBuffer> buffer =
200 StreamParserBuffer::CopyFrom(data, size, is_keyframe); 209 StreamParserBuffer::CopyFrom(data, size, is_keyframe);
201 210
202 if (track_num == video_.track_num() && video_encryption_key_id_.get()) { 211 if (track_num == video_.track_num() && video_encryption_key_id_.get()) {
203 buffer->SetDecryptConfig(scoped_ptr<DecryptConfig>(new DecryptConfig( 212 buffer->SetDecryptConfig(scoped_ptr<DecryptConfig>(new DecryptConfig(
204 video_encryption_key_id_.get(), video_encryption_key_id_size_))); 213 video_encryption_key_id_.get(), video_encryption_key_id_size_)));
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 248
240 buffers_.push_back(buffer); 249 buffers_.push_back(buffer);
241 return true; 250 return true;
242 } 251 }
243 252
244 void WebMClusterParser::Track::Reset() { 253 void WebMClusterParser::Track::Reset() {
245 buffers_.clear(); 254 buffers_.clear();
246 } 255 }
247 256
248 } // namespace media 257 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698