• 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 ST_AUDIO_POLICY_INTERFACE_H
17 #define ST_AUDIO_POLICY_INTERFACE_H
18 
19 #include "audio_module_info.h"
20 #include "audio_info.h"
21 #include "audio_policy_manager.h"
22 #include "audio_policy_ipc_interface_code.h"
23 #include "audio_session_callback.h"
24 #include "audio_volume_config.h"
25 
26 #include <memory>
27 #include <string>
28 
29 namespace OHOS {
30 namespace AudioStandard {
31 class IAudioPolicyInterface {
32 public:
~IAudioPolicyInterface()33     virtual ~IAudioPolicyInterface() {}
34 
35     virtual bool Init() = 0;
36 
37     virtual void InitKVStore() = 0;
38 
39     virtual bool ConnectServiceAdapter() = 0;
40 
41     virtual int32_t GetMaxVolumeLevel(AudioVolumeType volumeType) = 0;
42 
43     virtual int32_t GetMinVolumeLevel(AudioVolumeType volumeType) = 0;
44 
45     virtual int32_t SetSystemVolumeLevel(AudioStreamType streamType, int32_t volumeLevel, bool isFromVolumeKey) = 0;
46 
47     virtual int32_t GetSystemVolumeLevel(AudioStreamType streamType, bool isFromVolumeKey) = 0;
48 
49     virtual float GetSystemVolumeDb(AudioStreamType streamType) = 0;
50 
51     virtual int32_t SetStreamMute(AudioStreamType streamType, bool mute) = 0;
52 
53     virtual int32_t SetSourceOutputStreamMute(int32_t uid, bool setMute) = 0;
54 
55     virtual bool GetStreamMute(AudioStreamType streamType) = 0;
56 
57     virtual bool IsStreamActive(AudioStreamType streamType) = 0;
58 
59     virtual std::vector<SinkInfo> GetAllSinks() = 0;
60 
61     virtual std::vector<SinkInput> GetAllSinkInputs() = 0;
62 
63     virtual std::vector<SourceOutput> GetAllSourceOutputs() = 0;
64 
65     virtual AudioIOHandle OpenAudioPort(const AudioModuleInfo &audioPortInfo) = 0;
66 
67     virtual AudioIOHandle LoadLoopback(const LoopbackModuleInfo &moduleInfo) = 0;
68 
69     virtual int32_t CloseAudioPort(AudioIOHandle ioHandle) = 0;
70 
71     virtual int32_t SelectDevice(DeviceRole deviceRole, InternalDeviceType deviceType, std::string name);
72 
73     virtual int32_t SetDeviceActive(AudioIOHandle ioHandle, InternalDeviceType deviceType,
74                                     std::string name, bool active) = 0;
75 
76     virtual int32_t MoveSinkInputByIndexOrName(uint32_t sinkInputId, uint32_t sinkIndex, std::string sinkName) = 0;
77 
78     virtual int32_t MoveSourceOutputByIndexOrName(uint32_t sourceOutputId,
79         uint32_t sourceIndex, std::string sourceName) = 0;
80 
81     virtual int32_t SetRingerMode(AudioRingerMode ringerMode) = 0;
82 
83     virtual AudioRingerMode GetRingerMode() const = 0;
84 
85     virtual int32_t SetAudioSessionCallback(AudioSessionCallback *callback) = 0;
86 
87     virtual int32_t SuspendAudioDevice(std::string &name, bool isSuspend) = 0;
88 
89     virtual void SetVolumeForSwitchDevice(InternalDeviceType deviceType) = 0;
90 
91     virtual bool SetSinkMute(const std::string &sinkName, bool isMute) = 0;
92 
93     virtual float CalculateVolumeDb(int32_t volumeLevel) = 0;
94 
95     virtual int32_t SetSystemSoundUri(const std::string &key, const std::string &uri) = 0;
96 
97     virtual std::string GetSystemSoundUri(const std::string &key) = 0;
98 
99     virtual float GetMinStreamVolume() const = 0;
100 
101     virtual float GetMaxStreamVolume() const = 0;
102 
103     virtual int32_t UpdateSwapDeviceStatus() = 0;
104 
105     virtual bool IsVolumeUnadjustable() = 0;
106 
107     virtual void GetStreamVolumeInfoMap(StreamVolumeInfoMap &streamVolumeInfos);
108 
109     virtual float GetSystemVolumeInDb(AudioVolumeType volumeType, int32_t volumeLevel, DeviceType deviceType) = 0;
110 };
111 } // namespace AudioStandard
112 } // namespace OHOS
113 
114 #endif // ST_AUDIO_POLICY_INTERFACE_H
115