1 /* 2 * Copyright (c) 2021-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 #ifndef ST_AUDIO_AUDIO_SCENE_MANAGER_H 16 #define ST_AUDIO_AUDIO_SCENE_MANAGER_H 17 18 #include <bitset> 19 #include <list> 20 #include <string> 21 #include <unordered_map> 22 #include <unordered_set> 23 #include <mutex> 24 #include "singleton.h" 25 #include "audio_group_handle.h" 26 #include "audio_manager_base.h" 27 #include "audio_module_info.h" 28 #include "audio_volume_config.h" 29 #include "audio_errors.h" 30 #include "audio_router_center.h" 31 #include "audio_stream_collector.h" 32 33 #include "audio_iohandle_map.h" 34 #include "audio_active_device.h" 35 36 namespace OHOS { 37 namespace AudioStandard { 38 39 class AudioSceneManager { 40 public: GetInstance()41 static AudioSceneManager& GetInstance() 42 { 43 static AudioSceneManager instance; 44 return instance; 45 } 46 int32_t SetAudioSceneAfter(AudioScene audioScene, BluetoothOffloadState state); 47 void SetAudioScenePre(AudioScene audioScene, const int32_t uid = INVALID_UID, const int32_t pid = INVALID_PID); 48 AudioScene GetAudioScene(bool hasSystemPermission = true) const; 49 AudioScene GetLastAudioScene() const; 50 bool IsSameAudioScene(); 51 bool IsStreamActive(AudioStreamType streamType) const; 52 bool CheckVoiceCallActive(int32_t sessionId) const; 53 54 bool IsVoiceCallRelatedScene(); 55 bool IsInPhoneCallScene(); 56 private: AudioSceneManager()57 AudioSceneManager() : audioRouterCenter_(AudioRouterCenter::GetAudioRouterCenter()), 58 streamCollector_(AudioStreamCollector::GetAudioStreamCollector()), 59 audioActiveDevice_(AudioActiveDevice::GetInstance()), 60 audioIOHandleMap_(AudioIOHandleMap::GetInstance()) {} ~AudioSceneManager()61 ~AudioSceneManager() {} 62 private: 63 AudioScene audioScene_ = AUDIO_SCENE_DEFAULT; 64 AudioScene lastAudioScene_ = AUDIO_SCENE_DEFAULT; 65 66 AudioRouterCenter& audioRouterCenter_; 67 AudioStreamCollector& streamCollector_; 68 AudioActiveDevice& audioActiveDevice_; 69 AudioIOHandleMap& audioIOHandleMap_; 70 }; 71 72 } 73 } 74 75 #endif 76