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 = BTAV_A2DP_CODEC_BITS_PER_SAMPLE_24;
32   btav_a2dp_codec_channel_mode_t channel_mode = BTAV_A2DP_CODEC_CHANNEL_MODE_STEREO;
33 };
34 
35 // Invoked by audio server to set audio config (PCM for now)
36 bool SetAudioConfig(AudioConfig);
37 
38 // Invoked by audio server when it has audio data to stream.
39 // Returns whether the start request has been made successfully.
40 bool StartRequest();
41 
42 // Invoked by audio server when audio streaming is done.
43 bool StopRequest();
44 
45 // Invoked by audio server when audio streaming is suspended.
46 bool SuspendRequest();
47 
48 struct PresentationPosition {
49   uint64_t remote_delay_report_ns;
50   uint64_t total_bytes_read;
51   timespec data_position;
52 };
53 
54 // Invoked by audio server to check audio presentation position periodically.
55 PresentationPosition GetPresentationPosition();
56 
57 bool is_opus_supported();
58 
59 }  // namespace a2dp
60 }  // namespace audio
61 }  // namespace bluetooth
62