Add getCodecCapabilities as a supported function.
Add the ability to get a list of supported codecs and their capabilites through the HIDL interface. Bug: 111519504 Test: Compile Change-Id: I61dff240a98d59cb99b526d8988d0d0245140ee4
This commit is contained in:
parent
94acf41dcc
commit
5f0e90ece7
5 changed files with 195 additions and 68 deletions
|
@ -16,13 +16,25 @@ hidl_interface {
|
||||||
],
|
],
|
||||||
types: [
|
types: [
|
||||||
"AacObjectType",
|
"AacObjectType",
|
||||||
|
"AacParameters",
|
||||||
|
"AacVariableBitRate",
|
||||||
|
"AptxParameters",
|
||||||
|
"AudioCapabilities",
|
||||||
|
"AudioConfiguration",
|
||||||
"BitsPerSample",
|
"BitsPerSample",
|
||||||
"ChannelMode",
|
"ChannelMode",
|
||||||
|
"CodecCapabilities",
|
||||||
"CodecConfiguration",
|
"CodecConfiguration",
|
||||||
"CodecType",
|
"CodecType",
|
||||||
"LdacChannelMode",
|
"LdacChannelMode",
|
||||||
|
"LdacParameters",
|
||||||
|
"LdacQualityIndex",
|
||||||
|
"PcmParameters",
|
||||||
"SampleRate",
|
"SampleRate",
|
||||||
|
"SbcAllocMethod",
|
||||||
|
"SbcBlockLength",
|
||||||
"SbcChannelMode",
|
"SbcChannelMode",
|
||||||
|
"SbcParameters",
|
||||||
"SessionType",
|
"SessionType",
|
||||||
"Status",
|
"Status",
|
||||||
"TimeSpec",
|
"TimeSpec",
|
||||||
|
|
|
@ -27,6 +27,9 @@ import android.hardware.audio.common@5.0::SourceMetadata;
|
||||||
*
|
*
|
||||||
* Moreover, the Audio HAL can also get the presentation position of the stream
|
* Moreover, the Audio HAL can also get the presentation position of the stream
|
||||||
* and provide stream metadata.
|
* and provide stream metadata.
|
||||||
|
*
|
||||||
|
* Note: For HIDL APIs with a "generates" statement, the callback parameter used
|
||||||
|
* for return value must be invoked synchronously before the API call returns.
|
||||||
*/
|
*/
|
||||||
interface IBluetoothAudioPort {
|
interface IBluetoothAudioPort {
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -23,6 +23,9 @@ import IBluetoothAudioPort;
|
||||||
*
|
*
|
||||||
* The Bluetooth stack calls methods in this interface to start and end audio
|
* The Bluetooth stack calls methods in this interface to start and end audio
|
||||||
* sessions and sends callback events to the Audio HAL.
|
* sessions and sends callback events to the Audio HAL.
|
||||||
|
*
|
||||||
|
* Note: For HIDL APIs with a "generates" statement, the callback parameter used
|
||||||
|
* for return value must be invoked synchronously before the API call returns.
|
||||||
*/
|
*/
|
||||||
interface IBluetoothAudioProvider {
|
interface IBluetoothAudioProvider {
|
||||||
|
|
||||||
|
@ -35,8 +38,10 @@ interface IBluetoothAudioProvider {
|
||||||
* Note: endSession() must be called to unregister this IBluetoothAudioPort
|
* Note: endSession() must be called to unregister this IBluetoothAudioPort
|
||||||
*
|
*
|
||||||
* @param hostIf An instance of IBluetoothAudioPort for stream control
|
* @param hostIf An instance of IBluetoothAudioPort for stream control
|
||||||
* @param codecConfig The codec configuration negotiated with the remote
|
* @param audioConfig The audio configuration negotiated with the remote
|
||||||
* device
|
* device. The PCM parameters are set if software based encoding,
|
||||||
|
* otherwise the correct codec configuration is used for hardware
|
||||||
|
* encoding.
|
||||||
*
|
*
|
||||||
* @return status One of the following
|
* @return status One of the following
|
||||||
* SUCCESS if this IBluetoothAudioPort was successfully registered with
|
* SUCCESS if this IBluetoothAudioPort was successfully registered with
|
||||||
|
@ -47,10 +52,10 @@ interface IBluetoothAudioProvider {
|
||||||
* any other reason
|
* any other reason
|
||||||
* @return dataMQ The fast message queue for audio data from this provider.
|
* @return dataMQ The fast message queue for audio data from this provider.
|
||||||
* Audio data will be in PCM format as specified by the
|
* Audio data will be in PCM format as specified by the
|
||||||
* codecConfig.pcmDataConfiguration parameter.
|
* audioConfig.pcmConfig parameter.
|
||||||
* nullptr if streaming is offloaded to hardware or on failure.
|
* Invalid if streaming is offloaded to hardware or on failure.
|
||||||
*/
|
*/
|
||||||
startSession(IBluetoothAudioPort hostIf, CodecConfiguration codecConfig)
|
startSession(IBluetoothAudioPort hostIf, AudioConfiguration audioConfig)
|
||||||
generates (Status status, fmq_sync<uint8_t> dataMQ);
|
generates (Status status, fmq_sync<uint8_t> dataMQ);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -25,6 +25,9 @@ import IBluetoothAudioProvider;
|
||||||
* When the Bluetooth stack is ready to create an audio session, it must first
|
* When the Bluetooth stack is ready to create an audio session, it must first
|
||||||
* obtain the IBluetoothAudioProvider for that session type by calling
|
* obtain the IBluetoothAudioProvider for that session type by calling
|
||||||
* openProvider().
|
* openProvider().
|
||||||
|
*
|
||||||
|
* Note: For HIDL APIs with a "generates" statement, the callback parameter used
|
||||||
|
* for return value must be invoked synchronously before the API call returns.
|
||||||
*/
|
*/
|
||||||
interface IBluetoothAudioProvidersFactory {
|
interface IBluetoothAudioProvidersFactory {
|
||||||
|
|
||||||
|
@ -43,4 +46,26 @@ interface IBluetoothAudioProvidersFactory {
|
||||||
*/
|
*/
|
||||||
openProvider(SessionType sessionType)
|
openProvider(SessionType sessionType)
|
||||||
generates (Status status, IBluetoothAudioProvider provider);
|
generates (Status status, IBluetoothAudioProvider provider);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a list of audio capabilities for a session type.
|
||||||
|
*
|
||||||
|
* For software encoding, the PCM capabilities are returned.
|
||||||
|
* For hardware encoding, the supported codecs and their capabilities are
|
||||||
|
* returned.
|
||||||
|
*
|
||||||
|
* @param sessionType The session type (e.g.
|
||||||
|
* A2DP_SOFTWARE_ENCODING_DATAPATH).
|
||||||
|
* @return audioCapabilities A list containing all the capabilities
|
||||||
|
* supported by the sesson type. The capabilities is a list of
|
||||||
|
* available options when configuring the codec for the session.
|
||||||
|
* For software encoding it is the PCM data rate.
|
||||||
|
* For hardware encoding it is the list of supported codecs and their
|
||||||
|
* capabilities.
|
||||||
|
* If a provider isn't supported, an empty list should be returned.
|
||||||
|
* Note: Only one entry should exist per codec when using hardware
|
||||||
|
* encoding.
|
||||||
|
*/
|
||||||
|
getProviderCapabilities(SessionType sessionType)
|
||||||
|
generates (vec<AudioCapabilities> audioCapabilities);
|
||||||
};
|
};
|
||||||
|
|
|
@ -16,6 +16,14 @@
|
||||||
|
|
||||||
package android.hardware.bluetooth.audio@2.0;
|
package android.hardware.bluetooth.audio@2.0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The different audio parameter structs are used to provide a method to list
|
||||||
|
* all the Capabilities of a codec as well as to configure the codecs. All
|
||||||
|
* fields are bitfields unless specified. If used as a configuration, only one
|
||||||
|
* bit may be enabled. If used for Capabilities, enable all bits corresponding to
|
||||||
|
* supported features.
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* POSIX timespec.
|
* POSIX timespec.
|
||||||
*/
|
*/
|
||||||
|
@ -85,6 +93,25 @@ enum SbcChannelMode : uint8_t {
|
||||||
MONO = 0x08,
|
MONO = 0x08,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum SbcBlockLength : uint8_t {
|
||||||
|
BLOCKS_4 = 0x80,
|
||||||
|
BLOCKS_8 = 0x40,
|
||||||
|
BLOCKS_12 = 0x20,
|
||||||
|
BLOCKS_16 = 0x10,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum SbcNumSubbands : uint8_t {
|
||||||
|
SUBBAND_4 = 0x08,
|
||||||
|
SUBBAND_8 = 0x04,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum SbcAllocMethod : uint8_t {
|
||||||
|
/** SNR */
|
||||||
|
ALLOC_MD_S = 0x02,
|
||||||
|
/** Loudness */
|
||||||
|
ALLOC_MD_L = 0x01,
|
||||||
|
};
|
||||||
|
|
||||||
enum AacObjectType : uint8_t {
|
enum AacObjectType : uint8_t {
|
||||||
/** MPEG-2 Low Complexity. Support is Mandatory. */
|
/** MPEG-2 Low Complexity. Support is Mandatory. */
|
||||||
MPEG2_LC = 0x80,
|
MPEG2_LC = 0x80,
|
||||||
|
@ -96,6 +123,11 @@ enum AacObjectType : uint8_t {
|
||||||
MPEG4_SCALABLE = 0x10,
|
MPEG4_SCALABLE = 0x10,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum AacVariableBitRate : uint8_t {
|
||||||
|
ENABLED = 0x80,
|
||||||
|
DISABLED = 0x00,
|
||||||
|
};
|
||||||
|
|
||||||
enum LdacChannelMode : uint8_t {
|
enum LdacChannelMode : uint8_t {
|
||||||
/** Channel Mode: 3 bits */
|
/** Channel Mode: 3 bits */
|
||||||
UNKNOWN = 0x00,
|
UNKNOWN = 0x00,
|
||||||
|
@ -104,67 +136,117 @@ enum LdacChannelMode : uint8_t {
|
||||||
MONO = 0x04,
|
MONO = 0x04,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CodecConfiguration {
|
enum LdacQualityIndex : uint8_t {
|
||||||
/** Audio PCM data configuration */
|
// 990kbps
|
||||||
struct PcmDataConfiguration {
|
QUALITY_HIGH = 0x00,
|
||||||
/** Sampling rate for encoder */
|
// 660kbps
|
||||||
SampleRate sampleRate;
|
QUALITY_MID = 0x01,
|
||||||
/** Bits per sample for encoder */
|
// 330kbps
|
||||||
BitsPerSample bitsPerSample;
|
QUALITY_LOW = 0x02,
|
||||||
/** Channel mode for encoder */
|
// Adaptive Bit Rate mode
|
||||||
ChannelMode channelMode;
|
QUALITY_ABR = 0x7F,
|
||||||
} pcmDataConfiguration;
|
};
|
||||||
|
|
||||||
/** Encoded audio data codec configuration. It is used only if the
|
/** Used for Software Encoding audio feed parameters */
|
||||||
* HAL is responsible for encoding the PCM audio data. */
|
struct PcmParameters {
|
||||||
struct EncodedDataConfiguration {
|
SampleRate sampleRate;
|
||||||
/** Bluetooth A2DP codec */
|
ChannelMode channelMode;
|
||||||
CodecType codecType;
|
BitsPerSample bitsPerSample;
|
||||||
/**
|
};
|
||||||
* The encoded audio bitrate in bits / second.
|
|
||||||
* 0x00000000 - The audio bitrate is not specified / unused
|
/**
|
||||||
* 0x00000001 - 0x00FFFFFF - Encoded audio bitrate in bits/second
|
* Used for Hardware Encoding SBC codec parameters.
|
||||||
* 0x01000000 - 0xFFFFFFFF - Reserved
|
* minBitpool and maxBitpool are not bitfields.
|
||||||
*/
|
*/
|
||||||
uint32_t encodedAudioBitrate;
|
struct SbcParameters {
|
||||||
/** Peer MTU (in octets) */
|
SampleRate sampleRate;
|
||||||
uint16_t peerMtu;
|
SbcChannelMode channelMode;
|
||||||
/** Content protection by SCMS-T */
|
SbcBlockLength blockLength;
|
||||||
bool isScmstEnabled;
|
SbcNumSubbands numSubbands;
|
||||||
safe_union CodecSpecific {
|
SbcAllocMethod allocMethod;
|
||||||
/**
|
BitsPerSample bitsPerSample;
|
||||||
* SBC Codec specific information
|
uint8_t minBitpool;
|
||||||
* Refer to SBC Codec specific information elements in A2DP v1.3
|
uint8_t maxBitpool;
|
||||||
* Profile Specification.
|
};
|
||||||
*/
|
|
||||||
struct SbcData {
|
/** Used for Hardware Encoding AAC codec parameters */
|
||||||
/** Reserved: 4 bits | Channel Mode: 4 bits */
|
struct AacParameters {
|
||||||
SbcChannelMode channelMode;
|
AacObjectType objectType;
|
||||||
/** Block length: 4 bits | Subbands: 2 bits | Allocation Method: 2 bits */
|
SampleRate sampleRate;
|
||||||
uint8_t codecParameters;
|
ChannelMode channelMode;
|
||||||
/** Minimum bitpool value */
|
AacVariableBitRate variableBitRateEnabled;
|
||||||
uint8_t minBitpool;
|
BitsPerSample bitsPerSample;
|
||||||
/** Maximum bitpool value */
|
};
|
||||||
uint8_t maxBitpool;
|
|
||||||
} sbcData;
|
/**
|
||||||
struct AacData {
|
* Used for Hardware Encoding LDAC codec parameters
|
||||||
/** AAC Object Type */
|
* Only used when configuring the codec. When Capabilities are requested, this
|
||||||
AacObjectType aacObjectType;
|
* field is left empty since all qualities must be supported. Not a bitfield.
|
||||||
/** True if Variable Bit Rate is enabled */
|
*/
|
||||||
bool variableBitRateEnabled;
|
struct LdacParameters {
|
||||||
} aacData;
|
SampleRate sampleRate;
|
||||||
struct LdacData {
|
LdacChannelMode channelMode;
|
||||||
/** Reserved: 5 bits | Channel Mode: 3 bits */
|
LdacQualityIndex qualityIndex;
|
||||||
LdacChannelMode channelMode;
|
BitsPerSample bitsPerSample;
|
||||||
/**
|
};
|
||||||
* LDAC bitrate index value:
|
|
||||||
* 0x00 - High
|
/** Used for Hardware Encoding AptX and AptX-HD codec parameters */
|
||||||
* 0x01 - Mid
|
struct AptxParameters {
|
||||||
* 0x02 - Low
|
SampleRate sampleRate;
|
||||||
* 0x7F - ABR (Adaptive Bit Rate)
|
ChannelMode channelMode;
|
||||||
*/
|
BitsPerSample bitsPerSample;
|
||||||
uint8_t bitrateIndex;
|
};
|
||||||
} ldacData;
|
|
||||||
} codecSpecific;
|
/**
|
||||||
} encodedDataConfiguration;
|
* Used to specify the capabilities of the codecs supported by Hardware Encoding.
|
||||||
|
* AptX and AptX-HD both use the AptxParameters field.
|
||||||
|
*/
|
||||||
|
struct CodecCapabilities {
|
||||||
|
CodecType codecType;
|
||||||
|
|
||||||
|
safe_union Capabilities {
|
||||||
|
SbcParameters sbcCapabilities;
|
||||||
|
AacParameters aacCapabilities;
|
||||||
|
LdacParameters ldacCapabilities;
|
||||||
|
AptxParameters aptxCapabilities;
|
||||||
|
} capabilities;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Used to specify the capabilities of the different session types. */
|
||||||
|
safe_union AudioCapabilities {
|
||||||
|
PcmParameters pcmCapabilities;
|
||||||
|
CodecCapabilities codecCapabilities;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to configure a Hardware Encoding session.
|
||||||
|
* AptX and AptX-HD both use the AptxParameters field.
|
||||||
|
*/
|
||||||
|
struct CodecConfiguration {
|
||||||
|
CodecType codecType;
|
||||||
|
/**
|
||||||
|
* The encoded audio bitrate in bits / second.
|
||||||
|
* 0x00000000 - The audio bitrate is not specified / unused
|
||||||
|
* 0x00000001 - 0x00FFFFFF - Encoded audio bitrate in bits/second
|
||||||
|
* 0x01000000 - 0xFFFFFFFF - Reserved
|
||||||
|
*
|
||||||
|
* The HAL needs to support all legal bitrates for the selected codec.
|
||||||
|
*/
|
||||||
|
uint32_t encodedAudioBitrate;
|
||||||
|
/** Peer MTU (in octets) */
|
||||||
|
uint16_t peerMtu;
|
||||||
|
/** Content protection by SCMS-T */
|
||||||
|
bool isScmstEnabled;
|
||||||
|
safe_union CodecSpecific {
|
||||||
|
SbcParameters sbcConfig;
|
||||||
|
AacParameters aacConfig;
|
||||||
|
LdacParameters ldacConfig;
|
||||||
|
AptxParameters aptxConfig;
|
||||||
|
} config;
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Used to configure either a Hardware or Software Encoding session based on session type */
|
||||||
|
safe_union AudioConfiguration {
|
||||||
|
PcmParameters pcmConfig;
|
||||||
|
CodecConfiguration codecConfig;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue