1 /*
2  * Copyright (c) 2022-2023 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 FRAMEWORKS_AUDIO_CAPTURER_THROUGH_H
17 #define FRAMEWORKS_AUDIO_CAPTURER_THROUGH_H
18 
19 #include <mutex>
20 #include <sys/time.h>
21 
22 #include "audio_capturer.h"
23 #include "audio_capturer_impl.h"
24 
25 using OHOS::Audio::AudioCapturerImpl;
26 
27 namespace OHOS {
28 namespace Audio {
29 class AudioCapturer::AudioCapturerClient {
30 public:
31     AudioCapturerClient();
32     virtual ~AudioCapturerClient();
33     static bool GetMinFrameCount(int32_t sampleRate, int32_t channelCount, AudioCodecFormat audioFormat,
34                                  size_t &frameCount);
35     int32_t SetCapturerInfo(const AudioCapturerInfo info);
36     int32_t GetCapturerInfo(AudioCapturerInfo &info);
37     bool Start();
38     bool Stop();
39     bool Release();
40     int32_t Read(uint8_t *buffer, size_t userSize, bool isBlockingRead);
41     uint64_t GetFrameCount();
42     State GetStatus();
43     bool GetAudioTime(Timestamp &timestamp, Timestamp::Timebase base);
44 
45 private:
46     std::unique_ptr<AudioCapturerImpl> impl_;
47 };
48 }  // namespace Audio
49 }  // namespace OHOS
50 
51 #endif  // FRAMEWORKS_AUDIO_CAPTURER_THROUGH_H
52