1 /* 2 * Copyright (C) 2022 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #pragma once 18 19 #include "BluetoothAudioSession.h" 20 21 namespace aidl { 22 namespace android { 23 namespace hardware { 24 namespace bluetooth { 25 namespace audio { 26 27 class BluetoothAudioSessionReport { 28 public: 29 /*** 30 * The API reports the Bluetooth stack has started the session, and will 31 * inform registered bluetooth_audio outputs 32 ***/ OnSessionStarted(const SessionType & session_type,const std::shared_ptr<IBluetoothAudioPort> host_iface,const DataMQDesc * data_mq,const AudioConfiguration & audio_config,const std::vector<LatencyMode> & latency_modes)33 static void OnSessionStarted( 34 const SessionType& session_type, 35 const std::shared_ptr<IBluetoothAudioPort> host_iface, 36 const DataMQDesc* data_mq, const AudioConfiguration& audio_config, 37 const std::vector<LatencyMode>& latency_modes) { 38 std::shared_ptr<BluetoothAudioSession> session_ptr = 39 BluetoothAudioSessionInstance::GetSessionInstance(session_type); 40 if (session_ptr != nullptr) { 41 session_ptr->OnSessionStarted(host_iface, data_mq, audio_config, 42 latency_modes); 43 } 44 } 45 46 /*** 47 * The API reports the Bluetooth stack has ended the session, and will 48 * inform registered bluetooth_audio outputs 49 ***/ OnSessionEnded(const SessionType & session_type)50 static void OnSessionEnded(const SessionType& session_type) { 51 std::shared_ptr<BluetoothAudioSession> session_ptr = 52 BluetoothAudioSessionInstance::GetSessionInstance(session_type); 53 if (session_ptr != nullptr) { 54 session_ptr->OnSessionEnded(); 55 } 56 } 57 58 /*** 59 * The API reports the Bluetooth stack has replied the result of startStream 60 * or suspendStream, and will inform registered bluetooth_audio outputs 61 ***/ ReportControlStatus(const SessionType & session_type,const bool & start_resp,BluetoothAudioStatus status)62 static void ReportControlStatus(const SessionType& session_type, 63 const bool& start_resp, 64 BluetoothAudioStatus status) { 65 std::shared_ptr<BluetoothAudioSession> session_ptr = 66 BluetoothAudioSessionInstance::GetSessionInstance(session_type); 67 if (session_ptr != nullptr) { 68 session_ptr->ReportControlStatus(start_resp, status); 69 } 70 } 71 /*** 72 * The API reports the Bluetooth stack has replied the changed of the audio 73 * configuration, and will inform registered bluetooth_audio outputs 74 ***/ ReportAudioConfigChanged(const SessionType & session_type,const AudioConfiguration & audio_config)75 static void ReportAudioConfigChanged(const SessionType& session_type, 76 const AudioConfiguration& audio_config) { 77 std::shared_ptr<BluetoothAudioSession> session_ptr = 78 BluetoothAudioSessionInstance::GetSessionInstance(session_type); 79 if (session_ptr != nullptr) { 80 session_ptr->ReportAudioConfigChanged(audio_config); 81 } 82 } 83 /*** 84 * The API reports the Bluetooth stack has replied the changed of the low 85 * latency audio allowed, and will inform registered bluetooth_audio outputs 86 ***/ ReportLowLatencyModeAllowedChanged(const SessionType & session_type,bool allowed)87 static void ReportLowLatencyModeAllowedChanged( 88 const SessionType& session_type, bool allowed) { 89 std::shared_ptr<BluetoothAudioSession> session_ptr = 90 BluetoothAudioSessionInstance::GetSessionInstance(session_type); 91 if (session_ptr != nullptr) { 92 session_ptr->ReportLowLatencyModeAllowedChanged(allowed); 93 } 94 } 95 }; 96 97 } // namespace audio 98 } // namespace bluetooth 99 } // namespace hardware 100 } // namespace android 101 } // namespace aidl 102