• 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_ST_AUDIO_MANAGER_BASE_H
17 #define I_ST_AUDIO_MANAGER_BASE_H
18 
19 #include "ipc_types.h"
20 #include "iremote_broker.h"
21 #include "iremote_proxy.h"
22 #include "iremote_stub.h"
23 #include "audio_effect.h"
24 #include "pulseaudio_ipc_interface_code.h"
25 
26 namespace OHOS {
27 namespace AudioStandard {
28 class AudioDeviceDescriptor;
29 class IStandardAudioService : public IRemoteBroker {
30 public:
31     /**
32      * Sets Microphone Mute status.
33      *
34      * @param isMute Mute status true or false to be set.
35      * @return Returns 0 if success. Otherwise returns Errocode defined in audio_errors.h.
36      */
37     virtual int32_t SetMicrophoneMute(bool isMute) = 0;
38 
39      /**
40      * Gets Microphone Mute status.
41      *
42      * @return Returns true or false
43      */
44     virtual bool IsMicrophoneMute() = 0;
45 
46     /**
47      * @brief Set the Voice Volume.
48      *
49      * @param volume Voice colume to be set.
50      * @return int32_t Returns 0 if success. Otherwise returns Errocode defined in audio_errors.h.
51      */
52     virtual int32_t SetVoiceVolume(float volume) = 0;
53 
54     /**
55      * Sets Audio modes.
56      *
57      * @param audioScene Audio scene type.
58      * @param activeDevice Currently active priority device
59      * @return Returns 0 if success. Otherwise returns Errocode defined in audio_errors.h.
60      */
61     virtual int32_t SetAudioScene(AudioScene audioScene, DeviceType activeDevice) = 0;
62 
63     /**
64      * Obtains device array.
65      *
66      * @return Returns the array of audio device descriptor.
67      */
68     virtual std::vector<sptr<AudioDeviceDescriptor>> GetDevices(DeviceFlag deviceFlag) = 0;
69 
70     /**
71      * Set Audio Parameter.
72      *
73      * @param  key for the audio parameter to be set
74      * @param  value associated with the key for the audio parameter to be set
75      * @return none.
76      */
77     virtual void SetAudioParameter(const std::string &key, const std::string &value) = 0;
78 
79     /**
80      * Set Audio Parameter.
81      *
82      * @param  networkId for the distributed device
83      * @param  key for the audio parameter to be set
84      * @param  condition for the audio parameter to be set
85      * @param  value associated with the key for the audio parameter to be set
86      * @return none.
87      */
88     virtual void SetAudioParameter(const std::string& networkId, const AudioParamKey key, const std::string& condition,
89         const std::string& value) = 0;
90 
91     /**
92      * Get Audio Parameter.
93      *
94      * @param  key for the audio parameter to be set
95      * @return Returns value associated to the key requested.
96      */
97     virtual const std::string GetAudioParameter(const std::string &key) = 0;
98 
99     /**
100      * Set Audio Parameter.
101      *
102      * @param  networkId for the distributed device
103      * @param  key for the audio parameter to be set
104      * @param  condition for the audio parameter to be set
105      * @return none.
106      */
107     virtual const std::string GetAudioParameter(const std::string& networkId, const AudioParamKey key,
108         const std::string& condition) = 0;
109 
110     /**
111      * Update the audio route after device is detected and route is decided
112      *
113      * @return Returns 0 if success. Otherwise returns Errocode defined in audio_errors.h.
114      */
115     virtual int32_t UpdateActiveDeviceRoute(DeviceType type, DeviceFlag flag) = 0;
116 
117     /**
118      * Retrieve cookie information from the service
119      *
120      * @return Returns cookie information, null if failed.
121      */
122     virtual const char *RetrieveCookie(int32_t &size) = 0;
123 
124     /**
125      * Get the transaction Id
126      *
127      * @return Returns transaction id.
128      */
GetTransactionId(DeviceType deviceType,DeviceRole deviceRole)129     virtual uint64_t GetTransactionId(DeviceType deviceType, DeviceRole deviceRole)
130     {
131         (void)deviceType;
132         (void)deviceRole;
133         return 0;
134     }
135 
136     /**
137      * Notify device connect info
138      *
139      * @return Returns transaction id.
140      */
141     virtual void NotifyDeviceInfo(std::string networkId, bool connected) = 0;
142 
143     /**
144      * Check remote device state.
145      *
146      * @return Returns transaction id.
147      */
148     virtual int32_t CheckRemoteDeviceState(std::string networkId, DeviceRole deviceRole, bool isStartDevice) = 0;
149 
150     /**
151      * Set parameter callback
152      *
153      * @return Returns the setting result
154      */
155     virtual int32_t SetParameterCallback(const sptr<IRemoteObject>& object) = 0;
156 
157     /**
158      * Set wakeupSource callback
159      *
160      * @return Returns the setting result
161      */
162     virtual int32_t SetWakeupSourceCallback(const sptr<IRemoteObject>& object) = 0;
163 
164     /**
165      * Set audio mono state for accessibility
166      *
167      * @param  audioMono the state of mono audio for accessibility
168      * @return none.
169      */
170     virtual void SetAudioMonoState(bool audioMono) = 0;
171 
172     /**
173      * Set audio balance value for accessibility
174      *
175      * @param  audioBalance the value of audio balance for accessibility
176      * @return none.
177      */
178     virtual void SetAudioBalanceValue(float audioBalance) = 0;
179 
180     /**
181      * Create AudioProcess for play.
182      *
183      * @param config the config of the AudioProcess
184      *
185      * @return Returns AudioProcess client.
186     */
187     virtual sptr<IRemoteObject> CreateAudioProcess(const AudioProcessConfig &config) = 0;
188 
189     /**
190      * Use effect manager information to load effect libraries.
191      *
192      * @return true/false.
193      */
194     virtual bool LoadAudioEffectLibraries(std::vector<Library> libraries, std::vector<Effect> effects,
195         std::vector<Effect> &successEffects) = 0;
196 
197     /**
198      * Create effect chain manager for audio effect processing.
199      *
200      * @return true/false.
201      */
202     virtual bool CreateEffectChainManager(std::vector<EffectChain> &effectChains,
203         std::unordered_map<std::string, std::string> &map) = 0;
204 
205     /**
206      * Set output device sink for effect chain manager.
207      *
208      * @return true/false.
209      */
210     virtual bool SetOutputDeviceSink(int32_t device, std::string &sinkName) = 0;
211 
212     /**
213      * Regiest policy provider.
214      *
215      * @return result code.
216      */
217     virtual int32_t RegiestPolicyProvider(const sptr<IRemoteObject> &object) = 0;
218 
219     /**
220      * Request thread priority for client thread.
221      */
222     virtual void RequestThreadPriority(uint32_t tid, std::string bundleName) = 0;
223 
224     /**
225      * Create playback capturer manager.
226      *
227      * @return true/false.
228      */
229     virtual bool CreatePlaybackCapturerManager() = 0;
230 
231     /**
232      * Set StreamUsage set which support playback capturer.
233      *
234      * @param usage value of StreamUsage which support inner capturer.
235      *
236      * @return result of setting. 0 if success, error number else.
237     */
238     virtual int32_t SetSupportStreamUsage(std::vector<int32_t> usage) = 0;
239 
240     /**
241      * Mark if playback capture silently.
242      *
243      * @param state identify the capture state
244      *
245      * @return result of setting. 0 if success, error number else.
246     */
247     virtual int32_t SetCaptureSilentState(bool state) = 0;
248 
249 public:
250     DECLARE_INTERFACE_DESCRIPTOR(u"IStandardAudioService");
251 };
252 
253 class AudioManagerStub : public IRemoteStub<IStandardAudioService> {
254 public:
255     virtual int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply,
256         MessageOption &option) override;
257 };
258 } // namespace AudioStandard
259 } // namespace OHOS
260 #endif // I_ST_AUDIO_MANAGER_BASE_H
261