• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2021 HIMSA II K/S - www.himsa.com.
3  * Represented by EHIMA - 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 <hardware/bluetooth.h>
21 
22 #include <variant>
23 
24 namespace bluetooth {
25 namespace vc {
26 
27 enum class ConnectionState {
28   DISCONNECTED = 0,
29   CONNECTING,
30   CONNECTED,
31   DISCONNECTING
32 };
33 
34 class VolumeControlCallbacks {
35  public:
36   virtual ~VolumeControlCallbacks() = default;
37 
38   /** Callback for profile connection state change */
39   virtual void OnConnectionState(ConnectionState state,
40                                  const RawAddress& address) = 0;
41 
42   /* Callback for the volume change changed on the device */
43   virtual void OnVolumeStateChanged(const RawAddress& address, uint8_t volume,
44                                     bool mute) = 0;
45 
46   /* Callback for the volume change changed on the group*/
47   virtual void OnGroupVolumeStateChanged(int group_id, uint8_t volume,
48                                          bool mute) = 0;
49 };
50 
51 class VolumeControlInterface {
52  public:
53   virtual ~VolumeControlInterface() = default;
54 
55   /** Register the Volume Control callbacks */
56   virtual void Init(VolumeControlCallbacks* callbacks) = 0;
57 
58   /** Closes the interface */
59   virtual void Cleanup(void) = 0;
60 
61   /** Connect to Volume Control */
62   virtual void Connect(const RawAddress& address) = 0;
63 
64   /** Disconnect from Volume Control */
65   virtual void Disconnect(const RawAddress& address) = 0;
66 
67   /** Called when Volume control devices is unbonded */
68   virtual void RemoveDevice(const RawAddress& address) = 0;
69 
70   /** Set the volume */
71   virtual void SetVolume(std::variant<RawAddress, int> addr_or_group_id,
72                          uint8_t volume) = 0;
73 };
74 
75 } /* namespace vc */
76 } /* namespace bluetooth */
77