History log of /system/bt/stack/a2dp/a2dp_codec_config.cc
Revision Date Author Comments (<<< Hide modified files) (Show modified files >>>)
67ae84fb7f01d8458bfc1dcb506f32e7d9350d17 07-Apr-2017 Pavlin Radoslavov <pavlin@google.com> Add A2DP codec-specific information to dumpsys output

Now we print the following information:
* Current codec name
* Info for each supported codec:
- Priority
- Encoder interval (ms)
- Codec Config: Sampling rate, Bits per sample, Channel mode (MONO/STEREO)
- Selectable codec configuration
- Codec's local capability
- Packet counts (expected/dropped)
- PCM read counts (expected/actual)
- PCM read bytes (expected/actual)
* LDAC codec-specific info:
- LDAC quality mode: HIGH/MID/LOW/ABR
- LDAC saved transmit queue length [used in ABR mode]
* SBC codec-specific info:
- Frames counts (expected/dropped)

Sample of the new format is below:

---
A2DP Codecs State:
Current Codec: LDAC

A2DP LDAC State:
Priority: 1000000
Encoder interval (ms): 20
Config: Rate=96000 Bits=32 Mode=STEREO
Selectable: Rate=44100|48000|88200|96000 Bits=16|24|32 Mode=MONO|STEREO
Local capability: Rate=44100|48000|88200|96000 Bits=16|24|32 Mode=MONO|STEREO
Packet counts (expected/dropped) : 596 / 161
PCM read counts (expected/actual) : 2488 / 2488
PCM read bytes (expected/actual) : 2547712 / 2547712
LDAC quality mode : ABR
LDAC saved transmit queue length : 0

A2DP aptX-HD State:
Priority: 4001
Encoder interval (ms): 0
Config: Invalid
Selectable: Invalid
Local capability: Rate=44100|48000 Bits=24 Mode=STEREO
Packet counts (expected/dropped) : 0 / 0
PCM read counts (expected/actual) : 0 / 0
PCM read bytes (expected/actual) : 0 / 0

A2DP aptX State:
Priority: 3001
Encoder interval (ms): 0
Config: Rate=44100 Bits=16 Mode=STEREO
Selectable: Rate=44100|48000 Bits=16 Mode=STEREO
Local capability: Rate=44100|48000 Bits=16 Mode=STEREO
Packet counts (expected/dropped) : 0 / 0
PCM read counts (expected/actual) : 0 / 0
PCM read bytes (expected/actual) : 0 / 0

A2DP AAC State:
Priority: 2001
Encoder interval (ms): 20
Config: Rate=44100 Bits=16 Mode=STEREO
Selectable: Rate=44100|48000 Bits=16 Mode=STEREO
Local capability: Rate=44100|48000|88200|96000 Bits=16 Mode=STEREO
Packet counts (expected/dropped) : 0 / 0
PCM read counts (expected/actual) : 0 / 0
PCM read bytes (expected/actual) : 0 / 0

A2DP SBC State:
Priority: 1001
Encoder interval (ms): 20
Config: Rate=44100 Bits=16 Mode=STEREO
Selectable: Rate=44100 Bits=16 Mode=STEREO
Local capability: Rate=44100 Bits=16 Mode=STEREO
Packet counts (expected/dropped) : 580 / 0
PCM read counts (expected/actual) : 2900 / 2900
PCM read bytes (expected/actual) : 1484800 / 1484800
Frames counts (expected/dropped) : 3724 / 0
---

Bug: 36567128
Test: Stream A2DP and "adb shell dumpsys bluetooth_manager"
Change-Id: Idd86005b842a4e569b7df91b8bbaf0632ed7f7c9

(cherry picked from commit 302113d4e44f06e90f90a5903e33ae830edb58a3)
/system/bt/stack/a2dp/a2dp_codec_config.cc
3e4ecfdc4e4fd15cb47d17ed6bd4f660cb58e704 24-Feb-2017 Pavlin Radoslavov <pavlin@google.com> Add new internal API: enableOptionalCodecs()/disableOptionalCodecs()

This API can be used to enable the optional codecs, or disable them
and use only the mandatory SBC.
Internally, it is implemented by raising the SBC priority to
highest (so SBC will be used/selected), or reducing the SBC priority
to its default value (lowest).

