2023-05-01 22:45:52

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: [BlueZ PATCH v3 1/4] client/player: Add support for Metadata in BAP Profile

From: Abhay Maheta <[email protected]>

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
---
client/player.c | 87 +++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 85 insertions(+), 2 deletions(-)

diff --git a/client/player.c b/client/player.c
index 5572cc566e79..cc35721d85b7 100644
--- a/client/player.c
+++ b/client/player.c
@@ -70,6 +70,7 @@ struct endpoint {
uint16_t cid;
uint16_t vid;
struct iovec *caps;
+ struct iovec *meta;
bool auto_accept;
bool acquiring;
uint8_t cig;
@@ -1582,6 +1583,7 @@ struct endpoint_config {
GDBusProxy *proxy;
struct endpoint *ep;
struct iovec *caps;
+ struct iovec *meta;
uint8_t target_latency;
const struct codec_qos *qos;
};
@@ -1592,6 +1594,7 @@ static void append_properties(DBusMessageIter *iter,
DBusMessageIter dict;
struct codec_qos *qos = (void *)cfg->qos;
const char *key = "Capabilities";
+ const char *meta = "Metadata";

dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, "{sv}", &dict);

@@ -1602,6 +1605,15 @@ static void append_properties(DBusMessageIter *iter,
DBUS_TYPE_BYTE, &cfg->caps->iov_base,
cfg->caps->iov_len);

+ if (cfg->meta->iov_len) {
+ g_dbus_dict_append_basic_array(&dict, DBUS_TYPE_STRING, &meta,
+ DBUS_TYPE_BYTE, &cfg->meta->iov_base,
+ cfg->meta->iov_len);
+
+ bt_shell_printf("Metadata:\n");
+ bt_shell_hexdump(cfg->meta->iov_base, cfg->meta->iov_len);
+ }
+
if (!qos)
goto done;

@@ -1699,6 +1711,9 @@ static DBusMessage *endpoint_select_properties_reply(struct endpoint *ep,
iov_append(&cfg->caps, preset->data.iov_base, preset->data.iov_len);
cfg->target_latency = preset->target_latency;

+ /* Copy metadata */
+ iov_append(&cfg->meta, cfg->ep->meta->iov_base, cfg->ep->meta->iov_len);
+
if (preset->qos.phy)
/* Set QoS parameters */
cfg->qos = &preset->qos;
@@ -1847,6 +1862,12 @@ static void endpoint_free(void *data)
g_free(ep->caps);
}

+ if (ep->meta) {
+ if (ep->meta->iov_base)
+ g_free(ep->meta->iov_base);
+ g_free(ep->meta);
+ }
+
if (ep->msg)
dbus_message_unref(ep->msg);

@@ -1917,10 +1938,38 @@ static gboolean endpoint_vendor_exists(const GDBusPropertyTable *property,
return ep->cid && ep->vid;
}

+static gboolean endpoint_get_metadata(const GDBusPropertyTable *property,
+ DBusMessageIter *iter, void *data)
+{
+ struct endpoint *ep = data;
+ DBusMessageIter array;
+
+ dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY,
+ DBUS_TYPE_BYTE_AS_STRING, &array);
+
+ dbus_message_iter_append_fixed_array(&array, DBUS_TYPE_BYTE,
+ &ep->meta->iov_base,
+ ep->meta->iov_len);
+
+ dbus_message_iter_close_container(iter, &array);
+
+ return TRUE;
+}
+
+static gboolean endpoint_metadata_exists(const GDBusPropertyTable *property,
+ void *data)
+{
+ struct endpoint *ep = data;
+
+ return ep->meta ? TRUE : FALSE;
+}
+
static const GDBusPropertyTable endpoint_properties[] = {
{ "UUID", "s", endpoint_get_uuid, NULL, NULL },
{ "Codec", "y", endpoint_get_codec, NULL, NULL },
{ "Capabilities", "ay", endpoint_get_capabilities, NULL, NULL },
+ { "Metadata", "ay", endpoint_get_metadata, NULL,
+ endpoint_metadata_exists },
{ "Vendor", "u", endpoint_get_vendor, NULL, endpoint_vendor_exists },
{ }
};
@@ -1930,6 +1979,7 @@ static void register_endpoint_setup(DBusMessageIter *iter, void *user_data)
struct endpoint *ep = user_data;
DBusMessageIter dict;
const char *key = "Capabilities";
+ const char *meta = "Metadata";

dbus_message_iter_append_basic(iter, DBUS_TYPE_OBJECT_PATH, &ep->path);

@@ -1955,6 +2005,15 @@ static void register_endpoint_setup(DBusMessageIter *iter, void *user_data)
bt_shell_hexdump(ep->caps->iov_base, ep->caps->iov_len);
}

+ if (ep->meta) {
+ g_dbus_dict_append_basic_array(&dict, DBUS_TYPE_STRING, &meta,
+ DBUS_TYPE_BYTE, &ep->meta->iov_base,
+ ep->meta->iov_len);
+
+ bt_shell_printf("Metadata:\n");
+ bt_shell_hexdump(ep->meta->iov_base, ep->meta->iov_len);
+ }
+
dbus_message_iter_close_container(iter, &dict);
}

