Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 155fb1bd authored by Jeremy Wu's avatar Jeremy Wu
Browse files

Floss: implement le_audio_shim

This CL implements the topshim layer to bridge APIs between the native
stack and the Rust interface.

Bug: 317682584
Test: m Bluetooth
Flag: EXEMPT floss only changes
Change-Id: I3b1a122fe83b67282dbc7964dc472beb9899d29c
parent ba2e6728
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ cc_library_static {
        "gatt/gatt_ble_scanner_shim.cc",
        "gatt/gatt_shim.cc",
        "hfp/hfp_shim.cc",
        "le_audio/le_audio_shim.cc",
    ],
    generated_headers: [
        "BluetoothGeneratedDumpsysDataSchema_h",
@@ -87,6 +88,7 @@ gensrcs {
        "src/profiles/avrcp.rs",
        "src/profiles/gatt.rs",
        "src/profiles/hfp.rs",
        "src/profiles/le_audio.rs",
    ],
    output_extension: "rs.h",
    export_include_dirs: ["."],
@@ -103,6 +105,7 @@ gensrcs {
        "src/profiles/avrcp.rs",
        "src/profiles/gatt.rs",
        "src/profiles/hfp.rs",
        "src/profiles/le_audio.rs",
    ],
    output_extension: "cc",
    export_include_dirs: ["."],
+3 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ cxxbridge_header("btif_bridge_header") {
    "src/profiles/avrcp.rs",
    "src/profiles/gatt.rs",
    "src/profiles/hfp.rs",
    "src/profiles/le_audio.rs",
  ]
  all_dependent_configs = [ ":rust_topshim_config" ]
  deps = [ ":cxxlibheader" ]
@@ -43,6 +44,7 @@ cxxbridge_cc("btif_bridge_code") {
    "src/profiles/avrcp.rs",
    "src/profiles/gatt.rs",
    "src/profiles/hfp.rs",
    "src/profiles/le_audio.rs",
  ]
  deps = [
    ":btif_bridge_header",
@@ -64,6 +66,7 @@ source_set("btif_cxx_bridge_code") {
    "gatt/gatt_ble_scanner_shim.cc",
    "gatt/gatt_shim.cc",
    "hfp/hfp_shim.cc",
    "le_audio/le_audio_shim.cc",
    "metrics/metrics_shim.cc",
  ]

+564 −0

File added.

Preview size limit exceeded, changes collapsed.

+83 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#pragma once

#include <memory>

#include "audio_hal_interface/le_audio_software_host.h"
#include "include/hardware/bt_le_audio.h"
#include "rust/cxx.h"
#include "types/raw_address.h"

namespace bluetooth {
namespace topshim {
namespace rust {

struct BtLeAudioCodecConfig;
enum class BtLeAudioDirection : uint8_t;
struct BtLePcmConfig;
struct SourceMetadata;
struct SinkMetadata;

class LeAudioClientIntf {
 public:
  LeAudioClientIntf(le_audio::LeAudioClientInterface* intf) : intf_(intf){};

  void init(
      /*
LeAudioClientCallbacks* callbacks,
const std::vector<le_audio::btle_audio_codec_config_t>& offloading_preference
*/);
  void connect(RawAddress addr);
  void disconnect(RawAddress addr);
  void set_enable_state(RawAddress addr, bool enabled);
  void cleanup();
  void remove_device(RawAddress addr);
  void group_add_node(int group_id, RawAddress addr);
  void group_remove_node(int group_id, RawAddress addr);
  void group_set_active(int group_id);
  void set_codec_config_preference(
      int group_id,
      BtLeAudioCodecConfig input_codec_config,
      BtLeAudioCodecConfig output_codec_config);
  void set_ccid_information(int ccid, int context_type);
  void set_in_call(bool in_call);
  void send_audio_profile_preferences(
      int group_id, bool is_output_preference_le_audio, bool is_duplex_preference_le_audio);
  void set_unicast_monitor_mode(BtLeAudioDirection direction, bool enable);

  // interface for audio server
  bool host_start_audio_request();
  void host_stop_audio_request();
  bool peer_start_audio_request();
  void peer_stop_audio_request();
  BtLePcmConfig get_host_pcm_config();
  BtLePcmConfig get_peer_pcm_config();
  bool get_host_stream_started();
  bool get_peer_stream_started();
  void source_metadata_changed(::rust::Vec<SourceMetadata> metadata);
  void sink_metadata_changed(::rust::Vec<SinkMetadata> metadata);

 private:
  le_audio::LeAudioClientInterface* intf_;
};

std::unique_ptr<LeAudioClientIntf> GetLeAudioClientProfile(const unsigned char* btif);

}  // namespace rust
}  // namespace topshim
}  // namespace bluetooth
+703 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading