• 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_ROUTING_MANAGER_CALLBACK_H
17 #define MULTIMEDIA_AUDIO_ROUTING_MANAGER_CALLBACK_H
18 #include "audio_routing_manager.h"
19 #include "audio_system_manager.h"
20 #include "multimedia_audio_ffi.h"
21 
22 namespace OHOS {
23 namespace AudioStandard {
24 class CjAudioManagerAvailableDeviceChangeCallback : public AudioManagerAvailableDeviceChangeCallback {
25 public:
26     CjAudioManagerAvailableDeviceChangeCallback() = default;
27     virtual ~CjAudioManagerAvailableDeviceChangeCallback() = default;
28 
29     void RegisterFunc(const uint32_t usage, std::function<void(CDeviceChangeAction)> cjCallback);
30 
31     void OnAvailableDeviceChange(const AudioDeviceUsage usage, const DeviceChangeAction& deviceChangeAction) override;
32 
33 private:
34     std::vector<std::pair<uint32_t, std::function<void(CDeviceChangeAction)>>> callbackList_;
35     std::mutex cbMutex_;
36 };
37 
38 class CjAudioPreferredInputDeviceChangeCallback : public AudioPreferredInputDeviceChangeCallback {
39 public:
40     CjAudioPreferredInputDeviceChangeCallback() = default;
41     virtual ~CjAudioPreferredInputDeviceChangeCallback() = default;
42 
43     void RegisterFunc(std::function<void(CArrDeviceDescriptor)> cjCallback);
44 
45     void OnPreferredInputDeviceUpdated(const std::vector<std::shared_ptr<AudioDeviceDescriptor>>& desc) override;
46 
47 private:
48     std::function<void(CArrDeviceDescriptor)> func_ {};
49     std::mutex cbMutex_;
50 };
51 
52 class CjAudioPreferredOutputDeviceChangeCallback : public AudioPreferredOutputDeviceChangeCallback {
53 public:
54     CjAudioPreferredOutputDeviceChangeCallback() = default;
55     virtual ~CjAudioPreferredOutputDeviceChangeCallback() = default;
56 
57     void RegisterFunc(std::function<void(CArrDeviceDescriptor)> cjCallback);
58 
59     void OnPreferredOutputDeviceUpdated(const std::vector<std::shared_ptr<AudioDeviceDescriptor>>& desc) override;
60 
61 private:
62     std::function<void(CArrDeviceDescriptor)> func_ {};
63     std::mutex cbMutex_;
64 };
65 
66 class CjAudioManagerDeviceChangeCallback : public AudioManagerDeviceChangeCallback {
67 public:
68     CjAudioManagerDeviceChangeCallback() = default;
69     virtual ~CjAudioManagerDeviceChangeCallback() = default;
70 
71     void RegisterFunc(std::function<void(CDeviceChangeAction)> cjCallback);
72 
73     void OnDeviceChange(const DeviceChangeAction& deviceChangeAction) override;
74 
75 private:
76     std::function<void(CDeviceChangeAction)> func_ {};
77     std::mutex cbMutex_;
78 };
79 } // namespace AudioStandard
80 } // namespace OHOS
81 #endif // MULTIMEDIA_AUDIO_ROUTING_MANAGER_CALLBACK_H
82