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 deviceType; 38 int32_t sourceType; 39 } SourceAttr; 40 41 struct CapturerSourceAdapter { 42 int32_t deviceClass; 43 void *wapper; 44 int32_t (*CapturerSourceInit)(void *wapper, const SourceAttr *attr); 45 void (*CapturerSourceDeInit)(void *wapper); 46 int32_t (*CapturerSourceStart)(void *wapper); 47 int32_t (*CapturerSourceSetMute)(void *wapper, bool isMute); 48 bool (*CapturerSourceIsMuteRequired)(void *wapper); 49 int32_t (*CapturerSourceStop)(void *wapper); 50 int32_t (*CapturerSourceFrame)(void *wapper, char *frame, uint64_t requestBytes, uint64_t *replyBytes); 51 int32_t (*CapturerSourceSetVolume)(void *wapper, float left, float right); 52 int32_t (*CapturerSourceGetVolume)(void *wapper, float *left, float *right); 53 }; 54 55 int32_t LoadSourceAdapter(const char *device, const char *deviceNetworkId, const int32_t sourceType, 56 const char *sourceName, struct CapturerSourceAdapter **sourceAdapter); 57 int32_t UnLoadSourceAdapter(struct CapturerSourceAdapter *sourceAdapter); 58 const char *GetDeviceClass(int32_t deviceClass); 59 #ifdef __cplusplus 60 } 61 #endif 62 #endif // CAPTURER_SOURCE_ADAPTER_H 63