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 17 package android.bluetooth; 18 19 import static android.bluetooth.BluetoothLeAudioCodecConfig.FRAME_DURATION_10000; 20 import static android.bluetooth.BluetoothLeAudioCodecConfig.FRAME_DURATION_7500; 21 import static android.bluetooth.BluetoothLeAudioCodecConfig.FRAME_DURATION_NONE; 22 import static android.bluetooth.BluetoothLeAudioCodecConfig.FrameDuration; 23 import static android.bluetooth.BluetoothLeAudioCodecConfig.SAMPLE_RATE_11025; 24 import static android.bluetooth.BluetoothLeAudioCodecConfig.SAMPLE_RATE_16000; 25 import static android.bluetooth.BluetoothLeAudioCodecConfig.SAMPLE_RATE_176400; 26 import static android.bluetooth.BluetoothLeAudioCodecConfig.SAMPLE_RATE_192000; 27 import static android.bluetooth.BluetoothLeAudioCodecConfig.SAMPLE_RATE_22050; 28 import static android.bluetooth.BluetoothLeAudioCodecConfig.SAMPLE_RATE_24000; 29 import static android.bluetooth.BluetoothLeAudioCodecConfig.SAMPLE_RATE_32000; 30 import static android.bluetooth.BluetoothLeAudioCodecConfig.SAMPLE_RATE_384000; 31 import static android.bluetooth.BluetoothLeAudioCodecConfig.SAMPLE_RATE_44100; 32 import static android.bluetooth.BluetoothLeAudioCodecConfig.SAMPLE_RATE_48000; 33 import static android.bluetooth.BluetoothLeAudioCodecConfig.SAMPLE_RATE_8000; 34 import static android.bluetooth.BluetoothLeAudioCodecConfig.SAMPLE_RATE_88200; 35 import static android.bluetooth.BluetoothLeAudioCodecConfig.SAMPLE_RATE_96000; 36 import static android.bluetooth.BluetoothLeAudioCodecConfig.SAMPLE_RATE_NONE; 37 import static android.bluetooth.BluetoothLeAudioCodecConfig.SampleRate; 38 39 import android.annotation.NonNull; 40 import android.annotation.Nullable; 41 import android.annotation.SystemApi; 42 import android.bluetooth.BluetoothLeAudioCodecConfig.FrameDuration; 43 import android.bluetooth.BluetoothLeAudioCodecConfig.SampleRate; 44 import android.bluetooth.BluetoothUtils.TypeValueEntry; 45 import android.os.Parcel; 46 import android.os.Parcelable; 47 48 import java.nio.ByteBuffer; 49 import java.util.ArrayList; 50 import java.util.Arrays; 51 import java.util.List; 52 import java.util.Objects; 53 54 /** 55 * A class representing the codec specific config metadata information defined in the Basic Audio 56 * Profile. 57 * 58 * @hide 59 */ 60 @SystemApi 61 public final class BluetoothLeAudioCodecConfigMetadata implements Parcelable { 62 private static final int SAMPLING_FREQUENCY_TYPE = 0x01; 63 private static final int FRAME_DURATION_TYPE = 0x02; 64 private static final int AUDIO_CHANNEL_LOCATION_TYPE = 0x03; 65 private static final int OCTETS_PER_FRAME_TYPE = 0x04; 66 67 private final long mAudioLocation; 68 private final @SampleRate int mSampleRate; 69 private final @FrameDuration int mFrameDuration; 70 private final int mOctetsPerFrame; 71 private final byte[] mRawMetadata; 72 73 /** Audio codec sampling frequency from metadata. */ 74 private static final int CONFIG_SAMPLING_FREQUENCY_UNKNOWN = 0; 75 76 private static final int CONFIG_SAMPLING_FREQUENCY_8000 = 0x01; 77 private static final int CONFIG_SAMPLING_FREQUENCY_16000 = 0x03; 78 private static final int CONFIG_SAMPLING_FREQUENCY_24000 = 0x05; 79 private static final int CONFIG_SAMPLING_FREQUENCY_32000 = 0x06; 80 private static final int CONFIG_SAMPLING_FREQUENCY_44100 = 0x07; 81 private static final int CONFIG_SAMPLING_FREQUENCY_48000 = 0x08; 82 private static final int CONFIG_SAMPLING_FREQUENCY_11025 = 0x09; 83 private static final int CONFIG_SAMPLING_FREQUENCY_22050 = 0x0a; 84 private static final int CONFIG_SAMPLING_FREQUENCY_88200 = 0x0b; 85 private static final int CONFIG_SAMPLING_FREQUENCY_96000 = 0x0c; 86 private static final int CONFIG_SAMPLING_FREQUENCY_176400 = 0x0d; 87 private static final int CONFIG_SAMPLING_FREQUENCY_192000 = 0x0e; 88 private static final int CONFIG_SAMPLING_FREQUENCY_384000 = 0x0f; 89 90 /** Audio codec config frame duration from metadata. */ 91 private static final int CONFIG_FRAME_DURATION_UNKNOWN = -1; 92 93 private static final int CONFIG_FRAME_DURATION_7500 = 0x00; 94 private static final int CONFIG_FRAME_DURATION_10000 = 0x01; 95 BluetoothLeAudioCodecConfigMetadata( long audioLocation, @SampleRate int sampleRate, @FrameDuration int frameDuration, int octetsPerFrame, byte[] rawMetadata)96 private BluetoothLeAudioCodecConfigMetadata( 97 long audioLocation, 98 @SampleRate int sampleRate, 99 @FrameDuration int frameDuration, 100 int octetsPerFrame, 101 byte[] rawMetadata) { 102 mAudioLocation = audioLocation; 103 mSampleRate = sampleRate; 104 mFrameDuration = frameDuration; 105 mOctetsPerFrame = octetsPerFrame; 106 mRawMetadata = rawMetadata; 107 } 108 109 @Override equals(@ullable Object o)110 public boolean equals(@Nullable Object o) { 111 if (o != null && o instanceof BluetoothLeAudioCodecConfigMetadata) { 112 final BluetoothLeAudioCodecConfigMetadata oth = (BluetoothLeAudioCodecConfigMetadata) o; 113 return mAudioLocation == oth.getAudioLocation() 114 && mSampleRate == oth.getSampleRate() 115 && mFrameDuration == oth.getFrameDuration() 116 && mOctetsPerFrame == oth.getOctetsPerFrame() 117 && Arrays.equals(mRawMetadata, oth.getRawMetadata()); 118 } 119 return false; 120 } 121 122 @Override hashCode()123 public int hashCode() { 124 return Objects.hash( 125 mAudioLocation, 126 mSampleRate, 127 mFrameDuration, 128 mOctetsPerFrame, 129 Arrays.hashCode(mRawMetadata)); 130 } 131 132 @Override toString()133 public String toString() { 134 return "BluetoothLeAudioCodecConfigMetadata{" 135 + ("audioLocation=" + mAudioLocation) 136 + (", sampleRate=" + mSampleRate) 137 + (", frameDuration=" + mFrameDuration) 138 + (", octetsPerFrame=" + mOctetsPerFrame) 139 + (", rawMetadata=" + Arrays.toString(mRawMetadata)) 140 + '}'; 141 } 142 143 /** 144 * Get the audio location information as defined in the Generic Audio section of Bluetooth 145 * Assigned numbers. 146 * 147 * @return configured audio location, -1 if this metadata does not exist 148 * @hide 149 */ 150 @SystemApi getAudioLocation()151 public long getAudioLocation() { 152 return mAudioLocation; 153 } 154 155 /** 156 * Get the audio sample rate information as defined in the Generic Audio section of Bluetooth 157 * Assigned numbers 6.12.4.1 Supported_Sampling_Frequencies. 158 * 159 * <p>Internally this is converted from Sampling_Frequency values as defined in 6.12.5.1 160 * 161 * @return configured sample rate from meta data, {@link 162 * BluetoothLeAudioCodecConfig#SAMPLE_RATE_NONE} if this metadata does not exist 163 * @hide 164 */ 165 @SystemApi getSampleRate()166 public @SampleRate int getSampleRate() { 167 return mSampleRate; 168 } 169 170 /** 171 * Get the audio frame duration information as defined in the Generic Audio section of Bluetooth 172 * Assigned numbers 6.12.5.2 Frame_Duration. 173 * 174 * <p>Internally this is converted from Frame_Durations values as defined in 6.12.4.2 175 * 176 * @return configured frame duration from meta data, {@link 177 * BluetoothLeAudioCodecConfig#FRAME_DURATION_NONE} if this metadata does not exist 178 * @hide 179 */ 180 @SystemApi getFrameDuration()181 public @FrameDuration int getFrameDuration() { 182 return mFrameDuration; 183 } 184 185 /** 186 * Get the audio octets per frame information as defined in the Generic Audio section of 187 * Bluetooth Assigned numbers. 188 * 189 * @return configured octets per frame from meta data 0 if this metadata does not exist 190 * @hide 191 */ 192 @SystemApi getOctetsPerFrame()193 public int getOctetsPerFrame() { 194 return mOctetsPerFrame; 195 } 196 197 /** 198 * Get the raw bytes of stream metadata in Bluetooth LTV format. 199 * 200 * <p>Bluetooth LTV format for stream metadata is defined in the Generic Audio section of <a 201 * href="https://www.bluetooth.com/specifications/assigned-numbers/">Bluetooth Assigned 202 * Numbers</a>, including metadata that was not covered by the getter methods in this class. 203 * 204 * @return raw bytes of stream metadata in Bluetooth LTV format 205 * @hide 206 */ 207 @SystemApi getRawMetadata()208 public @NonNull byte[] getRawMetadata() { 209 return mRawMetadata; 210 } 211 212 /** 213 * {@inheritDoc} 214 * 215 * @hide 216 */ 217 @Override describeContents()218 public int describeContents() { 219 return 0; 220 } 221 222 /** 223 * {@inheritDoc} 224 * 225 * @hide 226 */ 227 @Override writeToParcel(Parcel out, int flags)228 public void writeToParcel(Parcel out, int flags) { 229 out.writeLong(mAudioLocation); 230 out.writeByteArray(mRawMetadata); 231 out.writeInt(mSampleRate); 232 out.writeInt(mFrameDuration); 233 out.writeInt(mOctetsPerFrame); 234 } 235 236 /** 237 * A {@link Parcelable.Creator} to create {@link BluetoothLeAudioCodecConfigMetadata} from 238 * parcel. 239 * 240 * @hide 241 */ 242 @SystemApi @NonNull 243 public static final Creator<BluetoothLeAudioCodecConfigMetadata> CREATOR = 244 new Creator<>() { 245 public @NonNull BluetoothLeAudioCodecConfigMetadata createFromParcel( 246 @NonNull Parcel in) { 247 long audioLocation = in.readLong(); 248 byte[] rawMetadata = in.createByteArray(); 249 if (rawMetadata == null) { 250 rawMetadata = new byte[0]; 251 } 252 int sampleRate = in.readInt(); 253 int frameDuration = in.readInt(); 254 int octetsPerFrame = in.readInt(); 255 return new BluetoothLeAudioCodecConfigMetadata( 256 audioLocation, sampleRate, frameDuration, octetsPerFrame, rawMetadata); 257 } 258 259 public @NonNull BluetoothLeAudioCodecConfigMetadata[] newArray(int size) { 260 return new BluetoothLeAudioCodecConfigMetadata[size]; 261 } 262 }; 263 264 /** 265 * Construct a {@link BluetoothLeAudioCodecConfigMetadata} from raw bytes. 266 * 267 * <p>The byte array will be parsed and values for each getter will be populated 268 * 269 * <p>Raw metadata cannot be set using builder in order to maintain raw bytes and getter value 270 * consistency 271 * 272 * @param rawBytes raw bytes of stream metadata in Bluetooth LTV format 273 * @return parsed {@link BluetoothLeAudioCodecConfigMetadata} object 274 * @throws IllegalArgumentException if <var>rawBytes</var> is null or when the raw bytes cannot 275 * be parsed to build the object 276 * @hide 277 */ 278 @SystemApi 279 @NonNull fromRawBytes(@onNull byte[] rawBytes)280 public static BluetoothLeAudioCodecConfigMetadata fromRawBytes(@NonNull byte[] rawBytes) { 281 if (rawBytes == null) { 282 throw new IllegalArgumentException("Raw bytes cannot be null"); 283 } 284 List<TypeValueEntry> entries = BluetoothUtils.parseLengthTypeValueBytes(rawBytes); 285 if (rawBytes.length > 0 && rawBytes[0] > 0 && entries.isEmpty()) { 286 throw new IllegalArgumentException( 287 "No LTV entries are found from rawBytes of size " + rawBytes.length); 288 } 289 long audioLocation = 0; 290 int samplingFrequency = CONFIG_SAMPLING_FREQUENCY_UNKNOWN; 291 int frameDuration = CONFIG_FRAME_DURATION_UNKNOWN; 292 int octetsPerFrame = 0; 293 for (TypeValueEntry entry : entries) { 294 if (entry.getType() == AUDIO_CHANNEL_LOCATION_TYPE) { 295 byte[] bytes = entry.getValue(); 296 // Get unsigned uint32_t to long 297 audioLocation = 298 ((bytes[0] & 0xFF) << 0) 299 | ((bytes[1] & 0xFF) << 8) 300 | ((bytes[2] & 0xFF) << 16) 301 | ((long) (bytes[3] & 0xFF) << 24); 302 } else if (entry.getType() == SAMPLING_FREQUENCY_TYPE) { 303 byte[] bytes = entry.getValue(); 304 // Get one byte for sampling frequency in value 305 samplingFrequency = (int) (bytes[0] & 0xFF); 306 } else if (entry.getType() == FRAME_DURATION_TYPE) { 307 byte[] bytes = entry.getValue(); 308 // Get one byte for frame duration in value 309 frameDuration = (int) (bytes[0] & 0xFF); 310 } else if (entry.getType() == OCTETS_PER_FRAME_TYPE) { 311 byte[] bytes = entry.getValue(); 312 // Get two bytes for octets per frame to int 313 octetsPerFrame = ((bytes[0] & 0xFF) << 0) | ((int) (bytes[1] & 0xFF) << 8); 314 } 315 } 316 return new BluetoothLeAudioCodecConfigMetadata( 317 audioLocation, 318 convertToSampleRateBitset(samplingFrequency), 319 convertToFrameDurationBitset(frameDuration), 320 octetsPerFrame, 321 rawBytes); 322 } 323 324 /** 325 * Builder for {@link BluetoothLeAudioCodecConfigMetadata}. 326 * 327 * @hide 328 */ 329 @SystemApi 330 public static final class Builder { 331 private long mAudioLocation = 0; 332 private int mSampleRate = SAMPLE_RATE_NONE; 333 private int mFrameDuration = FRAME_DURATION_NONE; 334 private int mOctetsPerFrame = 0; 335 private byte[] mRawMetadata = null; 336 337 /** 338 * Create an empty builder. 339 * 340 * @hide 341 */ 342 @SystemApi Builder()343 public Builder() {} 344 345 /** 346 * Create a builder with copies of information from original object. 347 * 348 * @param original original object 349 * @hide 350 */ 351 @SystemApi Builder(@onNull BluetoothLeAudioCodecConfigMetadata original)352 public Builder(@NonNull BluetoothLeAudioCodecConfigMetadata original) { 353 mAudioLocation = original.getAudioLocation(); 354 mSampleRate = original.getSampleRate(); 355 mFrameDuration = original.getFrameDuration(); 356 mOctetsPerFrame = original.getOctetsPerFrame(); 357 mRawMetadata = original.getRawMetadata(); 358 } 359 360 /** 361 * Set the audio location information as defined in the Generic Audio section of Bluetooth 362 * Assigned numbers. 363 * 364 * @param audioLocation configured audio location, -1 if does not exist 365 * @return this builder 366 * @hide 367 */ 368 @SystemApi 369 @NonNull setAudioLocation(long audioLocation)370 public Builder setAudioLocation(long audioLocation) { 371 mAudioLocation = audioLocation; 372 return this; 373 } 374 375 /** 376 * Set the audio sample rate information as defined in the Generic Audio section of 377 * Bluetooth Assigned 6.12.4.1 Supported_Sampling_Frequencies. 378 * 379 * <p>Internally this will be converted to Sampling_Frequency values as defined in 6.12.5.1 380 * 381 * @param sampleRate configured sample rate in meta data 382 * @return this builder 383 * @throws IllegalArgumentException if sample rate is invalid value 384 * @hide 385 */ 386 @SystemApi 387 @NonNull setSampleRate(@ampleRate int sampleRate)388 public Builder setSampleRate(@SampleRate int sampleRate) { 389 if (sampleRate != SAMPLE_RATE_NONE 390 && sampleRate != SAMPLE_RATE_8000 391 && sampleRate != SAMPLE_RATE_11025 392 && sampleRate != SAMPLE_RATE_16000 393 && sampleRate != SAMPLE_RATE_22050 394 && sampleRate != SAMPLE_RATE_24000 395 && sampleRate != SAMPLE_RATE_32000 396 && sampleRate != SAMPLE_RATE_44100 397 && sampleRate != SAMPLE_RATE_48000 398 && sampleRate != SAMPLE_RATE_88200 399 && sampleRate != SAMPLE_RATE_96000 400 && sampleRate != SAMPLE_RATE_176400 401 && sampleRate != SAMPLE_RATE_192000 402 && sampleRate != SAMPLE_RATE_384000) { 403 throw new IllegalArgumentException("Invalid sample rate " + sampleRate); 404 } 405 mSampleRate = sampleRate; 406 return this; 407 } 408 409 /** 410 * Set the audio frame duration information as defined in the Generic Audio section of 411 * Bluetooth Assigned numbers 6.12.5.2 Frame_Duration. 412 * 413 * <p>Internally this will be converted to Frame_Durations values as defined in 6.12.4.2 414 * 415 * @param frameDuration configured frame duration in meta data 416 * @return this builder 417 * @throws IllegalArgumentException if frameDuration is invalid value 418 * @hide 419 */ 420 @SystemApi 421 @NonNull setFrameDuration(@rameDuration int frameDuration)422 public Builder setFrameDuration(@FrameDuration int frameDuration) { 423 if (frameDuration != FRAME_DURATION_NONE 424 && frameDuration != FRAME_DURATION_7500 425 && frameDuration != FRAME_DURATION_10000) { 426 throw new IllegalArgumentException("Invalid frame duration " + frameDuration); 427 } 428 mFrameDuration = frameDuration; 429 return this; 430 } 431 432 /** 433 * Set the audio octets per frame information as defined in the Generic Audio section of 434 * Bluetooth Assigned numbers. 435 * 436 * @param octetsPerFrame configured octets per frame in meta data 437 * @return this builder 438 * @throws IllegalArgumentException if octetsPerFrame is invalid value 439 * @hide 440 */ 441 @SystemApi 442 @NonNull setOctetsPerFrame(int octetsPerFrame)443 public Builder setOctetsPerFrame(int octetsPerFrame) { 444 if (octetsPerFrame < 0) { 445 throw new IllegalArgumentException("Invalid octetsPerFrame " + octetsPerFrame); 446 } 447 mOctetsPerFrame = octetsPerFrame; 448 return this; 449 } 450 451 /** 452 * Build {@link BluetoothLeAudioCodecConfigMetadata}. 453 * 454 * @return constructed {@link BluetoothLeAudioCodecConfigMetadata} 455 * @throws IllegalArgumentException if the object cannot be built 456 * @hide 457 */ 458 @SystemApi build()459 public @NonNull BluetoothLeAudioCodecConfigMetadata build() { 460 List<TypeValueEntry> entries = new ArrayList<>(); 461 if (mRawMetadata != null) { 462 entries = BluetoothUtils.parseLengthTypeValueBytes(mRawMetadata); 463 if (mRawMetadata.length > 0 && mRawMetadata[0] > 0 && entries.isEmpty()) { 464 throw new IllegalArgumentException( 465 "No LTV entries are found from rawBytes of" 466 + " size " 467 + mRawMetadata.length 468 + " please check the original object" 469 + " passed to Builder's copy constructor"); 470 } 471 } 472 if (mSampleRate != SAMPLE_RATE_NONE) { 473 int samplingFrequency = convertToSamplingFrequencyValue(mSampleRate); 474 entries.removeIf(entry -> entry.getType() == SAMPLING_FREQUENCY_TYPE); 475 entries.add( 476 new TypeValueEntry( 477 SAMPLING_FREQUENCY_TYPE, 478 ByteBuffer.allocate(1) 479 .put((byte) (samplingFrequency & 0xFF)) 480 .array())); 481 } 482 if (mFrameDuration != FRAME_DURATION_NONE) { 483 int frameDuration = convertToFrameDurationValue(mFrameDuration); 484 entries.removeIf(entry -> entry.getType() == FRAME_DURATION_TYPE); 485 entries.add( 486 new TypeValueEntry( 487 FRAME_DURATION_TYPE, 488 ByteBuffer.allocate(1).put((byte) (frameDuration & 0xFF)).array())); 489 } 490 if (mAudioLocation != -1) { 491 entries.removeIf(entry -> entry.getType() == AUDIO_CHANNEL_LOCATION_TYPE); 492 entries.add( 493 new TypeValueEntry( 494 AUDIO_CHANNEL_LOCATION_TYPE, 495 ByteBuffer.allocate(4) 496 .putInt((int) (mAudioLocation & 0xFFFFFFFF)) 497 .array())); 498 } 499 if (mOctetsPerFrame != 0) { 500 entries.removeIf(entry -> entry.getType() == OCTETS_PER_FRAME_TYPE); 501 entries.add( 502 new TypeValueEntry( 503 OCTETS_PER_FRAME_TYPE, 504 ByteBuffer.allocate(2) 505 .putShort((short) (mOctetsPerFrame & 0xFFFF)) 506 .array())); 507 } 508 byte[] rawBytes = BluetoothUtils.serializeTypeValue(entries); 509 if (rawBytes == null) { 510 throw new IllegalArgumentException("Failed to serialize entries to bytes"); 511 } 512 return new BluetoothLeAudioCodecConfigMetadata( 513 mAudioLocation, mSampleRate, mFrameDuration, mOctetsPerFrame, rawBytes); 514 } 515 } 516 convertToSampleRateBitset(int samplingFrequencyValue)517 private static int convertToSampleRateBitset(int samplingFrequencyValue) { 518 switch (samplingFrequencyValue) { 519 case CONFIG_SAMPLING_FREQUENCY_8000: 520 return SAMPLE_RATE_8000; 521 case CONFIG_SAMPLING_FREQUENCY_11025: 522 return SAMPLE_RATE_11025; 523 case CONFIG_SAMPLING_FREQUENCY_16000: 524 return SAMPLE_RATE_16000; 525 case CONFIG_SAMPLING_FREQUENCY_22050: 526 return SAMPLE_RATE_22050; 527 case CONFIG_SAMPLING_FREQUENCY_24000: 528 return SAMPLE_RATE_24000; 529 case CONFIG_SAMPLING_FREQUENCY_32000: 530 return SAMPLE_RATE_32000; 531 case CONFIG_SAMPLING_FREQUENCY_44100: 532 return SAMPLE_RATE_44100; 533 case CONFIG_SAMPLING_FREQUENCY_48000: 534 return SAMPLE_RATE_48000; 535 case CONFIG_SAMPLING_FREQUENCY_88200: 536 return SAMPLE_RATE_88200; 537 case CONFIG_SAMPLING_FREQUENCY_96000: 538 return SAMPLE_RATE_96000; 539 case CONFIG_SAMPLING_FREQUENCY_176400: 540 return SAMPLE_RATE_176400; 541 case CONFIG_SAMPLING_FREQUENCY_192000: 542 return SAMPLE_RATE_192000; 543 case CONFIG_SAMPLING_FREQUENCY_384000: 544 return SAMPLE_RATE_384000; 545 default: 546 return SAMPLE_RATE_NONE; 547 } 548 } 549 convertToSamplingFrequencyValue(int sampleRateBitSet)550 private static int convertToSamplingFrequencyValue(int sampleRateBitSet) { 551 switch (sampleRateBitSet) { 552 case SAMPLE_RATE_8000: 553 return CONFIG_SAMPLING_FREQUENCY_8000; 554 case SAMPLE_RATE_11025: 555 return CONFIG_SAMPLING_FREQUENCY_11025; 556 case SAMPLE_RATE_16000: 557 return CONFIG_SAMPLING_FREQUENCY_16000; 558 case SAMPLE_RATE_22050: 559 return CONFIG_SAMPLING_FREQUENCY_22050; 560 case SAMPLE_RATE_24000: 561 return CONFIG_SAMPLING_FREQUENCY_24000; 562 case SAMPLE_RATE_32000: 563 return CONFIG_SAMPLING_FREQUENCY_32000; 564 case SAMPLE_RATE_44100: 565 return CONFIG_SAMPLING_FREQUENCY_44100; 566 case SAMPLE_RATE_48000: 567 return CONFIG_SAMPLING_FREQUENCY_48000; 568 case SAMPLE_RATE_88200: 569 return CONFIG_SAMPLING_FREQUENCY_88200; 570 case SAMPLE_RATE_96000: 571 return CONFIG_SAMPLING_FREQUENCY_96000; 572 case SAMPLE_RATE_176400: 573 return CONFIG_SAMPLING_FREQUENCY_176400; 574 case SAMPLE_RATE_192000: 575 return CONFIG_SAMPLING_FREQUENCY_192000; 576 case SAMPLE_RATE_384000: 577 return CONFIG_SAMPLING_FREQUENCY_384000; 578 default: 579 return CONFIG_SAMPLING_FREQUENCY_UNKNOWN; 580 } 581 } 582 convertToFrameDurationBitset(int frameDurationValue)583 private static int convertToFrameDurationBitset(int frameDurationValue) { 584 switch (frameDurationValue) { 585 case CONFIG_FRAME_DURATION_7500: 586 return FRAME_DURATION_7500; 587 case CONFIG_FRAME_DURATION_10000: 588 return FRAME_DURATION_10000; 589 default: 590 return FRAME_DURATION_NONE; 591 } 592 } 593 convertToFrameDurationValue(int frameDurationBitset)594 private static int convertToFrameDurationValue(int frameDurationBitset) { 595 switch (frameDurationBitset) { 596 case FRAME_DURATION_7500: 597 return CONFIG_FRAME_DURATION_7500; 598 case FRAME_DURATION_10000: 599 return CONFIG_FRAME_DURATION_10000; 600 default: 601 return CONFIG_FRAME_DURATION_UNKNOWN; 602 } 603 } 604 } 605