• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2020 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 ANDROID_V4L2_CODEC2_PLUGIN_STORE_VENDOR_ALLOCATOR_LOADER_H
6 #define ANDROID_V4L2_CODEC2_PLUGIN_STORE_VENDOR_ALLOCATOR_LOADER_H
7 
8 #include <memory>
9 #include <mutex>
10 
11 #include <C2Buffer.h>
12 
13 namespace android {
14 
15 // This class is for loading the vendor-specific C2Allocator implementations.
16 // The vendor should implement the shared library "libv4l2_codec2_vendor_allocator.so"
17 // and expose the function "C2Allocator* CreateAllocator(C2Allocator::id_t allocatorId);".
18 class VendorAllocatorLoader {
19 public:
20     using CreateAllocatorFunc = ::C2Allocator* (*)(C2Allocator::id_t /* allocatorId */);
21 
22     static std::unique_ptr<VendorAllocatorLoader> Create();
23     ~VendorAllocatorLoader();
24 
25     // Delegate to the vendor's shared library. |allocatorId| should be one of enum listed at
26     // V4L2AllocatorId.h.
27     C2Allocator* createAllocator(C2Allocator::id_t allocatorId);
28 
29 private:
30     VendorAllocatorLoader(void* libHandle, CreateAllocatorFunc createAllocatorFunc);
31 
32     void* mLibHandle;
33     CreateAllocatorFunc mCreateAllocatorFunc;
34 };
35 
36 }  // namespace android
37 #endif  // ANDROID_V4L2_CODEC2_PLUGIN_STORE_VENDOR_ALLOCATOR_LOADER_H
38