Commit graph

26 commits

Author SHA1 Message Date
Frédéric Danis
00d51c3d31 bluez5: Rename codec API from *a2dp* to *media*
The BlueZ Media1 interface will not only be used for A2DP but also for
LE Audio and code related can be shared.
2022-09-15 11:17:20 +00:00
Frédéric Danis
76adcfaabe bluez5: Add AAC decoder 2022-08-02 11:12:25 +02:00
Pauli Virtanen
a8eb146d39 bluez5: tell the codec whether endpoint is sink or source
Add a flag A2DP_CODEC_FLAG_SINK to incidate a sink endpoint.

Also enum_config and caps_preference_cmp may need to know whether the
codec is being configured for SRC or SNK. Also add the flags argument to
init_props.

Bump codec API version.
2022-07-19 13:44:56 +00:00
Pauli Virtanen
783fbc507b bluez5: fix minor error handling/warning issues 2022-07-06 14:36:22 +00:00
Pauli Virtanen
3d4eafcb0f bluez5: allow codecs to produce multiple packets from same data
Codecs may need to fragment a single encoder frame across multiple
packets that are sent consecutively.

Allow codec->encode() to set need_flush=NEED_FLUSH_FRAGMENT, so that
sink should immediately call start_encode + encode with NULL input data,
to produce the next packet.

Previously, other return values than need_flush=1 were unused, so no
need to bump codec ABI for this.
2022-04-30 23:43:10 +03:00
Pauli Virtanen
a86ff85444 bluez5: tolerate devices sending incorrect AAC caps
There is a report (#1342) of a device setting multiple bits for AAC
object type in SetConfiguration, although this appears to be forbidden.

It's not completely clear if this was due to e.g. some BlueZ bug, but it
should be safe to be lax and try to guess what is wanted in such case,
instead of being strict, in case it was due to device bug.
2021-10-02 10:29:48 +00:00
Pauli Virtanen
3092e4a7be bluez5: implement validate_config for AAC
Allows bailing out earlier on invalid config, and setting transport
channel info.
2021-10-02 10:29:48 +00:00
Pauli Virtanen
59d572de09 bluez5: split A2DP codecs to separate SPA plugins
Make easier to package A2DP codecs separately, by splitting each to a
separate SPA plugin.  Adjust the code to not use a global variable for
the codec list.

The A2DP SPA interface API is in the bluez5 private headers, and not
exposed in installed SPA headers, as it's too close to the
implementation.
2021-09-03 20:40:30 +03:00
Barnabás Pőcze
f5d51162c4 treewide: mark things static and const
Mark some structures, arrays static/const at various places.
In some cases this prevents unnecessary initialization
when a function is entered.

All in all, the text segments across all shared
libraries are reduced by about 2 KiB. However,
the total size increases by about 2 KiB as well.
2021-06-30 14:44:08 +02:00
Huang-Huang Bao
9384ba5500 bluez5: add properties for A2DP codec sample rate & channel mode configuration
Those properties are set as reference sample rate and channels number for A2DP configuration selecting.
2021-05-03 10:07:42 +00:00
Huang-Huang Bao
4292e8fe7e
a2dp: set marker bit on AAC header 2021-04-10 04:51:16 +08:00
Huang-Huang Bao
5c93f780cf a2dp: improve a2dp sink codec data flushing
Let codec decides when rtp packet need to be sent (terminated by MTU size in most case).
LDAC encoding loop can now be terminated by reading if frame_num is written, no 'frame_count' updating is needed.
RTP payload fragmentation can now be implemented more easily based on this.
2021-03-31 11:14:58 +00:00
Pauli Virtanen
54e06d9df0 bluez5: add additional aac encoder options, and implement optional vbr 2021-03-27 11:47:34 +00:00
Pauli Virtanen
a552655edc bluez5: add bluetoothAudioCodec property to device
Also make the "codecless" profiles to automatically switch to the codec
profiles.
2021-03-26 16:59:07 +00:00
Huang-Huang Bao
1d390addb1 a2dp: allow codec to hold Props params
Initial Props value are parsed from device settings, further changes are triggered by 'set_param' on a2dp node.
Codec can then use props to tweak its transcoder.
2021-03-20 09:16:20 +00:00
Pauli Virtanen
0dee15d0f6 bluez5: aac: set reasonable default bitrate
Set default bitrate to a reasonable value in caps, and handle unknown or
bogus bitrates from device.
2021-02-13 19:03:13 +00:00
Pauli Virtanen
d57c9bd1bd bluez5: aac: reject MPEG4_AAC_LTP, MPEG4_AAC_SCA in select_config
These modes are not actually supported by the code, so it should not
accept them.
2021-02-10 00:18:29 +02:00
Wim Taymans
5bb7a0f573 a2dp-codecs: add settings to codec init function
To make it possible to add extra config options in init.
Also add a method to update settings in a codec.
2021-01-07 17:39:39 +01:00
Wim Taymans
ece8a95c29 bluez5: improve a2dp codec api
Pass dict to select_config to influence the selection
Make a method to validate a config.
Add spa_dict to the codec to pass more info around.
2021-01-07 17:28:49 +01:00
Gabriel Ebner
392fcda01f a2dp: add aac encoder 2020-12-23 06:15:15 +00:00
Wim Taymans
8b52e44836 bluez5: support other ldac bit depth
Make the format_info const in codec_init, we just need to read the
final negotiated format in some cases.
Add some more ldac bit depths we support.
2020-12-11 13:30:11 +01:00
Kamil Sołtysik
0a8a854721 Fix codec names in comments 2020-12-05 19:23:27 +01:00
Wim Taymans
106d597305 bluez5: add aptX and aptX HD codecs
They need the libopenaptx libraries from
https://github.com/pali/libopenaptx
2020-12-04 11:34:38 +01:00
Wim Taymans
9818582abe a2dp: fix aac codec compilation 2020-12-03 19:03:38 +01:00
Grzegorz Uriasz
c1530ba171 Use RegisterApplication in bluez5 for A2DP if possible 2020-11-02 09:14:37 +01:00
Wim Taymans
e18c4d76dc a2dp: move codecs to separate files 2020-10-19 12:12:21 +02:00