• 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_system_manager.h"
24 
25 namespace OHOS {
26 namespace AudioStandard {
27 class IStandardAudioService : public IRemoteBroker {
28 public:
29     /**
30      * Obtains max volume.
31      *
32      * @return Returns the max volume.
33      */
34     virtual int32_t GetMaxVolume(AudioSystemManager::AudioVolumeType volumeType) = 0;
35 
36     /**
37      * Obtains min volume.
38      *
39      * @return Returns the min volume.
40      */
41     virtual int32_t GetMinVolume(AudioSystemManager::AudioVolumeType volumeType) = 0;
42 
43     /**
44      * Sets Microphone Mute status.
45      *
46      * @param isMute Mute status true or false to be set.
47      * @return Returns 0 if success. Otherise returns Errocode defined in audio_errors.h.
48      */
49     virtual int32_t SetMicrophoneMute(bool isMute) = 0;
50 
51      /**
52      * Gets Microphone Mute status.
53      *
54      * @return Returns true or false
55      */
56     virtual bool IsMicrophoneMute() = 0;
57 
58     /**
59      * Sets Audio modes.
60      *
61      * @param audioScene Audio scene type.
62      * @param activeDeviceList List of active device types.
63      * @return Returns 0 if success. Otherise returns Errocode defined in audio_errors.h.
64      */
65     virtual int32_t SetAudioScene(AudioScene audioScene) = 0;
66 
67     /**
68      * Obtains device array.
69      *
70      * @return Returns the array of audio device descriptor.
71      */
72     virtual std::vector<sptr<AudioDeviceDescriptor>> GetDevices(DeviceFlag deviceFlag) = 0;
73 
74     /**
75      * Set Audio Parameter.
76      *
77      * @param  key for the audio parameter to be set
78      * @param  value associated with the key for the audio parameter to be set
79      * @return none.
80      */
81     virtual void SetAudioParameter(const std::string &key, const std::string &value) = 0;
82 
83     /**
84      * Get Audio Parameter.
85      *
86      * @param  key for the audio parameter to be set
87      * @return Returns value associated to the key requested.
88      */
89     virtual const std::string GetAudioParameter(const std::string &key) = 0;
90 
91     /**
92      * Update the audio route after device is detected and route is decided
93      *
94      * @return Returns 0 if success. Otherise returns Errocode defined in audio_errors.h.
95      */
96     virtual int32_t UpdateActiveDeviceRoute(DeviceType type, DeviceFlag flag) = 0;
97 
98     /**
99      * Retrieve cookie information from the service
100      *
101      * @return Returns cookie information, null if failed.
102      */
103     virtual const char *RetrieveCookie(int32_t &size) = 0;
104 
105     enum {
106         GET_MAX_VOLUME = 0,
107         GET_MIN_VOLUME = 1,
108         GET_DEVICES = 2,
109         GET_AUDIO_PARAMETER = 3,
110         SET_AUDIO_PARAMETER = 4,
111         SET_MICROPHONE_MUTE = 5,
112         IS_MICROPHONE_MUTE = 6,
113         SET_AUDIO_SCENE = 7,
114         UPDATE_ROUTE_REQ = 8,
115         RETRIEVE_COOKIE = 9,
116     };
117 
118 public:
119     DECLARE_INTERFACE_DESCRIPTOR(u"IStandardAudioService");
120 };
121 
122 class AudioManagerStub : public IRemoteStub<IStandardAudioService> {
123 public:
124     virtual int OnRemoteRequest(uint32_t code, MessageParcel &data,
125                                 MessageParcel &reply, MessageOption &option) override;
126     bool IsPermissionValid();
127 };
128 } // namespace AudioStandard
129 } // namespace OHOS
130 #endif // I_ST_AUDIO_MANAGER_BASE_H
131