@@ -2072,6 +2131,30 @@ static void endpoint_auto_accept(const char *input, void *user_data)
bt_shell_prompt_input(ep->path, "CIG (auto/value):", endpoint_cig, ep);
}

+static void endpoint_set_metadata(const char *input, void *user_data)
+{
+ struct endpoint *ep = user_data;
+
+ if (!strcasecmp(input, "n") || !strcasecmp(input, "no")) {
+ free(ep->meta->iov_base);
+ ep->meta = NULL;
+ goto done;
+ }
+
+ if (!ep->meta)
+ ep->meta = g_new0(struct iovec, 1);
+
+ ep->meta->iov_base = str2bytearray((char *) input, &ep->meta->iov_len);
+ if (!ep->meta->iov_base) {
+ free(ep->meta);
+ ep->meta = NULL;
+ }
+
+done:
+ bt_shell_prompt_input(ep->path, "Auto Accept (yes/no):",
+ endpoint_auto_accept, ep);
+}
+
static void endpoint_set_capabilities(const char *input, void *user_data)
{
struct endpoint *ep = user_data;
@@ -2091,8 +2174,8 @@ static void endpoint_set_capabilities(const char *input, void *user_data)
ep->caps->iov_len = 0x00;
}

- bt_shell_prompt_input(ep->path, "Auto Accept (yes/no):",
- endpoint_auto_accept, ep);
+ bt_shell_prompt_input(ep->path, "Enter Metadata (value/no):",
+ endpoint_set_metadata, ep);
}

static char *uuid_generator(const char *text, int state)
--
2.40.0


2023-05-01 22:46:26

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: [BlueZ PATCH v3 3/4] shared/shell: Fix not releasing prompt

From: Luiz Augusto von Dentz <[email protected]>

This fixes not releasing prompt when queueing a line to be executed
since it can be considered as user input if the init script is
attempting to enter it as response to prompt input.
---
src/shared/shell.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/src/shared/shell.c b/src/shared/shell.c
index 8b8b253d0bcf..757e16199ddf 100644
--- a/src/shared/shell.c
+++ b/src/shared/shell.c
@@ -1295,6 +1295,9 @@ static int bt_shell_queue_exec(char *line)

/* Queue if already executing */
if (data.line) {
+ /* Check if prompt is being held then release using the line */
+ if (!bt_shell_release_prompt(line))
+ return 0;
queue_push_tail(data.queue, strdup(line));
return 0;
}
--
2.40.0

2023-05-02 01:41:31

by bluez.test.bot

[permalink] [raw]
Subject: RE: [BlueZ,v3,1/4] client/player: Add support for Metadata in BAP Profile

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=744260

---Test result---

Test Summary:
CheckPatch FAIL 2.24 seconds
GitLint PASS 1.13 seconds
BuildEll PASS 37.12 seconds
BluezMake PASS 1257.00 seconds
MakeCheck PASS 13.05 seconds
MakeDistcheck PASS 204.41 seconds
CheckValgrind PASS 328.74 seconds
CheckSmatch WARNING 455.54 seconds
bluezmakeextell PASS 137.58 seconds
IncrementalBuild PASS 4310.09 seconds
ScanBuild PASS 1440.05 seconds

Details
##############################
Test: CheckPatch - FAIL
Desc: Run checkpatch.pl script
Output:
[BlueZ,v3,4/4] shared/shell: Fix smatch warning
WARNING:EMAIL_SUBJECT: A patch subject line should describe the change not the tool that found it
#72:
Subject: [BlueZ PATCH v3 4/4] shared/shell: Fix smatch warning

/github/workspace/src/src/13228364.patch total: 0 errors, 1 warnings, 8 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplace.

/github/workspace/src/src/13228364.patch has style problems, please review.

NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPDX_LICENSE_TAG SPLIT_STRING SSCANF_TO_KSTRTO

NOTE: If any of the errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.


##############################
Test: CheckSmatch - WARNING
Desc: Run smatch tool with source
Output:
src/shared/shell.c: note: in included file (through /usr/include/readline/readline.h):src/shared/shell.c: note: in included file (through /usr/include/readline/readline.h):src/shared/shell.c: note: in included file (through /usr/include/readline/readline.h):src/shared/shell.c: note: in included file (through /usr/include/readline/readline.h):src/shared/shell.c: note: in included file (through /usr/include/readline/readline.h):src/shared/shell.c: note: in included file (through /usr/include/readline/readline.h):


---
Regards,
Linux Bluetooth

2023-05-02 16:54:01

by patchwork-bot+bluetooth

[permalink] [raw]
Subject: Re: [BlueZ PATCH v3 1/4] client/player: Add support for Metadata in BAP Profile

Hello:

This series was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <[email protected]>:

On Mon, 1 May 2023 15:44:07 -0700 you wrote:
> From: Abhay Maheta <[email protected]>
>
> 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
>
> [...]

Here is the summary with links:
- [BlueZ,v3,1/4] client/player: Add support for Metadata in BAP Profile
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=f9376b13b3fe
- [BlueZ,v3,2/4] client/player: Fix crash when RegisterEndpoint fails
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=416b8375ffde
- [BlueZ,v3,3/4] shared/shell: Fix not releasing prompt
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=0b88ee29ff1d
- [BlueZ,v3,4/4] shared/shell: Fix smatch warning
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=3818b99c764e

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html