Skip to content

Commit

Permalink
Command line utility for decoding A2DP codec blobs
Browse files Browse the repository at this point in the history
  • Loading branch information
arkq committed Jun 21, 2020
1 parent 8bcca3a commit 57d554c
Show file tree
Hide file tree
Showing 4 changed files with 455 additions and 0 deletions.
4 changes: 4 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ AC_ARG_ENABLE([rfcomm],
[AS_HELP_STRING([--enable-rfcomm], [enable building of bluealsa-rfcomm tool])])
AM_CONDITIONAL([ENABLE_RFCOMM], [test "x$enable_rfcomm" = "xyes"])

AC_ARG_ENABLE([a2dpconf],
[AS_HELP_STRING([--enable-a2dpconf], [enable building of a2dpconf tool])])
AM_CONDITIONAL([ENABLE_A2DPCONF], [test "x$enable_a2dpconf" = "xyes"])

AC_ARG_ENABLE([hcitop],
[AS_HELP_STRING([--enable-hcitop], [enable building of hcitop tool])])
AM_CONDITIONAL([ENABLE_HCITOP], [test "x$enable_hcitop" = "xyes"])
Expand Down
42 changes: 42 additions & 0 deletions src/a2dp-codecs.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,18 @@
.frequency1 = ((f) >> 4) & 0xff, \
.frequency2 = (f) & 0x0f,

#define ATRAC_CHANNEL_MODE_MONO 0x04
#define ATRAC_CHANNEL_MODE_DUAL_CHANNEL 0x02
#define ATRAC_CHANNEL_MODE_JOINT_STEREO 0x01

#define ATRAC_SAMPLING_FREQ_44100 0x02
#define ATRAC_SAMPLING_FREQ_48000 0x01

#define ATRAC_GET_BITRATE(a) \
((a).bitrate1 << 16 | (a).bitrate2 << 8 | (a).bitrate3)
#define ATRAC_GET_MAX_SUL(a) \
((a).max_sul1 << 8 | (a).max_sul2)

#define APTX_VENDOR_ID BT_COMPID_APT
#define APTX_CODEC_ID 0x0001

Expand Down Expand Up @@ -379,6 +391,21 @@ typedef struct {
uint8_t bitrate3;
} __attribute__ ((packed)) a2dp_aac_t;

typedef struct {
uint8_t rfa1:2;
uint8_t channel_mode:3;
uint8_t version:3;
uint8_t bitrate1:3;
uint8_t vbr:1;
uint8_t frequency:2;
uint8_t rfa2:2;
uint8_t bitrate2;
uint8_t bitrate3;
uint8_t max_sul1;
uint8_t max_sul2;
uint8_t rfa3;
} __attribute__ ((packed)) a2dp_atrac_t;

typedef struct {
a2dp_vendor_codec_t info;
uint8_t channel_mode:4;
Expand Down Expand Up @@ -450,6 +477,21 @@ typedef struct {
uint8_t bitrate3;
} __attribute__ ((packed)) a2dp_aac_t;

typedef struct {
uint8_t version:3;
uint8_t channel_mode:3;
uint8_t rfa1:2;
uint8_t rfa2:2;
uint8_t frequency:2;
uint8_t vbr:1;
uint8_t bitrate1:3;
uint8_t bitrate2;
uint8_t bitrate3;
uint8_t max_sul1;
uint8_t max_sul2;
uint8_t rfa3;
} __attribute__ ((packed)) a2dp_atrac_t;

typedef struct {
a2dp_vendor_codec_t info;
uint8_t frequency:4;
Expand Down
6 changes: 6 additions & 0 deletions utils/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ SUBDIRS = aplay rfcomm

bin_PROGRAMS =

if ENABLE_A2DPCONF
bin_PROGRAMS += a2dpconf
a2dpconf_CFLAGS = \
-I$(top_srcdir)/src
endif

if ENABLE_HCITOP
bin_PROGRAMS += hcitop
hcitop_CFLAGS = \
Expand Down
Loading

0 comments on commit 57d554c

Please sign in to comment.