1 /* 2 * Copyright (c) 2021-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 CAPTURER_SOURCE_ADAPTER_H 17 #define CAPTURER_SOURCE_ADAPTER_H 18 19 #include <stdint.h> 20 #include "audio_types.h" 21 22 #ifdef __cplusplus 23 extern "C" { 24 #endif 25 typedef struct { 26 const char *adapterName; 27 uint32_t open_mic_speaker; 28 enum AudioFormat format; 29 uint32_t sampleFmt; 30 uint32_t sampleRate; 31 uint32_t channel; 32 float volume; 33 uint32_t bufferSize; 34 bool isBigEndian; 35 const char *filePath; 36 const char *deviceNetworkId; 37 int32_t device_type; 38 } SourceAttr; 39 40 struct CapturerSourceAdapter { 41 int32_t deviceClass; 42 void *wapper; 43 int32_t (*CapturerSourceInit)(void *wapper, const SourceAttr *attr); 44 void (*CapturerSourceDeInit)(void *wapper); 45 int32_t (*CapturerSourceStart)(void *wapper); 46 int32_t (*CapturerSourceSetMute)(void *wapper, bool isMute); 47 bool (*CapturerSourceIsMuteRequired)(void *wapper); 48 int32_t (*CapturerSourceStop)(void *wapper); 49 int32_t (*CapturerSourceFrame)(void *wapper, char *frame, uint64_t requestBytes, uint64_t *replyBytes); 50 int32_t (*CapturerSourceSetVolume)(void *wapper, float left, float right); 51 int32_t (*CapturerSourceGetVolume)(void *wapper, float *left, float *right); 52 }; 53 54 int32_t LoadSourceAdapter(const char *device, const char *deviceNetworkId, 55 struct CapturerSourceAdapter **sourceAdapter); 56 int32_t UnLoadSourceAdapter(struct CapturerSourceAdapter *sourceAdapter); 57 const char *GetDeviceClass(void); 58 #ifdef __cplusplus 59 } 60 #endif 61 #endif // CAPTURER_SOURCE_ADAPTER_H 62