1094332d3Sopenharmony_ci/*
2094332d3Sopenharmony_ci * Copyright (c) 2022-2023 Shenzhen Kaihong DID Co., Ltd.
3094332d3Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4094332d3Sopenharmony_ci * you may not use this file except in compliance with the License.
5094332d3Sopenharmony_ci * You may obtain a copy of the License at
6094332d3Sopenharmony_ci *
7094332d3Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8094332d3Sopenharmony_ci *
9094332d3Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10094332d3Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11094332d3Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12094332d3Sopenharmony_ci * See the License for the specific language governing permissions and
13094332d3Sopenharmony_ci * limitations under the License.
14094332d3Sopenharmony_ci */
15094332d3Sopenharmony_ci
16094332d3Sopenharmony_ci#ifndef OHOS_HDI_CODEC_V3_0_CODECCOMPONENTSERVICE_H
17094332d3Sopenharmony_ci#define OHOS_HDI_CODEC_V3_0_CODECCOMPONENTSERVICE_H
18094332d3Sopenharmony_ci
19094332d3Sopenharmony_ci#include "component_node.h"
20094332d3Sopenharmony_ci#include "v3_0/icodec_component.h"
21094332d3Sopenharmony_ci#include "v1_0/imapper.h"
22094332d3Sopenharmony_ci
23094332d3Sopenharmony_cinamespace OHOS {
24094332d3Sopenharmony_cinamespace HDI {
25094332d3Sopenharmony_cinamespace Codec {
26094332d3Sopenharmony_cinamespace V3_0 {
27094332d3Sopenharmony_ciclass CodecComponentService : public ICodecComponent {
28094332d3Sopenharmony_cipublic:
29094332d3Sopenharmony_ci    CodecComponentService(const std::shared_ptr<OHOS::Codec::Omx::ComponentNode> &node,
30094332d3Sopenharmony_ci                          const std::shared_ptr<OHOS::Codec::Omx::ComponentMgr> mgr, const std::string name);
31094332d3Sopenharmony_ci    virtual ~CodecComponentService();
32094332d3Sopenharmony_ci    int32_t GetComponentVersion(CompVerInfo &verInfo) override;
33094332d3Sopenharmony_ci    int32_t SendCommand(CodecCommandType cmd, uint32_t param, const std::vector<int8_t> &cmdData) override;
34094332d3Sopenharmony_ci    int32_t GetParameter(uint32_t index, const std::vector<int8_t> &inParamStruct,
35094332d3Sopenharmony_ci                         std::vector<int8_t> &outParamStruct) override;
36094332d3Sopenharmony_ci    int32_t SetParameter(uint32_t index, const std::vector<int8_t> &paramStruct) override;
37094332d3Sopenharmony_ci    int32_t GetConfig(uint32_t index, const std::vector<int8_t> &inCfgStruct,
38094332d3Sopenharmony_ci                      std::vector<int8_t> &outCfgStruct) override;
39094332d3Sopenharmony_ci    int32_t SetConfig(uint32_t index, const std::vector<int8_t> &cfgStruct) override;
40094332d3Sopenharmony_ci    int32_t GetExtensionIndex(const std::string &paramName, uint32_t &indexType) override;
41094332d3Sopenharmony_ci    int32_t GetState(CodecStateType &state) override;
42094332d3Sopenharmony_ci    int32_t ComponentTunnelRequest(uint32_t port, int32_t tunneledComp, uint32_t tunneledPort,
43094332d3Sopenharmony_ci                                   const CodecTunnelSetupType &inTunnelSetup,
44094332d3Sopenharmony_ci                                   CodecTunnelSetupType &outTunnelSetup) override;
45094332d3Sopenharmony_ci    int32_t UseBuffer(uint32_t portIndex, const OmxCodecBuffer &inBuffer, OmxCodecBuffer &outBuffer) override;
46094332d3Sopenharmony_ci    int32_t AllocateBuffer(uint32_t portIndex, const OmxCodecBuffer &inBuffer, OmxCodecBuffer &outBuffer) override;
47094332d3Sopenharmony_ci    int32_t FreeBuffer(uint32_t portIndex, const OmxCodecBuffer &buffer) override;
48094332d3Sopenharmony_ci    int32_t EmptyThisBuffer(const OmxCodecBuffer &buffer) override;
49094332d3Sopenharmony_ci    int32_t FillThisBuffer(const OmxCodecBuffer &buffer) override;
50094332d3Sopenharmony_ci    int32_t SetCallbacks(const sptr<ICodecCallback> &callbacks, int64_t appData) override;
51094332d3Sopenharmony_ci    int32_t ComponentDeInit() override;
52094332d3Sopenharmony_ci    int32_t UseEglImage(uint32_t portIndex, const OmxCodecBuffer &inBuffer, OmxCodecBuffer &outBuffer,
53094332d3Sopenharmony_ci                        const std::vector<int8_t> &eglImage) override;
54094332d3Sopenharmony_ci    int32_t ComponentRoleEnum(std::vector<uint8_t> &role, uint32_t index) override;
55094332d3Sopenharmony_ci    int32_t SetParameterWithBuffer(uint32_t index, const std::vector<int8_t>& paramStruct,
56094332d3Sopenharmony_ci                                   const OmxCodecBuffer& inBuffer) override;
57094332d3Sopenharmony_ci
58094332d3Sopenharmony_ci    const std::string &GetComponentCompName() const;
59094332d3Sopenharmony_ci    void GetComponentNode(std::shared_ptr<OHOS::Codec::Omx::ComponentNode> &dumpNode_);
60094332d3Sopenharmony_ci    bool ReWrapNativeBufferInOmxBuffer(const OmxCodecBuffer &inBuffer);
61094332d3Sopenharmony_ciprivate:
62094332d3Sopenharmony_ci    void SetComponentRole();
63094332d3Sopenharmony_ci    void ReleaseCache();
64094332d3Sopenharmony_ci    bool isIPCMode_;
65094332d3Sopenharmony_ci    std::string name_;
66094332d3Sopenharmony_ci    std::shared_ptr<OHOS::Codec::Omx::ComponentNode> node_;
67094332d3Sopenharmony_ci    std::shared_ptr<OHOS::Codec::Omx::ComponentMgr> mgr_;
68094332d3Sopenharmony_ci};
69094332d3Sopenharmony_ci
70094332d3Sopenharmony_cisptr<OHOS::HDI::Display::Buffer::V1_0::IMapper> GetMapperService();
71094332d3Sopenharmony_ci
72094332d3Sopenharmony_ci}  // namespace V3_0
73094332d3Sopenharmony_ci}  // namespace Codec
74094332d3Sopenharmony_ci}  // namespace HDI
75094332d3Sopenharmony_ci}  // namespace OHOS
76094332d3Sopenharmony_ci
77094332d3Sopenharmony_ci#endif  // OHOS_HDI_CODEC_V3_0_CODECCOMPONENTSERVICE_H