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

Commit a725e2ed authored by Jakub Tyszkowski's avatar Jakub Tyszkowski Committed by Łukasz Rymanowski
Browse files

LeAudio: Codec Config AIDL to stack format helpers

This adds the translation layer between the AIDL types and the
BT stack types.

This will be used by the stack in the upcoming patches.

Bug: 340400084
Test: atest --host bluetooth-test-audio-hal-aidl-leaudio-utils bluetooth-test-audio-hal-le-audio-software bluetooth_le_audio_test bluetooth_le_audio_client_test bluetooth_test_broadcaster bluetooth_test_broadcaster_state_machine bluetooth_le_audio_codec_manager_test
Flag: EXEMPT; This layer is for the codec-extensibility which is not yet used
Change-Id: I372dc45fd183a4044297dfb8b3ec5dc7897bc636
parent 7c062494
Loading
Loading
Loading
Loading
+50 −0
Original line number Diff line number Diff line
@@ -273,6 +273,56 @@ cc_defaults {
    ],
}

// Bluetooth Audio client interface library unit tests
cc_test {
    name: "bluetooth-test-audio-hal-aidl-leaudio-utils",
    host_supported: true,
    defaults: [
        "fluoride_defaults",
        "latest_android_hardware_audio_common_ndk_static",
        "latest_android_hardware_bluetooth_audio_ndk_static",
        "latest_android_media_audio_common_types_ndk_static",
    ],
    include_dirs: [
        "packages/modules/Bluetooth/system",
        "packages/modules/Bluetooth/system/bta/include",
        "packages/modules/Bluetooth/system/gd",
        "packages/modules/Bluetooth/system/stack/include",
    ],
    srcs: [
        "aidl/le_audio_utils.cc",
        "aidl/le_audio_utils_unittest.cc",
    ],
    shared_libs: [
        "libbase",
        "libbinder",
        "libbinder_ndk",
        "libfmq",
        "liblog",
        "libstatslog",
        "libutils",
        "server_configurable_flags",
    ],
    static_libs: [
        "android.hardware.common-V2-ndk",
        "android.hardware.common.fmq-V1-ndk",
        "bluetooth_flags_c_lib",
        "libbluetooth-types",
        "libbluetooth_log",
        "libbt-bta",
        "libbt-common",
        "libbt-platform-protos-lite",
        "libbt_shim_bridge",
        "libchrome",
        "libevent",
        "libgmock",
    ],
    cflags: [
        "-DBUILDCFG",
    ],
    header_libs: ["libbluetooth_headers"],
}

// Bluetooth Audio client interface library unit tests
cc_test {
    name: "bluetooth-test-audio-hal-le-audio-software",
+709 −0

File added.

Preview size limit exceeded, changes collapsed.

+107 −0
Original line number Diff line number Diff line
/*
 * Copyright 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 <hardware/audio.h>

#include <vector>

#include "audio_aidl_interfaces.h"
#include "bta/le_audio/broadcaster/broadcaster_types.h"
#include "bta/le_audio/codec_manager.h"
#include "bta/le_audio/le_audio_types.h"

namespace bluetooth {
namespace audio {
namespace aidl {

::aidl::android::hardware::bluetooth::audio::CodecId
GetAidlCodecIdFromStackFormat(
    const ::bluetooth::le_audio::types::LeAudioCodecId& codec_id);

::bluetooth::le_audio::types::LeAudioCodecId GetStackCodecIdFromAidlFormat(
    const ::aidl::android::hardware::bluetooth::audio::CodecId& codec_id);

std::optional<std::vector<
    std::optional<::aidl::android::hardware::bluetooth::audio::MetadataLtv>>>
GetAidlMetadataFromStackFormat(const std::vector<uint8_t>& vec);

bluetooth::le_audio::types::LeAudioLtvMap GetStackMetadataFromAidlFormat(
    const std::vector<std::optional<
        ::aidl::android::hardware::bluetooth::audio::MetadataLtv>>& source);

std::optional<std::vector<
    std::optional<::aidl::android::hardware::bluetooth::audio::
                      IBluetoothAudioProvider::LeAudioDeviceCapabilities>>>
GetAidlLeAudioDeviceCapabilitiesFromStackFormat(
    const std::optional<
        std::vector<::bluetooth::le_audio::types::acs_ac_record>>& pacs);

::aidl::android::hardware::bluetooth::audio::IBluetoothAudioProvider::
    LeAudioBroadcastConfigurationRequirement
    GetAidlLeAudioBroadcastConfigurationRequirementFromStackFormat(
        const std::vector<std::pair<
            ::bluetooth::le_audio::types::LeAudioContextType, uint8_t>>&
            subgroup_quality);

::aidl::android::hardware::bluetooth::audio::IBluetoothAudioProvider::
    LeAudioConfigurationRequirement
    GetAidlLeAudioUnicastConfigurationRequirementsFromStackFormat(
        ::bluetooth::le_audio::types::LeAudioContextType context_type,
        const std::optional<std::vector<
            ::bluetooth::le_audio::CodecManager::
                UnicastConfigurationRequirements::DeviceDirectionRequirements>>&
            sink_reqs,
        const std::optional<std::vector<
            ::bluetooth::le_audio::CodecManager::
                UnicastConfigurationRequirements::DeviceDirectionRequirements>>&
            source_reqs);
::bluetooth::le_audio::types::LeAudioLtvMap GetStackLeAudioLtvMapFromAidlFormat(
    const std::vector<::aidl::android::hardware::bluetooth::audio::
                          CodecSpecificConfigurationLtv>& aidl_config_ltvs);

::bluetooth::le_audio::broadcaster::BroadcastSubgroupBisCodecConfig
GetStackBisConfigFromAidlFormat(
    const ::aidl::android::hardware::bluetooth::audio::IBluetoothAudioProvider::
        LeAudioSubgroupBisConfiguration& aidl_cfg,
    ::bluetooth::le_audio::types::LeAudioCodecId& out_codec_id);

std::vector<::bluetooth::le_audio::broadcaster::BroadcastSubgroupCodecConfig>
GetStackSubgroupsFromAidlFormat(
    const std::vector<
        ::aidl::android::hardware::bluetooth::audio::IBluetoothAudioProvider::
            LeAudioBroadcastSubgroupConfiguration>& aidl_subgroups);

struct ::bluetooth::le_audio::types::DataPathConfiguration
GetStackDataPathFromAidlFormat(
    const ::aidl::android::hardware::bluetooth::audio::IBluetoothAudioProvider::
        LeAudioDataPathConfiguration& dp);

std::optional<::bluetooth::le_audio::broadcaster::BroadcastConfiguration>
GetStackBroadcastConfigurationFromAidlFormat(
    const ::aidl::android::hardware::bluetooth::audio::IBluetoothAudioProvider::
        LeAudioBroadcastConfigurationSetting& setting);

std::optional<::bluetooth::le_audio::set_configurations::AudioSetConfiguration>
GetStackUnicastConfigurationFromAidlFormat(
    ::bluetooth::le_audio::types::LeAudioContextType ctx_type,
    const ::aidl::android::hardware::bluetooth::audio::IBluetoothAudioProvider::
        LeAudioAseConfigurationSetting& config);

}  // namespace aidl
}  // namespace audio
}  // namespace bluetooth
+1202 −0

File added.

Preview size limit exceeded, changes collapsed.