blob: 1b53da0c419793e3caf23ae728b3d613c8d4d52c [file] [log] [blame]
/*
* Copyright 2022 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include "client_interface_aidl.h"
namespace bluetooth {
namespace audio {
namespace aidl {
namespace a2dp {
namespace {
BluetoothAudioCtrlAck a2dp_ack_to_bt_audio_ctrl_ack(tA2DP_CTRL_ACK ack);
// Provide call-in APIs for the Bluetooth Audio HAL
class A2dpTransport
: public ::bluetooth::audio::aidl::IBluetoothSinkTransportInstance {
public:
A2dpTransport(SessionType sessionType);
BluetoothAudioCtrlAck StartRequest(bool is_low_latency) override;
BluetoothAudioCtrlAck SuspendRequest() override;
void StopRequest() override;
void SetLowLatency(bool is_low_latency) override;
bool GetPresentationPosition(uint64_t* remote_delay_report_ns,
uint64_t* total_bytes_read,
timespec* data_position) override;
void SourceMetadataChanged(const source_metadata_t& source_metadata);
void SinkMetadataChanged(const sink_metadata_t&) override;
tA2DP_CTRL_CMD GetPendingCmd() const;
void ResetPendingCmd();
void ResetPresentationPosition();
void LogBytesRead(size_t bytes_read) override;
// delay reports from AVDTP is based on 1/10 ms (100us)
void SetRemoteDelay(uint16_t delay_report);
private:
static tA2DP_CTRL_CMD a2dp_pending_cmd_;
static uint16_t remote_delay_report_;
uint64_t total_bytes_read_;
timespec data_position_;
};
} // namespace
} // namespace a2dp
} // namespace aidl
} // namespace audio
} // namespace bluetooth