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

Side by Side Diff: media/base/decoder_buffer.cc

Issue 11993002: Tighten up media::DecoderBuffer API contract for end of stream buffers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 11 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/decoder_buffer.h" 5 #include "media/base/decoder_buffer.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "media/base/decrypt_config.h" 8 #include "media/base/decrypt_config.h"
9 9
10 namespace media { 10 namespace media {
(...skipping 30 matching lines...) Expand all
41 CHECK(data); 41 CHECK(data);
42 return make_scoped_refptr(new DecoderBuffer(data, data_size)); 42 return make_scoped_refptr(new DecoderBuffer(data, data_size));
43 } 43 }
44 44
45 // static 45 // static
46 scoped_refptr<DecoderBuffer> DecoderBuffer::CreateEOSBuffer() { 46 scoped_refptr<DecoderBuffer> DecoderBuffer::CreateEOSBuffer() {
47 return make_scoped_refptr(new DecoderBuffer(NULL, 0)); 47 return make_scoped_refptr(new DecoderBuffer(NULL, 0));
48 } 48 }
49 49
50 base::TimeDelta DecoderBuffer::GetTimestamp() const { 50 base::TimeDelta DecoderBuffer::GetTimestamp() const {
51 DCHECK(!IsEndOfStream());
51 return timestamp_; 52 return timestamp_;
52 } 53 }
53 54
54 void DecoderBuffer::SetTimestamp(const base::TimeDelta& timestamp) { 55 void DecoderBuffer::SetTimestamp(const base::TimeDelta& timestamp) {
56 DCHECK(!IsEndOfStream());
55 timestamp_ = timestamp; 57 timestamp_ = timestamp;
56 } 58 }
57 59
58 base::TimeDelta DecoderBuffer::GetDuration() const { 60 base::TimeDelta DecoderBuffer::GetDuration() const {
61 DCHECK(!IsEndOfStream());
59 return duration_; 62 return duration_;
60 } 63 }
61 64
62 void DecoderBuffer::SetDuration(const base::TimeDelta& duration) { 65 void DecoderBuffer::SetDuration(const base::TimeDelta& duration) {
66 DCHECK(!IsEndOfStream());
63 duration_ = duration; 67 duration_ = duration;
64 } 68 }
65 69
66 const uint8* DecoderBuffer::GetData() const { 70 const uint8* DecoderBuffer::GetData() const {
71 DCHECK(!IsEndOfStream());
67 return data_.get(); 72 return data_.get();
68 } 73 }
69 74
70 uint8* DecoderBuffer::GetWritableData() const { 75 uint8* DecoderBuffer::GetWritableData() const {
76 DCHECK(!IsEndOfStream());
71 return data_.get(); 77 return data_.get();
72 } 78 }
73 79
74 int DecoderBuffer::GetDataSize() const { 80 int DecoderBuffer::GetDataSize() const {
81 DCHECK(!IsEndOfStream());
75 return size_; 82 return size_;
76 } 83 }
77 84
78 const DecryptConfig* DecoderBuffer::GetDecryptConfig() const { 85 const DecryptConfig* DecoderBuffer::GetDecryptConfig() const {
86 DCHECK(!IsEndOfStream());
79 return decrypt_config_.get(); 87 return decrypt_config_.get();
80 } 88 }
81 89
82 void DecoderBuffer::SetDecryptConfig(scoped_ptr<DecryptConfig> decrypt_config) { 90 void DecoderBuffer::SetDecryptConfig(scoped_ptr<DecryptConfig> decrypt_config) {
91 DCHECK(!IsEndOfStream());
83 decrypt_config_ = decrypt_config.Pass(); 92 decrypt_config_ = decrypt_config.Pass();
84 } 93 }
85 94
86 bool DecoderBuffer::IsEndOfStream() const { 95 bool DecoderBuffer::IsEndOfStream() const {
87 return data_ == NULL; 96 return data_ == NULL;
88 } 97 }
89 98
99 std::string DecoderBuffer::AsHumanReadableString() {
100 if (IsEndOfStream()) {
101 return "end of stream";
102 }
103
104 std::ostringstream s;
105 s << "timestamp: " << timestamp_.InMicroseconds()
106 << " duration: " << duration_.InMicroseconds()
107 << " size: " << size_
108 << " encrypted: " << (decrypt_config_ != NULL);
109 return s.str();
110 }
111
90 } // namespace media 112 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698