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_IEFFECTMODEL_H
17#define OHOS_HDI_AUDIO_EFFECT_V1_0_IEFFECTMODEL_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#include "audio/effect/v1_0/ieffect_control.h"
24
25#ifdef __cplusplus
26extern "C" {
27#endif /* __cplusplus */
28
29struct HdfRemoteService;
30
31#define IEFFECTMODEL_INTERFACE_DESC "ohos.hdi.audio.effect.v1_0.IEffectModel"
32
33#define IEFFECT_MODEL_MAJOR_VERSION 1
34#define IEFFECT_MODEL_MINOR_VERSION 0
35
36#ifndef HDI_BUFF_MAX_SIZE
37#define HDI_BUFF_MAX_SIZE (1024 * 200)
38#endif
39
40#ifndef HDI_CHECK_VALUE_RETURN
41#define HDI_CHECK_VALUE_RETURN(lv, compare, rv, ret) do { \
42    if ((lv) compare (rv)) { \
43        return ret; \
44    } \
45} while (false)
46#endif
47
48#ifndef HDI_CHECK_VALUE_RET_GOTO
49#define HDI_CHECK_VALUE_RET_GOTO(lv, compare, rv, ret, value, table) do { \
50    if ((lv) compare (rv)) { \
51        ret = value; \
52        goto table; \
53    } \
54} while (false)
55#endif
56
57enum {
58    CMD_EFFECT_MODEL_GET_VERSION = 0,
59    CMD_EFFECT_MODEL_IS_SUPPLY_EFFECT_LIBS = 1,
60    CMD_EFFECT_MODEL_GET_ALL_EFFECT_DESCRIPTORS = 2,
61    CMD_EFFECT_MODEL_CREATE_EFFECT_CONTROLLER = 3,
62    CMD_EFFECT_MODEL_DESTROY_EFFECT_CONTROLLER = 4,
63    CMD_EFFECT_MODEL_GET_EFFECT_DESCRIPTOR = 5,
64};
65
66struct IEffectModel {
67    int32_t (*IsSupplyEffectLibs)(struct IEffectModel *self, bool* supply);
68
69    int32_t (*GetAllEffectDescriptors)(struct IEffectModel *self, struct EffectControllerDescriptor* descs,
70         uint32_t* descsLen);
71
72    int32_t (*CreateEffectController)(struct IEffectModel *self, const struct EffectInfo* info,
73         struct IEffectControl** contoller, struct ControllerId* id);
74
75    int32_t (*DestroyEffectController)(struct IEffectModel *self, const struct ControllerId* id);
76
77    int32_t (*GetEffectDescriptor)(struct IEffectModel *self, const char* effectId,
78         struct EffectControllerDescriptor* desc);
79
80    int32_t (*GetVersion)(struct IEffectModel *self, uint32_t* majorVer, uint32_t* minorVer);
81
82    struct HdfRemoteService* (*AsObject)(struct IEffectModel *self);
83};
84
85// external method used to create client object, it support ipc and passthrought mode
86struct IEffectModel *IEffectModelGet(bool isStub);
87struct IEffectModel *IEffectModelGetInstance(const char *serviceName, bool isStub);
88
89// external method used to create release object, it support ipc and passthrought mode
90void IEffectModelRelease(struct IEffectModel *instance, bool isStub);
91void IEffectModelReleaseInstance(const char *serviceName, struct IEffectModel *instance, bool isStub);
92#ifdef __cplusplus
93}
94#endif /* __cplusplus */
95
96#endif // OHOS_HDI_AUDIO_EFFECT_V1_0_IEFFECTMODEL_H