• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2022 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 #include "codec_component_service.h"
17 #include <hdf_base.h>
18 #include "codec_log_wrapper.h"
19 namespace OHOS {
20 namespace HDI {
21 namespace Codec {
22 namespace V1_0 {
GetComponentVersion(CompVerInfo & verInfo)23 int32_t CodecComponentService::GetComponentVersion(CompVerInfo &verInfo)
24 {
25     return node_->GetComponentVersion(verInfo);
26 }
27 
SendCommand(OMX_COMMANDTYPE cmd,uint32_t param,const std::vector<int8_t> & cmdData)28 int32_t CodecComponentService::SendCommand(OMX_COMMANDTYPE cmd, uint32_t param, const std::vector<int8_t> &cmdData)
29 {
30     CODEC_LOGD("cmd [%{public}d]", cmd);
31     return node_->SendCommand(cmd, param, const_cast<int8_t *>(cmdData.data()));
32 }
33 
GetParameter(uint32_t index,const std::vector<int8_t> & inParamStruct,std::vector<int8_t> & outParamStruct)34 int32_t CodecComponentService::GetParameter(uint32_t index, const std::vector<int8_t> &inParamStruct,
35                                             std::vector<int8_t> &outParamStruct)
36 {
37     CODEC_LOGD("index [%{public}d]", index);
38     outParamStruct = inParamStruct;
39     return node_->GetParameter(static_cast<enum OMX_INDEXTYPE>(index), outParamStruct.data());
40 }
41 
SetParameter(uint32_t index,const std::vector<int8_t> & paramStruct)42 int32_t CodecComponentService::SetParameter(uint32_t index, const std::vector<int8_t> &paramStruct)
43 {
44     CODEC_LOGD("index [%{public}d]", index);
45     return node_->SetParameter(static_cast<enum OMX_INDEXTYPE>(index), paramStruct.data());
46 }
47 
GetConfig(uint32_t index,const std::vector<int8_t> & inCfgStruct,std::vector<int8_t> & outCfgStruct)48 int32_t CodecComponentService::GetConfig(uint32_t index, const std::vector<int8_t> &inCfgStruct,
49                                          std::vector<int8_t> &outCfgStruct)
50 {
51     CODEC_LOGD("index [%{public}d]", index);
52     outCfgStruct = inCfgStruct;
53     return node_->GetConfig(static_cast<enum OMX_INDEXTYPE>(index), outCfgStruct.data());
54 }
55 
SetConfig(uint32_t index,const std::vector<int8_t> & cfgStruct)56 int32_t CodecComponentService::SetConfig(uint32_t index, const std::vector<int8_t> &cfgStruct)
57 {
58     CODEC_LOGD("index [%{public}d]", index);
59     return node_->SetConfig(static_cast<enum OMX_INDEXTYPE>(index), cfgStruct.data());
60 }
61 
GetExtensionIndex(const std::string & paramName,uint32_t & indexType)62 int32_t CodecComponentService::GetExtensionIndex(const std::string &paramName, uint32_t &indexType)
63 {
64     CODEC_LOGD("paramName [%{public}s]", paramName.c_str());
65     return node_->GetExtensionIndex(paramName.c_str(), indexType);
66 }
67 
GetState(OMX_STATETYPE & state)68 int32_t CodecComponentService::GetState(OMX_STATETYPE &state)
69 {
70     return node_->GetState(state);
71 }
72 
ComponentTunnelRequest(uint32_t port,int32_t tunneledComp,uint32_t tunneledPort,const OMX_TUNNELSETUPTYPE & inTunnelSetup,OMX_TUNNELSETUPTYPE & outTunnelSetup)73 int32_t CodecComponentService::ComponentTunnelRequest(uint32_t port, int32_t tunneledComp, uint32_t tunneledPort,
74                                                       const OMX_TUNNELSETUPTYPE &inTunnelSetup,
75                                                       OMX_TUNNELSETUPTYPE &outTunnelSetup)
76 {
77     CODEC_LOGD("port [%{public}d]", port);
78     outTunnelSetup = inTunnelSetup;
79     return node_->ComponentTunnelRequest(port, tunneledComp, tunneledPort, outTunnelSetup);
80 }
81 
UseBuffer(uint32_t portIndex,const OmxCodecBuffer & inBuffer,OmxCodecBuffer & outBuffer)82 int32_t CodecComponentService::UseBuffer(uint32_t portIndex, const OmxCodecBuffer &inBuffer, OmxCodecBuffer &outBuffer)
83 {
84     CODEC_LOGD("portIndex [%{public}d]", portIndex);
85     outBuffer = inBuffer;
86     return node_->UseBuffer(portIndex, outBuffer);
87 }
88 
AllocateBuffer(uint32_t portIndex,const OmxCodecBuffer & inBuffer,OmxCodecBuffer & outBuffer)89 int32_t CodecComponentService::AllocateBuffer(uint32_t portIndex, const OmxCodecBuffer &inBuffer,
90                                               OmxCodecBuffer &outBuffer)
91 {
92     CODEC_LOGD("portIndex [%{public}d]", portIndex);
93     outBuffer = inBuffer;
94     return node_->AllocateBuffer(portIndex, outBuffer);
95 }
96 
FreeBuffer(uint32_t portIndex,const OmxCodecBuffer & buffer)97 int32_t CodecComponentService::FreeBuffer(uint32_t portIndex, const OmxCodecBuffer &buffer)
98 {
99     CODEC_LOGD("portIndex [%{public}d]", portIndex);
100     return node_->FreeBuffer(portIndex, buffer);
101 }
102 
EmptyThisBuffer(const OmxCodecBuffer & buffer)103 int32_t CodecComponentService::EmptyThisBuffer(const OmxCodecBuffer &buffer)
104 {
105     return node_->EmptyThisBuffer(const_cast<OmxCodecBuffer &>(buffer));
106 }
107 
FillThisBuffer(const OmxCodecBuffer & buffer)108 int32_t CodecComponentService::FillThisBuffer(const OmxCodecBuffer &buffer)
109 {
110     return node_->FillThisBuffer(const_cast<OmxCodecBuffer &>(buffer));
111 }
112 
SetCallbacks(const sptr<ICodecCallback> & callbacks,int64_t appData)113 int32_t CodecComponentService::SetCallbacks(const sptr<ICodecCallback> &callbacks, int64_t appData)
114 {
115     return node_->SetCallbacks(callbacks, appData);
116 }
117 
ComponentDeInit()118 int32_t CodecComponentService::ComponentDeInit()
119 {
120     return node_->ComponentDeInit();
121 }
122 
UseEglImage(uint32_t portIndex,const OmxCodecBuffer & inBuffer,OmxCodecBuffer & outBuffer,const std::vector<int8_t> & eglImage)123 int32_t CodecComponentService::UseEglImage(uint32_t portIndex, const OmxCodecBuffer &inBuffer,
124                                            OmxCodecBuffer &outBuffer, const std::vector<int8_t> &eglImage)
125 {
126     CODEC_LOGD("portIndex [%{public}d]", portIndex);
127     outBuffer = inBuffer;
128     return node_->UseEglImage(outBuffer, portIndex, eglImage.data());
129 }
130 
ComponentRoleEnum(std::vector<uint8_t> & role,uint32_t index)131 int32_t CodecComponentService::ComponentRoleEnum(std::vector<uint8_t> &role, uint32_t index)
132 {
133     CODEC_LOGD("index [%{public}d]", index);
134     return node_->ComponentRoleEnum(role, index);
135 }
136 }  // namespace V1_0
137 }  // namespace Codec
138 }  // namespace HDI
139 }  // namespace OHOS
140