1 /* 2 * Copyright 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 "client_interface_aidl.h" 20 21 namespace bluetooth { 22 namespace audio { 23 namespace aidl { 24 namespace a2dp { 25 26 namespace { 27 28 using ::bluetooth::audio::aidl::LatencyMode; 29 30 BluetoothAudioCtrlAck a2dp_ack_to_bt_audio_ctrl_ack(tA2DP_CTRL_ACK ack); 31 32 // Provide call-in APIs for the Bluetooth Audio HAL 33 class A2dpTransport 34 : public ::bluetooth::audio::aidl::IBluetoothSinkTransportInstance { 35 public: 36 A2dpTransport(SessionType sessionType); 37 38 BluetoothAudioCtrlAck StartRequest(bool is_low_latency) override; 39 40 BluetoothAudioCtrlAck SuspendRequest() override; 41 42 void StopRequest() override; 43 44 void SetLatencyMode(LatencyMode latency_mode) override; 45 46 bool GetPresentationPosition(uint64_t* remote_delay_report_ns, 47 uint64_t* total_bytes_read, 48 timespec* data_position) override; 49 50 void SourceMetadataChanged(const source_metadata_v7_t& source_metadata); 51 52 void SinkMetadataChanged(const sink_metadata_v7_t&) override; 53 54 tA2DP_CTRL_CMD GetPendingCmd() const; 55 56 void ResetPendingCmd(); 57 58 void ResetPresentationPosition(); 59 60 void LogBytesRead(size_t bytes_read) override; 61 62 // delay reports from AVDTP is based on 1/10 ms (100us) 63 void SetRemoteDelay(uint16_t delay_report); 64 65 private: 66 static tA2DP_CTRL_CMD a2dp_pending_cmd_; 67 static uint16_t remote_delay_report_; 68 uint64_t total_bytes_read_; 69 timespec data_position_; 70 }; 71 } // namespace 72 73 } // namespace a2dp 74 } // namespace aidl 75 } // namespace audio 76 } // namespace bluetooth 77