| Patty | 5c05c2f | 2021-11-04 21:03:32 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2021 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 | package android.bluetooth; |
| 18 | |
| Sagar Verma | cda6dbf | 2024-01-19 11:32:47 +0530 | [diff] [blame] | 19 | import android.annotation.FlaggedApi; |
| Patty | 5c05c2f | 2021-11-04 21:03:32 +0800 | [diff] [blame] | 20 | import android.annotation.IntDef; |
| 21 | import android.annotation.NonNull; |
| Anton Hansson | fa927a5 | 2023-11-09 09:08:19 +0000 | [diff] [blame] | 22 | import android.annotation.Nullable; |
| Patty | d8c4927 | 2022-01-19 16:26:00 +0800 | [diff] [blame] | 23 | import android.os.Parcel; |
| 24 | import android.os.Parcelable; |
| Patty | 5c05c2f | 2021-11-04 21:03:32 +0800 | [diff] [blame] | 25 | |
| Sagar Verma | cda6dbf | 2024-01-19 11:32:47 +0530 | [diff] [blame] | 26 | import com.android.bluetooth.flags.Flags; |
| 27 | |
| Patty | 5c05c2f | 2021-11-04 21:03:32 +0800 | [diff] [blame] | 28 | import java.lang.annotation.Retention; |
| 29 | import java.lang.annotation.RetentionPolicy; |
| Patty | 5aa4bd2 | 2022-01-25 19:58:37 +0800 | [diff] [blame] | 30 | import java.util.Objects; |
| Patty | 5c05c2f | 2021-11-04 21:03:32 +0800 | [diff] [blame] | 31 | |
| 32 | /** |
| 33 | * Represents the codec configuration for a Bluetooth LE Audio source device. |
| Patty | 5c05c2f | 2021-11-04 21:03:32 +0800 | [diff] [blame] | 34 | * |
| David Duarte | ee52b7e | 2023-12-02 01:32:11 +0000 | [diff] [blame] | 35 | * <p>Contains the source codec type. |
| 36 | * |
| 37 | * <p>The source codec type values are the same as those supported by the device hardware. |
| 38 | * |
| David Duarte | 5a02bb4 | 2023-12-04 23:07:42 +0000 | [diff] [blame] | 39 | * @see BluetoothLeAudioCodecConfig |
| Patty | 5c05c2f | 2021-11-04 21:03:32 +0800 | [diff] [blame] | 40 | */ |
| Patty | d8c4927 | 2022-01-19 16:26:00 +0800 | [diff] [blame] | 41 | public final class BluetoothLeAudioCodecConfig implements Parcelable { |
| Patty | 5c05c2f | 2021-11-04 21:03:32 +0800 | [diff] [blame] | 42 | // Add an entry for each source codec here. |
| 43 | |
| 44 | /** @hide */ |
| David Duarte | ee52b7e | 2023-12-02 01:32:11 +0000 | [diff] [blame] | 45 | @IntDef( |
| 46 | prefix = "SOURCE_CODEC_TYPE_", |
| Jakub Tyszkowski | 676bd92 | 2025-04-10 11:02:14 +0000 | [diff] [blame^] | 47 | value = { |
| 48 | SOURCE_CODEC_TYPE_LC3, |
| 49 | SOURCE_CODEC_TYPE_OPUS, |
| 50 | SOURCE_CODEC_TYPE_OPUS_HI_RES, |
| 51 | SOURCE_CODEC_TYPE_INVALID |
| 52 | }) |
| Patty | 5c05c2f | 2021-11-04 21:03:32 +0800 | [diff] [blame] | 53 | @Retention(RetentionPolicy.SOURCE) |
| 54 | public @interface SourceCodecType {}; |
| 55 | |
| 56 | public static final int SOURCE_CODEC_TYPE_LC3 = 0; |
| Łukasz Rymanowski | 61e1188 | 2024-11-20 14:13:27 +0000 | [diff] [blame] | 57 | |
| 58 | @FlaggedApi(Flags.FLAG_LEAUDIO_ADD_OPUS_CODEC_TYPE) |
| 59 | public static final int SOURCE_CODEC_TYPE_OPUS = 1; |
| 60 | |
| Jakub Tyszkowski | 676bd92 | 2025-04-10 11:02:14 +0000 | [diff] [blame^] | 61 | /** @hide */ |
| 62 | public static final int SOURCE_CODEC_TYPE_OPUS_HI_RES = 2; |
| 63 | |
| Patty | 5c05c2f | 2021-11-04 21:03:32 +0800 | [diff] [blame] | 64 | public static final int SOURCE_CODEC_TYPE_INVALID = 1000 * 1000; |
| 65 | |
| Patty | d8c4927 | 2022-01-19 16:26:00 +0800 | [diff] [blame] | 66 | /** @hide */ |
| David Duarte | ee52b7e | 2023-12-02 01:32:11 +0000 | [diff] [blame] | 67 | @IntDef( |
| 68 | prefix = "CODEC_PRIORITY_", |
| Patty | d8c4927 | 2022-01-19 16:26:00 +0800 | [diff] [blame] | 69 | value = {CODEC_PRIORITY_DISABLED, CODEC_PRIORITY_DEFAULT, CODEC_PRIORITY_HIGHEST}) |
| 70 | @Retention(RetentionPolicy.SOURCE) |
| 71 | public @interface CodecPriority {} |
| 72 | |
| 73 | /** |
| David Duarte | ee52b7e | 2023-12-02 01:32:11 +0000 | [diff] [blame] | 74 | * Codec priority disabled. Used to indicate that this codec is disabled and should not be used. |
| Patty | d8c4927 | 2022-01-19 16:26:00 +0800 | [diff] [blame] | 75 | */ |
| 76 | public static final int CODEC_PRIORITY_DISABLED = -1; |
| 77 | |
| David Duarte | ee52b7e | 2023-12-02 01:32:11 +0000 | [diff] [blame] | 78 | /** Codec priority default. Default value used for codec priority. */ |
| Patty | d8c4927 | 2022-01-19 16:26:00 +0800 | [diff] [blame] | 79 | public static final int CODEC_PRIORITY_DEFAULT = 0; |
| 80 | |
| David Duarte | ee52b7e | 2023-12-02 01:32:11 +0000 | [diff] [blame] | 81 | /** Codec priority highest. Used to indicate the highest priority a codec can have. */ |
| Patty | d8c4927 | 2022-01-19 16:26:00 +0800 | [diff] [blame] | 82 | public static final int CODEC_PRIORITY_HIGHEST = 1000 * 1000; |
| 83 | |
| 84 | /** @hide */ |
| David Duarte | ee52b7e | 2023-12-02 01:32:11 +0000 | [diff] [blame] | 85 | @IntDef( |
| 86 | flag = true, |
| 87 | prefix = "SAMPLE_RATE_", |
| 88 | value = { |
| 89 | SAMPLE_RATE_NONE, |
| 90 | SAMPLE_RATE_8000, |
| Sagar Verma | cda6dbf | 2024-01-19 11:32:47 +0530 | [diff] [blame] | 91 | SAMPLE_RATE_11025, |
| David Duarte | ee52b7e | 2023-12-02 01:32:11 +0000 | [diff] [blame] | 92 | SAMPLE_RATE_16000, |
| Sagar Verma | cda6dbf | 2024-01-19 11:32:47 +0530 | [diff] [blame] | 93 | SAMPLE_RATE_22050, |
| David Duarte | ee52b7e | 2023-12-02 01:32:11 +0000 | [diff] [blame] | 94 | SAMPLE_RATE_24000, |
| 95 | SAMPLE_RATE_32000, |
| 96 | SAMPLE_RATE_44100, |
| Sagar Verma | cda6dbf | 2024-01-19 11:32:47 +0530 | [diff] [blame] | 97 | SAMPLE_RATE_48000, |
| 98 | SAMPLE_RATE_88200, |
| 99 | SAMPLE_RATE_96000, |
| 100 | SAMPLE_RATE_176400, |
| 101 | SAMPLE_RATE_192000, |
| 102 | SAMPLE_RATE_384000 |
| David Duarte | ee52b7e | 2023-12-02 01:32:11 +0000 | [diff] [blame] | 103 | }) |
| Patty | d8c4927 | 2022-01-19 16:26:00 +0800 | [diff] [blame] | 104 | @Retention(RetentionPolicy.SOURCE) |
| 105 | public @interface SampleRate {} |
| 106 | |
| 107 | /** |
| David Duarte | ee52b7e | 2023-12-02 01:32:11 +0000 | [diff] [blame] | 108 | * Codec sample rate 0 Hz. Default value used for codec sample rate. Values are the bit mask as |
| 109 | * defined in the Bluetooth Assigned Numbers, Generic Audio, Supported_Sampling_Frequencies |
| Sagar Verma | cda6dbf | 2024-01-19 11:32:47 +0530 | [diff] [blame] | 110 | * table. |
| Patty | d8c4927 | 2022-01-19 16:26:00 +0800 | [diff] [blame] | 111 | */ |
| 112 | public static final int SAMPLE_RATE_NONE = 0; |
| 113 | |
| David Duarte | ee52b7e | 2023-12-02 01:32:11 +0000 | [diff] [blame] | 114 | /** Codec sample rate 8000 Hz. */ |
| Łukasz Rymanowski | 3c97945 | 2022-03-10 10:28:12 +0000 | [diff] [blame] | 115 | public static final int SAMPLE_RATE_8000 = 0x01 << 0; |
| Patty | d8c4927 | 2022-01-19 16:26:00 +0800 | [diff] [blame] | 116 | |
| Sagar Verma | cda6dbf | 2024-01-19 11:32:47 +0530 | [diff] [blame] | 117 | /** Codec sample rate 11025 Hz. */ |
| Sagar Verma | cda6dbf | 2024-01-19 11:32:47 +0530 | [diff] [blame] | 118 | public static final int SAMPLE_RATE_11025 = 0x01 << 1; |
| 119 | |
| David Duarte | ee52b7e | 2023-12-02 01:32:11 +0000 | [diff] [blame] | 120 | /** Codec sample rate 16000 Hz. */ |
| Łukasz Rymanowski | 3c97945 | 2022-03-10 10:28:12 +0000 | [diff] [blame] | 121 | public static final int SAMPLE_RATE_16000 = 0x01 << 2; |
| Patty | d8c4927 | 2022-01-19 16:26:00 +0800 | [diff] [blame] | 122 | |
| Sagar Verma | cda6dbf | 2024-01-19 11:32:47 +0530 | [diff] [blame] | 123 | /** Codec sample rate 22050 Hz. */ |
| Sagar Verma | cda6dbf | 2024-01-19 11:32:47 +0530 | [diff] [blame] | 124 | public static final int SAMPLE_RATE_22050 = 0x01 << 3; |
| 125 | |
| David Duarte | ee52b7e | 2023-12-02 01:32:11 +0000 | [diff] [blame] | 126 | /** Codec sample rate 24000 Hz. */ |
| Łukasz Rymanowski | 3c97945 | 2022-03-10 10:28:12 +0000 | [diff] [blame] | 127 | public static final int SAMPLE_RATE_24000 = 0x01 << 4; |
| Patty | d8c4927 | 2022-01-19 16:26:00 +0800 | [diff] [blame] | 128 | |
| David Duarte | ee52b7e | 2023-12-02 01:32:11 +0000 | [diff] [blame] | 129 | /** Codec sample rate 32000 Hz. */ |
| Łukasz Rymanowski | 3c97945 | 2022-03-10 10:28:12 +0000 | [diff] [blame] | 130 | public static final int SAMPLE_RATE_32000 = 0x01 << 5; |
| Patty | d8c4927 | 2022-01-19 16:26:00 +0800 | [diff] [blame] | 131 | |
| David Duarte | ee52b7e | 2023-12-02 01:32:11 +0000 | [diff] [blame] | 132 | /** Codec sample rate 44100 Hz. */ |
| Łukasz Rymanowski | 3c97945 | 2022-03-10 10:28:12 +0000 | [diff] [blame] | 133 | public static final int SAMPLE_RATE_44100 = 0x01 << 6; |
| Patty | d8c4927 | 2022-01-19 16:26:00 +0800 | [diff] [blame] | 134 | |
| David Duarte | ee52b7e | 2023-12-02 01:32:11 +0000 | [diff] [blame] | 135 | /** Codec sample rate 48000 Hz. */ |
| Łukasz Rymanowski | 3c97945 | 2022-03-10 10:28:12 +0000 | [diff] [blame] | 136 | public static final int SAMPLE_RATE_48000 = 0x01 << 7; |
| Patty | d8c4927 | 2022-01-19 16:26:00 +0800 | [diff] [blame] | 137 | |
| Sagar Verma | cda6dbf | 2024-01-19 11:32:47 +0530 | [diff] [blame] | 138 | /** Codec sample rate 88200 Hz. */ |
| Sagar Verma | cda6dbf | 2024-01-19 11:32:47 +0530 | [diff] [blame] | 139 | public static final int SAMPLE_RATE_88200 = 0x01 << 8; |
| 140 | |
| 141 | /** Codec sample rate 96000 Hz. */ |
| Sagar Verma | cda6dbf | 2024-01-19 11:32:47 +0530 | [diff] [blame] | 142 | public static final int SAMPLE_RATE_96000 = 0x01 << 9; |
| 143 | |
| 144 | /** Codec sample rate 176400 Hz. */ |
| Sagar Verma | cda6dbf | 2024-01-19 11:32:47 +0530 | [diff] [blame] | 145 | public static final int SAMPLE_RATE_176400 = 0x01 << 10; |
| 146 | |
| 147 | /** Codec sample rate 192000 Hz. */ |
| Sagar Verma | cda6dbf | 2024-01-19 11:32:47 +0530 | [diff] [blame] | 148 | public static final int SAMPLE_RATE_192000 = 0x01 << 11; |
| 149 | |
| 150 | /** Codec sample rate 384000 Hz. */ |
| Sagar Verma | cda6dbf | 2024-01-19 11:32:47 +0530 | [diff] [blame] | 151 | public static final int SAMPLE_RATE_384000 = 0x01 << 12; |
| 152 | |
| Patty | d8c4927 | 2022-01-19 16:26:00 +0800 | [diff] [blame] | 153 | /** @hide */ |
| David Duarte | ee52b7e | 2023-12-02 01:32:11 +0000 | [diff] [blame] | 154 | @IntDef( |
| 155 | flag = true, |
| 156 | prefix = "BITS_PER_SAMPLE_", |
| 157 | value = { |
| 158 | BITS_PER_SAMPLE_NONE, |
| 159 | BITS_PER_SAMPLE_16, |
| 160 | BITS_PER_SAMPLE_24, |
| 161 | BITS_PER_SAMPLE_32 |
| 162 | }) |
| Patty | d8c4927 | 2022-01-19 16:26:00 +0800 | [diff] [blame] | 163 | @Retention(RetentionPolicy.SOURCE) |
| 164 | public @interface BitsPerSample {} |
| 165 | |
| David Duarte | ee52b7e | 2023-12-02 01:32:11 +0000 | [diff] [blame] | 166 | /** Codec bits per sample 0. Default value of the codec bits per sample. */ |
| Patty | d8c4927 | 2022-01-19 16:26:00 +0800 | [diff] [blame] | 167 | public static final int BITS_PER_SAMPLE_NONE = 0; |
| 168 | |
| David Duarte | ee52b7e | 2023-12-02 01:32:11 +0000 | [diff] [blame] | 169 | /** Codec bits per sample 16. */ |
| Łukasz Rymanowski | 3c97945 | 2022-03-10 10:28:12 +0000 | [diff] [blame] | 170 | public static final int BITS_PER_SAMPLE_16 = 0x01 << 0; |
| Patty | d8c4927 | 2022-01-19 16:26:00 +0800 | [diff] [blame] | 171 | |
| David Duarte | ee52b7e | 2023-12-02 01:32:11 +0000 | [diff] [blame] | 172 | /** Codec bits per sample 24. */ |
| Łukasz Rymanowski | 3c97945 | 2022-03-10 10:28:12 +0000 | [diff] [blame] | 173 | public static final int BITS_PER_SAMPLE_24 = 0x01 << 1; |
| Patty | d8c4927 | 2022-01-19 16:26:00 +0800 | [diff] [blame] | 174 | |
| David Duarte | ee52b7e | 2023-12-02 01:32:11 +0000 | [diff] [blame] | 175 | /** Codec bits per sample 32. */ |
| Łukasz Rymanowski | 3c97945 | 2022-03-10 10:28:12 +0000 | [diff] [blame] | 176 | public static final int BITS_PER_SAMPLE_32 = 0x01 << 3; |
| Patty | d8c4927 | 2022-01-19 16:26:00 +0800 | [diff] [blame] | 177 | |
| Łukasz Rymanowski | 3c97945 | 2022-03-10 10:28:12 +0000 | [diff] [blame] | 178 | /** |
| David Duarte | ee52b7e | 2023-12-02 01:32:11 +0000 | [diff] [blame] | 179 | * Values are the bit mask as defined in the Bluetooth Assigned Numbers, Generic Audio, |
| 180 | * Supported_Audio_Channel_Counts table Note: We use only part of it. |
| 181 | * |
| 182 | * @hide |
| 183 | */ |
| 184 | @IntDef( |
| 185 | flag = true, |
| 186 | prefix = "CHANNEL_COUNT_", |
| Łukasz Rymanowski | 3c97945 | 2022-03-10 10:28:12 +0000 | [diff] [blame] | 187 | value = {CHANNEL_COUNT_NONE, CHANNEL_COUNT_1, CHANNEL_COUNT_2}) |
| Patty | d8c4927 | 2022-01-19 16:26:00 +0800 | [diff] [blame] | 188 | @Retention(RetentionPolicy.SOURCE) |
| Łukasz Rymanowski | 3c97945 | 2022-03-10 10:28:12 +0000 | [diff] [blame] | 189 | public @interface ChannelCount {} |
| Patty | d8c4927 | 2022-01-19 16:26:00 +0800 | [diff] [blame] | 190 | |
| David Duarte | ee52b7e | 2023-12-02 01:32:11 +0000 | [diff] [blame] | 191 | /** Codec channel mode NONE. Default value of the codec channel mode. */ |
| Łukasz Rymanowski | 3c97945 | 2022-03-10 10:28:12 +0000 | [diff] [blame] | 192 | public static final int CHANNEL_COUNT_NONE = 0; |
| Patty | d8c4927 | 2022-01-19 16:26:00 +0800 | [diff] [blame] | 193 | |
| David Duarte | ee52b7e | 2023-12-02 01:32:11 +0000 | [diff] [blame] | 194 | /** Codec channel mode MONO. */ |
| Łukasz Rymanowski | 3c97945 | 2022-03-10 10:28:12 +0000 | [diff] [blame] | 195 | public static final int CHANNEL_COUNT_1 = 0x01 << 0; |
| Patty | d8c4927 | 2022-01-19 16:26:00 +0800 | [diff] [blame] | 196 | |
| David Duarte | ee52b7e | 2023-12-02 01:32:11 +0000 | [diff] [blame] | 197 | /** Codec channel mode STEREO. */ |
| Łukasz Rymanowski | 3c97945 | 2022-03-10 10:28:12 +0000 | [diff] [blame] | 198 | public static final int CHANNEL_COUNT_2 = 0x01 << 1; |
| Patty | d8c4927 | 2022-01-19 16:26:00 +0800 | [diff] [blame] | 199 | |
| Łukasz Rymanowski | 3c97945 | 2022-03-10 10:28:12 +0000 | [diff] [blame] | 200 | /** |
| David Duarte | ee52b7e | 2023-12-02 01:32:11 +0000 | [diff] [blame] | 201 | * Values are the bit mask as defined in the Bluetooth Assigned Numbers, Generic Audio, |
| Łukasz Rymanowski | 3c97945 | 2022-03-10 10:28:12 +0000 | [diff] [blame] | 202 | * Supported_Frame_Durations table |
| 203 | * |
| David Duarte | ee52b7e | 2023-12-02 01:32:11 +0000 | [diff] [blame] | 204 | * @hide |
| 205 | */ |
| 206 | @IntDef( |
| 207 | flag = true, |
| 208 | prefix = "FRAME_DURATION_", |
| Patty | d8c4927 | 2022-01-19 16:26:00 +0800 | [diff] [blame] | 209 | value = {FRAME_DURATION_NONE, FRAME_DURATION_7500, FRAME_DURATION_10000}) |
| 210 | @Retention(RetentionPolicy.SOURCE) |
| 211 | public @interface FrameDuration {} |
| 212 | |
| David Duarte | ee52b7e | 2023-12-02 01:32:11 +0000 | [diff] [blame] | 213 | /** Frame duration 0. Default value of the frame duration. */ |
| Patty | d8c4927 | 2022-01-19 16:26:00 +0800 | [diff] [blame] | 214 | public static final int FRAME_DURATION_NONE = 0; |
| 215 | |
| David Duarte | ee52b7e | 2023-12-02 01:32:11 +0000 | [diff] [blame] | 216 | /** Frame duration 7500 us. */ |
| Łukasz Rymanowski | 3c97945 | 2022-03-10 10:28:12 +0000 | [diff] [blame] | 217 | public static final int FRAME_DURATION_7500 = 0x01 << 0; |
| Patty | d8c4927 | 2022-01-19 16:26:00 +0800 | [diff] [blame] | 218 | |
| David Duarte | ee52b7e | 2023-12-02 01:32:11 +0000 | [diff] [blame] | 219 | /** Frame duration 10000 us. */ |
| Łukasz Rymanowski | 3c97945 | 2022-03-10 10:28:12 +0000 | [diff] [blame] | 220 | public static final int FRAME_DURATION_10000 = 0x01 << 1; |
| Patty | d8c4927 | 2022-01-19 16:26:00 +0800 | [diff] [blame] | 221 | |
| Patty | 5c05c2f | 2021-11-04 21:03:32 +0800 | [diff] [blame] | 222 | private final @SourceCodecType int mCodecType; |
| Patty | d8c4927 | 2022-01-19 16:26:00 +0800 | [diff] [blame] | 223 | private final @CodecPriority int mCodecPriority; |
| 224 | private final @SampleRate int mSampleRate; |
| 225 | private final @BitsPerSample int mBitsPerSample; |
| Łukasz Rymanowski | 3c97945 | 2022-03-10 10:28:12 +0000 | [diff] [blame] | 226 | private final @ChannelCount int mChannelCount; |
| Patty | d8c4927 | 2022-01-19 16:26:00 +0800 | [diff] [blame] | 227 | private final @FrameDuration int mFrameDuration; |
| 228 | private final int mOctetsPerFrame; |
| Łukasz Rymanowski | 3c97945 | 2022-03-10 10:28:12 +0000 | [diff] [blame] | 229 | private final int mMinOctetsPerFrame; |
| 230 | private final int mMaxOctetsPerFrame; |
| 231 | |
| Patty | 5c05c2f | 2021-11-04 21:03:32 +0800 | [diff] [blame] | 232 | /** |
| 233 | * Creates a new BluetoothLeAudioCodecConfig. |
| 234 | * |
| 235 | * @param codecType the source codec type |
| Patty | d8c4927 | 2022-01-19 16:26:00 +0800 | [diff] [blame] | 236 | * @param codecPriority the priority of this codec |
| 237 | * @param sampleRate the codec sample rate |
| 238 | * @param bitsPerSample the bits per sample of this codec |
| Łukasz Rymanowski | 3c97945 | 2022-03-10 10:28:12 +0000 | [diff] [blame] | 239 | * @param channelCount the channel count of this codec |
| Patty | d8c4927 | 2022-01-19 16:26:00 +0800 | [diff] [blame] | 240 | * @param frameDuration the frame duration of this codec |
| 241 | * @param octetsPerFrame the octets per frame of this codec |
| Łukasz Rymanowski | 3c97945 | 2022-03-10 10:28:12 +0000 | [diff] [blame] | 242 | * @param minOctetsPerFrame the minimum octets per frame of this codec |
| 243 | * @param maxOctetsPerFrame the maximum octets per frame of this codec |
| Patty | 5c05c2f | 2021-11-04 21:03:32 +0800 | [diff] [blame] | 244 | */ |
| David Duarte | ee52b7e | 2023-12-02 01:32:11 +0000 | [diff] [blame] | 245 | private BluetoothLeAudioCodecConfig( |
| 246 | @SourceCodecType int codecType, |
| 247 | @CodecPriority int codecPriority, |
| 248 | @SampleRate int sampleRate, |
| 249 | @BitsPerSample int bitsPerSample, |
| 250 | @ChannelCount int channelCount, |
| 251 | @FrameDuration int frameDuration, |
| 252 | int octetsPerFrame, |
| 253 | int minOctetsPerFrame, |
| 254 | int maxOctetsPerFrame) { |
| Patty | 5c05c2f | 2021-11-04 21:03:32 +0800 | [diff] [blame] | 255 | mCodecType = codecType; |
| Patty | d8c4927 | 2022-01-19 16:26:00 +0800 | [diff] [blame] | 256 | mCodecPriority = codecPriority; |
| 257 | mSampleRate = sampleRate; |
| 258 | mBitsPerSample = bitsPerSample; |
| Łukasz Rymanowski | 3c97945 | 2022-03-10 10:28:12 +0000 | [diff] [blame] | 259 | mChannelCount = channelCount; |
| Patty | d8c4927 | 2022-01-19 16:26:00 +0800 | [diff] [blame] | 260 | mFrameDuration = frameDuration; |
| 261 | mOctetsPerFrame = octetsPerFrame; |
| Łukasz Rymanowski | 3c97945 | 2022-03-10 10:28:12 +0000 | [diff] [blame] | 262 | mMinOctetsPerFrame = minOctetsPerFrame; |
| 263 | mMaxOctetsPerFrame = maxOctetsPerFrame; |
| Patty | d8c4927 | 2022-01-19 16:26:00 +0800 | [diff] [blame] | 264 | } |
| 265 | |
| 266 | @Override |
| 267 | public int describeContents() { |
| 268 | return 0; |
| 269 | } |
| 270 | |
| David Duarte | ee52b7e | 2023-12-02 01:32:11 +0000 | [diff] [blame] | 271 | /** {@link Parcelable.Creator} interface implementation. */ |
| Ömer Faruk Yılmaz | 9d13b8f | 2025-04-10 05:01:39 +0000 | [diff] [blame] | 272 | public static final @NonNull Parcelable.Creator<BluetoothLeAudioCodecConfig> CREATOR = |
| 273 | new Parcelable.Creator<BluetoothLeAudioCodecConfig>() { |
| 274 | public BluetoothLeAudioCodecConfig createFromParcel(Parcel in) { |
| 275 | int codecType = in.readInt(); |
| 276 | int codecPriority = in.readInt(); |
| 277 | int sampleRate = in.readInt(); |
| 278 | int bitsPerSample = in.readInt(); |
| 279 | int channelCount = in.readInt(); |
| 280 | int frameDuration = in.readInt(); |
| 281 | int octetsPerFrame = in.readInt(); |
| 282 | int minOctetsPerFrame = in.readInt(); |
| 283 | int maxOctetsPerFrame = in.readInt(); |
| 284 | return new BluetoothLeAudioCodecConfig( |
| 285 | codecType, |
| 286 | codecPriority, |
| 287 | sampleRate, |
| 288 | bitsPerSample, |
| 289 | channelCount, |
| 290 | frameDuration, |
| 291 | octetsPerFrame, |
| 292 | minOctetsPerFrame, |
| 293 | maxOctetsPerFrame); |
| 294 | } |
| Patty | d8c4927 | 2022-01-19 16:26:00 +0800 | [diff] [blame] | 295 | |
| Ömer Faruk Yılmaz | 9d13b8f | 2025-04-10 05:01:39 +0000 | [diff] [blame] | 296 | public BluetoothLeAudioCodecConfig[] newArray(int size) { |
| 297 | return new BluetoothLeAudioCodecConfig[size]; |
| 298 | } |
| 299 | }; |
| Patty | d8c4927 | 2022-01-19 16:26:00 +0800 | [diff] [blame] | 300 | |
| 301 | @Override |
| 302 | public void writeToParcel(@NonNull Parcel out, int flags) { |
| 303 | out.writeInt(mCodecType); |
| 304 | out.writeInt(mCodecPriority); |
| 305 | out.writeInt(mSampleRate); |
| 306 | out.writeInt(mBitsPerSample); |
| Łukasz Rymanowski | 3c97945 | 2022-03-10 10:28:12 +0000 | [diff] [blame] | 307 | out.writeInt(mChannelCount); |
| Patty | d8c4927 | 2022-01-19 16:26:00 +0800 | [diff] [blame] | 308 | out.writeInt(mFrameDuration); |
| 309 | out.writeInt(mOctetsPerFrame); |
| Łukasz Rymanowski | 3c97945 | 2022-03-10 10:28:12 +0000 | [diff] [blame] | 310 | out.writeInt(mMinOctetsPerFrame); |
| 311 | out.writeInt(mMaxOctetsPerFrame); |
| Patty | 5c05c2f | 2021-11-04 21:03:32 +0800 | [diff] [blame] | 312 | } |
| 313 | |
| William Escande | 0f45ca0 | 2025-02-20 18:21:32 -0800 | [diff] [blame] | 314 | private static String sampleRateToString(@SampleRate int sampleRateBit) { |
| Łukasz Rymanowski | 4b6c0d0 | 2024-04-22 15:02:02 +0000 | [diff] [blame] | 315 | switch (sampleRateBit) { |
| 316 | case SAMPLE_RATE_NONE: |
| 317 | return "None"; |
| 318 | case SAMPLE_RATE_8000: |
| 319 | return "8 kHz"; |
| 320 | case SAMPLE_RATE_11025: |
| 321 | return "11.025 kHz"; |
| 322 | case SAMPLE_RATE_16000: |
| 323 | return "16 kHz"; |
| 324 | case SAMPLE_RATE_22050: |
| 325 | return "22.05 kHz"; |
| 326 | case SAMPLE_RATE_24000: |
| 327 | return "24 kHz"; |
| 328 | case SAMPLE_RATE_32000: |
| 329 | return "32 kHz"; |
| 330 | case SAMPLE_RATE_44100: |
| 331 | return "44.1 kHz"; |
| 332 | case SAMPLE_RATE_48000: |
| 333 | return "48 kHz"; |
| 334 | case SAMPLE_RATE_88200: |
| 335 | return "88.2 kHz"; |
| 336 | case SAMPLE_RATE_96000: |
| 337 | return "96 kHz"; |
| 338 | case SAMPLE_RATE_176400: |
| 339 | return "176.4 kHz"; |
| 340 | case SAMPLE_RATE_192000: |
| 341 | return "192 kHz"; |
| 342 | case SAMPLE_RATE_384000: |
| 343 | return "384 kHz"; |
| 344 | default: |
| 345 | return "Unknown bit " + sampleRateBit; |
| 346 | } |
| 347 | } |
| 348 | |
| William Escande | 0f45ca0 | 2025-02-20 18:21:32 -0800 | [diff] [blame] | 349 | private static String frameDurationToString(@FrameDuration int frameDurationBit) { |
| Łukasz Rymanowski | 4b6c0d0 | 2024-04-22 15:02:02 +0000 | [diff] [blame] | 350 | switch (frameDurationBit) { |
| 351 | case FRAME_DURATION_NONE: |
| 352 | return "None"; |
| 353 | case FRAME_DURATION_7500: |
| 354 | return "7.5 ms"; |
| 355 | case FRAME_DURATION_10000: |
| 356 | return "10 ms"; |
| 357 | default: |
| 358 | return "Unknown bit " + frameDurationBit; |
| 359 | } |
| 360 | } |
| 361 | |
| Patty | 5c05c2f | 2021-11-04 21:03:32 +0800 | [diff] [blame] | 362 | @Override |
| 363 | public String toString() { |
| David Duarte | ee52b7e | 2023-12-02 01:32:11 +0000 | [diff] [blame] | 364 | return "{codecName:" |
| 365 | + getCodecName() |
| 366 | + ",mCodecType:" |
| 367 | + mCodecType |
| 368 | + ",mCodecPriority:" |
| 369 | + mCodecPriority |
| 370 | + ",mSampleRate:" |
| Łukasz Rymanowski | 4b6c0d0 | 2024-04-22 15:02:02 +0000 | [diff] [blame] | 371 | + sampleRateToString(mSampleRate) |
| David Duarte | ee52b7e | 2023-12-02 01:32:11 +0000 | [diff] [blame] | 372 | + ",mBitsPerSample:" |
| 373 | + mBitsPerSample |
| Łukasz Rymanowski | 4b6c0d0 | 2024-04-22 15:02:02 +0000 | [diff] [blame] | 374 | + ",mChannelCountBitMask:" |
| David Duarte | ee52b7e | 2023-12-02 01:32:11 +0000 | [diff] [blame] | 375 | + mChannelCount |
| 376 | + ",mFrameDuration:" |
| Łukasz Rymanowski | 4b6c0d0 | 2024-04-22 15:02:02 +0000 | [diff] [blame] | 377 | + frameDurationToString(mFrameDuration) |
| David Duarte | ee52b7e | 2023-12-02 01:32:11 +0000 | [diff] [blame] | 378 | + ",mOctetsPerFrame:" |
| 379 | + mOctetsPerFrame |
| 380 | + ",mMinOctetsPerFrame:" |
| 381 | + mMinOctetsPerFrame |
| 382 | + ",mMaxOctetsPerFrame:" |
| 383 | + mMaxOctetsPerFrame |
| 384 | + "}"; |
| Patty | 5c05c2f | 2021-11-04 21:03:32 +0800 | [diff] [blame] | 385 | } |
| 386 | |
| 387 | /** |
| 388 | * Gets the codec type. |
| 389 | * |
| 390 | * @return the codec type |
| 391 | */ |
| 392 | public @SourceCodecType int getCodecType() { |
| 393 | return mCodecType; |
| 394 | } |
| 395 | |
| 396 | /** |
| Patty | 5c05c2f | 2021-11-04 21:03:32 +0800 | [diff] [blame] | 397 | * Gets the codec name. |
| 398 | * |
| 399 | * @return the codec name |
| 400 | */ |
| 401 | public @NonNull String getCodecName() { |
| 402 | switch (mCodecType) { |
| 403 | case SOURCE_CODEC_TYPE_LC3: |
| 404 | return "LC3"; |
| 405 | case SOURCE_CODEC_TYPE_INVALID: |
| 406 | return "INVALID CODEC"; |
| Jakub Tyszkowski | 676bd92 | 2025-04-10 11:02:14 +0000 | [diff] [blame^] | 407 | case SOURCE_CODEC_TYPE_OPUS_HI_RES: |
| 408 | if (Flags.leaudioAddOpusHiResCodecType()) { |
| 409 | return "Opus Hi-Res"; |
| 410 | } |
| 411 | // Fall-through intended |
| Patty | 5c05c2f | 2021-11-04 21:03:32 +0800 | [diff] [blame] | 412 | default: |
| Łukasz Rymanowski | 61e1188 | 2024-11-20 14:13:27 +0000 | [diff] [blame] | 413 | if (Flags.leaudioAddOpusCodecType()) { |
| 414 | if (mCodecType == SOURCE_CODEC_TYPE_OPUS) { |
| 415 | return "Opus"; |
| 416 | } |
| 417 | } |
| Patty | 5c05c2f | 2021-11-04 21:03:32 +0800 | [diff] [blame] | 418 | break; |
| 419 | } |
| 420 | return "UNKNOWN CODEC(" + mCodecType + ")"; |
| 421 | } |
| 422 | |
| 423 | /** |
| Patty | d8c4927 | 2022-01-19 16:26:00 +0800 | [diff] [blame] | 424 | * Returns the codec selection priority. |
| David Duarte | ee52b7e | 2023-12-02 01:32:11 +0000 | [diff] [blame] | 425 | * |
| 426 | * <p>The codec selection priority is relative to other codecs: larger value means higher |
| 427 | * priority. |
| Patty | d8c4927 | 2022-01-19 16:26:00 +0800 | [diff] [blame] | 428 | */ |
| 429 | public @CodecPriority int getCodecPriority() { |
| 430 | return mCodecPriority; |
| 431 | } |
| 432 | |
| David Duarte | ee52b7e | 2023-12-02 01:32:11 +0000 | [diff] [blame] | 433 | /** Returns the codec sample rate. */ |
| Patty | d8c4927 | 2022-01-19 16:26:00 +0800 | [diff] [blame] | 434 | public @SampleRate int getSampleRate() { |
| 435 | return mSampleRate; |
| 436 | } |
| 437 | |
| David Duarte | ee52b7e | 2023-12-02 01:32:11 +0000 | [diff] [blame] | 438 | /** Returns the codec bits per sample. */ |
| Patty | d8c4927 | 2022-01-19 16:26:00 +0800 | [diff] [blame] | 439 | public @BitsPerSample int getBitsPerSample() { |
| 440 | return mBitsPerSample; |
| 441 | } |
| 442 | |
| David Duarte | ee52b7e | 2023-12-02 01:32:11 +0000 | [diff] [blame] | 443 | /** Returns the codec channel mode. */ |
| Łukasz Rymanowski | 3c97945 | 2022-03-10 10:28:12 +0000 | [diff] [blame] | 444 | public @ChannelCount int getChannelCount() { |
| 445 | return mChannelCount; |
| Patty | d8c4927 | 2022-01-19 16:26:00 +0800 | [diff] [blame] | 446 | } |
| 447 | |
| David Duarte | ee52b7e | 2023-12-02 01:32:11 +0000 | [diff] [blame] | 448 | /** Returns the frame duration. */ |
| Patty | 3a61c47 | 2022-02-08 12:16:46 +0800 | [diff] [blame] | 449 | public @FrameDuration int getFrameDuration() { |
| Patty | d8c4927 | 2022-01-19 16:26:00 +0800 | [diff] [blame] | 450 | return mFrameDuration; |
| 451 | } |
| 452 | |
| David Duarte | ee52b7e | 2023-12-02 01:32:11 +0000 | [diff] [blame] | 453 | /** Returns the octets per frame */ |
| Patty | 3a61c47 | 2022-02-08 12:16:46 +0800 | [diff] [blame] | 454 | public int getOctetsPerFrame() { |
| Patty | d8c4927 | 2022-01-19 16:26:00 +0800 | [diff] [blame] | 455 | return mOctetsPerFrame; |
| 456 | } |
| 457 | |
| David Duarte | ee52b7e | 2023-12-02 01:32:11 +0000 | [diff] [blame] | 458 | /** Returns the minimum octets per frame */ |
| Łukasz Rymanowski | 3c97945 | 2022-03-10 10:28:12 +0000 | [diff] [blame] | 459 | public int getMinOctetsPerFrame() { |
| 460 | return mMinOctetsPerFrame; |
| 461 | } |
| 462 | |
| David Duarte | ee52b7e | 2023-12-02 01:32:11 +0000 | [diff] [blame] | 463 | /** Returns the maximum octets per frame */ |
| Łukasz Rymanowski | 3c97945 | 2022-03-10 10:28:12 +0000 | [diff] [blame] | 464 | public int getMaxOctetsPerFrame() { |
| 465 | return mMaxOctetsPerFrame; |
| 466 | } |
| 467 | |
| Patty | 5aa4bd2 | 2022-01-25 19:58:37 +0800 | [diff] [blame] | 468 | @Override |
| Anton Hansson | fa927a5 | 2023-11-09 09:08:19 +0000 | [diff] [blame] | 469 | public boolean equals(@Nullable Object o) { |
| Patty | 5aa4bd2 | 2022-01-25 19:58:37 +0800 | [diff] [blame] | 470 | if (o instanceof BluetoothLeAudioCodecConfig) { |
| 471 | BluetoothLeAudioCodecConfig other = (BluetoothLeAudioCodecConfig) o; |
| 472 | return (other.getCodecType() == mCodecType |
| 473 | && other.getCodecPriority() == mCodecPriority |
| 474 | && other.getSampleRate() == mSampleRate |
| 475 | && other.getBitsPerSample() == mBitsPerSample |
| Łukasz Rymanowski | 3c97945 | 2022-03-10 10:28:12 +0000 | [diff] [blame] | 476 | && other.getChannelCount() == mChannelCount |
| Patty | 5aa4bd2 | 2022-01-25 19:58:37 +0800 | [diff] [blame] | 477 | && other.getFrameDuration() == mFrameDuration |
| Łukasz Rymanowski | 3c97945 | 2022-03-10 10:28:12 +0000 | [diff] [blame] | 478 | && other.getOctetsPerFrame() == mOctetsPerFrame |
| 479 | && other.getMinOctetsPerFrame() == mMinOctetsPerFrame |
| 480 | && other.getMaxOctetsPerFrame() == mMaxOctetsPerFrame); |
| Patty | 5aa4bd2 | 2022-01-25 19:58:37 +0800 | [diff] [blame] | 481 | } |
| 482 | return false; |
| 483 | } |
| 484 | |
| 485 | /** |
| David Duarte | ee52b7e | 2023-12-02 01:32:11 +0000 | [diff] [blame] | 486 | * Returns a hash representation of this BluetoothLeAudioCodecConfig based on all the config |
| 487 | * values. |
| Patty | 5aa4bd2 | 2022-01-25 19:58:37 +0800 | [diff] [blame] | 488 | */ |
| 489 | @Override |
| 490 | public int hashCode() { |
| David Duarte | ee52b7e | 2023-12-02 01:32:11 +0000 | [diff] [blame] | 491 | return Objects.hash( |
| 492 | mCodecType, |
| 493 | mCodecPriority, |
| 494 | mSampleRate, |
| 495 | mBitsPerSample, |
| 496 | mChannelCount, |
| 497 | mFrameDuration, |
| 498 | mOctetsPerFrame, |
| 499 | mMinOctetsPerFrame, |
| 500 | mMaxOctetsPerFrame); |
| Patty | 5aa4bd2 | 2022-01-25 19:58:37 +0800 | [diff] [blame] | 501 | } |
| 502 | |
| Patty | d8c4927 | 2022-01-19 16:26:00 +0800 | [diff] [blame] | 503 | /** |
| Patty | 5c05c2f | 2021-11-04 21:03:32 +0800 | [diff] [blame] | 504 | * Builder for {@link BluetoothLeAudioCodecConfig}. |
| David Duarte | ee52b7e | 2023-12-02 01:32:11 +0000 | [diff] [blame] | 505 | * |
| 506 | * <p>By default, the codec type will be set to {@link |
| 507 | * BluetoothLeAudioCodecConfig#SOURCE_CODEC_TYPE_INVALID} |
| Patty | 5c05c2f | 2021-11-04 21:03:32 +0800 | [diff] [blame] | 508 | */ |
| 509 | public static final class Builder { |
| 510 | private int mCodecType = BluetoothLeAudioCodecConfig.SOURCE_CODEC_TYPE_INVALID; |
| Patty | d8c4927 | 2022-01-19 16:26:00 +0800 | [diff] [blame] | 511 | private int mCodecPriority = BluetoothLeAudioCodecConfig.CODEC_PRIORITY_DEFAULT; |
| 512 | private int mSampleRate = BluetoothLeAudioCodecConfig.SAMPLE_RATE_NONE; |
| 513 | private int mBitsPerSample = BluetoothLeAudioCodecConfig.BITS_PER_SAMPLE_NONE; |
| Łukasz Rymanowski | 3c97945 | 2022-03-10 10:28:12 +0000 | [diff] [blame] | 514 | private int mChannelCount = BluetoothLeAudioCodecConfig.CHANNEL_COUNT_NONE; |
| Patty | d8c4927 | 2022-01-19 16:26:00 +0800 | [diff] [blame] | 515 | private int mFrameDuration = BluetoothLeAudioCodecConfig.FRAME_DURATION_NONE; |
| 516 | private int mOctetsPerFrame = 0; |
| Łukasz Rymanowski | 3c97945 | 2022-03-10 10:28:12 +0000 | [diff] [blame] | 517 | private int mMinOctetsPerFrame = 0; |
| 518 | private int mMaxOctetsPerFrame = 0; |
| Patty | d8c4927 | 2022-01-19 16:26:00 +0800 | [diff] [blame] | 519 | |
| 520 | public Builder() {} |
| 521 | |
| 522 | public Builder(@NonNull BluetoothLeAudioCodecConfig config) { |
| 523 | mCodecType = config.getCodecType(); |
| 524 | mCodecPriority = config.getCodecPriority(); |
| 525 | mSampleRate = config.getSampleRate(); |
| 526 | mBitsPerSample = config.getBitsPerSample(); |
| Łukasz Rymanowski | 3c97945 | 2022-03-10 10:28:12 +0000 | [diff] [blame] | 527 | mChannelCount = config.getChannelCount(); |
| Patty | d8c4927 | 2022-01-19 16:26:00 +0800 | [diff] [blame] | 528 | mFrameDuration = config.getFrameDuration(); |
| 529 | mOctetsPerFrame = config.getOctetsPerFrame(); |
| Łukasz Rymanowski | 3c97945 | 2022-03-10 10:28:12 +0000 | [diff] [blame] | 530 | mMinOctetsPerFrame = config.getMinOctetsPerFrame(); |
| 531 | mMaxOctetsPerFrame = config.getMaxOctetsPerFrame(); |
| Patty | d8c4927 | 2022-01-19 16:26:00 +0800 | [diff] [blame] | 532 | } |
| Patty | 5c05c2f | 2021-11-04 21:03:32 +0800 | [diff] [blame] | 533 | |
| 534 | /** |
| Patty | d8c4927 | 2022-01-19 16:26:00 +0800 | [diff] [blame] | 535 | * Set codec type for Bluetooth LE audio codec config. |
| Patty | 5c05c2f | 2021-11-04 21:03:32 +0800 | [diff] [blame] | 536 | * |
| 537 | * @param codecType of this codec |
| 538 | * @return the same Builder instance |
| 539 | */ |
| 540 | public @NonNull Builder setCodecType(@SourceCodecType int codecType) { |
| 541 | mCodecType = codecType; |
| 542 | return this; |
| 543 | } |
| 544 | |
| 545 | /** |
| Patty | d8c4927 | 2022-01-19 16:26:00 +0800 | [diff] [blame] | 546 | * Set codec priority for Bluetooth LE audio codec config. |
| 547 | * |
| 548 | * @param codecPriority of this codec |
| 549 | * @return the same Builder instance |
| 550 | */ |
| 551 | public @NonNull Builder setCodecPriority(@CodecPriority int codecPriority) { |
| 552 | mCodecPriority = codecPriority; |
| 553 | return this; |
| 554 | } |
| 555 | |
| 556 | /** |
| 557 | * Set sample rate for Bluetooth LE audio codec config. |
| 558 | * |
| 559 | * @param sampleRate of this codec |
| 560 | * @return the same Builder instance |
| 561 | */ |
| 562 | public @NonNull Builder setSampleRate(@SampleRate int sampleRate) { |
| 563 | mSampleRate = sampleRate; |
| 564 | return this; |
| 565 | } |
| 566 | |
| 567 | /** |
| 568 | * Set the bits per sample for LE audio codec config. |
| 569 | * |
| 570 | * @param bitsPerSample of this codec |
| 571 | * @return the same Builder instance |
| 572 | */ |
| 573 | public @NonNull Builder setBitsPerSample(@BitsPerSample int bitsPerSample) { |
| 574 | mBitsPerSample = bitsPerSample; |
| 575 | return this; |
| 576 | } |
| 577 | |
| 578 | /** |
| Łukasz Rymanowski | 3c97945 | 2022-03-10 10:28:12 +0000 | [diff] [blame] | 579 | * Set the channel count for Bluetooth LE audio codec config. |
| Patty | d8c4927 | 2022-01-19 16:26:00 +0800 | [diff] [blame] | 580 | * |
| Łukasz Rymanowski | 3c97945 | 2022-03-10 10:28:12 +0000 | [diff] [blame] | 581 | * @param channelCount of this codec |
| Patty | d8c4927 | 2022-01-19 16:26:00 +0800 | [diff] [blame] | 582 | * @return the same Builder instance |
| 583 | */ |
| Łukasz Rymanowski | 3c97945 | 2022-03-10 10:28:12 +0000 | [diff] [blame] | 584 | public @NonNull Builder setChannelCount(@ChannelCount int channelCount) { |
| 585 | mChannelCount = channelCount; |
| Patty | d8c4927 | 2022-01-19 16:26:00 +0800 | [diff] [blame] | 586 | return this; |
| 587 | } |
| 588 | |
| 589 | /** |
| 590 | * Set the frame duration for Bluetooth LE audio codec config. |
| 591 | * |
| 592 | * @param frameDuration of this codec |
| 593 | * @return the same Builder instance |
| 594 | */ |
| 595 | public @NonNull Builder setFrameDuration(@FrameDuration int frameDuration) { |
| 596 | mFrameDuration = frameDuration; |
| 597 | return this; |
| 598 | } |
| 599 | |
| 600 | /** |
| 601 | * Set the octets per frame for Bluetooth LE audio codec config. |
| 602 | * |
| 603 | * @param octetsPerFrame of this codec |
| 604 | * @return the same Builder instance |
| 605 | */ |
| 606 | public @NonNull Builder setOctetsPerFrame(int octetsPerFrame) { |
| 607 | mOctetsPerFrame = octetsPerFrame; |
| 608 | return this; |
| 609 | } |
| 610 | |
| 611 | /** |
| Łukasz Rymanowski | 3c97945 | 2022-03-10 10:28:12 +0000 | [diff] [blame] | 612 | * Set the minimum octets per frame for Bluetooth LE audio codec config. |
| 613 | * |
| 614 | * @param minOctetsPerFrame of this codec |
| 615 | * @return the same Builder instance |
| 616 | */ |
| 617 | public @NonNull Builder setMinOctetsPerFrame(int minOctetsPerFrame) { |
| 618 | mMinOctetsPerFrame = minOctetsPerFrame; |
| 619 | return this; |
| 620 | } |
| 621 | |
| 622 | /** |
| 623 | * Set the maximum octets per frame for Bluetooth LE audio codec config. |
| 624 | * |
| 625 | * @param maxOctetsPerFrame of this codec |
| 626 | * @return the same Builder instance |
| 627 | */ |
| 628 | public @NonNull Builder setMaxOctetsPerFrame(int maxOctetsPerFrame) { |
| 629 | mMaxOctetsPerFrame = maxOctetsPerFrame; |
| 630 | return this; |
| 631 | } |
| 632 | |
| 633 | /** |
| Patty | 5c05c2f | 2021-11-04 21:03:32 +0800 | [diff] [blame] | 634 | * Build {@link BluetoothLeAudioCodecConfig}. |
| David Duarte | ee52b7e | 2023-12-02 01:32:11 +0000 | [diff] [blame] | 635 | * |
| Patty | 5c05c2f | 2021-11-04 21:03:32 +0800 | [diff] [blame] | 636 | * @return new BluetoothLeAudioCodecConfig built |
| 637 | */ |
| 638 | public @NonNull BluetoothLeAudioCodecConfig build() { |
| David Duarte | ee52b7e | 2023-12-02 01:32:11 +0000 | [diff] [blame] | 639 | return new BluetoothLeAudioCodecConfig( |
| 640 | mCodecType, |
| 641 | mCodecPriority, |
| 642 | mSampleRate, |
| 643 | mBitsPerSample, |
| 644 | mChannelCount, |
| 645 | mFrameDuration, |
| 646 | mOctetsPerFrame, |
| 647 | mMinOctetsPerFrame, |
| 648 | mMaxOctetsPerFrame); |
| Patty | 5c05c2f | 2021-11-04 21:03:32 +0800 | [diff] [blame] | 649 | } |
| 650 | } |
| 651 | } |