Commit Graph

59 Commits

Author SHA1 Message Date
Pauli Virtanen
1c60eb02e6 client/player: parse Google's Opus A2DP vendor codec capabilities
Support parsing Opus (Google) A2DP vendor codec capabilities.

Transport /org/bluez/hci0/dev_B8_7B_D4_32_44_15/sep3/fd2
        UUID: 0000110a-0000-1000-8000-00805f9b34fb
        Codec: 0xff (255)
        Media Codec: Vendor Specific A2DP Codec
        Vendor ID 0x000000e0
        Vendor Specific Codec ID 0x0001
        Vendor Specific Data: 0x92
                Vendor Specific Value (Opus [Google])
                Frequencies: 48kHz
                Channel modes: Stereo
                Frame durations: 20 ms
        Device: /org/bluez/hci0/dev_B8_7B_D4_32_44_15
        State: idle
        Delay: 0x0898 (2200)
        Volume: 0x001e (30)
        Endpoint: /org/bluez/hci0/dev_B8_7B_D4_32_44_15/sep3
2024-02-06 17:24:42 -05:00
Iulia Tanasescu
a692cc44dc client/player: Update bcast endpoint input prompts
This updates the input prompts for broadcast endpoint register and
config.

To register a broadcast endpoint, the user will be asked to enter
the supported stream locations and context types.

At broadcast source endpoint config, the user will provide stream
config options: The BIG that the new stream will be part of, the
stream Channel Allocation, and the metadata of the subgroup to
include the stream. These options will be used to configure the
BASE and the BIG.

The flow to create a Broadcast Source is the following:

[bluetooth]# endpoint.register 00001852-0000-1000-8000-
00805f9b34fb 0x06
[/local/endpoint/ep0] Auto Accept (yes/no): y
[/local/endpoint/ep0] Max Transports (auto/value): a
[/local/endpoint/ep0] Locations: 3
[/local/endpoint/ep0] Supported Context (value): 15
[NEW] Endpoint /org/bluez/hci0/pac_bcast0
Endpoint /local/endpoint/ep0 registered

[bluetooth]# endpoint.config /org/bluez/hci0/pac_bcast0
/local/endpoint/ep0 16_2_1
[/local/endpoint/ep0] BIG (auto/value): 1
[/local/endpoint/ep0] Enter channel location (value/no): 3
[/local/endpoint/ep0] Enter Metadata (value/no): 0x03 0x02
0x04 0x00

To create a Broadcast Sink, enter the following:

[bluetooth]# endpoint.register 00001851-0000-1000-8000-
00805f9b34fb 0x06
[/local/endpoint/ep0] Auto Accept (yes/no): y
[/local/endpoint/ep0] Max Transports (auto/value): a
[/local/endpoint/ep0] Locations: 3
[/local/endpoint/ep0] Supported Context (value): 15

[bluetooth]# scan on
[NEW] Endpoint /org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/
pac_bcast0

[bluetooth]# endpoint.config
/org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/pac_bcast0
/local/endpoint/ep0 16_2_1
2024-01-30 13:32:55 -05:00
Luiz Augusto von Dentz
0273602c19 client/player: Enable endpoint.show to work with local endpoints
This enables local endpoints to be printed with endpoint.show:

[bluetooth]# endpoint.show /local/endpoint/pac_snk/lc3
Endpoint /local/endpoint/pac_snk/lc3
	UUID 00002bc9-0000-1000-8000-00805f9b34fb
	Codec 0x06 (6)
	Capabilities.#0: len 0x03 type 0x01
	Capabilities.Sampling Frequencies: 0x00ff
	Capabilities.Sampling Frequency: 8 Khz (0x0001)
	Capabilities.Sampling Frequency: 11.25 Khz (0x0002)
	Capabilities.Sampling Frequency: 16 Khz (0x0004)
	Capabilities.Sampling Frequency: 22.05 Khz (0x0008)
	Capabilities.Sampling Frequency: 24 Khz (0x0010)
	Capabilities.Sampling Frequency: 32 Khz (0x0020)
	Capabilities.Sampling Frequency: 44.1 Khz (0x0040)
	Capabilities.Sampling Frequency: 48 Khz (0x0080)
	Capabilities.#1: len 0x02 type 0x02
	Capabilities.Frame Duration: 0x03
	Capabilities.Frame Duration: 7.5 ms (0x01)
	Capabilities.Frame Duration: 10 ms (0x02)
	Capabilities.#2: len 0x02 type 0x03
	Capabilities.Audio Channel Count: 0x03
	Capabilities.Audio Channel Count: 1 channel (0x01)
	Capabilities.Audio Channel Count: 2 channel (0x02)
	Capabilities.#3: len 0x05 type 0x04
	Capabilities.Frame Length: 30 (0x001e) - 240 (0x00f0)
	Locations 0x00000003 (3)
	SupportedContext 0x00000fff (4095)
	Context 0x00000fff (4095)
