• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 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 I_AUDIO_POLICY_BASE_H
17 #define I_AUDIO_POLICY_BASE_H
18 
19 #include "audio_interrupt_callback.h"
20 #include "audio_policy_types.h"
21 #include "i_audio_volume_key_event_callback.h"
22 #include "ipc_types.h"
23 #include "iremote_broker.h"
24 #include "iremote_proxy.h"
25 #include "iremote_stub.h"
26 #include "audio_system_manager.h"
27 
28 namespace OHOS {
29 namespace AudioStandard {
30 using InternalDeviceType = DeviceType;
31 
32 class IAudioPolicy : public IRemoteBroker {
33 public:
34 
35     virtual int32_t SetStreamVolume(AudioStreamType streamType, float volume) = 0;
36 
37     virtual float GetStreamVolume(AudioStreamType streamType) = 0;
38 
39     virtual int32_t SetLowPowerVolume(int32_t streamId, float volume) = 0;
40 
41     virtual float GetLowPowerVolume(int32_t streamId) = 0;
42 
43     virtual float GetSingleStreamVolume(int32_t streamId) = 0;
44 
45     virtual int32_t SetStreamMute(AudioStreamType streamType, bool mute) = 0;
46 
47     virtual bool GetStreamMute(AudioStreamType streamType) = 0;
48 
49     virtual bool IsStreamActive(AudioStreamType streamType) = 0;
50 
51     virtual std::vector<sptr<AudioDeviceDescriptor>> GetDevices(DeviceFlag deviceFlag) = 0;
52 
53     virtual int32_t SetDeviceActive(InternalDeviceType deviceType, bool active) = 0;
54 
55     virtual bool IsDeviceActive(InternalDeviceType deviceType) = 0;
56 
57     virtual DeviceType GetActiveOutputDevice() = 0;
58 
59     virtual DeviceType GetActiveInputDevice() = 0;
60 
61     virtual std::shared_ptr<ToneInfo> GetToneConfig(int32_t ltonetype) = 0;
62 
63     virtual std::vector<int32_t> GetSupportedTones() = 0;
64 
65     virtual int32_t SetRingerMode(AudioRingerMode ringMode) = 0;
66 
67     virtual AudioRingerMode GetRingerMode() = 0;
68 
69     virtual int32_t SetAudioScene(AudioScene scene) = 0;
70 
71     virtual int32_t SetMicrophoneMute(bool isMute) = 0;
72 
73     virtual int32_t SetMicrophoneMuteAudioConfig(bool isMute) = 0;
74 
75     virtual bool IsMicrophoneMute(API_VERSION api_v = API_9) = 0;
76 
77     virtual AudioScene GetAudioScene() = 0;
78 
79     virtual int32_t SetRingerModeCallback(const int32_t clientId, const sptr<IRemoteObject> &object) = 0;
80 
81     virtual int32_t UnsetRingerModeCallback(const int32_t clientId) = 0;
82 
83     virtual int32_t SetMicStateChangeCallback(const int32_t clientId, const sptr<IRemoteObject> &object) = 0;
84 
85     virtual int32_t SetDeviceChangeCallback(const int32_t clientId, const DeviceFlag flag,
86         const sptr<IRemoteObject> &object) = 0;
87 
88     virtual int32_t UnsetDeviceChangeCallback(const int32_t clientId) = 0;
89 
90     virtual int32_t SetAudioInterruptCallback(const uint32_t sessionID, const sptr<IRemoteObject> &object) = 0;
91 
92     virtual int32_t UnsetAudioInterruptCallback(const uint32_t sessionID) = 0;
93 
94     virtual int32_t ActivateAudioInterrupt(const AudioInterrupt &audioInterrupt) = 0;
95 
96     virtual int32_t DeactivateAudioInterrupt(const AudioInterrupt &audioInterrupt) = 0;
97 
98     virtual int32_t SetAudioManagerInterruptCallback(const uint32_t clientID, const sptr<IRemoteObject> &object) = 0;
99 
100     virtual int32_t UnsetAudioManagerInterruptCallback(const uint32_t clientID) = 0;
101 
102     virtual int32_t RequestAudioFocus(const uint32_t clientID, const AudioInterrupt &audioInterrupt) = 0;
103 
104     virtual int32_t AbandonAudioFocus(const uint32_t clientID, const AudioInterrupt &audioInterrupt) = 0;
105 
106     virtual AudioStreamType GetStreamInFocus() = 0;
107 
108     virtual int32_t GetSessionInfoInFocus(AudioInterrupt &audioInterrupt) = 0;
109 
110     virtual int32_t SetVolumeKeyEventCallback(const int32_t clientPid, const sptr<IRemoteObject> &object) = 0;
111 
112     virtual int32_t UnsetVolumeKeyEventCallback(const int32_t clientPid) = 0;
113 
114     virtual bool VerifyClientPermission(const std::string &permission, uint32_t appTokenId, int32_t appUid,
115         bool privacyFlag, AudioPermissionState state) = 0;
116 
117     virtual bool getUsingPemissionFromPrivacy(const std::string &permission, uint32_t appTokenId,
118         AudioPermissionState state) = 0;
119 
120     virtual int32_t ReconfigureAudioChannel(const uint32_t &count, DeviceType deviceType) = 0;
121 
122     virtual int32_t GetAudioLatencyFromXml() = 0;
123 
124     virtual uint32_t GetSinkLatencyFromXml() = 0;
125 
126     virtual int32_t RegisterAudioRendererEventListener(int32_t clientUID, const sptr<IRemoteObject> &object) = 0;
127 
128     virtual int32_t UnregisterAudioRendererEventListener(int32_t clientUID) = 0;
129 
130     virtual int32_t RegisterAudioCapturerEventListener(int32_t clientUID, const sptr<IRemoteObject> &object) = 0;
131 
132     virtual int32_t UnregisterAudioCapturerEventListener(int32_t clientUID) = 0;
133 
134     virtual int32_t RegisterTracker(AudioMode &mode,
135         AudioStreamChangeInfo &streamChangeInfo, const sptr<IRemoteObject> &object) = 0;
136 
137     virtual int32_t UpdateTracker(AudioMode &mode, AudioStreamChangeInfo &streamChangeInfo) = 0;
138 
139     virtual int32_t GetCurrentRendererChangeInfos(
140         std::vector<std::unique_ptr<AudioRendererChangeInfo>> &audioRendererChangeInfos) = 0;
141 
142     virtual int32_t GetCurrentCapturerChangeInfos(
143         std::vector<std::unique_ptr<AudioCapturerChangeInfo>> &audioCapturerChangeInfos) = 0;
144 
145     virtual int32_t UpdateStreamState(const int32_t clientUid, StreamSetState streamSetState,
146                                             AudioStreamType audioStreamType) = 0;
147 
148     virtual int32_t SelectOutputDevice(sptr<AudioRendererFilter> audioRendererFilter,
149         std::vector<sptr<AudioDeviceDescriptor>> audioDeviceDescriptors) = 0;
150 
151     virtual std::string GetSelectedDeviceInfo(int32_t uid, int32_t pid, AudioStreamType streamType) = 0;
152 
153     virtual int32_t SelectInputDevice(sptr<AudioCapturerFilter> audioCapturerFilter,
154         std::vector<sptr<AudioDeviceDescriptor>> audioDeviceDescriptors) = 0;
155 
156     virtual std::vector<sptr<VolumeGroupInfo>> GetVolumeGroupInfos() = 0;
157 
158     virtual bool IsAudioRendererLowLatencySupported(const AudioStreamInfo &audioStreamInfo) = 0;
159 
160     virtual std::vector<sptr<AudioDeviceDescriptor>> GetActiveOutputDeviceDescriptors() = 0;
161 public:
162     DECLARE_INTERFACE_DESCRIPTOR(u"IAudioPolicy");
163 };
164 } // namespace AudioStandard
165 } // namespace OHOS
166 #endif // I_AUDIO_POLICY_BASE_H
167