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.media; 18 19 import android.annotation.IntDef; 20 import android.annotation.NonNull; 21 22 import java.lang.annotation.Retention; 23 import java.lang.annotation.RetentionPolicy; 24 25 /** 26 * The AudioDescriptor contains the information to describe the audio playback/capture 27 * capabilities. The capabilities are described by a byte array, which is defined by a 28 * particular standard. This is used when the format is unrecognized to the platform. 29 */ 30 public class AudioDescriptor { 31 /** 32 * The audio standard is not specified. 33 */ 34 public static final int STANDARD_NONE = 0; 35 /** 36 * The Extended Display Identification Data (EDID) standard for a short audio descriptor. 37 */ 38 public static final int STANDARD_EDID = 1; 39 40 /** @hide */ 41 @IntDef({ 42 STANDARD_NONE, 43 STANDARD_EDID, 44 }) 45 @Retention(RetentionPolicy.SOURCE) 46 public @interface AudioDescriptorStandard {} 47 48 private final int mStandard; 49 private final byte[] mDescriptor; 50 private final int mEncapsulationType; 51 AudioDescriptor(int standard, int encapsulationType, @NonNull byte[] descriptor)52 AudioDescriptor(int standard, int encapsulationType, @NonNull byte[] descriptor) { 53 mStandard = standard; 54 mEncapsulationType = encapsulationType; 55 mDescriptor = descriptor; 56 } 57 58 /** 59 * @return the standard that defines audio playback/capture capabilities. 60 */ getStandard()61 public @AudioDescriptorStandard int getStandard() { 62 return mStandard; 63 } 64 65 /** 66 * @return a byte array that describes audio playback/capture capabilities as encoded by the 67 * standard for this AudioDescriptor. 68 */ getDescriptor()69 public @NonNull byte[] getDescriptor() { 70 return mDescriptor; 71 } 72 73 /** 74 * The encapsulation type indicates what encapsulation type is required when the framework is 75 * using this extra audio descriptor for playing to a device exposing this audio profile. 76 * When encapsulation is required, only playback with {@link android.media.AudioTrack} API is 77 * supported. But playback with {@link android.media.MediaPlayer} is not. 78 * When an encapsulation type is required, the {@link AudioFormat} encoding selected when 79 * creating the {@link AudioTrack} must match the encapsulation type, e.g 80 * AudioFormat#ENCODING_IEC61937 for AudioProfile.AUDIO_ENCAPSULATION_TYPE_IEC61937. 81 * 82 * @return an integer representing the encapsulation type 83 * 84 * @see AudioProfile#AUDIO_ENCAPSULATION_TYPE_NONE 85 * @see AudioProfile#AUDIO_ENCAPSULATION_TYPE_IEC61937 86 */ getEncapsulationType()87 public @AudioProfile.EncapsulationType int getEncapsulationType() { 88 return mEncapsulationType; 89 } 90 } 91