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 "base/memory/aligned_memory.h" | 8 #include "base/memory/aligned_memory.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 public: | 28 public: |
29 enum { | 29 enum { |
30 kPaddingSize = 16, | 30 kPaddingSize = 16, |
31 #if defined(ARCH_CPU_ARM_FAMILY) | 31 #if defined(ARCH_CPU_ARM_FAMILY) |
32 kAlignmentSize = 16 | 32 kAlignmentSize = 16 |
33 #else | 33 #else |
34 kAlignmentSize = 32 | 34 kAlignmentSize = 32 |
35 #endif | 35 #endif |
36 }; | 36 }; |
37 | 37 |
38 // Allocates buffer of size |buffer_size| >= 0. Buffer will be padded and | 38 // Allocates buffer with |size| >= 0. Buffer will be padded and aligned |
39 // aligned as necessary. | 39 // as necessary. |
40 explicit DecoderBuffer(int buffer_size); | 40 explicit DecoderBuffer(int size); |
41 | 41 |
42 // Create a DecoderBuffer whose |data_| is copied from |data|. Buffer will be | 42 // Create a DecoderBuffer whose |data_| is copied from |data|. Buffer will be |
43 // padded and aligned as necessary. |data| must not be NULL and |size| >= 0. | 43 // padded and aligned as necessary. |data| must not be NULL and |size| >= 0. |
44 static scoped_refptr<DecoderBuffer> CopyFrom(const uint8* data, int size); | 44 static scoped_refptr<DecoderBuffer> CopyFrom(const uint8* data, int size); |
45 | 45 |
46 // Create a DecoderBuffer indicating we've reached end of stream. GetData() | 46 // Create a DecoderBuffer indicating we've reached end of stream. GetData() |
47 // and GetWritableData() will return NULL and GetDataSize() will return 0. | 47 // and GetWritableData() will return NULL and GetDataSize() will return 0. |
48 static scoped_refptr<DecoderBuffer> CreateEOSBuffer(); | 48 static scoped_refptr<DecoderBuffer> CreateEOSBuffer(); |
49 | 49 |
50 base::TimeDelta GetTimestamp() const; | 50 base::TimeDelta GetTimestamp() const; |
51 void SetTimestamp(const base::TimeDelta& timestamp); | 51 void SetTimestamp(const base::TimeDelta& timestamp); |
52 | 52 |
53 base::TimeDelta GetDuration() const; | 53 base::TimeDelta GetDuration() const; |
54 void SetDuration(const base::TimeDelta& duration); | 54 void SetDuration(const base::TimeDelta& duration); |
55 | 55 |
56 const uint8* GetData() const; | 56 const uint8* GetData() const; |
57 uint8* GetWritableData() const; | 57 uint8* GetWritableData() const; |
58 | 58 |
59 int GetDataSize() const; | 59 int GetDataSize() const; |
60 | 60 |
61 const DecryptConfig* GetDecryptConfig() const; | 61 const DecryptConfig* GetDecryptConfig() const; |
62 void SetDecryptConfig(scoped_ptr<DecryptConfig> decrypt_config); | 62 void SetDecryptConfig(scoped_ptr<DecryptConfig> decrypt_config); |
63 | 63 |
64 // If there's no data in this buffer, it represents end of stream. | 64 // If there's no data in this buffer, it represents end of stream. |
65 // | |
66 // TODO(scherkus): Change to be an actual settable flag as opposed to being | |
67 // based on the value of |data_|, see http://crbug.com/169133 | |
68 bool IsEndOfStream() const; | 65 bool IsEndOfStream() const; |
69 | 66 |
70 protected: | 67 protected: |
71 friend class base::RefCountedThreadSafe<DecoderBuffer>; | 68 friend class base::RefCountedThreadSafe<DecoderBuffer>; |
72 | 69 |
73 // Allocates a buffer of size |size| >= 0 and copies |data| into it. Buffer | 70 // Allocates a buffer of size |size| >= 0 and copies |data| into it. Buffer |
74 // will be padded and aligned as necessary. If |data| is NULL then |data_| is | 71 // will be padded and aligned as necessary. If |data| is NULL then |data_| is |
75 // set to NULL and |buffer_size_| to 0. | 72 // set to NULL and |buffer_size_| to 0. |
76 DecoderBuffer(const uint8* data, int size); | 73 DecoderBuffer(const uint8* data, int size); |
77 virtual ~DecoderBuffer(); | 74 virtual ~DecoderBuffer(); |
78 | 75 |
79 private: | 76 private: |
80 base::TimeDelta timestamp_; | 77 base::TimeDelta timestamp_; |
81 base::TimeDelta duration_; | 78 base::TimeDelta duration_; |
82 | 79 |
83 int buffer_size_; | 80 int size_; |
84 scoped_ptr<uint8, base::ScopedPtrAlignedFree> data_; | 81 scoped_ptr<uint8, base::ScopedPtrAlignedFree> data_; |
85 scoped_ptr<DecryptConfig> decrypt_config_; | 82 scoped_ptr<DecryptConfig> decrypt_config_; |
86 | 83 |
87 // Constructor helper method for memory allocations. | 84 // Constructor helper method for memory allocations. |
88 void Initialize(); | 85 void Initialize(); |
89 | 86 |
90 DISALLOW_COPY_AND_ASSIGN(DecoderBuffer); | 87 DISALLOW_COPY_AND_ASSIGN(DecoderBuffer); |
91 }; | 88 }; |
92 | 89 |
93 } // namespace media | 90 } // namespace media |
94 | 91 |
95 #endif // MEDIA_BASE_DECODER_BUFFER_H_ | 92 #endif // MEDIA_BASE_DECODER_BUFFER_H_ |
OLD | NEW |