| 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_key_frame_| 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 // The buffer's |is_key_frame_| will default to false. |
| 50 static scoped_refptr<DecoderBuffer> CopyFrom(const uint8* data, int size); | 51 static scoped_refptr<DecoderBuffer> CopyFrom(const uint8* data, int size); |
| 51 | 52 |
| 52 // Create a DecoderBuffer whose |data_| is copied from |data| and |side_data_| | 53 // 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 | 54 // 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. | 55 // Data pointers must not be NULL and sizes must be >= 0. The buffer's |
| 56 // |is_key_frame_| will default to false. |
| 55 static scoped_refptr<DecoderBuffer> CopyFrom(const uint8* data, int size, | 57 static scoped_refptr<DecoderBuffer> CopyFrom(const uint8* data, int size, |
| 56 const uint8* side_data, | 58 const uint8* side_data, |
| 57 int side_data_size); | 59 int side_data_size); |
| 58 | 60 |
| 59 // Create a DecoderBuffer indicating we've reached end of stream. | 61 // Create a DecoderBuffer indicating we've reached end of stream. |
| 60 // | 62 // |
| 61 // Calling any method other than end_of_stream() on the resulting buffer | 63 // Calling any method other than end_of_stream() on the resulting buffer |
| 62 // is disallowed. | 64 // is disallowed. |
| 63 static scoped_refptr<DecoderBuffer> CreateEOSBuffer(); | 65 static scoped_refptr<DecoderBuffer> CreateEOSBuffer(); |
| 64 | 66 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 return splice_timestamp_; | 149 return splice_timestamp_; |
| 148 } | 150 } |
| 149 | 151 |
| 150 // When set to anything but kNoTimestamp() indicates this buffer is part of a | 152 // When set to anything but kNoTimestamp() indicates this buffer is part of a |
| 151 // splice around |splice_timestamp|. | 153 // splice around |splice_timestamp|. |
| 152 void set_splice_timestamp(base::TimeDelta splice_timestamp) { | 154 void set_splice_timestamp(base::TimeDelta splice_timestamp) { |
| 153 DCHECK(!end_of_stream()); | 155 DCHECK(!end_of_stream()); |
| 154 splice_timestamp_ = splice_timestamp; | 156 splice_timestamp_ = splice_timestamp; |
| 155 } | 157 } |
| 156 | 158 |
| 159 bool is_key_frame() const { |
| 160 DCHECK(!end_of_stream()); |
| 161 return is_key_frame_; |
| 162 } |
| 163 |
| 164 void set_is_key_frame(bool is_key_frame) { |
| 165 DCHECK(!end_of_stream()); |
| 166 is_key_frame_ = is_key_frame; |
| 167 } |
| 168 |
| 157 // Returns a human-readable string describing |*this|. | 169 // Returns a human-readable string describing |*this|. |
| 158 std::string AsHumanReadableString(); | 170 std::string AsHumanReadableString(); |
| 159 | 171 |
| 160 protected: | 172 protected: |
| 161 friend class base::RefCountedThreadSafe<DecoderBuffer>; | 173 friend class base::RefCountedThreadSafe<DecoderBuffer>; |
| 162 | 174 |
| 163 // Allocates a buffer of size |size| >= 0 and copies |data| into it. Buffer | 175 // 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 | 176 // will be padded and aligned as necessary. If |data| is NULL then |data_| is |
| 165 // set to NULL and |buffer_size_| to 0. | 177 // set to NULL and |buffer_size_| to 0. |is_key_frame_| will default to |
| 178 // false. |
| 166 DecoderBuffer(const uint8* data, int size, | 179 DecoderBuffer(const uint8* data, int size, |
| 167 const uint8* side_data, int side_data_size); | 180 const uint8* side_data, int side_data_size); |
| 168 virtual ~DecoderBuffer(); | 181 virtual ~DecoderBuffer(); |
| 169 | 182 |
| 170 private: | 183 private: |
| 171 base::TimeDelta timestamp_; | 184 base::TimeDelta timestamp_; |
| 172 base::TimeDelta duration_; | 185 base::TimeDelta duration_; |
| 173 | 186 |
| 174 int size_; | 187 int size_; |
| 175 scoped_ptr<uint8, base::AlignedFreeDeleter> data_; | 188 scoped_ptr<uint8, base::AlignedFreeDeleter> data_; |
| 176 int side_data_size_; | 189 int side_data_size_; |
| 177 scoped_ptr<uint8, base::AlignedFreeDeleter> side_data_; | 190 scoped_ptr<uint8, base::AlignedFreeDeleter> side_data_; |
| 178 scoped_ptr<DecryptConfig> decrypt_config_; | 191 scoped_ptr<DecryptConfig> decrypt_config_; |
| 179 DiscardPadding discard_padding_; | 192 DiscardPadding discard_padding_; |
| 180 base::TimeDelta splice_timestamp_; | 193 base::TimeDelta splice_timestamp_; |
| 194 bool is_key_frame_; |
| 181 | 195 |
| 182 // Constructor helper method for memory allocations. | 196 // Constructor helper method for memory allocations. |
| 183 void Initialize(); | 197 void Initialize(); |
| 184 | 198 |
| 185 DISALLOW_COPY_AND_ASSIGN(DecoderBuffer); | 199 DISALLOW_COPY_AND_ASSIGN(DecoderBuffer); |
| 186 }; | 200 }; |
| 187 | 201 |
| 188 } // namespace media | 202 } // namespace media |
| 189 | 203 |
| 190 #endif // MEDIA_BASE_DECODER_BUFFER_H_ | 204 #endif // MEDIA_BASE_DECODER_BUFFER_H_ |
| OLD | NEW |