2024-01-30 13:32:27 -05:00
Luiz Augusto von Dentz
74e49f67e9 client/player: Add .name field to struct capabilities
This adds .name field to struct capabilities which is then used to form
the endpoint object path so it is easier to identify the endpoint
capabilities:

[bluetooth]# endpoint.list local
/local/endpoint/pac_snk/lc3
/local/endpoint/pac_src/lc3
/local/endpoint/bcaa/lc3
2024-01-29 16:17:30 -05:00
Luiz Augusto von Dentz
2faff4cadf client/player: Use util_iov_dup/util_iov_free whenever possible
This uses util_iov_dup/util_iov_free whenever possible.
2024-01-29 16:08:15 -05:00
Luiz Augusto von Dentz
423fcc4c4c client/player: Add metadata support to struct capabilities
This enables defining metadata as part of the struct capabilities.
2024-01-29 15:50:47 -05:00
Silviu Florian Barbulescu
ba943aadd0 client/player: Remove hardcoded BASE from player
Remove hardcoded BASE and QoS for broadcast and use the information
from the preset instead.
2024-01-23 10:30:14 -05:00
Luiz Augusto von Dentz
4908e58bd1 player: Fix endpoint.config for broadcast
endpoint.config where taking different arguments for broadcast which is
not recommended with shell as it doesn't support such a thing.

So instead of taking different arguments for broadcast both remote and
local endpoints shall be passed but in case of broadcast source both the
remote and the local endpoint actually refer to the same endpoint
registered by bluetoothctl:

endpoint.config /org/bluez/hci0/pac_bcast0 /local/endpoint/ep2 16_2_1
2024-01-19 13:12:40 -05:00
Luiz Augusto von Dentz
62cf4a2ab5 client/player: Add support for printing A2DP codec details
This adds support for printing Capabilities and Configuration of A2DP
endpoints and transports:

bluetoothctl> endpoint.show /org/bluez/hci0/dev_94_DB_56_F7_F2_88/sep1
Endpoint /org/bluez/hci0/dev_94_DB_56_F7_F2_88/sep1
	UUID: 0000110b-0000-1000-8000-00805f9b34fb
	Codec: 0x00 (0)
	Media Codec: SBC
	Channel Modes: Mono DualChannel Stereo JointStereo
	Frequencies: 44.1Khz 48Khz
	Subbands: 4 8
	Blocks: 4 8 12 16
	Bitpool Range: 2-53
	...

bluetoothctl> transport.show /org/bluez/hci0/dev_94_DB_56_F7_F2_88/sep1/fd7
Transport /org/bluez/hci0/dev_94_DB_56_F7_F2_88/sep1/fd7
	UUID: 0000110a-0000-1000-8000-00805f9b34fb
	Codec: 0x00 (0)
	Media Codec: SBC
	Channel Modes: JointStereo
	Frequencies: 48Khz
	Subbands: 8
	Blocks: 16
	Bitpool Range: 2-53
2024-01-17 16:22:15 -05:00
Luiz Augusto von Dentz
c85546cba7 client/player: Adjust the SDU size based on the number of locations
If there are multiple locations, aka. multiplexing, being selected then
that should be accounted properly on the SDU size since the presets only
account for just 1 channel.

Fixes: https://github.com/bluez/bluez/issues/662
2024-01-04 12:55:13 -05:00
Luiz Augusto von Dentz
e01208dac6 client/player: Use ChannelAllocation given on SelectProperties
This makes use of ChannelAllocation when present on SelectProperties
dictionary which is then passed on to bluetoothd and send over as part
of Codec Configuration:

