Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #ifndef MEDIA_BASE_DECODER_BUFFER_H_ | 5 #ifndef MEDIA_BASE_DECODER_BUFFER_H_ |
| 6 #define MEDIA_BASE_DECODER_BUFFER_H_ | 6 #define MEDIA_BASE_DECODER_BUFFER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 35 enum { | 35 enum { |
| 36 kPaddingSize = 32, | 36 kPaddingSize = 32, |
| 37 #if defined(ARCH_CPU_ARM_FAMILY) | 37 #if defined(ARCH_CPU_ARM_FAMILY) |
| 38 kAlignmentSize = 16 | 38 kAlignmentSize = 16 |
| 39 #else | 39 #else |
| 40 kAlignmentSize = 32 | 40 kAlignmentSize = 32 |
| 41 #endif | 41 #endif |
| 42 }; | 42 }; |
| 43 | 43 |
| 44 // Allocates buffer with |size| >= 0. Buffer will be padded and aligned | 44 // Allocates buffer with |size| >= 0. Buffer will be padded and aligned |
| 45 // as necessary. | 45 // as necessary, and is_keyframe() will default to false. |
| 46 explicit DecoderBuffer(int size); | 46 explicit DecoderBuffer(int size); |
| 47 | 47 |
| 48 // Create a DecoderBuffer whose |data_| is copied from |data|. Buffer will be | 48 // Create a DecoderBuffer whose |data_| is copied from |data|. Buffer will be |
| 49 // padded and aligned as necessary. |data| must not be NULL and |size| >= 0. | 49 // padded and aligned as necessary. |data| must not be NULL and |size| >= 0. |
| 50 static scoped_refptr<DecoderBuffer> CopyFrom(const uint8* data, int size); | 50 // |is_keyframe| indicates if the buffer is a random access point. |
| 51 static scoped_refptr<DecoderBuffer> CopyFrom(const uint8* data, int size, | |
| 52 bool is_keyframe); | |
|
xhwang
2014/11/10 20:14:12
We don't set a lot of variables in CopyFrom, e.g.
wolenetz
2014/11/11 22:39:41
Done. This makes the change less extensive, too. K
| |
| 51 | 53 |
| 52 // Create a DecoderBuffer whose |data_| is copied from |data| and |side_data_| | 54 // Create a DecoderBuffer whose |data_| is copied from |data| and |side_data_| |
| 53 // is copied from |side_data|. Buffers will be padded and aligned as necessary | 55 // is copied from |side_data|. Buffers will be padded and aligned as necessary |
| 54 // Data pointers must not be NULL and sizes must be >= 0. | 56 // Data pointers must not be NULL and sizes must be >= 0. |is_keyframe| |
| 57 // indicates if the buffer is a random access point. | |
| 55 static scoped_refptr<DecoderBuffer> CopyFrom(const uint8* data, int size, | 58 static scoped_refptr<DecoderBuffer> CopyFrom(const uint8* data, int size, |
| 56 const uint8* side_data, | 59 const uint8* side_data, |
| 57 int side_data_size); | 60 int side_data_size, |
| 61 bool is_keyframe); | |
|
xhwang
2014/11/10 20:14:12
ditto.
wolenetz
2014/11/11 22:39:41
Done.
| |
| 58 | 62 |
| 59 // Create a DecoderBuffer indicating we've reached end of stream. | 63 // Create a DecoderBuffer indicating we've reached end of stream. |
| 60 // | 64 // |
| 61 // Calling any method other than end_of_stream() on the resulting buffer | 65 // Calling any method other than end_of_stream() on the resulting buffer |
| 62 // is disallowed. | 66 // is disallowed. |
| 63 static scoped_refptr<DecoderBuffer> CreateEOSBuffer(); | 67 static scoped_refptr<DecoderBuffer> CreateEOSBuffer(); |
| 64 | 68 |
| 65 base::TimeDelta timestamp() const { | 69 base::TimeDelta timestamp() const { |
| 66 DCHECK(!end_of_stream()); | 70 DCHECK(!end_of_stream()); |
| 67 return timestamp_; | 71 return timestamp_; |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 147 return splice_timestamp_; | 151 return splice_timestamp_; |
| 148 } | 152 } |
| 149 | 153 |
| 150 // When set to anything but kNoTimestamp() indicates this buffer is part of a | 154 // When set to anything but kNoTimestamp() indicates this buffer is part of a |
| 151 // splice around |splice_timestamp|. | 155 // splice around |splice_timestamp|. |
| 152 void set_splice_timestamp(base::TimeDelta splice_timestamp) { | 156 void set_splice_timestamp(base::TimeDelta splice_timestamp) { |
| 153 DCHECK(!end_of_stream()); | 157 DCHECK(!end_of_stream()); |
| 154 splice_timestamp_ = splice_timestamp; | 158 splice_timestamp_ = splice_timestamp; |
| 155 } | 159 } |
| 156 | 160 |
| 161 bool is_keyframe() const { | |
| 162 DCHECK(!end_of_stream()); | |
| 163 return is_keyframe_; | |
| 164 } | |
| 165 | |
| 166 void set_is_keyframe(bool is_keyframe) { | |
| 167 DCHECK(!end_of_stream()); | |
| 168 is_keyframe_ = is_keyframe; | |
| 169 } | |
| 170 | |
| 157 // Returns a human-readable string describing |*this|. | 171 // Returns a human-readable string describing |*this|. |
| 158 std::string AsHumanReadableString(); | 172 std::string AsHumanReadableString(); |
| 159 | 173 |
| 160 protected: | 174 protected: |
| 161 friend class base::RefCountedThreadSafe<DecoderBuffer>; | 175 friend class base::RefCountedThreadSafe<DecoderBuffer>; |
| 162 | 176 |
| 163 // Allocates a buffer of size |size| >= 0 and copies |data| into it. Buffer | 177 // Allocates a buffer of size |size| >= 0 and copies |data| into it. Buffer |
| 164 // will be padded and aligned as necessary. If |data| is NULL then |data_| is | 178 // will be padded and aligned as necessary. If |data| is NULL then |data_| is |
| 165 // set to NULL and |buffer_size_| to 0. | 179 // set to NULL and |buffer_size_| to 0. |is_keyframe| indicates if the buffer |
| 180 // is a random access point. | |
| 166 DecoderBuffer(const uint8* data, int size, | 181 DecoderBuffer(const uint8* data, int size, |
| 167 const uint8* side_data, int side_data_size); | 182 const uint8* side_data, int side_data_size, |
| 183 bool is_keyframe); | |
|
xhwang
2014/11/10 20:14:12
ditto
wolenetz
2014/11/11 22:39:41
Done.
| |
| 168 virtual ~DecoderBuffer(); | 184 virtual ~DecoderBuffer(); |
| 169 | 185 |
| 170 private: | 186 private: |
| 171 base::TimeDelta timestamp_; | 187 base::TimeDelta timestamp_; |
| 172 base::TimeDelta duration_; | 188 base::TimeDelta duration_; |
| 173 | 189 |
| 174 int size_; | 190 int size_; |
| 175 scoped_ptr<uint8, base::AlignedFreeDeleter> data_; | 191 scoped_ptr<uint8, base::AlignedFreeDeleter> data_; |
| 176 int side_data_size_; | 192 int side_data_size_; |
| 177 scoped_ptr<uint8, base::AlignedFreeDeleter> side_data_; | 193 scoped_ptr<uint8, base::AlignedFreeDeleter> side_data_; |
| 178 scoped_ptr<DecryptConfig> decrypt_config_; | 194 scoped_ptr<DecryptConfig> decrypt_config_; |
| 179 DiscardPadding discard_padding_; | 195 DiscardPadding discard_padding_; |
| 180 base::TimeDelta splice_timestamp_; | 196 base::TimeDelta splice_timestamp_; |
| 197 bool is_keyframe_; | |
|
xhwang
2014/11/10 20:14:12
It seems to me key and frame should be two words,
wolenetz
2014/11/11 22:39:41
There is much inconsistency on the web about this
| |
| 181 | 198 |
| 182 // Constructor helper method for memory allocations. | 199 // Constructor helper method for memory allocations. |
| 183 void Initialize(); | 200 void Initialize(); |
| 184 | 201 |
| 185 DISALLOW_COPY_AND_ASSIGN(DecoderBuffer); | 202 DISALLOW_COPY_AND_ASSIGN(DecoderBuffer); |
| 186 }; | 203 }; |
| 187 | 204 |
| 188 } // namespace media | 205 } // namespace media |
| 189 | 206 |
| 190 #endif // MEDIA_BASE_DECODER_BUFFER_H_ | 207 #endif // MEDIA_BASE_DECODER_BUFFER_H_ |
| OLD | NEW |