Josh Wu | 6ab53e7 | 2021-12-29 23:53:33 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2022 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 | |
Josh Wu | 98d7e08 | 2022-01-21 03:04:21 -0800 | [diff] [blame] | 17 | #define LOG_TAG "BTAudioProviderLeAudioHW" |
Josh Wu | 6ab53e7 | 2021-12-29 23:53:33 -0800 | [diff] [blame] | 18 | |
| 19 | #include "LeAudioOffloadAudioProvider.h" |
| 20 | |
| 21 | #include <BluetoothAudioCodecs.h> |
| 22 | #include <BluetoothAudioSessionReport.h> |
| 23 | #include <android-base/logging.h> |
| 24 | |
| 25 | namespace aidl { |
| 26 | namespace android { |
| 27 | namespace hardware { |
| 28 | namespace bluetooth { |
| 29 | namespace audio { |
| 30 | |
| 31 | LeAudioOffloadOutputAudioProvider::LeAudioOffloadOutputAudioProvider() |
| 32 | : LeAudioOffloadAudioProvider() { |
| 33 | session_type_ = SessionType::LE_AUDIO_HARDWARE_OFFLOAD_ENCODING_DATAPATH; |
| 34 | } |
| 35 | |
| 36 | LeAudioOffloadInputAudioProvider::LeAudioOffloadInputAudioProvider() |
| 37 | : LeAudioOffloadAudioProvider() { |
| 38 | session_type_ = SessionType::LE_AUDIO_HARDWARE_OFFLOAD_DECODING_DATAPATH; |
| 39 | } |
| 40 | |
Alice Kuo | e80a576 | 2022-02-09 14:44:29 +0800 | [diff] [blame] | 41 | LeAudioOffloadBroadcastAudioProvider::LeAudioOffloadBroadcastAudioProvider() |
| 42 | : LeAudioOffloadAudioProvider() { |
| 43 | session_type_ = |
| 44 | SessionType::LE_AUDIO_BROADCAST_HARDWARE_OFFLOAD_ENCODING_DATAPATH; |
| 45 | } |
| 46 | |
Josh Wu | 6ab53e7 | 2021-12-29 23:53:33 -0800 | [diff] [blame] | 47 | LeAudioOffloadAudioProvider::LeAudioOffloadAudioProvider() |
| 48 | : BluetoothAudioProvider() {} |
| 49 | |
| 50 | bool LeAudioOffloadAudioProvider::isValid(const SessionType& sessionType) { |
| 51 | return (sessionType == session_type_); |
| 52 | } |
| 53 | |
| 54 | ndk::ScopedAStatus LeAudioOffloadAudioProvider::startSession( |
| 55 | const std::shared_ptr<IBluetoothAudioPort>& host_if, |
Chen Chen | c92270e | 2022-02-14 18:29:52 -0800 | [diff] [blame] | 56 | const AudioConfiguration& audio_config, |
Cheney Ni | 6ecbc76 | 2022-03-03 00:12:48 +0800 | [diff] [blame] | 57 | const std::vector<LatencyMode>& latency_modes, DataMQDesc* _aidl_return) { |
Alice Kuo | ee398a9 | 2022-07-10 23:59:18 +0800 | [diff] [blame] | 58 | if (session_type_ == |
| 59 | SessionType::LE_AUDIO_BROADCAST_HARDWARE_OFFLOAD_ENCODING_DATAPATH) { |
| 60 | if (audio_config.getTag() != AudioConfiguration::leAudioBroadcastConfig) { |
| 61 | LOG(WARNING) << __func__ << " - Invalid Audio Configuration=" |
| 62 | << audio_config.toString(); |
| 63 | *_aidl_return = DataMQDesc(); |
| 64 | return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT); |
| 65 | } |
| 66 | } else if (audio_config.getTag() != AudioConfiguration::leAudioConfig) { |
Josh Wu | 6ab53e7 | 2021-12-29 23:53:33 -0800 | [diff] [blame] | 67 | LOG(WARNING) << __func__ << " - Invalid Audio Configuration=" |
| 68 | << audio_config.toString(); |
| 69 | *_aidl_return = DataMQDesc(); |
| 70 | return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT); |
| 71 | } |
Josh Wu | 6ab53e7 | 2021-12-29 23:53:33 -0800 | [diff] [blame] | 72 | |
Bao Do | 6112bda | 2023-11-15 03:57:59 +0000 | [diff] [blame^] | 73 | return BluetoothAudioProvider::startSession(host_if, audio_config, |
| 74 | latency_modes, _aidl_return); |
Josh Wu | 6ab53e7 | 2021-12-29 23:53:33 -0800 | [diff] [blame] | 75 | } |
| 76 | |
| 77 | ndk::ScopedAStatus LeAudioOffloadAudioProvider::onSessionReady( |
| 78 | DataMQDesc* _aidl_return) { |
Cheney Ni | 6ecbc76 | 2022-03-03 00:12:48 +0800 | [diff] [blame] | 79 | BluetoothAudioSessionReport::OnSessionStarted( |
| 80 | session_type_, stack_iface_, nullptr, *audio_config_, latency_modes_); |
Josh Wu | 6ab53e7 | 2021-12-29 23:53:33 -0800 | [diff] [blame] | 81 | *_aidl_return = DataMQDesc(); |
| 82 | return ndk::ScopedAStatus::ok(); |
| 83 | } |
Bao Do | 6112bda | 2023-11-15 03:57:59 +0000 | [diff] [blame^] | 84 | ndk::ScopedAStatus LeAudioOffloadAudioProvider::setCodecPriority( |
| 85 | const CodecId& in_codecId, int32_t in_priority) { |
| 86 | codec_priority_map_[in_codecId] = in_priority; |
| 87 | return ndk::ScopedAStatus::ok(); |
| 88 | }; |
| 89 | |
| 90 | ndk::ScopedAStatus LeAudioOffloadAudioProvider::getLeAudioAseConfiguration( |
| 91 | const std::optional<std::vector< |
| 92 | std::optional<IBluetoothAudioProvider::LeAudioDeviceCapabilities>>>& |
| 93 | in_remoteSinkAudioCapabilities, |
| 94 | const std::optional<std::vector< |
| 95 | std::optional<IBluetoothAudioProvider::LeAudioDeviceCapabilities>>>& |
| 96 | in_remoteSourceAudioCapabilities, |
| 97 | const std::vector<IBluetoothAudioProvider::LeAudioConfigurationRequirement>& |
| 98 | in_requirements, |
| 99 | std::vector<IBluetoothAudioProvider::LeAudioAseConfigurationSetting>* |
| 100 | _aidl_return) { |
| 101 | /* TODO: Implement */ |
| 102 | (void)in_remoteSinkAudioCapabilities; |
| 103 | (void)in_remoteSourceAudioCapabilities; |
| 104 | (void)in_requirements; |
| 105 | (void)_aidl_return; |
| 106 | return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION); |
| 107 | }; |
| 108 | |
| 109 | ndk::ScopedAStatus LeAudioOffloadAudioProvider::getLeAudioAseQosConfiguration( |
| 110 | const IBluetoothAudioProvider::LeAudioAseQosConfigurationRequirement& |
| 111 | in_qosRequirement, |
| 112 | IBluetoothAudioProvider::LeAudioAseQosConfigurationPair* _aidl_return) { |
| 113 | /* TODO: Implement */ |
| 114 | (void)in_qosRequirement; |
| 115 | (void)_aidl_return; |
| 116 | return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION); |
| 117 | }; |
| 118 | |
| 119 | ndk::ScopedAStatus LeAudioOffloadAudioProvider::onSinkAseMetadataChanged( |
| 120 | IBluetoothAudioProvider::AseState in_state, |
| 121 | const std::optional<std::vector<std::optional<MetadataLtv>>>& in_metadata) { |
| 122 | (void)in_state; |
| 123 | (void)in_metadata; |
| 124 | return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION); |
| 125 | }; |
| 126 | |
| 127 | ndk::ScopedAStatus LeAudioOffloadAudioProvider::onSourceAseMetadataChanged( |
| 128 | IBluetoothAudioProvider::AseState in_state, |
| 129 | const std::optional<std::vector<std::optional<MetadataLtv>>>& in_metadata) { |
| 130 | (void)in_state; |
| 131 | (void)in_metadata; |
| 132 | return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION); |
| 133 | }; |
| 134 | |
| 135 | ndk::ScopedAStatus |
| 136 | LeAudioOffloadAudioProvider::getLeAudioBroadcastConfiguration( |
| 137 | const std::optional<std::vector< |
| 138 | std::optional<IBluetoothAudioProvider::LeAudioDeviceCapabilities>>>& |
| 139 | in_remoteSinkAudioCapabilities, |
| 140 | const IBluetoothAudioProvider::LeAudioBroadcastConfigurationRequirement& |
| 141 | in_requirement, |
| 142 | IBluetoothAudioProvider::LeAudioBroadcastConfigurationSetting* |
| 143 | _aidl_return) { |
| 144 | /* TODO: Implement */ |
| 145 | (void)in_remoteSinkAudioCapabilities; |
| 146 | (void)in_requirement; |
| 147 | (void)_aidl_return; |
| 148 | return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION); |
| 149 | }; |
Josh Wu | 6ab53e7 | 2021-12-29 23:53:33 -0800 | [diff] [blame] | 150 | |
| 151 | } // namespace audio |
| 152 | } // namespace bluetooth |
| 153 | } // namespace hardware |
| 154 | } // namespace android |
Cheney Ni | 6ecbc76 | 2022-03-03 00:12:48 +0800 | [diff] [blame] | 155 | } // namespace aidl |