< ACL Data TX: Handle 2048 flags 0x00 dlen 109
      ATT: Write Command (0x52) len 104
        Handle: 0x0098 Type: ASE Control Point (0x2bc6)
          Data: 0104050202060000000010020103020201030428000503010000000
	  6020206000000001002010302020103042800050302000000010202060000
	  0000100201030202010304280005030100000002020206000000001002010
	  302020103042800050302000000
            Opcode: Codec Configuration (0x01)
            Number of ASE(s): 4
            ASE: #0
            ASE ID: 0x05
            Target Latency: Balance Latency/Reliability (0x02)
            PHY: 0x02
            LE 2M PHY (0x02)
            Codec: LC3 (0x06)
            Codec Specific Configuration: #0: len 0x02 type 0x01
              Sampling Frequency: 16 Khz (0x03)
            Codec Specific Configuration: #1: len 0x02 type 0x02
              Frame Duration: 10 ms (0x01)
            Codec Specific Configuration: #2: len 0x03 type 0x04
              Frame Length: 40 (0x0028)
            Codec Specific Configuration: #3: len 0x05 type 0x03
           Location: 0x00000001
              Front Left (0x00000001)
            ASE: #1
            ASE ID: 0x06
            Target Latency: Balance Latency/Reliability (0x02)
            PHY: 0x02
            LE 2M PHY (0x02)
            Codec: LC3 (0x06)
            Codec Specific Configuration: #0: len 0x02 type 0x01
              Sampling Frequency: 16 Khz (0x03)
            Codec Specific Configuration: #1: len 0x02 type 0x02
              Frame Duration: 10 ms (0x01)
            Codec Specific Configuration: #2: len 0x03 type 0x04
              Frame Length: 40 (0x0028)
            Codec Specific Configuration: #3: len 0x05 type 0x03
           Location: 0x00000002
              Front Right (0x00000002)
            ASE: #2
            ASE ID: 0x01
            Target Latency: Balance Latency/Reliability (0x02)
            PHY: 0x02
            LE 2M PHY (0x02)
            Codec: LC3 (0x06)
            Codec Specific Configuration: #0: len 0x02 type 0x01
              Sampling Frequency: 16 Khz (0x03)
            Codec Specific Configuration: #1: len 0x02 type 0x02
              Frame Duration: 10 ms (0x01)
            Codec Specific Configuration: #2: len 0x03 type 0x04
              Frame Length: 40 (0x0028)
            Codec Specific Configuration: #3: len 0x05 type 0x03
           Location: 0x00000001
              Front Left (0x00000001)
            ASE: #3
            ASE ID: 0x02
            Target Latency: Balance Latency/Reliability (0x02)
            PHY: 0x02
            LE 2M PHY (0x02)
            Codec: LC3 (0x06)
            Codec Specific Configuration: #0: len 0x02 type 0x01
              Sampling Frequency: 16 Khz (0x03)
            Codec Specific Configuration: #1: len 0x02 type 0x02
              Frame Duration: 10 ms (0x01)
            Codec Specific Configuration: #2: len 0x03 type 0x04
              Frame Length: 40 (0x0028)
            Codec Specific Configuration: #3: len 0x05 type 0x03
           Location: 0x00000002
              Front Right (0x00000002)
2023-12-15 11:08:29 -05:00
Luiz Augusto von Dentz
477c41c683 client/player: Fix not prompting all parameter on endpoint.register
When Auto Accept is not enable not all parameters are requested.
2023-12-08 17:12:53 -05:00
Luiz Augusto von Dentz
813e1ce119 client/player: Add presets from GMAP
This adds the following presets from GMAP:

