• 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") = 0;
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_SOURCE_H
17 #define I_AUDIO_CAPTURER_SOURCE_H
18 
19 #include <cstdint>
20 #include "audio_info.h"
21 #include "audio_types.h"
22 
23 namespace OHOS {
24 namespace AudioStandard {
25 typedef struct {
26     const char *adapterName;
27     uint32_t open_mic_speaker;
28     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 } IAudioSourceAttr;
39 
40 class IAudioCapturerSource {
41 public:
42     static IAudioCapturerSource *GetInstance(const char *devceClass, const char *deviceNetworkId);
43 
44     virtual int32_t Init(IAudioSourceAttr &atrr) = 0;
45     virtual bool IsInited(void) = 0;
46     virtual void DeInit(void) = 0;
47 
48     virtual int32_t Start(void) = 0;
49     virtual int32_t Stop(void) = 0;
50     virtual int32_t Flush(void) = 0;
51     virtual int32_t Reset(void) = 0;
52     virtual int32_t Pause(void) = 0;
53     virtual int32_t Resume(void) = 0;
54     virtual int32_t CaptureFrame(char *frame, uint64_t requestBytes, uint64_t &replyBytes) = 0;
55     virtual int32_t SetVolume(float left, float right) = 0;
56     virtual int32_t GetVolume(float &left, float &right) = 0;
57     virtual int32_t SetMute(bool isMute) = 0;
58     virtual int32_t GetMute(bool &isMute) = 0;
59     virtual int32_t SetAudioScene(AudioScene audioScene, DeviceType activeDevice) = 0;
60     virtual int32_t SetInputRoute(DeviceType deviceType) = 0;
61     virtual uint64_t GetTransactionId() = 0;
62 
63     virtual ~IAudioCapturerSource() = default;
64 };
65 }  // namespace AudioStandard
66 }  // namespace OHOS
67 #endif  // AUDIO_CAPTURER_SOURCE_H
68