Test: A2DP streaming and enabling/disabling/selecting optional codecs
Bug: 35873828
Change-Id: Ia1311d790441b7b5471c9fda7aeee8aa3306b16e
(cherry picked from commit 2073c3eb61f69864e645c50005f11c4e8b5e2588)
/system/bt/stack/a2dp/a2dp_codec_config.cc
a6ba5aca4e8c1a200b8cc29fb60d390a7196416a 01-Feb-2017 Pavlin Radoslavov <pavlin@google.com> Add a mechanism to configure the default A2DP codec priorities

Previously, the relative codec priorities were hard-codec internally.
The new mechanism uses the following configurable resources in
packages/apps/Bluetooth/res/values/config.xml to re-assign the
default codec priorities per device, or to explicitly disable a codec.

- a2dp_source_codec_priority_sbc
- a2dp_source_codec_priority_aac
- a2dp_source_codec_priority_aptx
- a2dp_source_codec_priority_aptx_hd
- a2dp_source_codec_priority_ldac

Those values are assigned on startup.
Also, they can be changed per device by using an overlay:
device/<VENDOR>/<DEVICE>/overlay/packages/apps/Bluetooth/res/values/config.xml

Test: Manually streaming to a headset
Change-Id: I5312299aea4a11c92fbe999d521adb39346b9866
/system/bt/stack/a2dp/a2dp_codec_config.cc
494e53e904e8aecc28178fda5856071776b2caf0 26-Jan-2017 Pavlin Radoslavov <pavlin@google.com> Update the A2DP Codec Config API

Previously, the JNI upcall would contain only the current codec config.
In the new API, the upcall contains:
1. The current codec config
2. The list of codecs containing the local codecs capabilities
3. The list of codecs containing the selectable codecs capabilities.
This list is the intersection of the local codecs capabilities
and the capabilities of the paired device.

Also, updated the codec backend to accomodate the above changes:
* Update all selectable codecs inside bta_av_co_audio_set_codec()
* Changed getCodecConfigAndCapabilities() to return current codec
config, local codecs capabilities, and selectable codecs capabilities.
* Updated each codec to compute and store a copy of the selectable
capabilities, and the local capabilities.
* Updated tA2DP_SBC_CIE to include new field bits_per_sample
(for consistency with the rest of the codecs).
* Replaced usage of codec_priority of 0 with BTAV_A2DP_CODEC_PRIORITY_DEFAULT
* If there is user codec (re)config call, we always send an upcall
to inform the Java layer about the most recent codec info.
Thus, the caller would always know whether the request succeeded or failed.

Test: A2DP streaming with headsets and switching the codecs
Change-Id: Ie7a5cd5c2ab01bb8676032be05bc2ad03baa1e3f
/system/bt/stack/a2dp/a2dp_codec_config.cc
d5f4960b425ac84cc7a9fd699f39c06869ce2666 04-Jan-2017 Pavlin Radoslavov <pavlin@google.com> Integration of the AAC codec for A2DP source

Also:
- Implemented data fragmentation inside bta_av_data_path()
that is RTP compatible.
- Do not use the codec_type when composing the RTP payload type
per RFC 3016, Section 4.2. That value doesn't have actual meaning
in the context of the Bluetooth supported codecs, and is ambiguous:
all vendor codecs map to the same value 0xFF.
- Updated support function A2DP_BitsSet() so it works for
up to 64-bit integers.
- Updated a log message inside l2c_data_write() to print
packet length and peer MTU on error.

Test: A2DP streaming to AAC headsets
Bug: 30958229
Change-Id: I1b530f1c5c495b8231fd68bed788d4567096683d
/system/bt/stack/a2dp/a2dp_codec_config.cc
8e419b13ecb1e33aeb785d0221bacc5744e51113 01-Nov-2016 Pavlin Radoslavov <pavlin@google.com> Integration of the LDAC codec for A2DP source

The codec can be used if the encoding shared library is installed
on the device:
libldacBT_enc.so

Also, increased the maximum number of SEPs AVDT_NUM_SEPS from 3
to 6 to accomodate Sink devices that support more than 3 codecs.

Test: A2DP streaming to LDAC headsets
Bug: 30958229
Change-Id: I114c3e6be2ebe1ac8aece62a3146637d37cd938e
/system/bt/stack/a2dp/a2dp_codec_config.cc
3a3ec66a1bb7f5c99b17239021d6d184a3abd4ee 25-Oct-2016 Pavlin Radoslavov <pavlin@google.com> Integration of the aptX and aptX-HD codecs for A2DP source