16_1_gs
16_2_gs
32_1_gs
32_2_gs
48_1_gs
48_2_gs
32_1_gr
32_2_gr
48_1_gr
48_2_gr
48_3_gr
48_4_gr
32_1_gr_l+r
32_2_gr_l+r
48_1_gr_l+r
48_2_gr_l+r
48_3_gr_l+r
48_4_gr_l+r
2023-11-22 15:58:36 -05:00
Luiz Augusto von Dentz
e126cf2049 client: Add support for setting Locations, SupportedContext and Context
This adds proper defaults for Locations, SupportedContext and Context
properties since bluetoothd no longer automatically set proper
defaults.
2023-10-20 16:25:31 -07:00
Luiz Augusto von Dentz
8a335099bc client: Make use of bap-debug functions
This make use of bap-debug functions to decode Capabilities,
Configuration and Metadata.
2023-10-20 11:05:08 -07:00
Luiz Augusto von Dentz
8e5142a1fa client: Make endpoint.show print ISO specific capabilities
This makes endpoint.show print Locations, SupportedContext, Context and
Qos capabilities.
2023-09-28 17:25:43 -07:00
Luiz Augusto von Dentz
1c79a45667 client: Make Endpoint.SelectProperties reply properly
This makes Endpoint.SelectProperties reply with QoS property since it
is now a single property.
2023-09-28 17:25:43 -07:00
Luiz Augusto von Dentz
d1bb05e3ed client: Make transport.show to print QoS configuration
This makes transport.show to print QoS configuration since it is now a
single property:

