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

Commit 926fd43c authored by Grzegorz Kołodziejczyk's avatar Grzegorz Kołodziejczyk Committed by Łukasz Rymanowski
Browse files

leaudio: Add BAP and CSIP integration along with audio path

LE Audio implements PAC handling, device grouping into sets,
audio policy by the content type, group stream management,
broadcast etc.
Devices are always part of the group which creates sets.
Sets can be managed by the LeAudio system service which has an API to add/remove
specific devices to/from the group.

Any stream operations are done by the LeAudio system service
with a usage of the group_id.

Note, this group_id is not the same number as the CIG_ID however,
we might say it has the same meaning.

When devices are part of a coordinated set (CSIS), then LeAudio
implementation will discover all of them and notify upper layer about them.
Upper layers are to decide to bond CSIS devices. Native code will
group them.

Fluoride also integrates Android Audio 2.1 framework and once stream is
established then Le Audio session is opened and ready to receive
periodically (up to implementation) audio data from media server
(16bit, 16kHz/24kHz/32kHz/48kHz PCM - up to policy implementation) from
the audio system.

PCM frames are encoded by LC3 codec (system/bt/embdrv/lc3) and pushed over HCI to the
controller.

Bug: 150670922
Tag: #feature
Sponsor: jpawlowski@
Test: atest --host bluetooth_le_audio_test bluetooth_le_audio_client_test

Change-Id: I25d9422fb2b43843a59a9e398fac1e09c7e4869c
parent e9c4ba84
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ interface IBluetoothLeAudio {
    @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.BLUETOOTH_CONNECT)")
    int getConnectionPolicy(in BluetoothDevice device, in AttributionSource attributionSource);

    /* Same value as bluetooth::groups::kGroupUnknown */
    const int LE_AUDIO_GROUP_ID_INVALID = -1;

    const int GROUP_STATUS_INACTIVE = 0;
+117 −0
Original line number Diff line number Diff line
@@ -91,6 +91,12 @@ cc_library_static {
        "groups/groups.cc",
        "vc/device.cc",
        "vc/vc.cc",
        "le_audio/client.cc",
        "le_audio/devices.cc",
        "le_audio/state_machine.cc",
        "le_audio/client_parser.cc",
        "le_audio/client_audio.cc",
        "le_audio/le_audio_types.cc",
        "hearing_aid/hearing_aid.cc",
        "hearing_aid/hearing_aid_audio_source.cc",
        "hf_client/bta_hf_client_act.cc",
@@ -394,3 +400,114 @@ cc_test {
        cfi: false,
    },
}

// bta unit tests for LE Audio
// ========================================================
cc_test {
    name: "bluetooth_le_audio_test",
    test_suites: ["device-tests"],
    defaults: [
        "fluoride_defaults",
        "clang_coverage_bin",
    ],
    host_supported: true,
    include_dirs: [
        "packages/modules/Bluetooth/system",
        "packages/modules/Bluetooth/system/bta/include",
        "packages/modules/Bluetooth/system/bta/test/common",
        "packages/modules/Bluetooth/system/btif/include",
        "packages/modules/Bluetooth/system/gd",
        "packages/modules/Bluetooth/system/stack/include",
    ],
    srcs : [
        ":TestStubOsi",
        "test/common/bta_gatt_api_mock.cc",
        "test/common/bta_gatt_queue_mock.cc",
        "test/common/btm_api_mock.cc",
        "le_audio/client_audio.cc",
        "le_audio/client_audio_test.cc",
        "le_audio/client_parser.cc",
        "le_audio/client_parser_test.cc",
        "le_audio/devices.cc",
        "le_audio/devices_test.cc",
        "le_audio/le_audio_types.cc",
        "le_audio/le_audio_types_test.cc",
        "le_audio/mock_iso_manager.cc",
        "test/common/mock_controller.cc",
        "le_audio/state_machine.cc",
        "le_audio/state_machine_test.cc"
    ],
    shared_libs: [
        "libprotobuf-cpp-lite",
        "libcrypto",
        "liblog",  // __android_log_print
    ],
    static_libs : [
        "libgmock",
        "libbt-common",
        "libbt-protos-lite",
        "libosi",
    ],
    sanitize: {
        cfi: false,
    },
}

