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