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(int group_id, BtLeAudioCodecConfig input_codec_config, 55 BtLeAudioCodecConfig output_codec_config); 56 void set_ccid_information(int ccid, int context_type); 57 void set_in_call(bool in_call); 58 void send_audio_profile_preferences(int group_id, bool is_output_preference_le_audio, 59 bool is_duplex_preference_le_audio); 60 void set_unicast_monitor_mode(BtLeAudioDirection direction, bool enable); 61 62 // interface for audio server 63 bool host_start_audio_request(); 64 void host_stop_audio_request(); 65 bool peer_start_audio_request(); 66 void peer_stop_audio_request(); 67 BtLePcmConfig get_host_pcm_config(); 68 BtLePcmConfig get_peer_pcm_config(); 69 BtLeStreamStartedStatus get_host_stream_started(); 70 BtLeStreamStartedStatus get_peer_stream_started(); 71 void source_metadata_changed(::rust::Vec<SourceMetadata> metadata); 72 void sink_metadata_changed(::rust::Vec<SinkMetadata> metadata); 73 74 private: 75 le_audio::LeAudioClientInterface* intf_; 76 }; 77 78 std::unique_ptr<LeAudioClientIntf> GetLeAudioClientProfile(const unsigned char* btif); 79 80 } // namespace rust 81 } // namespace topshim 82 } // namespace bluetooth 83