1 /* 2 * Copyright 2018 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_2_1.h" 20 21 namespace android { 22 namespace bluetooth { 23 namespace audio { 24 25 class BluetoothAudioSessionReport_2_1 { 26 public: 27 // The API reports the Bluetooth stack has started the session, and will 28 // inform registered bluetooth_audio outputs OnSessionStarted(const::android::hardware::bluetooth::audio::V2_1::SessionType & session_type,const sp<IBluetoothAudioPort> host_iface,const DataMQ::Descriptor * dataMQ,const::android::hardware::bluetooth::audio::V2_1::AudioConfiguration & audio_config)29 static void OnSessionStarted( 30 const ::android::hardware::bluetooth::audio::V2_1::SessionType& 31 session_type, 32 const sp<IBluetoothAudioPort> host_iface, 33 const DataMQ::Descriptor* dataMQ, 34 const ::android::hardware::bluetooth::audio::V2_1::AudioConfiguration& 35 audio_config) { 36 std::shared_ptr<BluetoothAudioSession_2_1> session_ptr = 37 BluetoothAudioSessionInstance_2_1::GetSessionInstance(session_type); 38 if (session_ptr != nullptr) { 39 session_ptr->OnSessionStarted(host_iface, dataMQ, audio_config); 40 } 41 } 42 // The API reports the Bluetooth stack has ended the session, and will 43 // inform registered bluetooth_audio outputs OnSessionEnded(const::android::hardware::bluetooth::audio::V2_1::SessionType & session_type)44 static void OnSessionEnded( 45 const ::android::hardware::bluetooth::audio::V2_1::SessionType& 46 session_type) { 47 std::shared_ptr<BluetoothAudioSession_2_1> session_ptr = 48 BluetoothAudioSessionInstance_2_1::GetSessionInstance(session_type); 49 if (session_ptr != nullptr) { 50 session_ptr->GetAudioSession()->OnSessionEnded(); 51 } 52 } 53 // The API reports the Bluetooth stack has replied the result of startStream 54 // or suspendStream, and will inform registered bluetooth_audio outputs ReportControlStatus(const::android::hardware::bluetooth::audio::V2_1::SessionType & session_type,const bool & start_resp,const BluetoothAudioStatus & status)55 static void ReportControlStatus( 56 const ::android::hardware::bluetooth::audio::V2_1::SessionType& 57 session_type, 58 const bool& start_resp, const BluetoothAudioStatus& status) { 59 std::shared_ptr<BluetoothAudioSession_2_1> session_ptr = 60 BluetoothAudioSessionInstance_2_1::GetSessionInstance(session_type); 61 if (session_ptr != nullptr) { 62 session_ptr->GetAudioSession()->ReportControlStatus(start_resp, status); 63 } 64 } 65 }; 66 67 } // namespace audio 68 } // namespace bluetooth 69 } // namespace android 70