1 /*
2  * Copyright (C) 2018 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef VNDK_HIDL_BUFFERPOOL_V1_0_ALLOCATOR_H
18 #define VNDK_HIDL_BUFFERPOOL_V1_0_ALLOCATOR_H
19 
20 #include <bufferpool/BufferPoolTypes.h>
21 
22 using android::hardware::media::bufferpool::V1_0::ResultStatus;
23 using android::hardware::media::bufferpool::V1_0::implementation::
24     BufferPoolAllocation;
25 using android::hardware::media::bufferpool::V1_0::implementation::
26     BufferPoolAllocator;
27 
28 // buffer allocator for the tests
29 class TestBufferPoolAllocator : public BufferPoolAllocator {
30  public:
TestBufferPoolAllocator()31   TestBufferPoolAllocator() {}
32 
~TestBufferPoolAllocator()33   ~TestBufferPoolAllocator() override {}
34 
35   ResultStatus allocate(const std::vector<uint8_t> &params,
36                         std::shared_ptr<BufferPoolAllocation> *alloc,
37                         size_t *allocSize) override;
38 
39   bool compatible(const std::vector<uint8_t> &newParams,
40                   const std::vector<uint8_t> &oldParams) override;
41 
42   static bool Fill(const native_handle_t *handle, const unsigned char val);
43 
44   static bool Verify(const native_handle_t *handle, const unsigned char val);
45 
46 };
47 
48 // retrieve buffer allocator paramters
49 void getTestAllocatorParams(std::vector<uint8_t> *params);
50 
51 #endif  // VNDK_HIDL_BUFFERPOOL_V1_0_ALLOCATOR_H
52