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