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_DATA_BUFFER_H_ | 5 #ifndef MEDIA_BASE_DATA_BUFFER_H_ |
6 #define MEDIA_BASE_DATA_BUFFER_H_ | 6 #define MEDIA_BASE_DATA_BUFFER_H_ |
7 | 7 |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/time.h" | 10 #include "base/time.h" |
11 #include "media/base/media_export.h" | 11 #include "media/base/media_export.h" |
12 | 12 |
13 namespace media { | 13 namespace media { |
14 | 14 |
15 // A simple buffer that takes ownership of the given data pointer or allocates | 15 // A simple buffer that takes ownership of the given data pointer or allocates |
16 // as necessary. | 16 // as necessary. |
17 // | 17 // |
18 // Unlike DecoderBuffer, allocations are assumed to be allocated with the | 18 // Unlike DecoderBuffer, allocations are assumed to be allocated with the |
19 // default memory allocator (i.e., new uint8[]). | 19 // default memory allocator (i.e., new uint8[]). |
| 20 // |
| 21 // NOTE: It is illegal to call any method when IsEndOfStream() is true. |
20 class MEDIA_EXPORT DataBuffer : public base::RefCountedThreadSafe<DataBuffer> { | 22 class MEDIA_EXPORT DataBuffer : public base::RefCountedThreadSafe<DataBuffer> { |
21 public: | 23 public: |
22 // Allocates buffer of size |buffer_size| >= 0. | 24 // Allocates buffer of size |buffer_size| >= 0. |
23 explicit DataBuffer(int buffer_size); | 25 explicit DataBuffer(int buffer_size); |
24 | 26 |
25 // Assumes valid data of size |buffer_size|. | 27 // Assumes valid data of size |buffer_size|. |
26 DataBuffer(scoped_array<uint8> buffer, int buffer_size); | 28 DataBuffer(scoped_array<uint8> buffer, int buffer_size); |
27 | 29 |
28 // Create a DataBuffer whose |data_| is copied from |data|. | 30 // Create a DataBuffer whose |data_| is copied from |data|. |
29 // | 31 // |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 scoped_array<uint8> data_; | 74 scoped_array<uint8> data_; |
73 int buffer_size_; | 75 int buffer_size_; |
74 int data_size_; | 76 int data_size_; |
75 | 77 |
76 DISALLOW_COPY_AND_ASSIGN(DataBuffer); | 78 DISALLOW_COPY_AND_ASSIGN(DataBuffer); |
77 }; | 79 }; |
78 | 80 |
79 } // namespace media | 81 } // namespace media |
80 | 82 |
81 #endif // MEDIA_BASE_DATA_BUFFER_H_ | 83 #endif // MEDIA_BASE_DATA_BUFFER_H_ |
OLD | NEW |