1 /* 2 * Copyright 2021 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 <stdint.h> 20 #include <time.h> 21 22 #include "include/hardware/bt_av.h" 23 24 namespace bluetooth { 25 namespace audio { 26 namespace a2dp { 27 28 // Audio config from audio server; PCM format for now 29 struct AudioConfig { 30 btav_a2dp_codec_sample_rate_t sample_rate = BTAV_A2DP_CODEC_SAMPLE_RATE_48000; 31 btav_a2dp_codec_bits_per_sample_t bits_per_sample = 32 BTAV_A2DP_CODEC_BITS_PER_SAMPLE_24; 33 btav_a2dp_codec_channel_mode_t channel_mode = 34 BTAV_A2DP_CODEC_CHANNEL_MODE_STEREO; 35 }; 36 37 // Invoked by audio server to set audio config (PCM for now) 38 bool SetAudioConfig(AudioConfig); 39 40 // Invoked by audio server when it has audio data to stream. 41 // Returns whether the start request has been made successfully. 42 bool StartRequest(); 43 44 // Invoked by audio server when audio streaming is done. 45 bool StopRequest(); 46 47 // Invoked by audio server when audio streaming is suspended. 48 bool SuspendRequest(); 49 50 struct PresentationPosition { 51 uint64_t remote_delay_report_ns; 52 uint64_t total_bytes_read; 53 timespec data_position; 54 }; 55 56 // Invoked by audio server to check audio presentation position periodically. 57 PresentationPosition GetPresentationPosition(); 58 59 bool is_opus_supported(); 60 61 } // namespace a2dp 62 } // namespace audio 63 } // namespace bluetooth 64