Extended the A2DP codec abstraction API

 * Added new A2DP codec-independent API and updated/renamed existing API.
   - A2D_InitCodecConfig()
   - A2D_InitDefaultCodec()
   - A2D_SetCodec()
   - A2D_IsCodecSupported() -> A2D_IsSourceCodecSupported()
   - A2D_IsSinkCodecSupported()
   - A2D_BuildSrc2SinkConfig() - previously bta_av_build_src_cfg()
   - A2D_IsSinkCodecSupported() - previously
       bta_av_co_audio_sink_supports_config()
   - A2D_IsSourceCodecSupported() - previously
       bta_av_co_audio_media_supports_config()
   - A2D_IsPeerSourceCodecSupported()
   - A2D_GetDefaultConfigSbc() - to be deleted
   - A2D_CodecSepIndexStr()

 * Added the corresponding SBC-specific implementation and a placeholder
   for vendor implementation.

 * Added the corresponding unit tests

Also:
 * Added type tA2D_CODEC_SEP_INDEX and list each known codec (Source or Sink):
   A2D_CODEC_SEP_INDEX_*
 * Renamed BTIF_SV_AV_AA_SBC_INDEX -> A2D_CODEC_SEP_INDEX_SBC
 * Renamed BTIF_SV_AV_AA_SBC_SINK_INDEX -> A2D_CODEC_SEP_INDEX_SBC_SINK
 * Renamed BTA_AV_MAX_SEPS -> A2D_CODEC_SEP_INDEX_MAX
 * Renamed tA2D_CODEC -> tA2D_CODEC_TYPE
 * Renamed tBTIF_AV_MEDIA_FEEDINGS -> tA2D_AV_MEDIA_FEEDINGS
 * Renamed tBTIF_AV_CODEC_ID -> tA2D_AV_CODEC_ID (to be deleted)
 * Renamed BTIF_AV_CODEC_PCM -> tA2D_AV_CODEC_PCM (to be deleted)
 * Renamed BTIF_AV_CODEC_NONE -> tA2D_AV_CODEC_NONE (to be deleted)
 * tBTIF_AV_MEDIA_FEED_CFG_PCM -> tA2D_AV_MEDIA_FEED_CFG_PCM (to be
   deleted)
 * tBTIF_AV_MEDIA_FEED_CFG -> tA2D_AV_MEDIA_FEED_CFG (to be deleted)
 * Moved SBC codec-related configuration and capabilities from
   btif/co/bta_av_co.cc to stack/a2dp/a2d_sbc.c :
   - bta_av_co_sbc_caps -> a2d_sbc_caps
   - bta_av_co_sbc_sink_caps -> a2d_sbc_sink_caps
   - btif_av_sbc_default_config -> a2d_sbc_default_config
 * Replaced usage of BTIF_AV_SBC_DEFAULT_SAMP_FREQ with
   A2D_SBC_IE_SAMP_FREQ_44
 * Merged bta_av_sbc_cfg_matches_cap() and bta_av_sbc_cfg_in_cap()
   into A2D_CodecInfoMatchesCapabilitySbc()
 * Misc other fixes and cleanup: use tA2D_STATUS as appropriate, remove
   FUNC_TRACE(), etc.

Bug: 30958229
Change-Id: I35e224754041cdce479c87e57d8e2c8b3adc8edd
22 files changed
tree: c68821af24a1fa1b3e562539ffd99eb26458d66c
  1. audio_a2dp_hw/
  2. bta/
  3. btcore/
  4. btif/
  5. build/
  6. conf/
  7. device/
  8. doc/
  9. embdrv/
  10. hci/
  11. include/
  12. main/
  13. osi/
  14. service/
  15. stack/
  16. test/
  17. tools/
  18. udrv/
  19. utils/
  20. vendor_libs/
  21. vnd/
  22. .gitignore
  23. .gn
  24. Android.mk
  25. BUILD.gn
  26. CleanSpec.mk
  27. EventLogTags.logtags
  28. MODULE_LICENSE_APACHE2
  29. NOTICE
  30. README.md
README.md

Fluoride Bluetooth stack

Building and running on AOSP

Just build AOSP - Fluoride is there by default.

Building and running on Linux

Instructions for Ubuntu, tested on 15.10 with GCC 5.2.1.

Install required libraries

sudo apt-get install libevent-dev

Install build tools

  • Install ninja build system
sudo apt-get install ninja-build

or download binary from https://github.com/ninja-build/ninja/releases

  • Install gn - meta-build system that generates NinjaBuild files.

Get sha1 of current version from here and then download corresponding executable:

wget -O gn http://storage.googleapis.com/chromium-gn/<gn.sha1>

i.e. if sha1 is "3491f6687bd9f19946035700eb84ce3eed18c5fa" (value from 24 Feb 2016) do

wget -O gn http://storage.googleapis.com/chromium-gn/3491f6687bd9f19946035700eb84ce3eed18c5fa

Then make binary executable and put it on your PATH, i.e.:

chmod a+x ./gn
sudo mv ./gn /usr/bin

Download source

mkdir ~/fluoride
cd ~/fluoride
git clone https://android.googlesource.com/platform/system/bt

Then fetch third party dependencies:

cd ~/fluoride/bt
mkdir third_party
cd third_party
git clone https://github.com/google/googletest.git
git clone https://android.googlesource.com/platform/external/libchrome
git clone https://android.googlesource.com/platform/external/modp_b64
git clone https://android.googlesource.com/platform/external/tinyxml2

And third party dependencies of third party dependencies:

cd fluoride/bt/third_party/libchrome/base/third_party
mkdir valgrind
cd valgrind
curl https://chromium.googlesource.com/chromium/src/base/+/master/third_party/valgrind/valgrind.h?format=TEXT | base64 -d > valgrind.h
curl https://chromium.googlesource.com/chromium/src/base/+/master/third_party/valgrind/memcheck.h?format=TEXT | base64 -d > memcheck.h

Fluoride currently has dependency on some internal Android projects, which also need to be downloaded. This will be removed in future:

cd ~/fluoride
git clone https://android.googlesource.com/platform/system/core
git clone https://android.googlesource.com/platform/hardware/libhardware
git clone https://android.googlesource.com/platform/system/media

Configure your build

We need to configure some paths to make the build successful. Run:

cd ~/fluoride/bt
gn args out/Default

This will prompt you to fill the contents of your "out/Default/args.gn" file. Make it look like below. Replace "/home/job" with path to your home directory, and don't use "~" in build arguments:

# Build arguments go here. Examples:
#   is_component_build = true
#   is_debug = false
# See "gn args <out_dir> --list" for available build arguments.

libhw_include_path = "/home/job/fluoride/libhardware/include"
core_include_path = "/home/job/fluoride/core/include"
audio_include_path = "/home/job/fluoride/media/audio/include"

Then generate your build files by calling

cd ~/fluoride/bt
gn gen out/Default

Build

cd ~/fluoride/bt
ninja -C out/Default all

This will build all targets (the shared library, executables, tests, etc) and put them in out/Default. To build an individual target, replace "all" with the target of your choice, e.g. ninja -C out/Default net_test_osi.

Run

cd ~/fluoride/bt/out/Default
LD_LIBRARY_PATH=./ ./bluetoothtbd -create-ipc-socket=fluoride