blob: 633cdaaf1f0c5b184ca372c1f46611f303cd02fe [file] [log] [blame]
Dale Satherad2cbf22016-02-10 17:00:57 -08001// Copyright 2016 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef SERVICES_MEDIA_FRAMEWORK_PAYLOAD_ALLOCATOR_H_
6#define SERVICES_MEDIA_FRAMEWORK_PAYLOAD_ALLOCATOR_H_
7
8#include <stddef.h>
9
10namespace mojo {
11namespace media {
12
13// Abstract base class for objects that allocate buffers for packets.
14class PayloadAllocator {
15 public:
16 // Gets the default allocator, which allocates vanilla memory from the heap.
17 static PayloadAllocator* GetDefault();
18
19 // Allocates and returns a buffer of the indicated size or returns nullptr
20 // if the allocation fails.
21 virtual void* AllocatePayloadBuffer(size_t size) = 0;
22
23 // Releases a buffer previously allocated via AllocatePayloadBuffer.
Dale Sathereee34002016-06-20 10:47:59 -070024 virtual void ReleasePayloadBuffer(void* buffer) = 0;
Dale Satherad2cbf22016-02-10 17:00:57 -080025};
26
27} // namespace media
28} // namespace mojo
29
Dale Sather4ccdd212016-03-23 09:27:19 -070030#endif // SERVICES_MEDIA_FRAMEWORK_PAYLOAD_ALLOCATOR_H_