1/* 2 * Copyright (c) 2023 Huawei Device 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_AUDIO_EFFECT_V1_0_IEFFECTCONTROL_H 17#define OHOS_HDI_AUDIO_EFFECT_V1_0_IEFFECTCONTROL_H 18 19#include <stdbool.h> 20#include <stdint.h> 21#include <hdf_base.h> 22#include "audio/effect/v1_0/effect_types.h" 23 24#ifdef __cplusplus 25extern "C" { 26#endif /* __cplusplus */ 27 28struct HdfRemoteService; 29 30#define IEFFECTCONTROL_INTERFACE_DESC "ohos.hdi.audio.effect.v1_0.IEffectControl" 31 32#define IEFFECT_CONTROL_MAJOR_VERSION 1 33#define IEFFECT_CONTROL_MINOR_VERSION 0 34 35#ifndef HDI_BUFF_MAX_SIZE 36#define HDI_BUFF_MAX_SIZE (1024 * 200) 37#endif 38 39#ifndef HDI_CHECK_VALUE_RETURN 40#define HDI_CHECK_VALUE_RETURN(lv, compare, rv, ret) do { \ 41 if ((lv) compare (rv)) { \ 42 return ret; \ 43 } \ 44} while (false) 45#endif 46 47#ifndef HDI_CHECK_VALUE_RET_GOTO 48#define HDI_CHECK_VALUE_RET_GOTO(lv, compare, rv, ret, value, table) do { \ 49 if ((lv) compare (rv)) { \ 50 ret = value; \ 51 goto table; \ 52 } \ 53} while (false) 54#endif 55 56enum { 57 CMD_EFFECT_CONTROL_GET_VERSION = 0, 58 CMD_EFFECT_CONTROL_EFFECT_PROCESS = 1, 59 CMD_EFFECT_CONTROL_SEND_COMMAND = 2, 60 CMD_EFFECT_CONTROL_GET_EFFECT_DESCRIPTOR = 3, 61 CMD_EFFECT_CONTROL_EFFECT_REVERSE = 4, 62}; 63 64struct IEffectControl { 65 int32_t (*EffectProcess)(struct IEffectControl *self, const struct AudioEffectBuffer* input, 66 struct AudioEffectBuffer* output); 67 68 int32_t (*SendCommand)(struct IEffectControl *self, uint32_t cmdId, const int8_t* cmdData, uint32_t cmdDataLen, 69 int8_t* replyData, uint32_t* replyDataLen); 70 71 int32_t (*GetEffectDescriptor)(struct IEffectControl *self, struct EffectControllerDescriptor* desc); 72 73 int32_t (*EffectReverse)(struct IEffectControl *self, const struct AudioEffectBuffer* input, 74 struct AudioEffectBuffer* output); 75 76 int32_t (*GetVersion)(struct IEffectControl *self, uint32_t* majorVer, uint32_t* minorVer); 77 78 struct HdfRemoteService* (*AsObject)(struct IEffectControl *self); 79}; 80 81// no external method used to create client object, it only support ipc mode 82struct IEffectControl *IEffectControlGet(struct HdfRemoteService *remote); 83 84// external method used to release client object, it support ipc and passthrought mode 85void IEffectControlRelease(struct IEffectControl *instance, bool isStub); 86#ifdef __cplusplus 87} 88#endif /* __cplusplus */ 89 90#endif // OHOS_HDI_AUDIO_EFFECT_V1_0_IEFFECTCONTROL_H