1 /*
2  * Copyright 2024 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 #ifdef TARGET_FLOSS
20 #include <audio_hal_interface/audio_linux.h>
21 #else
22 #include <hardware/audio.h>
23 #endif
24 
25 #include <stdint.h>
26 
27 #include <vector>
28 
29 // APIs exposed to the audio server.
30 namespace bluetooth {
31 namespace audio {
32 namespace le_audio {
33 
34 struct btle_pcm_parameters {
35   uint32_t data_interval_us;
36   uint32_t sample_rate;
37   uint8_t bits_per_sample;
38   uint8_t channels_count;
39 };
40 
41 enum class btle_stream_started_status : int32_t {
42   CANCELED = -1,
43   IDLE = 0,
44   STARTED = 1,
45 };
46 
47 // Invoked by audio server when it has audio data to stream.
48 // Returns whether the start request has been made successfully.
49 bool HostStartRequest();
50 
51 // Invoked by audio server when audio streaming is done.
52 void HostStopRequest();
53 
54 // Whether the peer stream has started.
55 // Returns 1, when the stream has started,
56 //         -1, when the previous request has been cancelled,
57 //         0, otherwise.
58 btle_stream_started_status GetHostStreamStarted();
59 
60 // Returns the current host audio config.
61 btle_pcm_parameters GetHostPcmConfig();
62 
63 // Invoked by audio server when metadata for playback path has changed.
64 void SourceMetadataChanged(const source_metadata_v7_t& metadata);
65 
66 // Invoked by audio server to request audio data streamed from the peer.
67 // Returns whether the start request has been made successfully.
68 bool PeerStartRequest();
69 
70 // Invoked by audio server when audio streaming is done.
71 void PeerStopRequest();
72 
73 // Whether the peer stream has started.
74 // Returns 1, when the stream has started,
75 //         -1, when the previous request has been cancelled,
76 //         0, otherwise.
77 btle_stream_started_status GetPeerStreamStarted();
78 
79 // Returns the current peer audio config.
80 btle_pcm_parameters GetPeerPcmConfig();
81 
82 // Invoked by audio server when metadata for capture path has changed.
83 void SinkMetadataChanged(const sink_metadata_v7_t& metadata);
84 
85 }  // namespace le_audio
86 }  // namespace audio
87 }  // namespace bluetooth
88