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_AUDIO_POLICY_BASE_H 17 #define I_AUDIO_POLICY_BASE_H 18 19 #include "audio_interrupt_callback.h" 20 #include "audio_policy_manager.h" 21 #include "audio_policy_types.h" 22 #include "i_audio_volume_key_event_callback.h" 23 #include "ipc_types.h" 24 #include "iremote_broker.h" 25 #include "iremote_proxy.h" 26 #include "iremote_stub.h" 27 28 namespace OHOS { 29 namespace AudioStandard { 30 class IAudioPolicy : public IRemoteBroker { 31 public: 32 33 virtual int32_t SetStreamVolume(AudioStreamType streamType, float volume) = 0; 34 35 virtual float GetStreamVolume(AudioStreamType streamType) = 0; 36 37 virtual int32_t SetStreamMute(AudioStreamType streamType, bool mute) = 0; 38 39 virtual bool GetStreamMute(AudioStreamType streamType) = 0; 40 41 virtual bool IsStreamActive(AudioStreamType streamType) = 0; 42 43 virtual std::vector<sptr<AudioDeviceDescriptor>> GetDevices(DeviceFlag deviceFlag) = 0; 44 45 virtual int32_t SetDeviceActive(InternalDeviceType deviceType, bool active) = 0; 46 47 virtual bool IsDeviceActive(InternalDeviceType deviceType) = 0; 48 49 virtual int32_t SetRingerMode(AudioRingerMode ringMode) = 0; 50 51 virtual AudioRingerMode GetRingerMode() = 0; 52 53 virtual int32_t SetAudioScene(AudioScene scene) = 0; 54 55 virtual AudioScene GetAudioScene() = 0; 56 57 virtual int32_t SetRingerModeCallback(const int32_t clientId, const sptr<IRemoteObject> &object) = 0; 58 59 virtual int32_t UnsetRingerModeCallback(const int32_t clientId) = 0; 60 61 virtual int32_t SetDeviceChangeCallback(const int32_t clientId, const sptr<IRemoteObject> &object) = 0; 62 63 virtual int32_t UnsetDeviceChangeCallback(const int32_t clientId) = 0; 64 65 virtual int32_t SetAudioInterruptCallback(const uint32_t sessionID, const sptr<IRemoteObject> &object) = 0; 66 67 virtual int32_t UnsetAudioInterruptCallback(const uint32_t sessionID) = 0; 68 69 virtual int32_t ActivateAudioInterrupt(const AudioInterrupt &audioInterrupt) = 0; 70 71 virtual int32_t DeactivateAudioInterrupt(const AudioInterrupt &audioInterrupt) = 0; 72 73 virtual int32_t SetAudioManagerInterruptCallback(const uint32_t clientID, const sptr<IRemoteObject> &object) = 0; 74 75 virtual int32_t UnsetAudioManagerInterruptCallback(const uint32_t clientID) = 0; 76 77 virtual int32_t RequestAudioFocus(const uint32_t clientID, const AudioInterrupt &audioInterrupt) = 0; 78 79 virtual int32_t AbandonAudioFocus(const uint32_t clientID, const AudioInterrupt &audioInterrupt) = 0; 80 81 virtual AudioStreamType GetStreamInFocus() = 0; 82 83 virtual int32_t GetSessionInfoInFocus(AudioInterrupt &audioInterrupt) = 0; 84 85 virtual int32_t SetVolumeKeyEventCallback(const int32_t clientPid, const sptr<IRemoteObject> &object) = 0; 86 87 virtual int32_t UnsetVolumeKeyEventCallback(const int32_t clientPid) = 0; 88 public: 89 DECLARE_INTERFACE_DESCRIPTOR(u"IAudioPolicy"); 90 }; 91 } // namespace AudioStandard 92 } // namespace OHOS 93 #endif // I_AUDIO_POLICY_BASE_H 94