xref: /aosp_15_r20/external/v4l2_codec2/v4l2/include/v4l2_codec2/v4l2/V4L2ComponentFactory.h (revision 0ec5a0ec62797f775085659156625e7f1bdb369f)
1 // Copyright 2021 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_V4L2_V4L2_COMPONENT_FACTORY_H
6 #define ANDROID_V4L2_CODEC2_V4L2_V4L2_COMPONENT_FACTORY_H
7 
8 #include <memory>
9 #include <string>
10 
11 #include <C2ComponentFactory.h>
12 #include <util/C2InterfaceHelper.h>
13 #include <v4l2_codec2/common/Common.h>
14 
15 namespace android {
16 
17 struct SupportedCapabilities;
18 class DecodeInterface;
19 class EncodeInterface;
20 
21 class V4L2ComponentFactory : public C2ComponentFactory {
22 public:
23     static std::unique_ptr<V4L2ComponentFactory> create(
24             const std::string& componentName, std::shared_ptr<C2ReflectorHelper> reflector);
25     V4L2ComponentFactory(const std::string& componentName, bool isEncoder,
26                          std::shared_ptr<C2ReflectorHelper> reflector);
27     ~V4L2ComponentFactory() override = default;
28 
29     // Implementation of C2ComponentFactory.
30     c2_status_t createComponent(c2_node_id_t id, std::shared_ptr<C2Component>* const component,
31                                 ComponentDeleter deleter) override;
32     c2_status_t createInterface(c2_node_id_t id,
33                                 std::shared_ptr<C2ComponentInterface>* const interface,
34                                 InterfaceDeleter deleter) override;
35 
36 private:
37     c2_status_t createEncodeInterface(std::shared_ptr<EncodeInterface>* intfImpl);
38     c2_status_t createDecodeInterface(std::shared_ptr<DecodeInterface>* intfImpl);
39 
40     const std::string mComponentName;
41     const bool mIsEncoder;
42     std::shared_ptr<C2ReflectorHelper> mReflector;
43     std::unique_ptr<SupportedCapabilities> mCapabilites;
44 };
45 
46 }  // namespace android
47 
48 #endif  // ANDROID_V4L2_CODEC2_V4L2_V4L2_COMPONENT_FACTORY_H
49