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 | 9 |
10 #include "base/memory/aligned_memory.h" | 10 #include "base/memory/aligned_memory.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 }; | 40 }; |
41 | 41 |
42 // Allocates buffer with |size| >= 0. Buffer will be padded and aligned | 42 // Allocates buffer with |size| >= 0. Buffer will be padded and aligned |
43 // as necessary. | 43 // as necessary. |
44 explicit DecoderBuffer(int size); | 44 explicit DecoderBuffer(int size); |
45 | 45 |
46 // Create a DecoderBuffer whose |data_| is copied from |data|. Buffer will be | 46 // Create a DecoderBuffer whose |data_| is copied from |data|. Buffer will be |
47 // padded and aligned as necessary. |data| must not be NULL and |size| >= 0. | 47 // padded and aligned as necessary. |data| must not be NULL and |size| >= 0. |
48 static scoped_refptr<DecoderBuffer> CopyFrom(const uint8* data, int size); | 48 static scoped_refptr<DecoderBuffer> CopyFrom(const uint8* data, int size); |
49 | 49 |
50 // Create a DecoderBuffer whose |data_| is copied from |data| and |side_data_| | |
51 // is copied from |side_data|. Buffers will be padded and aligned as necessary | |
52 // Data pointers must not be NULL and sizes must be >= 0. | |
53 static scoped_refptr<DecoderBuffer> CopyFrom(const uint8* data, int size, | |
54 const uint8* side_data, | |
55 int side_data_size); | |
56 | |
57 // Create a DecoderBuffer indicating we've reached end of stream. | 50 // Create a DecoderBuffer indicating we've reached end of stream. |
58 // | 51 // |
59 // Calling any method other than IsEndOfStream() on the resulting buffer | 52 // Calling any method other than IsEndOfStream() on the resulting buffer |
60 // is disallowed. | 53 // is disallowed. |
61 static scoped_refptr<DecoderBuffer> CreateEOSBuffer(); | 54 static scoped_refptr<DecoderBuffer> CreateEOSBuffer(); |
62 | 55 |
63 base::TimeDelta GetTimestamp() const; | 56 base::TimeDelta GetTimestamp() const; |
64 void SetTimestamp(const base::TimeDelta& timestamp); | 57 void SetTimestamp(const base::TimeDelta& timestamp); |
65 | 58 |
66 base::TimeDelta GetDuration() const; | 59 base::TimeDelta GetDuration() const; |
67 void SetDuration(const base::TimeDelta& duration); | 60 void SetDuration(const base::TimeDelta& duration); |
68 | 61 |
69 const uint8* GetData() const; | 62 const uint8* GetData() const; |
70 uint8* GetWritableData() const; | 63 uint8* GetWritableData() const; |
71 | 64 |
72 int GetDataSize() const; | 65 int GetDataSize() const; |
73 | 66 |
74 const uint8* GetSideData() const; | |
75 int GetSideDataSize() const; | |
76 | |
77 const DecryptConfig* GetDecryptConfig() const; | 67 const DecryptConfig* GetDecryptConfig() const; |
78 void SetDecryptConfig(scoped_ptr<DecryptConfig> decrypt_config); | 68 void SetDecryptConfig(scoped_ptr<DecryptConfig> decrypt_config); |
79 | 69 |
80 // If there's no data in this buffer, it represents end of stream. | 70 // If there's no data in this buffer, it represents end of stream. |
81 bool IsEndOfStream() const; | 71 bool IsEndOfStream() const; |
82 | 72 |
83 // Returns a human-readable string describing |*this|. | 73 // Returns a human-readable string describing |*this|. |
84 std::string AsHumanReadableString(); | 74 std::string AsHumanReadableString(); |
85 | 75 |
86 protected: | 76 protected: |
87 friend class base::RefCountedThreadSafe<DecoderBuffer>; | 77 friend class base::RefCountedThreadSafe<DecoderBuffer>; |
88 | 78 |
89 // Allocates a buffer of size |size| >= 0 and copies |data| into it. Buffer | 79 // Allocates a buffer of size |size| >= 0 and copies |data| into it. Buffer |
90 // will be padded and aligned as necessary. If |data| is NULL then |data_| is | 80 // will be padded and aligned as necessary. If |data| is NULL then |data_| is |
91 // set to NULL and |buffer_size_| to 0. | 81 // set to NULL and |buffer_size_| to 0. |
92 DecoderBuffer(const uint8* data, int size); | 82 DecoderBuffer(const uint8* data, int size); |
93 DecoderBuffer(const uint8* data, int size, | |
94 const uint8* side_data, int side_data_size); | |
95 virtual ~DecoderBuffer(); | 83 virtual ~DecoderBuffer(); |
96 | 84 |
97 private: | 85 private: |
98 base::TimeDelta timestamp_; | 86 base::TimeDelta timestamp_; |
99 base::TimeDelta duration_; | 87 base::TimeDelta duration_; |
100 | 88 |
101 int size_; | 89 int size_; |
102 scoped_ptr<uint8, base::ScopedPtrAlignedFree> data_; | 90 scoped_ptr<uint8, base::ScopedPtrAlignedFree> data_; |
103 int side_data_size_; | |
104 scoped_ptr<uint8, base::ScopedPtrAlignedFree> side_data_; | |
105 scoped_ptr<DecryptConfig> decrypt_config_; | 91 scoped_ptr<DecryptConfig> decrypt_config_; |
106 | 92 |
107 // Constructor helper method for memory allocations. | 93 // Constructor helper method for memory allocations. |
108 void Initialize(); | 94 void Initialize(); |
109 | 95 |
110 DISALLOW_COPY_AND_ASSIGN(DecoderBuffer); | 96 DISALLOW_COPY_AND_ASSIGN(DecoderBuffer); |
111 }; | 97 }; |
112 | 98 |
113 } // namespace media | 99 } // namespace media |
114 | 100 |
115 #endif // MEDIA_BASE_DECODER_BUFFER_H_ | 101 #endif // MEDIA_BASE_DECODER_BUFFER_H_ |
OLD | NEW |