OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 SERVICES_MEDIA_FRAMEWORK_PAYLOAD_ALLOCATOR_H_ | 5 #ifndef SERVICES_MEDIA_FRAMEWORK_PAYLOAD_ALLOCATOR_H_ |
6 #define SERVICES_MEDIA_FRAMEWORK_PAYLOAD_ALLOCATOR_H_ | 6 #define SERVICES_MEDIA_FRAMEWORK_PAYLOAD_ALLOCATOR_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 namespace mojo { | 10 namespace mojo { |
11 namespace media { | 11 namespace media { |
12 | 12 |
13 // Abstract base class for objects that allocate buffers for packets. | 13 // Abstract base class for objects that allocate buffers for packets. |
14 class PayloadAllocator { | 14 class PayloadAllocator { |
15 public: | 15 public: |
16 // Gets the default allocator, which allocates vanilla memory from the heap. | 16 // Gets the default allocator, which allocates vanilla memory from the heap. |
17 static PayloadAllocator* GetDefault(); | 17 static PayloadAllocator* GetDefault(); |
18 | 18 |
19 // Allocates and returns a buffer of the indicated size or returns nullptr | 19 // Allocates and returns a buffer of the indicated size or returns nullptr |
20 // if the allocation fails. | 20 // if the allocation fails. |
21 virtual void* AllocatePayloadBuffer(size_t size) = 0; | 21 virtual void* AllocatePayloadBuffer(size_t size) = 0; |
22 | 22 |
23 // Releases a buffer previously allocated via AllocatePayloadBuffer. | 23 // Releases a buffer previously allocated via AllocatePayloadBuffer. |
24 virtual void ReleasePayloadBuffer(size_t size, void* buffer) = 0; | 24 virtual void ReleasePayloadBuffer(size_t size, void* buffer) = 0; |
25 }; | 25 }; |
26 | 26 |
27 } // namespace media | 27 } // namespace media |
28 } // namespace mojo | 28 } // namespace mojo |
29 | 29 |
30 #endif // SERVICES_MEDIA_FRAMEWORK_PAYLOAD_ALLOCATOR_H_ | 30 #endif // SERVICES_MEDIA_FRAMEWORK_PAYLOAD_ALLOCATOR_H_ |
OLD | NEW |