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 #include <android/hardware/bluetooth/audio/2.0/types.h> 18 19 #include "../session/BluetoothAudioSession.h" 20 21 namespace aidl { 22 namespace android { 23 namespace hardware { 24 namespace bluetooth { 25 namespace audio { 26 27 using SessionType_2_0 = 28 ::android::hardware::bluetooth::audio::V2_0::SessionType; 29 using PortStatusCallbacks_2_0 = 30 ::android::bluetooth::audio::PortStatusCallbacks; 31 using AudioConfig_2_0 = 32 ::android::hardware::bluetooth::audio::V2_0::AudioConfiguration; 33 34 class HidlToAidlMiddleware_2_0 { 35 public: 36 static bool IsAidlAvailable(); 37 38 static bool IsSessionReady(const SessionType_2_0& session_type); 39 40 static uint16_t RegisterControlResultCback( 41 const SessionType_2_0& session_type, 42 const PortStatusCallbacks_2_0& cbacks); 43 44 static void UnregisterControlResultCback(const SessionType_2_0& session_type, 45 uint16_t cookie); 46 47 static const AudioConfig_2_0 GetAudioConfig( 48 const SessionType_2_0& session_type); 49 50 static bool StartStream(const SessionType_2_0& session_type); 51 52 static void StopStream(const SessionType_2_0& session_type); 53 54 static bool SuspendStream(const SessionType_2_0& session_type); 55 56 static bool GetPresentationPosition(const SessionType_2_0& session_type, 57 uint64_t* remote_delay_report_ns, 58 uint64_t* total_bytes_readed, 59 timespec* data_position); 60 61 static void UpdateTracksMetadata( 62 const SessionType_2_0& session_type, 63 const struct source_metadata* source_metadata); 64 65 static size_t OutWritePcmData(const SessionType_2_0& session_type, 66 const void* buffer, size_t bytes); 67 68 static size_t InReadPcmData(const SessionType_2_0& session_type, void* buffer, 69 size_t bytes); 70 }; 71 72 } // namespace audio 73 } // namespace bluetooth 74 } // namespace hardware 75 } // namespace android 76 } // namespace aidl 77