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_VDI_AUDIO_V1_0_IAUDIORENDER_H
17 #define OHOS_VDI_AUDIO_V1_0_IAUDIORENDER_H
18 
19 #include <stdbool.h>
20 #include <stdint.h>
21 #include "audio_types_vdi.h"
22 #include "iaudio_callback_vdi.h"
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif /* __cplusplus */
27 
28 #define IAUDIO_VDI_RENDER_MAJOR_VERSION 1
29 #define IAUDIO_VDI_RENDER_MINOR_VERSION 0
30 
31 struct IAudioRenderVdi {
32     int32_t (*GetLatency)(struct IAudioRenderVdi *self, uint32_t *ms);
33     int32_t (*RenderFrame)(struct IAudioRenderVdi *self, const int8_t *frame, uint32_t frameLen, uint64_t *replyBytes);
34     int32_t (*GetRenderPosition)(struct IAudioRenderVdi *self, uint64_t *frames, struct AudioTimeStampVdi *time);
35     int32_t (*SetRenderSpeed)(struct IAudioRenderVdi *self, float speed);
36     int32_t (*GetRenderSpeed)(struct IAudioRenderVdi *self, float *speed);
37     int32_t (*SetChannelMode)(struct IAudioRenderVdi *self, enum AudioChannelModeVdi mode);
38     int32_t (*GetChannelMode)(struct IAudioRenderVdi *self, enum AudioChannelModeVdi *mode);
39     int32_t (*RegCallback)(struct IAudioRenderVdi *self, RenderCallbackVdi audioCallback, void *cookie);
40     int32_t (*DrainBuffer)(struct IAudioRenderVdi *self, enum AudioDrainNotifyTypeVdi *type);
41     int32_t (*IsSupportsDrain)(struct IAudioRenderVdi *self, bool *support);
42     int32_t (*CheckSceneCapability)(struct IAudioRenderVdi *self, const struct AudioSceneDescriptorVdi *scene,
43         bool *supported);
44     int32_t (*SelectScene)(struct IAudioRenderVdi *self, const struct AudioSceneDescriptorVdi *scene);
45     int32_t (*SetMute)(struct IAudioRenderVdi *self, bool mute);
46     int32_t (*GetMute)(struct IAudioRenderVdi *self, bool *mute);
47     int32_t (*SetVolume)(struct IAudioRenderVdi *self, float volume);
48     int32_t (*GetVolume)(struct IAudioRenderVdi *self, float *volume);
49     int32_t (*GetGainThreshold)(struct IAudioRenderVdi *self, float *min, float *max);
50     int32_t (*GetGain)(struct IAudioRenderVdi *self, float *gain);
51     int32_t (*SetGain)(struct IAudioRenderVdi *self, float gain);
52     int32_t (*GetFrameSize)(struct IAudioRenderVdi *self, uint64_t *size);
53     int32_t (*GetFrameCount)(struct IAudioRenderVdi *self, uint64_t *count);
54     int32_t (*SetSampleAttributes)(struct IAudioRenderVdi *self, const struct AudioSampleAttributesVdi *attrs);
55     int32_t (*GetSampleAttributes)(struct IAudioRenderVdi *self, struct AudioSampleAttributesVdi *attrs);
56     int32_t (*GetCurrentChannelId)(struct IAudioRenderVdi *self, uint32_t *channelId);
57     int32_t (*SetExtraParams)(struct IAudioRenderVdi *self, const char *keyValueList);
58     int32_t (*GetExtraParams)(struct IAudioRenderVdi *self, char *keyValueList, uint32_t keyValueListLen);
59     int32_t (*ReqMmapBuffer)(struct IAudioRenderVdi *self, int32_t reqSize, struct AudioMmapBufferDescriptorVdi *desc);
60     int32_t (*GetMmapPosition)(struct IAudioRenderVdi *self, uint64_t *frames, struct AudioTimeStampVdi *time);
61     int32_t (*AddAudioEffect)(struct IAudioRenderVdi *self, uint64_t effectid);
62     int32_t (*RemoveAudioEffect)(struct IAudioRenderVdi *self, uint64_t effectid);
63     int32_t (*GetFrameBufferSize)(struct IAudioRenderVdi *self, uint64_t *bufferSize);
64     int32_t (*Start)(struct IAudioRenderVdi *self);
65     int32_t (*Stop)(struct IAudioRenderVdi *self);
66     int32_t (*Pause)(struct IAudioRenderVdi *self);
67     int32_t (*Resume)(struct IAudioRenderVdi *self);
68     int32_t (*Flush)(struct IAudioRenderVdi *self);
69     int32_t (*TurnStandbyMode)(struct IAudioRenderVdi *self);
70     int32_t (*AudioDevDump)(struct IAudioRenderVdi *self, int32_t range, int32_t fd);
71     int32_t (*IsSupportsPauseAndResume)(struct IAudioRenderVdi *self, bool *supportPause, bool *supportResume);
72     int32_t (*SetBufferSize)(struct IAudioRenderVdi *self, uint32_t size);
73 };
74 
75 #ifdef __cplusplus
76 }
77 #endif /* __cplusplus */
78 
79 #endif /* OHOS_VDI_AUDIO_V1_0_IAUDIORENDER_H */