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_V4_0_CODECCOMPONENTSERVICE_H 17 #define OHOS_HDI_CODEC_V4_0_CODECCOMPONENTSERVICE_H 18 19 #include "component_node.h" 20 #include "v4_0/icodec_component.h" 21 22 namespace OHOS { 23 namespace HDI { 24 namespace Codec { 25 namespace V4_0 { 26 class CodecComponentService : public ICodecComponent { 27 public: 28 CodecComponentService(const std::shared_ptr<OHOS::Codec::Omx::ComponentNode> &node, 29 const std::shared_ptr<OHOS::Codec::Omx::ComponentMgr> mgr, const std::string name); 30 virtual ~CodecComponentService(); 31 int32_t GetComponentVersion(CompVerInfo &verInfo) override; 32 int32_t SendCommand(CodecCommandType cmd, uint32_t param, const std::vector<int8_t> &cmdData) override; 33 int32_t GetParameter(uint32_t index, const std::vector<int8_t> &inParamStruct, 34 std::vector<int8_t> &outParamStruct) override; 35 int32_t SetParameter(uint32_t index, const std::vector<int8_t> ¶mStruct) override; 36 int32_t GetConfig(uint32_t index, const std::vector<int8_t> &inCfgStruct, 37 std::vector<int8_t> &outCfgStruct) override; 38 int32_t SetConfig(uint32_t index, const std::vector<int8_t> &cfgStruct) override; 39 int32_t GetExtensionIndex(const std::string ¶mName, uint32_t &indexType) override; 40 int32_t GetState(CodecStateType &state) override; 41 int32_t ComponentTunnelRequest(uint32_t port, int32_t tunneledComp, uint32_t tunneledPort, 42 const CodecTunnelSetupType &inTunnelSetup, 43 CodecTunnelSetupType &outTunnelSetup) override; 44 int32_t UseBuffer(uint32_t portIndex, const OmxCodecBuffer &inBuffer, OmxCodecBuffer &outBuffer) override; 45 int32_t AllocateBuffer(uint32_t portIndex, const OmxCodecBuffer &inBuffer, OmxCodecBuffer &outBuffer) override; 46 int32_t FreeBuffer(uint32_t portIndex, const OmxCodecBuffer &buffer) override; 47 int32_t EmptyThisBuffer(const OmxCodecBuffer &buffer) override; 48 int32_t FillThisBuffer(const OmxCodecBuffer &buffer) override; 49 int32_t SetCallbacks(const sptr<ICodecCallback> &callbacks, int64_t appData) override; 50 int32_t ComponentDeInit() override; 51 int32_t UseEglImage(uint32_t portIndex, const OmxCodecBuffer &inBuffer, OmxCodecBuffer &outBuffer, 52 const std::vector<int8_t> &eglImage) override; 53 int32_t ComponentRoleEnum(std::vector<uint8_t> &role, uint32_t index) override; 54 int32_t SetParameterWithBuffer(uint32_t index, const std::vector<int8_t>& paramStruct, 55 const OmxCodecBuffer& inBuffer) override; 56 57 const std::string &GetComponentCompName() const; 58 void GetComponentNode(std::shared_ptr<OHOS::Codec::Omx::ComponentNode> &dumpNode_); 59 60 private: 61 void SetComponentRole(); 62 void ReleaseCache(); 63 bool isIPCMode_; 64 std::string name_; 65 std::mutex nodeMutex_; 66 std::shared_ptr<OHOS::Codec::Omx::ComponentNode> node_; 67 std::shared_ptr<OHOS::Codec::Omx::ComponentMgr> mgr_; 68 }; 69 70 } // namespace V4_0 71 } // namespace Codec 72 } // namespace HDI 73 } // namespace OHOS 74 75 #endif // OHOS_HDI_CODEC_V4_0_CODECCOMPONENTSERVICE_H