• 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_types.h"
23 #include "audio_session_callback.h"
24 
25 #include <memory>
26 #include <string>
27 
28 namespace OHOS {
29 namespace AudioStandard {
30 class IAudioPolicyInterface {
31 public:
~IAudioPolicyInterface()32     virtual ~IAudioPolicyInterface() {}
33 
34     virtual bool Init() = 0;
35 
36     virtual void InitKVStore() = 0;
37 
38     virtual bool ConnectServiceAdapter() = 0;
39 
40     virtual int32_t SetStreamVolume(AudioStreamType streamType, float volume) = 0;
41 
42     virtual float GetStreamVolume(AudioStreamType streamType) = 0;
43 
44     virtual int32_t SetStreamMute(AudioStreamType streamType, bool mute) = 0;
45 
46     virtual int32_t SetSourceOutputStreamMute(int32_t uid, bool setMute) = 0;
47 
48     virtual bool GetStreamMute(AudioStreamType streamType) = 0;
49 
50     virtual bool IsStreamActive(AudioStreamType streamType) = 0;
51 
52     virtual std::vector<SinkInput> GetAllSinkInputs() = 0;
53 
54     virtual std::vector<SourceOutput> GetAllSourceOutputs() = 0;
55 
56     virtual AudioIOHandle OpenAudioPort(const AudioModuleInfo &audioPortInfo) = 0;
57 
58     virtual int32_t CloseAudioPort(AudioIOHandle ioHandle) = 0;
59 
60     virtual int32_t SelectDevice(DeviceRole deviceRole, InternalDeviceType deviceType, std::string name);
61 
62     virtual int32_t SetDeviceActive(AudioIOHandle ioHandle, InternalDeviceType deviceType,
63                                     std::string name, bool active) = 0;
64 
65     virtual int32_t MoveSinkInputByIndexOrName(uint32_t sinkInputId, uint32_t sinkIndex, std::string sinkName) = 0;
66 
67     virtual int32_t MoveSourceOutputByIndexOrName(uint32_t sourceOutputId,
68         uint32_t sourceIndex, std::string sourceName) = 0;
69 
70     virtual int32_t SetRingerMode(AudioRingerMode ringerMode) = 0;
71 
72     virtual AudioRingerMode GetRingerMode() const = 0;
73 
74     virtual int32_t SetAudioSessionCallback(AudioSessionCallback *callback) = 0;
75 
76     virtual int32_t SuspendAudioDevice(std::string &name, bool isSuspend) = 0;
77 };
78 } // namespace AudioStandard
79 } // namespace OHOS
80 
81 #endif // ST_AUDIO_POLICY_INTERFACE_H
82