Each of the codecs can be used if the corresponding encoding
shared library is installed on the device:
- aptX: libaptX.so
- aptX-HD: libaptXHD.so

Test: A2DP streaming to aptX and aptX-HD headsets
Bug: 30958229
Change-Id: I1ca36da653721576f5a5b6bdac186b9ea2790c85
/system/bt/stack/a2dp/a2dp_codec_config.cc
5ce0116fbf5b530d5b93f11312096eade1021c1e 05-Dec-2016 Pavlin Radoslavov <pavlin@google.com> Add a mechanism for configuring the A2DP Source codecs

* Codec config internal abstraction:
- Add new classes A2dpCodecConfig and A2dpCodecs that (will)
encapsulate all codec-related APIs
- Add unit tests for the above two classes
- Add method A2dpCodecConfig.buildCodecConfig(), and use it when
creating the codec configuration instead of A2DP_InitSource2SinkCodec().
The new method can build the codec config by taking into account
optional user codec-related configuration preferences.
- Use the A2DP codec config API from the hardware/libhardware bt_av.h API
- Replace enum tA2DP_CODEC_SEP_INDEX with btav_a2dp_codec_index_t
from the bt_av.h API
- Move codec-specific functions from stack/include/a2dp_api.h
and stack/a2dp/a2dp_api.cc to stack/include/a2dp_codec_api.h
and stack/a2dp/a2dp_codec_config.cc
- Create a new base class A2dpCodecConfig() to hold some of the
codec-related state, and implement the corresponding A2dpCodecConfigSbc
and A2dpCodecConfigSbcSink derived classes.
- Move A2DP spec-related constants from stack/include/a2dp_api.h
to stack/include/a2dp_constants.h
- Move A2DP-related error codes from stack/include/a2dp_api.h
to stack/include/a2dp_error_codes.h
- Move A2DP SBC spec-related constants from stack/include/a2dp_sbc.h to
stack/include/a2dp_sbc_constants.h

* Implement the backend mechanism for handling user (re)configuration of
A2DP Source codecs as requested via the JNI API calls.
Also, any codec changes are reported back via JNI API callbacks.
The current audio parameter selection (sample rate, bits per
sample, channel mode - mono/stereo) is as follows:
- If the user selected parameters are acceptable (based on
local codec capability and the remote Sink capability),
those parameters are used.
- Else if the Audio HAL's requested parameters are acceptable,
those are used.
- Else if the default settings are acceptable, those are used.
- Else use the best match among the local and the remote device's
capabilities.

* Update the mechanism for handling OTA configuration requests from the
remote Sink device.
- The OTA prefered codec configuration is ignored if the current
codec configuration contains explicit user configuration, or if the
codec configuration for the same codec contains explicit user
configuration.

* Refactor the Audio HAL <-> Bluetooth audio parameter negotiation
mechanism:
The new mechanism gives some flexibility to the Media Framework to
choose the appropriate audio format (sample rate, bits per sample,
and channel mode - mono/stereo), and at the same time allows
the Bluetooth stack to double-check / overwrite the choice.
- out_get_parameters() on the Audio HAL side asks the Bluetooth stack
for all currently supported formats (for the current codec),
and returns them to the Media Framework: sample rate, bits per sample,
and channel mode (mono/stereo).
- The first time adev_open_output_stream() is called on the Audio HAL,
it asks the Bluetooth stack about the audio format currently selected
by the Bluetooth stack (based on codec negotiation with the Sink device,
and User Configuration).
- The second time adev_open_output_stream() is called on the Audio HAL,
its "config" will eventually contain the audio format selected
internally by the Media Framework. That audio format is sent to the
Bluetooth stack.
If that format is acceptable to the Bluetooth stack, the Bluetooth
stack will reconfigure itself internally, and will respond back with
those values. Otherwise, it will respond back with the values that
should be used instead.

* Misc other fixes and refactoring:
- Fix the BTA handling of A2DP codec reconfiguration
- Fix a bug in the implementation of A2DP_BitsSet(), and add the
approriate unit test. Also, fix the code that was using this function
incorrectly.
- The SBC encoder is compiled as a separate library
- Replace leftover usage of "false" with "FALSE" for macros, and
vice-versa for variable values.

Test: A2DP streaming to headsets, TestPlans/71390
Bug: 30958229
Change-Id: I440b6126e2250e33b0075f9789dd93154c007c2b
/system/bt/stack/a2dp/a2dp_codec_config.cc