• 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_info.h"
24 
25 namespace OHOS {
26 namespace AudioStandard {
27 class AudioDeviceDescriptor;
28 class IStandardAudioService : public IRemoteBroker {
29 public:
30     /**
31      * Obtains max volume.
32      *
33      * @return Returns the max volume.
34      */
35     virtual int32_t GetMaxVolume(AudioVolumeType volumeType) = 0;
36 
37     /**
38      * Obtains min volume.
39      *
40      * @return Returns the min volume.
41      */
42     virtual int32_t GetMinVolume(AudioVolumeType volumeType) = 0;
43 
44     /**
45      * Sets Microphone Mute status.
46      *
47      * @param isMute Mute status true or false to be set.
48      * @return Returns 0 if success. Otherwise returns Errocode defined in audio_errors.h.
49      */
50     virtual int32_t SetMicrophoneMute(bool isMute) = 0;
51 
52      /**
53      * Gets Microphone Mute status.
54      *
55      * @return Returns true or false
56      */
57     virtual bool IsMicrophoneMute() = 0;
58 
59     /**
60      * @brief Set the Voice Volume.
61      *
62      * @param volume Voice colume to be set.
63      * @return int32_t Returns 0 if success. Otherwise returns Errocode defined in audio_errors.h.
64      */
65     virtual int32_t SetVoiceVolume(float volume) = 0;
66 
67     /**
68      * Sets Audio modes.
69      *
70      * @param audioScene Audio scene type.
71      * @param activeDevice Currently active priority device
72      * @return Returns 0 if success. Otherwise returns Errocode defined in audio_errors.h.
73      */
74     virtual int32_t SetAudioScene(AudioScene audioScene, DeviceType activeDevice) = 0;
75 
76     /**
77      * Obtains device array.
78      *
79      * @return Returns the array of audio device descriptor.
80      */
81     virtual std::vector<sptr<AudioDeviceDescriptor>> GetDevices(DeviceFlag deviceFlag) = 0;
82 
83     /**
84      * Set Audio Parameter.
85      *
86      * @param  key for the audio parameter to be set
87      * @param  value associated with the key for the audio parameter to be set
88      * @return none.
89      */
90     virtual void SetAudioParameter(const std::string &key, const std::string &value) = 0;
91 
92     /**
93      * Set Audio Parameter.
94      *
95      * @param  networkId for the distributed device
96      * @param  key for the audio parameter to be set
97      * @param  condition for the audio parameter to be set
98      * @param  value associated with the key for the audio parameter to be set
99      * @return none.
100      */
101     virtual void SetAudioParameter(const std::string& networkId, const AudioParamKey key, const std::string& condition,
102         const std::string& value) = 0;
103 
104     /**
105      * Get Audio Parameter.
106      *
107      * @param  key for the audio parameter to be set
108      * @return Returns value associated to the key requested.
109      */
110     virtual const std::string GetAudioParameter(const std::string &key) = 0;
111 
112     /**
113      * Set Audio Parameter.
114      *
115      * @param  networkId for the distributed device
116      * @param  key for the audio parameter to be set
117      * @param  condition for the audio parameter to be set
118      * @return none.
119      */
120     virtual const std::string GetAudioParameter(const std::string& networkId, const AudioParamKey key,
121         const std::string& condition) = 0;
122 
123     /**
124      * Update the audio route after device is detected and route is decided
125      *
126      * @return Returns 0 if success. Otherwise returns Errocode defined in audio_errors.h.
127      */
128     virtual int32_t UpdateActiveDeviceRoute(DeviceType type, DeviceFlag flag) = 0;
129 
130     /**
131      * Retrieve cookie information from the service
132      *
133      * @return Returns cookie information, null if failed.
134      */
135     virtual const char *RetrieveCookie(int32_t &size) = 0;
136 
137     /**
138      * Get the transaction Id
139      *
140      * @return Returns transaction id.
141      */
GetTransactionId(DeviceType deviceType,DeviceRole deviceRole)142     virtual uint64_t GetTransactionId(DeviceType deviceType, DeviceRole deviceRole)
143     {
144         (void)deviceType;
145         (void)deviceRole;
146         return 0;
147     }
148 
149     /**
150      * Notify device connect info
151      *
152      * @return Returns transaction id.
153      */
154     virtual void NotifyDeviceInfo(std::string networkId, bool connected) = 0;
155 
156     /**
157      * Check remote device state.
158      *
159      * @return Returns transaction id.
160      */
161     virtual int32_t CheckRemoteDeviceState(std::string networkId, DeviceRole deviceRole, bool isStartDevice) = 0;
162 
163     /**
164      * Set parameter callback
165      *
166      * @return Returns the setting result
167      */
168     virtual int32_t SetParameterCallback(const sptr<IRemoteObject>& object) = 0;
169 
170     /**
171      * Set audio mono state for accessibility
172      *
173      * @param  audioMono the state of mono audio for accessibility
174      * @return none.
175      */
176     virtual void SetAudioMonoState(bool audioMono) = 0;
177 
178     /**
179      * Set audio balance value for accessibility
180      *
181      * @param  audioBalance the value of audio balance for accessibility
182      * @return none.
183      */
184     virtual void SetAudioBalanceValue(float audioBalance) = 0;
185 
186     enum {
187         GET_MAX_VOLUME = 0,
188         GET_MIN_VOLUME = 1,
189         GET_DEVICES = 2,
190         GET_AUDIO_PARAMETER = 3,
191         SET_AUDIO_PARAMETER = 4,
192         SET_MICROPHONE_MUTE = 5,
193         IS_MICROPHONE_MUTE = 6,
194         SET_AUDIO_SCENE = 7,
195         UPDATE_ROUTE_REQ = 8,
196         RETRIEVE_COOKIE = 9,
197         GET_TRANSACTION_ID = 10,
198         SET_PARAMETER_CALLBACK = 11,
199         GET_REMOTE_AUDIO_PARAMETER = 12,
200         SET_REMOTE_AUDIO_PARAMETER = 13,
201         NOTIFY_DEVICE_INFO = 14,
202         CHECK_REMOTE_DEVICE_STATE = 15,
203         SET_VOICE_VOLUME = 16,
204         SET_AUDIO_MONO_STATE = 17,
205         SET_AUDIO_BALANCE_VALUE = 18,
206     };
207 
208 public:
209     DECLARE_INTERFACE_DESCRIPTOR(u"IStandardAudioService");
210 };
211 
212 class AudioManagerStub : public IRemoteStub<IStandardAudioService> {
213 public:
214     virtual int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply,
215         MessageOption &option) override;
216 };
217 } // namespace AudioStandard
218 } // namespace OHOS
219 #endif // I_ST_AUDIO_MANAGER_BASE_H
220