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