OSDN Git Service

Add a mechanism for configuring the A2DP Source codecs
authorPavlin Radoslavov <pavlin@google.com>
Mon, 5 Dec 2016 21:02:26 +0000 (13:02 -0800)
committerPavlin Radoslavov <pavlin@google.com>
Wed, 4 Jan 2017 02:09:43 +0000 (18:09 -0800)
commit5ce0116fbf5b530d5b93f11312096eade1021c1e
treeb631dacd6e8b1a054085b73c1ebfd43fc3ffadf6
parentdec747b3baa2afbd9301ffbf3dc68c02d5ade398
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
49 files changed:
audio_a2dp_hw/audio_a2dp_hw.cc
audio_a2dp_hw/audio_a2dp_hw.h
audio_a2dp_hw/audio_a2dp_hw_utils.cc
bta/av/bta_av_aact.cc
bta/av/bta_av_api.cc
bta/av/bta_av_int.h
bta/av/bta_av_main.cc
bta/include/bta_av_api.h
bta/include/bta_av_co.h
btif/Android.mk
btif/co/bta_av_co.cc
btif/include/btif_a2dp_source.h
btif/include/btif_av.h
btif/include/btif_av_co.h
btif/src/bluetooth.cc
btif/src/btif_a2dp_control.cc
btif/src/btif_a2dp_source.cc
btif/src/btif_av.cc
embdrv/sbc/decoder/Android.mk
embdrv/sbc/encoder/Android.mk [new file with mode: 0644]
embdrv/sbc/encoder/include/sbc_encoder.h
embdrv/sbc/encoder/include/sbc_types.h
embdrv/sbc/encoder/srce/sbc_encoder.c
include/bt_target.h
main/Android.mk
stack/Android.mk
stack/a2dp/a2dp_api.cc
stack/a2dp/a2dp_codec_config.cc [new file with mode: 0644]
stack/a2dp/a2dp_sbc.cc
stack/a2dp/a2dp_sbc_encoder.cc
stack/a2dp/a2dp_vendor.cc
stack/avdt/avdt_ccb.cc
stack/avdt/avdt_int.h
stack/avdt/avdt_scb.cc
stack/avdt/avdt_scb_act.cc
stack/avrc/avrc_api.cc
stack/avrc/avrc_bld_tg.cc
stack/include/a2dp_api.h
stack/include/a2dp_codec_api.h [new file with mode: 0644]
stack/include/a2dp_constants.h [new file with mode: 0644]
stack/include/a2dp_error_codes.h [new file with mode: 0644]
stack/include/a2dp_sbc.h
stack/include/a2dp_sbc_constants.h [new file with mode: 0644]
stack/include/a2dp_sbc_encoder.h
stack/include/a2dp_sbc_up_sample.h
stack/include/a2dp_vendor.h
stack/test/stack_a2dp_test.cc
udrv/include/uipc.h
udrv/ulinux/uipc.cc