1 /*
2  * Copyright (c) 2022-2023 Shenzhen Kaihong DID Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef OHOS_HDI_CODEC_V3_0_CODECCOMPONENTSERVICE_H
17 #define OHOS_HDI_CODEC_V3_0_CODECCOMPONENTSERVICE_H
18 
19 #include "component_node.h"
20 #include "v3_0/icodec_component.h"
21 #include "v1_0/imapper.h"
22 
23 namespace OHOS {
24 namespace HDI {
25 namespace Codec {
26 namespace V3_0 {
27 class CodecComponentService : public ICodecComponent {
28 public:
29     CodecComponentService(const std::shared_ptr<OHOS::Codec::Omx::ComponentNode> &node,
30                           const std::shared_ptr<OHOS::Codec::Omx::ComponentMgr> mgr, const std::string name);
31     virtual ~CodecComponentService();
32     int32_t GetComponentVersion(CompVerInfo &verInfo) override;
33     int32_t SendCommand(CodecCommandType cmd, uint32_t param, const std::vector<int8_t> &cmdData) override;
34     int32_t GetParameter(uint32_t index, const std::vector<int8_t> &inParamStruct,
35                          std::vector<int8_t> &outParamStruct) override;
36     int32_t SetParameter(uint32_t index, const std::vector<int8_t> &paramStruct) override;
37     int32_t GetConfig(uint32_t index, const std::vector<int8_t> &inCfgStruct,
38                       std::vector<int8_t> &outCfgStruct) override;
39     int32_t SetConfig(uint32_t index, const std::vector<int8_t> &cfgStruct) override;
40     int32_t GetExtensionIndex(const std::string &paramName, uint32_t &indexType) override;
41     int32_t GetState(CodecStateType &state) override;
42     int32_t ComponentTunnelRequest(uint32_t port, int32_t tunneledComp, uint32_t tunneledPort,
43                                    const CodecTunnelSetupType &inTunnelSetup,
44                                    CodecTunnelSetupType &outTunnelSetup) override;
45     int32_t UseBuffer(uint32_t portIndex, const OmxCodecBuffer &inBuffer, OmxCodecBuffer &outBuffer) override;
46     int32_t AllocateBuffer(uint32_t portIndex, const OmxCodecBuffer &inBuffer, OmxCodecBuffer &outBuffer) override;
47     int32_t FreeBuffer(uint32_t portIndex, const OmxCodecBuffer &buffer) override;
48     int32_t EmptyThisBuffer(const OmxCodecBuffer &buffer) override;
49     int32_t FillThisBuffer(const OmxCodecBuffer &buffer) override;
50     int32_t SetCallbacks(const sptr<ICodecCallback> &callbacks, int64_t appData) override;
51     int32_t ComponentDeInit() override;
52     int32_t UseEglImage(uint32_t portIndex, const OmxCodecBuffer &inBuffer, OmxCodecBuffer &outBuffer,
53                         const std::vector<int8_t> &eglImage) override;
54     int32_t ComponentRoleEnum(std::vector<uint8_t> &role, uint32_t index) override;
55     int32_t SetParameterWithBuffer(uint32_t index, const std::vector<int8_t>& paramStruct,
56                                    const OmxCodecBuffer& inBuffer) override;
57 
58     const std::string &GetComponentCompName() const;
59     void GetComponentNode(std::shared_ptr<OHOS::Codec::Omx::ComponentNode> &dumpNode_);
60 private:
61     void SetComponentRole();
62     void ReleaseCache();
63     bool isIPCMode_;
64     std::string name_;
65     std::shared_ptr<OHOS::Codec::Omx::ComponentNode> node_;
66     std::shared_ptr<OHOS::Codec::Omx::ComponentMgr> mgr_;
67 };
68 
69 sptr<OHOS::HDI::Display::Buffer::V1_0::IMapper> GetMapperService();
70 
71 }  // namespace V3_0
72 }  // namespace Codec
73 }  // namespace HDI
74 }  // namespace OHOS
75 
76 #endif  // OHOS_HDI_CODEC_V3_0_CODECCOMPONENTSERVICE_H