1 /* 2 * Copyright (C) 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 #include <memory> 20 21 #include "audio_hal_interface/le_audio_software_host.h" 22 #include "include/hardware/bt_le_audio.h" 23 #include "rust/cxx.h" 24 #include "types/raw_address.h" 25 26 namespace bluetooth { 27 namespace topshim { 28 namespace rust { 29 30 enum class BtLeAudioDirection : uint8_t; 31 enum class BtLeStreamStartedStatus : int32_t; 32 struct BtLeAudioCodecConfig; 33 struct BtLePcmConfig; 34 struct SourceMetadata; 35 struct SinkMetadata; 36 37 class LeAudioClientIntf { 38 public: LeAudioClientIntf(le_audio::LeAudioClientInterface * intf)39 LeAudioClientIntf(le_audio::LeAudioClientInterface* intf) : intf_(intf){}; 40 41 void init( 42 /* 43 LeAudioClientCallbacks* callbacks, 44 const std::vector<le_audio::btle_audio_codec_config_t>& offloading_preference 45 */); 46 void connect(RawAddress addr); 47 void disconnect(RawAddress addr); 48 void set_enable_state(RawAddress addr, bool enabled); 49 void cleanup(); 50 void remove_device(RawAddress addr); 51 void group_add_node(int group_id, RawAddress addr); 52 void group_remove_node(int group_id, RawAddress addr); 53 void group_set_active(int group_id); 54 void set_codec_config_preference( 55 int group_id, 56 BtLeAudioCodecConfig input_codec_config, 57 BtLeAudioCodecConfig output_codec_config); 58 void set_ccid_information(int ccid, int context_type); 59 void set_in_call(bool in_call); 60 void send_audio_profile_preferences( 61 int group_id, bool is_output_preference_le_audio, bool is_duplex_preference_le_audio); 62 void set_unicast_monitor_mode(BtLeAudioDirection direction, bool enable); 63 64 // interface for audio server 65 bool host_start_audio_request(); 66 void host_stop_audio_request(); 67 bool peer_start_audio_request(); 68 void peer_stop_audio_request(); 69 BtLePcmConfig get_host_pcm_config(); 70 BtLePcmConfig get_peer_pcm_config(); 71 BtLeStreamStartedStatus get_host_stream_started(); 72 BtLeStreamStartedStatus get_peer_stream_started(); 73 void source_metadata_changed(::rust::Vec<SourceMetadata> metadata); 74 void sink_metadata_changed(::rust::Vec<SinkMetadata> metadata); 75 76 private: 77 le_audio::LeAudioClientInterface* intf_; 78 }; 79 80 std::unique_ptr<LeAudioClientIntf> GetLeAudioClientProfile(const unsigned char* btif); 81 82 } // namespace rust 83 } // namespace topshim 84 } // namespace bluetooth 85