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

Side by Side Diff: media/base/stream_parser_buffer.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: Address CR comments 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 (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/base/stream_parser_buffer.h" 5 #include "media/base/stream_parser_buffer.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "media/base/buffers.h" 8 #include "media/base/buffers.h"
9 9
10 namespace media { 10 namespace media {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 54
55 scoped_refptr<StreamParserBuffer> StreamParserBuffer::CopyFrom( 55 scoped_refptr<StreamParserBuffer> StreamParserBuffer::CopyFrom(
56 const uint8* data, int data_size, 56 const uint8* data, int data_size,
57 const uint8* side_data, int side_data_size, 57 const uint8* side_data, int side_data_size,
58 bool is_keyframe, Type type, TrackId track_id) { 58 bool is_keyframe, Type type, TrackId track_id) {
59 return make_scoped_refptr( 59 return make_scoped_refptr(
60 new StreamParserBuffer(data, data_size, side_data, side_data_size, 60 new StreamParserBuffer(data, data_size, side_data, side_data_size,
61 is_keyframe, type, track_id)); 61 is_keyframe, type, track_id));
62 } 62 }
63 63
64 base::TimeDelta StreamParserBuffer::GetDecodeTimestamp() const { 64 DecodeTimestamp StreamParserBuffer::GetDecodeTimestamp() const {
65 if (decode_timestamp_ == kNoTimestamp()) 65 if (decode_timestamp_ == kNoDecodeTimestamp())
66 return timestamp(); 66 return DecodeTimestamp::FromPresentationTime(timestamp());
67 return decode_timestamp_; 67 return decode_timestamp_;
68 } 68 }
69 69
70 void StreamParserBuffer::SetDecodeTimestamp(base::TimeDelta timestamp) { 70 void StreamParserBuffer::SetDecodeTimestamp(DecodeTimestamp timestamp) {
71 decode_timestamp_ = timestamp; 71 decode_timestamp_ = timestamp;
72 if (preroll_buffer_) 72 if (preroll_buffer_)
73 preroll_buffer_->SetDecodeTimestamp(timestamp); 73 preroll_buffer_->SetDecodeTimestamp(timestamp);
74 } 74 }
75 75
76 StreamParserBuffer::StreamParserBuffer(const uint8* data, int data_size, 76 StreamParserBuffer::StreamParserBuffer(const uint8* data, int data_size,
77 const uint8* side_data, 77 const uint8* side_data,
78 int side_data_size, bool is_keyframe, 78 int side_data_size, bool is_keyframe,
79 Type type, TrackId track_id) 79 Type type, TrackId track_id)
80 : DecoderBuffer(data, data_size, side_data, side_data_size), 80 : DecoderBuffer(data, data_size, side_data, side_data_size),
81 is_keyframe_(is_keyframe), 81 is_keyframe_(is_keyframe),
82 decode_timestamp_(kNoTimestamp()), 82 decode_timestamp_(kNoDecodeTimestamp()),
83 config_id_(kInvalidConfigId), 83 config_id_(kInvalidConfigId),
84 type_(type), 84 type_(type),
85 track_id_(track_id) { 85 track_id_(track_id) {
86 // TODO(scherkus): Should DataBuffer constructor accept a timestamp and 86 // TODO(scherkus): Should DataBuffer constructor accept a timestamp and
87 // duration to force clients to set them? Today they end up being zero which 87 // duration to force clients to set them? Today they end up being zero which
88 // is both a common and valid value and could lead to bugs. 88 // is both a common and valid value and could lead to bugs.
89 if (data) { 89 if (data) {
90 set_duration(kNoTimestamp()); 90 set_duration(kNoTimestamp());
91 } 91 }
92 } 92 }
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 std::make_pair(kInfiniteDuration(), base::TimeDelta())); 189 std::make_pair(kInfiniteDuration(), base::TimeDelta()));
190 } 190 }
191 191
192 void StreamParserBuffer::set_timestamp(base::TimeDelta timestamp) { 192 void StreamParserBuffer::set_timestamp(base::TimeDelta timestamp) {
193 DecoderBuffer::set_timestamp(timestamp); 193 DecoderBuffer::set_timestamp(timestamp);
194 if (preroll_buffer_) 194 if (preroll_buffer_)
195 preroll_buffer_->set_timestamp(timestamp); 195 preroll_buffer_->set_timestamp(timestamp);
196 } 196 }
197 197
198 } // namespace media 198 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698