• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 ST_AUDIO_GENERAL_MANAGER_H
17 #define ST_AUDIO_GENERAL_MANAGER_H
18 
19 #include <mutex>
20 #include "audio_policy_interface.h"
21 #include "audio_manager_base.h"
22 
23 namespace OHOS {
24 namespace AudioStandard {
25 class AudioGeneralManager {
26 public:
27     static AudioGeneralManager *GetInstance();
28 
29     virtual ~AudioGeneralManager();
30 
31     AudioGeneralManager();
32 
33     int32_t GetCallingPid();
34 
35     const sptr<IStandardAudioService> GetAudioGeneralManagerProxy();
36 
37     int32_t SetAudioDeviceRefinerCallback(const std::shared_ptr<AudioDeviceRefiner> &callback);
38 
39     int32_t GetPreferredOutputDeviceForRendererInfo(AudioRendererInfo rendererInfo,
40         std::vector<std::shared_ptr<AudioDeviceDescriptor>> &desc);
41 
42     int32_t UnsetAudioDeviceRefinerCallback();
43 
44     void SaveRemoteInfo(const std::string &networkId, DeviceType deviceType);
45 
46     int32_t TriggerFetchDevice(AudioStreamDeviceChangeReasonExt reason);
47 
48     int32_t SetPreferredDevice(const PreferredType preferredType,
49         const std::shared_ptr<AudioDeviceDescriptor> &desc, const int32_t uid = INVALID_UID);
50 
51     int32_t SetPreferredOutputDeviceChangeCallback(AudioRendererInfo rendererInfo,
52         const std::shared_ptr<AudioPreferredOutputDeviceChangeCallback>& callback);
53 
54     int32_t RegisterFocusInfoChangeCallback(const std::shared_ptr<AudioFocusInfoChangeCallback> &callback);
55 
56     std::vector<std::shared_ptr<AudioDeviceDescriptor>> GetDevicesInner(DeviceFlag deviceFlag);
57 
58     int32_t SetDeviceChangeCallback(const DeviceFlag flag,
59         const std::shared_ptr<AudioManagerDeviceChangeCallback>& callback);
60 
61     int32_t SetDistribuitedOutputChangeCallback(const std::shared_ptr<AudioDistribuitedOutputChangeCallback> &cb);
62 
63     int32_t SetQueryClientTypeCallback(
64         const std::shared_ptr<AudioQueryClientTypeCallback>& callback);
65 
66     int32_t SetExtraParameters(const std::string &key,
67         const std::vector<std::pair<std::string, std::string>> &kvpairs);
68 
69     int32_t GetVolume(AudioVolumeType volumeType) const;
70 
71     int32_t RegisterVolumeKeyEventCallback(const int32_t clientPid,
72         const std::shared_ptr<VolumeKeyEventCallback> &callback, API_VERSION api_v = API_9);
73 
74     DeviceType GetActiveOutputDevice();
75 
76     AudioScene GetAudioScene() const;
77 
78     int32_t SetAudioSceneChangeCallback(const std::shared_ptr<AudioManagerAudioSceneChangedCallback> &callback);
79 
80     int32_t GetMaxVolume(AudioVolumeType volumeType);
81 
82     int32_t UnregisterFocusInfoChangeCallback(
83         const std::shared_ptr<AudioFocusInfoChangeCallback> &callback);
84 
85     int32_t GetAudioFocusInfoList(
86         std::list<std::pair<AudioInterrupt, AudioFocuState>> &focusInfoList);
87 
88     int32_t SelectOutputDevice(std::vector<std::shared_ptr<AudioDeviceDescriptor>> audioDeviceDescriptors) const;
89 
90     int32_t UnregisterVolumeKeyEventCallback(const int32_t clientPid,
91         const std::shared_ptr<VolumeKeyEventCallback> &callback = nullptr);
92 
93     int32_t RegisterAudioCapturerEventListener(const int32_t clientPid,
94         const std::shared_ptr<AudioCapturerStateChangeCallback> &callback);
95 
96     int32_t GetCurrentRendererChangeInfos(
97         std::vector<std::shared_ptr<AudioRendererChangeInfo>> &audioRendererChangeInfos);
98 
99     int32_t RegisterAudioRendererEventListener(const std::shared_ptr<AudioRendererStateChangeCallback> &callback);
100 
101     int32_t GetPreferredInputDeviceForCapturerInfo(
102         AudioCapturerInfo captureInfo, std::vector<std::shared_ptr<AudioDeviceDescriptor>> &desc);
103 
104     int32_t SetPreferredInputDeviceChangeCallback(
105         AudioCapturerInfo &capturerInfo, const std::shared_ptr<AudioPreferredInputDeviceChangeCallback> &callback);
106 
107     int32_t GetCurrentCapturerChangeInfos(
108         std::vector<std::shared_ptr<AudioCapturerChangeInfo>> &audioCapturerChangeInfos);
109     int32_t SetAudioClientInfoMgrCallback(const std::shared_ptr<AudioClientInfoMgrCallback> &callback);
110 
111 private:
112     std::shared_ptr<AudioFocusInfoChangeCallback> audioFocusInfoCallback_ = nullptr;
113     int32_t volumeChangeClientPid_ = -1;
114 };
115 } // namespace AudioStandard
116 } // namespace OHOS
117 #endif // ST_AUDIO_GENERAL_MANAGER_H
118