1 /*
2  * Copyright 2019 HIMSA II K/S - www.himsa.com. Represented by EHIMA -
3  * www.ehima.com
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #pragma once
19 
20 #include <array>
21 #include <optional>
22 
23 #include "raw_address.h"
24 
25 namespace bluetooth {
26 namespace le_audio {
27 
28 enum class ConnectionState {
29   DISCONNECTED = 0,
30   CONNECTING,
31   CONNECTED,
32   DISCONNECTING
33 };
34 
35 enum class GroupStatus {
36   IDLE = 0,
37   STREAMING,
38   SUSPENDED,
39   RECONFIGURED,
40   DESTROYED,
41 };
42 
43 class LeAudioClientCallbacks {
44  public:
45   virtual ~LeAudioClientCallbacks() = default;
46 
47   /** Callback for profile connection state change */
48   virtual void OnConnectionState(ConnectionState state,
49                                  const RawAddress& address) = 0;
50 
51   /* Callback with group status update */
52   virtual void OnGroupStatus(uint8_t group_id, GroupStatus group_status,
53                              uint8_t group_flags) = 0;
54 
55   /* Callback for newly recognized or reconfigured existing le audio device */
56   virtual void OnAudioConf(const RawAddress& addr, uint8_t direction,
57                            uint8_t group_id, uint32_t snk_audio_location,
58                            uint32_t src_audio_location) = 0;
59 
60   /* Callback for available set member  */
61   virtual void OnSetMemberAvailable(const RawAddress& address,
62                                     uint8_t group_id) = 0;
63 };
64 
65 class LeAudioClientInterface {
66  public:
67   virtual ~LeAudioClientInterface() = default;
68 
69   /* Register the LeAudio callbacks */
70   virtual void Initialize(LeAudioClientCallbacks* callbacks) = 0;
71 
72   /** Connect to LEAudio */
73   virtual void Connect(const RawAddress& address) = 0;
74 
75   /** Disconnect from LEAudio */
76   virtual void Disconnect(const RawAddress& address) = 0;
77 
78   /* Cleanup the LeAudio */
79   virtual void Cleanup(void) = 0;
80 
81   /* Request to stream audio */
82   virtual void GroupStream(uint8_t group_id, uint16_t content_type) = 0;
83 
84   /* Request to suspend audio */
85   virtual void GroupSuspend(uint8_t group_id) = 0;
86 
87   /* Request to stop streaming audio */
88   virtual void GroupStop(uint8_t group_id) = 0;
89 };
90 
91 static constexpr uint8_t INSTANCE_ID_UNDEFINED = 0xFF;
92 
93 } /* namespace le_audio */
94 } /* namespace bluetooth */
95