transport.show <transport>
Transport /org/bluez/hci0/dev_00_AA_01_01_00_03/pac_sink0/fd1
	UUID: 00002bcb-0000-1000-8000-00805f9b34fb
	Codec: 0x06 (6)
	Configuration:
  02 01 03 02 02 01 03 04 28 00                    ........(.
	Device: /org/bluez/hci0/dev_00_AA_01_01_00_03
	State: idle
	Endpoint: /org/bluez/hci0/dev_00_AA_01_01_00_03/pac_sink0
	QoS Key: CIG
	QoS Value: 0x00 (0)
	QoS Key: CIS
	QoS Value: 0x00 (0)
	QoS Key: Framing
	QoS Value: 0x00 (0)
	QoS Key: PresentationDelay
	QoS Value: 0x00009c40 (40000)
	QoS Key: Interval
	QoS Value: 0x00002710 (10000)
	QoS Key: Latency
	QoS Value: 0x000a (10)
	QoS Key: SDU
	QoS Value: 0x0028 (40)
	QoS Key: PHY
	QoS Value: 0x02 (2)
	QoS Key: Retransmissions
	QoS Value: 0x02 (2)
	Location: 0x00000003 (3)
	Links: /org/bluez/hci0/dev_00_AA_01_01_00_03/pac_source0/fd0
2023-09-28 17:25:43 -07:00
Luiz Augusto von Dentz
771b19e196 transport: Implement QoS property
This implements Transport.QoS as a dict instead of listing each field as
a individual property.
2023-09-28 17:25:43 -07:00
Claudia Draghicescu
0a824ce8f6 client/player: Remove Broadcast parameter
Remove unused gdbus parameter.
Fix length for Codec Specific Configuration.
2023-08-23 14:33:59 -07:00
Claudia Draghicescu
4352a42ec1 client/player: Add broadcast sink endpoint
Added support for broadcast sink registration using the 0x1851 UUID.
Added support for remote endpoint creation when a broadcast source
is discovered.
Added support for creating a local endpoint when the broadcast sink
endpoint was registered from an external application (Pipewire).
To test this feature use the following commands:

[bluetooth]# endpoint.register 00001851-0000-1000-8000-00805f9b34fb 0x06
[bluetooth]# scan on
[NEW] Endpoint /org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/pac_bcast0
[bluetooth]# endpoint.config
/org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/pac_bcast0
/local/endpoint/ep0 16_2_1
2023-08-08 15:10:05 -07:00
Silviu Florian Barbulescu
1dbd9ba1f1 Rename BAA_SERVICE to BCAA_SERVICE add BAA_SERVICE(0x1851)
Rename BAA_SERVICE to BCAA_SERVICE and added BAA_SERVICE(0x1851)
as UUID for the broadcast sink.
2023-07-31 10:33:25 -07:00
Luiz Augusto von Dentz
8f525dbccd client/player: Fix transport.acquire for linked transports
Linked (bi-directional) transports can be acquired on single D-Bus
method call which was not being handled properly by the current code
causing unexpected errors.
2023-06-20 12:54:23 -07:00
Luiz Augusto von Dentz
0053bc5472 client/player: Fix auto registration of broadcast endpoint
For broadcast endpoint broadcast must be set properly.
2023-06-20 12:54:23 -07:00
Silviu Florian Barbulescu
eb821743f9 client/player: Add support for broadcast source
This adds bluetoothctl support for broadcast source.
To test the current implementation use bluetoothctl with the commands:
endpoint.register 00001852-0000-1000-8000-00805f9b34fb 0x06
endpoint.config <created endpoint> <local endpoint> 16_2_1
transport.acquire <created transport>
transport.send <created transport> <file.wav>
2023-06-07 16:03:10 -07:00
Luiz Augusto von Dentz
f3977023f9 client/player: Add codec as parameter to endpoint.presets
This changes endpoint.presets command to take codec as parameter.
2023-05-12 13:31:53 -07:00
Luiz Augusto von Dentz
1707c35771 client/player: Fix not checking for SupportedUUIDs
When registering an endpoint it should always check for SupportedUUIDs.
2023-05-12 13:31:53 -07:00
Luiz Augusto von Dentz
fe16cf2a7e client/player: Add support to Max Transports in endpoint.register
[bluetooth]# endpoint.register 00002bc9-0000-1000-8000-00805f9b34fb 0x06
[/local/endpoint/ep0] Auto Accept (yes/no): y
[/local/endpoint/ep0] Max Transports (auto/value): 1
[/local/endpoint/ep0] CIG (auto/value): a
[/local/endpoint/ep0] CIS (auto/value): a
2023-05-12 13:31:53 -07:00
Luiz Augusto von Dentz
67fd8479f1 client/player: Fix crashes accessing metadata
If metadata is not set the respective iovec is left NULL so it needs to
be checked before accessing its fields.
2023-05-12 13:31:53 -07:00
Luiz Augusto von Dentz
416b8375ff client/player: Fix crash when RegisterEndpoint fails
If RegisterEndpoint fails when there are multiple adapters it would
attempt to free the same endpoint multiple times.
2023-05-01 12:27:20 -07:00
Abhay Maheta
f9376b13b3 client/player: Add support for Metadata in BAP Profile
This adds support for Metadata in BAP profile.
In order to register zero Metadata, 0 shall be
entered when prompted.

[bluetooth]# endpoint.register 00002bc9-0000-1000-8000-00805f9b34fb 0x06
[/local/endpoint/ep0] Enter Metadata (value/no): n
[/local/endpoint/ep0] Auto Accept (yes/no): y
[/local/endpoint/ep0] CIG (auto/value): a
[/local/endpoint/ep0] CIS (auto/value): a
Capabilities:
  03 01 ff 00 02 02 03 02 03 03 05 04 1e 00 f0 00  ................
Endpoint /local/endpoint/ep0 registered
2023-04-28 16:07:41 -07:00
Iulia Tanasescu
c4d9b99db5 Split bt_iso_qos into dedicated structures
Split bt_iso_qos into dedicated unicast and broadcast
structures and add additional broadcast parameters.
2023-03-31 14:33:28 -07:00
Luiz Augusto von Dentz
31ab084f07 client/player: Update High Reliability presets
This updates High Reliability presets as published in BAP 1.0.1:

https://www.bluetooth.com/specifications/bap-1-0-1/
2023-03-10 13:41:06 -08:00
Luiz Augusto von Dentz
24aeb31961 client: Allow transport.send command to work with multiple transports
This enables transport.send to work with multiple transports instead of
sending one by one which can create synchronization problems.
2023-03-02 12:19:39 -08:00
Luiz Augusto von Dentz
dcbdf5e67f media: Rework support of Vendor to use uint32_t as type
This reworks the handlings of Vendor property to use a single uint32_t.
2023-01-31 17:07:31 -08:00
Abhay Maheta
33d99e12c3 client/player: Add support for Company ID, Vendor ID
This adds support for Company ID and Vendor Codec ID in  BAP profile.
This also adds handling of Vendor Specific Coding format for BAP
Profile.

Now it allows to enter zero codec capabilities for vendor codec.
In order to register zero codec capabilities, 0 shall be
entered when prompted.
2023-01-31 17:07:31 -08:00
Luiz Augusto von Dentz
1270afa5aa client/player: Fix transport.send/receice tab completion
Commands transport.send/receive were not settings any completion
callback so this makes sure it uses transport_generator to generate the
list of transport that could be used to send.
2022-12-15 13:07:41 -08:00
Luiz Augusto von Dentz
318b1a19cb client/player: Print transport progress
This uses bt_shell_echo to print out the transfer progress on the echo
area.
2022-12-15 13:04:45 -08:00
Luiz Augusto von Dentz
e51d6c5f2e client/player: Use bt_shell_echo to print transfer progress
This uses bt_shell_echo to print transfer progress.
2022-12-15 13:04:33 -08:00
Luiz Augusto von Dentz
89b2072b4f client/player: Make transport.send non-blocking
This makes transport.send command non-blocking by using timerfd
callback to initiate the transfers.
2022-12-14 13:26:40 -08:00
Luiz Augusto von Dentz
e07c1e723e client/player: Fix not calculating time to wait
The difference of time start and current time may have advanced just
enough to add a second leaving start nanoseconds to be bigger.
2022-12-09 13:24:16 -08:00
Luiz Augusto von Dentz
a4bde19d3b client: Move common print_* functions to its own file
This move common print_* functions to its own file so they can be
properly reused instead of duplicating the code.
2022-12-02 11:20:26 -08:00
Luiz Augusto von Dentz
7642669e44 client/player: Add support for custom preset
This adds support for a custom preset which asks the user to enter its
configuration:

[bluetooth]# endpoint.presets 00002bc9-0000-1000-8000-00805f9b34fb custom
[Codec] Enter frequency (Khz): 48
[Codec] Enter frame duration (ms): 10
[Codec] Enter channel allocation: 0x000000003
[Codec] Enter frame length: 100
[QoS] Enter Target Latency (Low, Balance, High): Low
[QoS] Enter SDU Interval (us): 10000
[QoS] Enter Framing (Unframed, Framed): Unframed
[QoS] Enter PHY (1M, 2M): 2M
[QoS] Enter Max SDU: 200
[QoS] Enter RTN: 3
[QoS] Enter Max Transport Latency (ms): 20
[QoS] Enter Presentation Delay (us): 10000
2022-12-02 11:19:53 -08:00
Luiz Augusto von Dentz
5a872af406 client/player: Fix scan-build warning
This fixes the following warning:

client/player.c:1775:25: warning: Dereference of null pointer
[core.NullDereference]
iov_append(&cfg->caps, preset->data.iov_base, preset->data.iov_len);
                        ^~~~~~~~~~~~~~~~~~~~~
2022-11-21 13:03:04 -08:00
Luiz Augusto von Dentz
25a31f5a93 client/player: Fix attempting to acquire already acquired transport
If the transport has links check if the link is acquiring before
attempting to call Acquire otherwise it may cause an error to be
printed.
2022-09-29 13:58:41 -07:00
Christian Eggers
7b07f1f980 client/player: fix printf format string
Use macros from inttypes.h for correct printf format specifier for
int64_t
2022-09-26 10:57:00 -07:00
Luiz Augusto von Dentz
d8febc76a4 client/player: Fix checkpatch warning
This fixes the following checkpatch warning:

WARNING:LINE_SPACING: Missing a blank line after declarations
216: FILE: client/player.c:625:
+               GDBusProxy *proxy = l->data;
+               print_player(proxy, NULL);
2022-08-30 14:24:08 -07:00
Luiz Augusto von Dentz
d297a5873d client: Add -e/--endpoint option to auto register endpoints
This adds -e/--endpoint option that can be used to auto register
supported endpoints.
2022-08-29 14:36:06 -07:00
Luiz Augusto von Dentz
9e298f8402 client/player: Use QoS interval on transport.send
This makes use of QoS interval when sending a file.
2022-08-29 12:43:05 -07:00
Luiz Augusto von Dentz
dc61ec4419 client/player: Add support for PACS endpoints
This adds support for PAC_SINK and PAC_SOURCE endpoints as well as LC3
presets.
2022-08-29 12:43:05 -07:00