1 /* 2 * Copyright (c) 2022 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 I_AUDIO_CAPTURER_SINK_INTF_H 17 #define I_AUDIO_CAPTURER_SINK_INTF_H 18 19 #include <stdbool.h> 20 #include "audio_hdiadapter_info.h" 21 22 #ifdef __cplusplus 23 extern "C" { 24 #endif 25 26 // should be same with IAudioSourceAttr in i_audio_capturer_source.h 27 typedef struct { 28 const char *adapterName; 29 uint32_t openMicSpeaker; 30 enum HdiAdapterFormat format; 31 uint32_t sampleRate; 32 uint32_t channel; 33 float volume; 34 uint32_t bufferSize; 35 bool isBigEndian; 36 const char *filePath; 37 const char *deviceNetworkId; 38 int32_t deviceType; 39 int32_t sourceType; 40 uint64_t channelLayout; 41 } SourceAttr; 42 43 struct CapturerSourceAdapter { 44 int32_t deviceClass; 45 void *wapper; 46 int32_t (*CapturerSourceInit)(void *wapper, const SourceAttr *attr); 47 void (*CapturerSourceDeInit)(void *wapper); 48 int32_t (*CapturerSourceStart)(void *wapper); 49 int32_t (*CapturerSourceSetMute)(void *wapper, bool isMute); 50 bool (*CapturerSourceIsMuteRequired)(void *wapper); 51 int32_t (*CapturerSourceStop)(void *wapper); 52 int32_t (*CapturerSourceFrame)(void *wapper, char *frame, uint64_t requestBytes, uint64_t *replyBytes); 53 int32_t (*CapturerSourceSetVolume)(void *wapper, float left, float right); 54 int32_t (*CapturerSourceGetVolume)(void *wapper, float *left, float *right); 55 int32_t (*CapturerSourceAppsUid) (void *wapper, const int32_t appsUid[PA_MAX_OUTPUTS_PER_SOURCE], 56 const size_t size); 57 }; 58 59 int32_t FillinSourceWapper(const char *deviceClass, const char *deviceNetworkId, 60 const int32_t sourceType, const char *sourceName, void **wapper); 61 int32_t IAudioCapturerSourceInit(void *wapper, const SourceAttr *attr); 62 void IAudioCapturerSourceDeInit(void *wapper); 63 int32_t IAudioCapturerSourceStart(void *wapper); 64 int32_t IAudioCapturerSourceStop(void *wapper); 65 int32_t IAudioCapturerSourceFrame(void *wapper, char *frame, uint64_t requestBytes, uint64_t *replyBytes); 66 int32_t IAudioCapturerSourceSetVolume(void *wapper, float left, float right); 67 bool IAudioCapturerSourceIsMuteRequired(void *wapper); 68 int32_t IAudioCapturerSourceSetMute(void *wapper, bool isMute); 69 int32_t IAudioCapturerSourceGetVolume(void *wapper, float *left, float *right); 70 int32_t IAudioCapturerSourceUpdateAppsUid(void *wapper, const int32_t appsUid[MAX_MIX_CHANNELS], 71 const size_t size); 72 73 #ifdef __cplusplus 74 } 75 #endif 76 77 #endif // AUDIO_CAPTURER_SINK_INTF_H 78