cc_test {
    name: "bluetooth_le_audio_client_test",
    test_suites: ["device-tests"],
    defaults: [
        "fluoride_bta_defaults",
        "clang_coverage_bin",
    ],
    host_supported: true,
    include_dirs: [
        "packages/modules/Bluetooth/system",
        "packages/modules/Bluetooth/system/bta/include",
        "packages/modules/Bluetooth/system/bta/test/common",
        "packages/modules/Bluetooth/system/stack/include",
    ],
    srcs : [
        "gatt/database.cc",
        "gatt/database_builder.cc",
        "le_audio/client.cc",
        "le_audio/client_parser.cc",
        "le_audio/devices.cc",
        "le_audio/le_audio_client_test.cc",
        "le_audio/le_audio_types.cc",
        "le_audio/mock_iso_manager.cc",
        "le_audio/mock_le_audio_client_audio.cc",
        "le_audio/mock_state_machine.cc",
        "test/common/btm_api_mock.cc",
        "test/common/bta_gatt_api_mock.cc",
        "test/common/bta_gatt_queue_mock.cc",
        "test/common/btif_storage_mock.cc",
        "test/common/mock_csis_client.cc",
        "test/common/mock_controller.cc",
        "test/common/mock_device_groups.cc",
    ],
    shared_libs: [
        "libprotobuf-cpp-lite",
        "libcrypto",
        "liblog",
    ],
    static_libs : [
        "crypto_toolbox_for_tests",
        "libgmock",
        "libbt-common",
        "libbt-protos-lite",
        "libosi",
        "liblc3codec",
    ],
    sanitize: {
        cfi: true,
        scs: true,
        address: true,
        all_undefined: true,
        integer_overflow: true,
        diag: {
            undefined : true
        },
    },
}
+1 −1
Original line number Diff line number Diff line
@@ -1144,7 +1144,7 @@ class CsisClientImpl : public CsisClient {
    if ((csis_group->GetDiscoveryState() !=
         CsisDiscoveryState::CSIS_DISCOVERY_IDLE)) {
      LOG(ERROR) << __func__
                 << " Incorrect ase group: " << loghex(csis_group->GetGroupId())
                 << " Incorrect ase group: " << csis_group->GetGroupId()
                 << " state "
                 << loghex(static_cast<int>(csis_group->GetDiscoveryState()));
      return;
+48 −0
Original line number Diff line number Diff line
/*
 * Copyright 2019 HIMSA II K/S - www.himsa.com. Represented by EHIMA -
 * www.ehima.com
 *
 * 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 <base/callback_forward.h>
#include <hardware/bt_le_audio.h>

/* Interface class */
class LeAudioClient {
 public:
  virtual ~LeAudioClient(void) = default;

  static void Initialize(bluetooth::le_audio::LeAudioClientCallbacks* callbacks,
                         base::Closure initCb,
                         base::Callback<bool()> hal_2_1_verifier);
  static void Cleanup(void);
  static LeAudioClient* Get(void);
  static void DebugDump(int fd);

  virtual void RemoveDevice(const RawAddress& address) = 0;
  virtual void Connect(const RawAddress& address) = 0;
  virtual void Disconnect(const RawAddress& address) = 0;
  virtual void GroupAddNode(const int group_id, const RawAddress& addr) = 0;
  virtual void GroupRemoveNode(const int group_id, const RawAddress& addr) = 0;
  virtual void GroupStream(const int group_id, const uint16_t content_type) = 0;
  virtual void GroupSuspend(const int group_id) = 0;
  virtual void GroupStop(const int group_id) = 0;
  virtual void GroupDestroy(const int group_id) = 0;
  virtual void GroupSetActive(const int group_id) = 0;
  virtual std::vector<RawAddress> GetGroupDevices(const int group_id) = 0;
  static void AddFromStorage(const RawAddress& addr, bool autoconnect);
  static bool IsLeAudioClientRunning();
};
+2839 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading