• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 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 #ifndef GD_RUST_TOPSHIM_BTAV_BTAV_SHIM_H
17 #define GD_RUST_TOPSHIM_BTAV_BTAV_SHIM_H
18 
19 #include <memory>
20 
21 #include "audio_hal_interface/a2dp_encoding_host.h"
22 #include "include/hardware/avrcp/avrcp.h"
23 #include "include/hardware/bt_av.h"
24 #include "rust/cxx.h"
25 #include "types/raw_address.h"
26 
27 namespace bluetooth {
28 namespace topshim {
29 namespace rust {
30 
31 struct A2dpCodecConfig;
32 struct RustPresentationPosition;
33 struct RustRawAddress;
34 
35 class A2dpIntf {
36  public:
A2dpIntf(const btav_source_interface_t * intf)37   A2dpIntf(const btav_source_interface_t* intf) : intf_(intf){};
38   ~A2dpIntf();
39 
40   // interface for Settings
41   int init() const;
42   int connect(RustRawAddress bt_addr) const;
43   int disconnect(RustRawAddress bt_addr) const;
44   int set_silence_device(RustRawAddress bt_addr, bool silent) const;
45   int set_active_device(RustRawAddress bt_addr) const;
46   int config_codec(RustRawAddress bt_addr, ::rust::Vec<A2dpCodecConfig> codec_preferences) const;
47   void cleanup() const;
48 
49   // interface for Audio server
50   bool set_audio_config(A2dpCodecConfig rconfig) const;
51   bool start_audio_request() const;
52   bool stop_audio_request() const;
53   RustPresentationPosition get_presentation_position() const;
54 
55  private:
56   const btav_source_interface_t* intf_;
57 };
58 
59 std::unique_ptr<A2dpIntf> GetA2dpProfile(const unsigned char* btif);
60 
61 class AvrcpIntf {
62  public:
AvrcpIntf(bluetooth::avrcp::ServiceInterface * intf)63   AvrcpIntf(bluetooth::avrcp::ServiceInterface* intf) : intf_(intf) {}
64   ~AvrcpIntf();
65 
66   void init();
67   void cleanup();
68   int connect(RustRawAddress bt_addr);
69   int disconnect(RustRawAddress bt_addr);
70 
71   // interface for Audio server
72   void set_volume(int8_t volume);
73 
74  private:
75   bluetooth::avrcp::ServiceInterface* intf_;
76 };
77 
78 std::unique_ptr<AvrcpIntf> GetAvrcpProfile(const unsigned char* btif);
79 
80 }  // namespace rust
81 }  // namespace topshim
82 }  // namespace bluetooth
83 
84 #endif  // GD_RUST_TOPSHIM_BTAV_BTAV_SHIM_H
85