• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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     bool hasEcConfig;
42     enum HdiAdapterFormat formatEc;
43     uint32_t sampleRateEc;
44     uint32_t channelEc;
45 } SourceAttr;
46 
47 struct CapturerSourceAdapter {
48     int32_t deviceClass;
49     void *wapper;
50     int32_t (*CapturerSourceInit)(void *wapper, const SourceAttr *attr);
51     void (*CapturerSourceDeInit)(void *wapper);
52     int32_t (*CapturerSourceStart)(void *wapper);
53     int32_t (*CapturerSourceSetMute)(void *wapper, bool isMute);
54     bool (*CapturerSourceIsMuteRequired)(void *wapper);
55     int32_t (*CapturerSourceStop)(void *wapper);
56     int32_t (*CapturerSourceFrame)(void *wapper, char *frame, uint64_t requestBytes, uint64_t *replyBytes);
57     int32_t (*CapturerSourceFrameWithEc)(void *wapper, FrameDesc *fdesc, uint64_t *replyBytes,
58         FrameDesc *fdescEc, uint64_t *replyBytesEc);
59     int32_t (*CapturerSourceSetVolume)(void *wapper, float left, float right);
60     int32_t (*CapturerSourceGetVolume)(void *wapper, float *left, float *right);
61     int32_t (*CapturerSourceAppsUid)(void *wapper, const int32_t appsUid[PA_MAX_OUTPUTS_PER_SOURCE],
62         const size_t size);
63     int32_t (*CapturerSourceGetCaptureId)(void *wapper, uint32_t *captureId);
64 };
65 
66 int32_t FillinSourceWapper(const char *deviceClass, const char *deviceNetworkId,
67     const int32_t sourceType, const char *sourceName, void **wapper);
68 int32_t IAudioCapturerSourceInit(void *wapper, const SourceAttr *attr);
69 void IAudioCapturerSourceDeInit(void *wapper);
70 int32_t IAudioCapturerSourceStart(void *wapper);
71 int32_t IAudioCapturerSourceStop(void *wapper);
72 int32_t IAudioCapturerSourceFrame(void *wapper, char *frame, uint64_t requestBytes, uint64_t *replyBytes);
73 int32_t IAudioCapturerSourceFrameWithEc(void *wapper, FrameDesc *fdesc, uint64_t *replyBytes,
74     FrameDesc *fdescEc, uint64_t *replyBytesEc);
75 int32_t IAudioCapturerSourceSetVolume(void *wapper, float left, float right);
76 bool IAudioCapturerSourceIsMuteRequired(void *wapper);
77 int32_t IAudioCapturerSourceSetMute(void *wapper, bool isMute);
78 int32_t IAudioCapturerSourceGetVolume(void *wapper, float *left, float *right);
79 int32_t IAudioCapturerSourceUpdateAppsUid(void *wapper, const int32_t appsUid[MAX_MIX_CHANNELS],
80     const size_t size);
81 int32_t IAudioCapturerSourceGetCaptureId(void *wapper, uint32_t *captureId);
82 
83 #ifdef __cplusplus
84 }
85 #endif
86 
87 #endif  // AUDIO_CAPTURER_SINK_INTF_H
88