1 /* 2 * Copyright (c) 2022-2025 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_ROUTING_MANAGER_H 17 #define ST_AUDIO_ROUTING_MANAGER_H 18 19 #include <iostream> 20 21 #include "audio_system_manager.h" 22 #include "audio_group_manager.h" 23 #include "microphone_descriptor.h" 24 #include "audio_policy_interface.h" 25 26 namespace OHOS { 27 namespace AudioStandard { 28 29 class AudioDeviceDescriptor; 30 class AudioRendererFilter; 31 class AudioDeviceRefiner; 32 33 class AudioRoutingManager { 34 public: 35 AudioRoutingManager() = default; 36 virtual ~AudioRoutingManager() = default; 37 38 static AudioRoutingManager *GetInstance(); 39 int32_t SetMicStateChangeCallback(const std::shared_ptr<AudioManagerMicStateChangeCallback> &callback); 40 int32_t GetPreferredOutputDeviceForRendererInfo(AudioRendererInfo rendererInfo, 41 std::vector<std::shared_ptr<AudioDeviceDescriptor>> &desc); 42 int32_t SetPreferredOutputDeviceChangeCallback(AudioRendererInfo rendererInfo, 43 const std::shared_ptr<AudioPreferredOutputDeviceChangeCallback> &callback); 44 int32_t UnsetPreferredOutputDeviceChangeCallback( 45 const std::shared_ptr<AudioPreferredOutputDeviceChangeCallback> &callback = nullptr); 46 int32_t GetPreferredInputDeviceForCapturerInfo(AudioCapturerInfo captureInfo, 47 std::vector<std::shared_ptr<AudioDeviceDescriptor>> &desc); 48 int32_t SetPreferredInputDeviceChangeCallback(AudioCapturerInfo capturerInfo, 49 const std::shared_ptr<AudioPreferredInputDeviceChangeCallback> &callback); 50 int32_t UnsetPreferredInputDeviceChangeCallback( 51 const std::shared_ptr<AudioPreferredInputDeviceChangeCallback> &callback = nullptr); 52 std::vector<sptr<MicrophoneDescriptor>> GetAvailableMicrophones(); 53 std::vector<std::shared_ptr<AudioDeviceDescriptor>> GetAvailableDevices(AudioDeviceUsage usage); 54 std::shared_ptr<AudioDeviceDescriptor> GetActiveBluetoothDevice(); 55 int32_t SetAudioDeviceRefinerCallback(const std::shared_ptr<AudioDeviceRefiner> &callback); 56 int32_t UnsetAudioDeviceRefinerCallback(); 57 int32_t SetPreferredDevice(const PreferredType preferredType, const std::shared_ptr<AudioDeviceDescriptor> &desc, 58 const int32_t uid = INVALID_UID); 59 int32_t SetDeviceVolumeBehavior(const std::string &networkId, DeviceType deviceType, VolumeBehavior volumeBehavior); 60 int32_t SetDeviceConnectionStatus(const std::shared_ptr<AudioDeviceDescriptor> &desc, const bool isConnected); 61 private: 62 int32_t GetCallingPid(); 63 }; 64 65 } // namespace AudioStandard 66 } // namespace OHOS 67 #endif // ST_AUDIO_ROUTING_MANAGER_H 68 69