Add support for setting bcode on bcast sink
v2 cover Add support for setting bcode on bcast sink
This series allows the user to set the broadcast code before syncing to a broadcast source. Upon calling transport.select if the source is encrypted the user will be prompted to enter the broadcast code. Then, the code is set in the associated stream's QoS. From here it can be accessed by iso_do_big_sync, which will pass it to the kernel.
Vlad Pruteanu (8):
doc/media: Add Encryption and BCode fields to QoS property
transport: Make get_bcast_qos return the encryption flag
gdbus: Add g_dbus_proxy_set_property_dict
doc/media: Make QoS property readwrite
transport: Add set_bcast_qos method
shared/bap: Enable set qos method for BT_BAP_BCAST_SINK stream client/player: Prompt the user to enter the bcode
bap: Refresh qos stored in setup before doing BIG sync
client/player.c | 59 ++++++++++++++++ doc/org.bluez.MediaTransport.rst | 12 +++- gdbus/client.c | 115 +++++++++++++++++++++++++++++++ gdbus/gdbus.h | 6 ++ profiles/audio/bap.c | 2 + profiles/audio/transport.c | 39 ++++++++++- src/shared/bap.c | 2 +- 7 files changed, 230 insertions(+), 5 deletions(-)
Signature · 1 line
2.40.1
PATCH v2 1/8 doc/media: Add Encryption and BCode fields to QoS property
This adds the missing QoS fields, Encryption and BCode.
--- doc/org.bluez.MediaTransport.rst | 8 ++++++++ 1 file changed, 8 insertions(+)
doc/org.bluez.MediaTransport.rst +8 -0
@@ -242,6 +242,14 @@ dict QoS [readonly, optional, ISO only, experimental] Indicates configured framing. + :array{byte} BCode: + + Indicates the string used for encryption/decryption. + + :byte encryption: + + Indicates if the stream is encrypted. + :byte Options: Indicates configured broadcast options.
Signature · 1 line
2.40.1
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=884682
---Test result---
Test Summary:
CheckPatch PASS 3.21 seconds GitLint PASS 2.12 seconds BuildEll PASS 27.19 seconds BluezMake PASS 1750.76 seconds MakeCheck PASS 13.11 seconds MakeDistcheck PASS 181.81 seconds CheckValgrind PASS 255.83 seconds CheckSmatch WARNING 360.37 seconds bluezmakeextell PASS 122.20 seconds IncrementalBuild PASS 12970.89 seconds ScanBuild PASS 1055.91 seconds
Details
##############################
Test: CheckSmatch - WARNING
Desc: Run smatch tool with source
Output:src/shared/bap.c:288:25: warning: array of flexible structuressrc/shared/bap.c: note: in included file:./src/shared/ascs.h:88:25: warning: array of flexible structuressrc/shared/bap.c:288:25: warning: array of flexible structuressrc/shared/bap.c: note: in included file:./src/shared/ascs.h:88:25: warning: array of flexible structuressrc/shared/bap.c:288:25: warning: array of flexible structuressrc/shared/bap.c: note: in included file:./src/shared/ascs.h:88:25: warning: array of flexible structures
---
Regards,
Linux Bluetooth
PATCH v2 2/8 transport: Make get_bcast_qos return the encryption flag
In reply to Vlad PruteanuThis adds the encryption flag to the response returned by the get_bcast_qos method.
--- profiles/audio/transport.c | 2 ++ 1 file changed, 2 insertions(+)
profiles/audio/transport.c +2 -0
@@ -1174,6 +1174,8 @@ static gboolean get_bcast_qos(const GDBusPropertyTable *property, &bap->qos.bcast.packing);dict_append_entry (&dict,"Framing" ,DBUS_TYPE_BYTE , &bap->qos.bcast.framing); +dict_append_entry (&dict,"Encryption" ,DBUS_TYPE_BYTE , + &bap->qos.bcast.encryption);if (bap->qos.bcast.bcode) dict_append_array(&dict, "BCode", DBUS_TYPE_BYTE, &bap->qos.bcast.bcode->iov_base,
Signature · 1 line
2.40.1
PATCH v2 3/8 gdbus: Add g_dbus_proxy_set_property_dict
In reply to Vlad PruteanuThis adds a new gdbus function to allow for the setting of a dictionary-type property (a{sv}). It receives the name of the property, the name of the first entry to be set from the dictionary, it's type and value, followed by the second pair of entry_name, type, value, and so on, marking the end of the entries with NULL. Additionally, if the type is an array, the type of the array and it's length must also be proviedd. These values are passed as a dict entry, to the set method associated with the property. There, it must be parsed and the appropriate entry updated.
Example of usage:
g_dbus_proxy_set_property_dict(proxy, "dict_property_name", cb, user_data, NULL, "entry_1", DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, value_1_len, value_1, "entry_2", DBUS_TYPE_BYTE, value_2, NULL)
--- gdbus/client.c | 115 +++++++++++++++++++++++++++++++++++++++++++++++++ gdbus/gdbus.h | 6 +++ 2 files changed, 121 insertions(+)
gdbus/client.c +115 -0
@@ -4,6 +4,7 @@* D-Bus helper library * * Copyright (C) 2004-2011 Marcel Holtmann <[email protected]> +* Copyright 2024 NXP * * */
@@ -15,6 +16,7 @@#define _GNU_SOURCE#include <stdio.h> #include <string.h> +#include <stdarg.h> #include <glib.h> #include <dbus/dbus.h>
@@ -208,6 +210,44 @@ void g_dbus_dict_append_array(DBusMessageIter *dict, n_elements); } +static void append_dict_variant (DBusMessageIter *iter,char *entry,int type, +void *val, ...) +{ +DBusMessageIter variant, dict; +va_list args; +int array_type, size; + +dbus_message_iter_open_container (iter,DBUS_TYPE_VARIANT , + DBUS_TYPE_ARRAY_AS_STRING + DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING + DBUS_TYPE_STRING_AS_STRING + DBUS_TYPE_VARIANT_AS_STRING +DBUS_DICT_ENTRY_END_CHAR_AS_STRING , + &variant); + +dbus_message_iter_open_container (&variant,DBUS_TYPE_ARRAY , +DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING + DBUS_TYPE_STRING_AS_STRING + DBUS_TYPE_VARIANT_AS_STRING + DBUS_DICT_ENTRY_END_CHAR_AS_STRING, + &dict); + +va_start (args, val); + +if (type ==DBUS_TYPE_ARRAY ) { + array_type =va_arg (args, int); + size =va_arg (args, int); +g_dbus_dict_append_array (&dict, entry, array_type, val, size); + }else +g_dbus_dict_append_entry (&dict, entry, type, val); + +va_end (args); + +dbus_message_iter_close_container (&variant, &dict); + +dbus_message_iter_close_container (iter, &variant); +} +static void iter_append_iter (DBusMessageIter *base,DBusMessageIter *iter) {int type;
@@ -885,6 +925,81 @@ gboolean g_dbus_proxy_set_property_basic(GDBusProxy *proxy,return TRUE; } +gboolean g_dbus_proxy_set_property_dict (GDBusProxy *proxy, +const char *name,GDBusResultFunction function, +void *user_data,GDBusDestroyFunction destroy, +char *entry, ...) +{ +struct set_property_data *data; +GDBusClient *client; +DBusMessage *msg; +DBusMessageIter iter; +DBusPendingCall *call; +va_list args; +int type, array_type, size; +void *value; + +if (proxy ==NULL || name ==NULL ) +return FALSE; + + client = proxy->client; +if (client ==NULL ) +return FALSE; + + data = g_try_new0(struct set_property_data, 1); +if (data ==NULL ) +return FALSE; + + data->function = function; + data->user_data = user_data; + data->destroy = destroy; + + msg =dbus_message_new_method_call (client->service_name, + proxy->obj_path,DBUS_INTERFACE_PROPERTIES ,"Set" ); +if (msg ==NULL ) { +g_free (data); +return FALSE; + } + +dbus_message_iter_init_append (msg, &iter); +dbus_message_iter_append_basic (&iter,DBUS_TYPE_STRING , + &proxy->interface); +dbus_message_iter_append_basic (&iter,DBUS_TYPE_STRING , &name); + +va_start (args, entry); + +while (entry !=NULL ) { + type =va_arg (args, int); +if (type ==DBUS_TYPE_ARRAY ) { + array_type =va_arg (args, int); + size =va_arg (args, int); + value = va_arg(args, void *); +append_dict_variant (&iter, entry, type, &value, + array_type, size); + }else { + value = va_arg(args, void *); +append_dict_variant (&iter, entry, type, &value); + } + entry = va_arg(args, char *); + } + +va_end (args); + +if (g_dbus_send_message_with_reply (client->dbus_conn, msg, + &call,-1 ) == FALSE) { +dbus_message_unref (msg); +g_free (data); +return FALSE; + } + +dbus_pending_call_set_notify (call, set_property_reply, data, g_free); +dbus_pending_call_unref (call); + +dbus_message_unref (msg); + +return TRUE; +} + gboolean g_dbus_proxy_set_property_array(GDBusProxy *proxy, const char *name, int type, const void *value, size_t size, GDBusResultFunction function,
gdbus/gdbus.h +6 -0
@@ -4,6 +4,7 @@* D-Bus helper library * * Copyright (C) 2004-2011 Marcel Holtmann <[email protected]> +* Copyright 2024 NXP * * */
@@ -362,6 +363,11 @@ gboolean g_dbus_proxy_set_property_basic(GDBusProxy *proxy, GDBusResultFunction function, void *user_data, GDBusDestroyFunction destroy); +gboolean g_dbus_proxy_set_property_dict (GDBusProxy *proxy, +const char *name,GDBusResultFunction function, +void *user_data,GDBusDestroyFunction destroy, +char *entry, ...); + gboolean g_dbus_proxy_set_property_array(GDBusProxy *proxy, const char *name, int type, const void *value, size_t size, GDBusResultFunction function,
Signature · 1 line
2.40.1
PATCH v2 4/8 doc/media: Make QoS property readwrite
In reply to Vlad PruteanuUpdate the QoS property to allow for write, so that fields such as BCode can be updated.
--- doc/org.bluez.MediaTransport.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
doc/org.bluez.MediaTransport.rst +2 -2
@@ -149,8 +149,8 @@ array{object} Links [readonly, optional, ISO only, experimental] Linked transport objects which the transport is associated with. -dict QoS [readonly, optional, ISO only, experimental] -````````````````````````````````````````````````````` +dict QoS [readwrite, optional, ISO only, experimental] +`````````````````````````````````````````````````````` Only present when QoS is configured.
Signature · 1 line
2.40.1
PATCH v2 5/8 transport: Add set_bcast_qos method
In reply to Vlad PruteanuThis adds a set method for the QoS property of bcast transports. This is needed so that applications like bluetoothctl are able to modify the QoS (for example, for setting the broadcast code).
--- profiles/audio/transport.c | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-)
profiles/audio/transport.c +35 -2
@@ -5,7 +5,7 @@* * Copyright (C) 2006-2007 Nokia Corporation * Copyright (C) 2004-2009 Marcel Holtmann <[email protected]> -* Copyright 2023 NXP +* Copyright 2023-2024 NXP * * */
@@ -1208,13 +1208,46 @@ static gboolean qos_bcast_exists(const GDBusPropertyTable *property, void *data)return bap->qos.bcast.io_qos.phy !=0x00 ; } +static void set_bcast_qos (const GDBusPropertyTable *property, +DBusMessageIter *dict,GDBusPendingPropertySet id, +void *data) +{ +DBusMessageIter array, entry, value; +struct media_transport *transport = data; +struct bap_transport *bap = transport->data; +struct bt_bap_qos *bap_qos =bt_bap_stream_get_qos (bap->stream); +char *key; + +dbus_message_iter_recurse (dict, &array); + +dbus_message_iter_recurse (&array, &entry); +dbus_message_iter_get_basic (&entry, &key); + +dbus_message_iter_next (&entry); +dbus_message_iter_recurse (&entry, &value); + +if (!strcasecmp (key,"BCode" )) { +uint8_t *val; +int len; +DBusMessageIter array; + +dbus_message_iter_recurse (&value, &array); +dbus_message_iter_get_fixed_array (&array, &val, &len); + + bap_qos->bcast.bcode =util_iov_new (val, len); + } + +bt_bap_stream_qos (bap->stream, bap_qos,NULL ,NULL ); +g_dbus_pending_property_success (id); +} +static const GDBusPropertyTable transport_bap_bc_properties[] = { {"Device" ,"o" , get_device }, {"UUID" ,"s" , get_uuid }, {"Codec" ,"y" , get_codec }, {"Configuration" ,"ay" , get_configuration }, {"State" ,"s" , get_state }, - {"QoS" ,"a{sv}" , get_bcast_qos,NULL , qos_bcast_exists }, + {"QoS" ,"a{sv}" , get_bcast_qos, set_bcast_qos, qos_bcast_exists }, {"Endpoint" ,"o" , get_endpoint,NULL , endpoint_exists }, {"Location" ,"u" , get_location }, {"Metadata" ,"ay" , get_metadata },
Signature · 1 line
2.40.1
PATCH v2 6/8 shared/bap: Enable set qos method for BT_BAP_BCAST_SINK stream
In reply to Vlad PruteanuThis enables the set qos method, bap_bcast_qos, for the bcast sink streams as well.
--- src/shared/bap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
src/shared/bap.c +1 -1
@@ -2243,7 +2243,7 @@ static const struct bt_bap_stream_ops stream_ops[] = { bap_ucast_release, bap_ucast_detach), STREAM_OPS(BT_BAP_BCAST_SINK, bap_bcast_set_state, bap_bcast_get_state, - bap_bcast_config, NULL, bap_bcast_sink_enable, + bap_bcast_config, bap_bcast_qos, bap_bcast_sink_enable, bap_bcast_start, bap_bcast_disable, NULL, bap_bcast_metadata, bap_bcast_sink_get_dir, bap_bcast_get_location,
Signature · 1 line
2.40.1
PATCH v2 7/8 client/player: Prompt the user to enter the bcode
In reply to Vlad PruteanuThis adds support for entering the broadcast code on sink side. When the user selects a transport, if the transport is encrypted, the user will be prompted to enter the broadcast code before the process of transport selection can continue.
--- client/player.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+)
client/player.c +59 -0
@@ -5022,8 +5022,67 @@ static void cmd_acquire_transport(int argc, char *argv[])return bt_shell_noninteractive_quit (EXIT_SUCCESS ); } +static void set_bcode_cb (const DBusError *error,void *user_data) +{ +GDBusProxy *proxy = user_data; + +if (dbus_error_is_set (error)) { +bt_shell_printf ("Failed to set broadcast code: %s\n" , + error->name); +return bt_shell_noninteractive_quit (EXIT_FAILURE ); + } + +bt_shell_printf ("Setting broadcast code succeeded\n" ); + +if (!g_dbus_proxy_method_call (proxy,"Select" ,NULL , + select_reply, proxy,NULL )) +return bt_shell_noninteractive_quit (EXIT_FAILURE ); +} + +static void set_bcode (const char *input,void *user_data) +{ +GDBusProxy *proxy = user_data; +char *bcode =g_strdup (input); + +if (g_dbus_proxy_set_property_dict (proxy,"QoS" , + set_bcode_cb, user_data, +NULL ,"BCode" ,DBUS_TYPE_ARRAY ,DBUS_TYPE_BYTE , +strlen (bcode), bcode,NULL ) == FALSE) { +bt_shell_printf ("Setting broadcast code failed\n" ); +return bt_shell_noninteractive_quit (EXIT_FAILURE ); + } +} +static void transport_select (GDBusProxy *proxy,bool prompt) { +DBusMessageIter iter, array, entry, value; +unsigned char encryption; +const char *key; + +if (g_dbus_proxy_get_property (proxy,"QoS" , &iter) == FALSE) +return ; + +dbus_message_iter_recurse (&iter, &array); + +while (dbus_message_iter_get_arg_type (&array) != +DBUS_TYPE_INVALID ) { +dbus_message_iter_recurse (&array, &entry); +dbus_message_iter_get_basic (&entry, &key); + +if (!strcasecmp (key,"Encryption" )) { +dbus_message_iter_next (&entry); +dbus_message_iter_recurse (&entry, &value); +dbus_message_iter_get_basic (&value, &encryption); +if (encryption ==1 ) { +bt_shell_prompt_input ("" , +"Enter broadcast code:" , set_bcode, proxy); +return ; + } +break ; + } +dbus_message_iter_next (&array); + } +if (!g_dbus_proxy_method_call (proxy,"Select" ,NULL , select_reply, proxy,NULL )) {bt_shell_printf ("Failed select transport\n" );
Signature · 1 line
2.40.1
PATCH v2 8/8 bap: Refresh qos stored in setup before doing BIG sync
In reply to Vlad PruteanuWhen syncing to an encrypted stream, after setting the broadcast code, the qos values stored in the setup must be refreshed so that they reflect this change.
--- profiles/audio/bap.c | 2 ++ 1 file changed, 2 insertions(+)
profiles/audio/bap.c +2 -0
@@ -3066,6 +3066,8 @@ static void iso_do_big_sync(GIOChannel *io, void *user_data) iso_bc_addr.bc_bis[0 ] = bis_index; iso_bc_addr.bc_num_bis =1 ; +/* Refresh qos stored in setup */ + setup->qos = *bt_bap_stream_get_qos (setup->stream);/* Set the user requested QOS */ memset (&qos,0 ,sizeof (qos)); qos.bcast.big = setup->qos.bcast.big;
Signature · 1 line
2.40.1
This series was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:
Hello:
This series was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:
Quoted 16 lines · On Thu, 29 Aug 2024 12:51:58 +0300 you wrote:
This series allows the user to set the broadcast code before syncing to a broadcast source. Upon calling transport.select if the source is encrypted the user will be prompted to enter the broadcast code. Then, the code is set in the associated stream's QoS. From here it can be accessed by
iso_do_big_sync, which will pass it to the kernel.Vlad Pruteanu (8):
doc/media: Add Encryption and BCode fields to QoS property
transport: Makeget_bcast_qosreturn the encryption flag
gdbus: Addg_dbus_proxy_set_property_dict
doc/media: Make QoS property readwrite
transport: Addset_bcast_qosmethod
shared/bap: Enable set qos method forBT_BAP_BCAST_SINKstream client/player: Prompt the user to enter the bcode
bap: Refresh qos stored in setup before doing BIG sync
Quoted 1 line
[...]
Here is the summary with links:
- [BlueZ,v2,1/8] doc/media: Add Encryption and BCode fields to QoS property
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=5c9431fc2b97 - [BlueZ,v2,2/8] transport: Make get_bcast_qos return the encryption flag https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=f72fd8265000 - [BlueZ,v2,3/8] gdbus: Add g_dbus_proxy_set_property_dict https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=a1bde349db6b - [BlueZ,v2,4/8] doc/media: Make QoS property readwrite https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=b48d366458ed - [BlueZ,v2,5/8] transport: Add set_bcast_qos method https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=c922cc4a74e2 - [BlueZ,v2,6/8] shared/bap: Enable set qos method for BT_BAP_BCAST_SINK stream https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=8d43c209f084 - [BlueZ,v2,7/8] client/player: Prompt the user to enter the bcode https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=35f2bb95171e - [BlueZ,v2,8/8] bap: Refresh qos stored in setup before doing BIG sync https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=4ecfdef3b52f
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html