• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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 MULTIMEDIA_AUDIO_CAPTURER_IMPL_H
17 #define MULTIMEDIA_AUDIO_CAPTURER_IMPL_H
18 #include <list>
19 
20 #include "audio_capturer.h"
21 #include "cj_common_ffi.h"
22 #include "multimedia_audio_capturer_callback.h"
23 #include "multimedia_audio_ffi.h"
24 #include "native/ffi_remote_data.h"
25 
26 namespace OHOS {
27 namespace AudioStandard {
28 using namespace std;
29 class MMAAudioCapturerImpl : public OHOS::FFI::FFIData {
30     DECL_TYPE(MMAAudioCapturerImpl, OHOS::FFI::FFIData)
31 public:
32     MMAAudioCapturerImpl();
33 
34     ~MMAAudioCapturerImpl();
35 
36     int32_t CreateAudioCapturer(CAudioCapturerOptions options);
37 
38     int32_t GetState();
39 
40     uint32_t GetStreamId(int32_t* errorCode);
41 
42     int64_t GetAudioTime(int32_t* errorCode);
43 
44     uint32_t GetBufferSize(int32_t* errorCode);
45 
46     uint32_t GetOverflowCount();
47 
48     int32_t Start();
49 
50     int32_t Stop();
51 
52     int32_t Release();
53 
54     CAudioCapturerInfo GetCurrentCapturerInfo(int32_t* errorCode);
55 
56     CAudioStreamInfo GetStreamInfo(int32_t* errorCode);
57 
58     CAudioCapturerChangeInfo GetAudioCapturerChangeInfo(int32_t* errorCode);
59 
60     CArrDeviceDescriptor GetInputDevices(int32_t* errorCode);
61 
62     void RegisterCallback(int32_t callbackType, void (*callback)(), int32_t* errorCode);
63 
64     void RegisterCallbackWithFrame(int32_t callbackType, void (*callback)(), int64_t frame, int32_t* errorCode);
65 
66 private:
67     void RegisterCArrCallback(int32_t callbackType, void (*callback)(), int32_t* errorCode);
68     std::shared_ptr<AudioCapturer> audioCapturer_ {};
69     std::shared_ptr<CjAudioCapturerCallback> callback_ {};
70     std::shared_ptr<CjCapturerPositionCallback> positionCb_ {};
71     std::shared_ptr<CjCapturerPeriodPositionCallback> periodPositionCb_ {};
72     std::shared_ptr<CjAudioCapturerReadCallback> capturerReadDataCb_ {};
73     std::list<std::shared_ptr<CjAudioCapturerDeviceChangeCallback>> deviceChangeCallbacks_;
74     std::list<std::shared_ptr<CjAudioCapturerInfoChangeCallback>> capturerInfoChangeCallbacks_;
75 };
76 } // namespace AudioStandard
77 } // namespace OHOS
78 #endif // MULTIMEDIA_AUDIO_CAPTURER_IMPL_H
79