From patchwork Wed Jul 12 08:58:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudia Draghicescu X-Patchwork-Id: 13309856 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BD54EEB64DD for ; Wed, 12 Jul 2023 09:03:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231613AbjGLJDc (ORCPT ); Wed, 12 Jul 2023 05:03:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229524AbjGLJCk (ORCPT ); Wed, 12 Jul 2023 05:02:40 -0400 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2078.outbound.protection.outlook.com [40.107.8.78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91748E65 for ; Wed, 12 Jul 2023 02:01:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PDaDNHJ6n5araAgLmtbXlHlWoPr+YMqswpQP2EUO6N2BdZCVcNqHRtADQNbwuVM3gyLnmVONzh6xQIa9bfJa1xf5d6S5GUYf81xXCrCq/ZKexkI6r+ByAw0ZYahv9HI85MQLXzXs0hLU5m3KZuYsZs24BDBH3IHtrZ9sFkO+uibXXR1z2ktPmiN6AVNgNDjsRXkTRkKdpeD9JQDRxABNJiyTjtrarpGWTRH/QoQT3wmrXBVXECC6n3lCUdiAHb4KptWqkfNh6y4VCFbmkGGChsy6/Vs+m6vpsMlhUbXeWB23REueNLqoAPEcxEtNiQSAtlQq9mVEqSmglw9UTqsbdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=UIYCGA4vTKlT73QdH4yyyNetbnOjjwag1DyqYXZk2CQ=; b=atqHmrGPZsGILtYp5Rtp+HwaXoXC66kPVJ/uPPwb2M++xUBBBu2w/CHxfvs4vs3XUG5trCOBQENiYGXhQJBmQYlMtVkdeYSxf4rA/Fo7aPDmCAWdORH/fLHi9XccxOyE9UeQXL1FWhsholz86pDl4hR8SjXu6f2LK5xgw+LFsDb15E/SikDD2WGFJ9HlFzucw10+7ThWu+W86D9ukjktQCADcqZIBh94O7uVtzA795rrJhm6vUXpsa0RyMZ2YMvMDI9WA+9bLmNBH5bqys00XpktaNguQoNlurfQQUKnyV7ofj2POPuxrxTnofME0hmWYQlLGNjaZH7XAPh+ZQCrBw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=UIYCGA4vTKlT73QdH4yyyNetbnOjjwag1DyqYXZk2CQ=; b=sRjqLYKo2wadMj7wC/Mz9krJju/rBVUBQsQURYZeAjZvDEfx/3GQ3Fagbm5hO38cjj3t/AKYQQ2BFlTC41AArMlpPgSeT2dZoJ+KdY6bcCunAXd6hVY1j25+OTaMpvcicvuBLdBLZAYqWeVa8kDVBRPcHUtPlvzrHOHfYvGR6GI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from GV1PR04MB9151.eurprd04.prod.outlook.com (2603:10a6:150:26::9) by PAXPR04MB8525.eurprd04.prod.outlook.com (2603:10a6:102:210::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.24; Wed, 12 Jul 2023 09:01:16 +0000 Received: from GV1PR04MB9151.eurprd04.prod.outlook.com ([fe80::2cc8:4c5d:9b6f:5cab]) by GV1PR04MB9151.eurprd04.prod.outlook.com ([fe80::2cc8:4c5d:9b6f:5cab%7]) with mapi id 15.20.6588.017; Wed, 12 Jul 2023 09:01:16 +0000 From: Claudia Draghicescu To: linux-bluetooth@vger.kernel.org Cc: iulia.tanasescu@nxp.com, mihai-octavian.urzica@nxp.com, silviu.barbulescu@nxp.com, vlad.pruteanu@nxp.com, andrei.istodorescu@nxp.com, Claudia Draghicescu Subject: [PATCH BlueZ 1/6] client/player: Add broadcast sink endpoint registration and configuration. Date: Wed, 12 Jul 2023 11:58:55 +0300 Message-Id: <20230712085900.5423-2-claudia.rosu@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230712085900.5423-1-claudia.rosu@nxp.com> References: <20230712085900.5423-1-claudia.rosu@nxp.com> X-ClientProxiedBy: AS4P250CA0004.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:5df::12) To GV1PR04MB9151.eurprd04.prod.outlook.com (2603:10a6:150:26::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1PR04MB9151:EE_|PAXPR04MB8525:EE_ X-MS-Office365-Filtering-Correlation-Id: 457b96d9-6941-4f3c-4c9c-08db82b68ca4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: c1WlKtm5oGZw55LUhoWBDa5tTl+OIZMrv55wlrRhmGDXs+qIp0/Wf7OFdn7QJq+efmPHPOexkXrLYUyiexDH8xVC0bI7ssJQz3G2w6hwPDemoahvLZOJ3uWRqK5GZLbwpgCaYEdNLTlv9hnKI70GD50xhM0v4D6/DAKFoeTLOe00bPWRgCC1ightncwfjmQ1utboxk+t+wGX8NMdAJ+BZXUisXid8b2gYnSqAZeeu6WdV419BDdBWY21x3HZFxm+3kMBw4vzTprW/WLbC6kwSvw4QQpwtDlgd9E0PERHLac1DqIGLM3LPEhsQzvthO01/lCW0xje4OG+YYheU9h2iSq369+GpR9EpiJ9iWyiKWuh1IpCllpMrBeSXar4K9ml3Nyxwa3QKutL4m5etYBLMZJxty+Tuh5VUfWGQtGPYjhlC73qbgqkjV7MV2y+Z0gXKz+1HXv0fQjoTpJ05VF3tRyL28HNUX12rr43HhNJFIiOBcr5Lqt5/+H02aM5tW/4/X6HvKrOB6E3eECv4Ryu9i7PKbheLmO1xWTSnQyjp3rYCbE5b9ftdVzd7suScxbYt8bvr5phEb6ABfvcHRYkGv2b+C1eSBzyAqZ4Q+Lr3llUZFv6grCWyQ54N+RMoSO9 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:GV1PR04MB9151.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(376002)(366004)(39860400002)(346002)(396003)(136003)(451199021)(55236004)(83380400001)(2616005)(2906002)(36756003)(86362001)(38350700002)(38100700002)(41300700001)(4326008)(52116002)(6916009)(6512007)(316002)(6486002)(5660300002)(8676002)(8936002)(478600001)(66946007)(66476007)(6666004)(66556008)(186003)(26005)(1076003)(6506007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: JBu9aZmpS+ZBblnborzHq8Cj4c5wf+Juv4EcJlwrAqpmK3XenbeRWmTnc1uL2kA0k0wFMjb0HkxhEy23vS9aShHjEBAJBwxXamKme+8YcHsgscJXFKtrs9nw4rH4tOqG4z66K6BETASr3EDkIrz4fwekO7E28p2KRcdAp+ynq1I6PU/d11ex61edHkkrQphibNzzYAVOrtUNCWRaIl5ILYM0gF4zHR6f8QLwpdGncs7q6yjZJbAkDvwCsuLNyJY+x+4JpI093vPgYxDwsdS3jYhPX93U9IvVHzac1pSgRtaJygWxFDgFOlzUM1ecATmKcpl/6GKmuO/0XOVv6hGIxSOnmzukXyv6NeruYgdggBMK+KF4aEXjdxZEstSp6BOj1ogMezpD887A8bGwTH1Q2AUj/+GYlaMWHgdpwOSf5So/xB5bY9iqX1BujxXRirD6F/GEoYFTuVgTnyBAV0YiVtCJAnuh2qRYfwpuMZK/qXeCG7oBpvgTPkoWyGjh99KN5BkzCIR49ChhHTUMiL9hl/qKch3zB8zculpQHwYNDvCdEjTzeEtIZQSKMazdY2dcYtOud7wUp4waDf1rDH7qzmd0MbuN81AHrzKlaWoW2jG6u7SEVGmKg9mXyHiBQzbOqrc4vI10/iFpzNdaNUUm8WrA9SWlT32ClgOqO3/IfHWua+qOdgTOe0EfesiS50y229hZar5umCJPzINC4kFeuVB81A3+hwtqZlerKVV7MHkDOMn99KVzHYUStJIwv12x2Zfx7i0Y2Iv+Q8VTkKKRWS78pHEE1wvhJJWy9Dv4kSGUmQ6a0VVvutYNsGqfkTy6GW1JvETQPNm6jmuk+FufQkt2K+ovUpaVDRBECwFayT8FH0HMcN7g4ANTfUB49cI7y7jzX08BHafxshk+l37okHwYpidDVxzOy6a7LYzMOt/brr+fp+wTh5jDQe6baxzTvsJUKf2XZghkyI92xpQ7O1jopvP3MXIwbD734DIj0MIWd7DFF6kI2B4zTTzK4APoppkY3Pfmtioj2ETJNZbQVzhgU+coY/3Q501zWpgPZ4pnYwSQAx5YYzu+1AlCDrLix80D0Vb/8ek76gQ7nIs7iAJ5aBduPiEh2AIyANX/vCsKgZQ3/vX7iR40neI517lwM2VNs4mhcGZtTp6HjWlBC4Wei74gXx6zIzTDzz4NTj/+Ce14iyf90k+1zBCThgWnqQj/2B8uKAknABuwVyyH7kcPfoxVRqoV222sl63AFCaJeHvgfkvkohd2PCXTJXxMC6A1eQx0fzoEt7sQ7Ewb0J5h+djwcYSLBDSSLvVaoN1jRjl+/PuWxU6BG+tXzb8zmAnPE+yeC2evLtSxUNWj7ZPgfzuHGo7Va36fi3GFCqbwyWzqjWUkn1txCzreXyv+uuys58SCkYKmsVPQuyIj/1NHiBcmFP2x+r5pgMG8Vel22DphK3KjQK96q1ZgFpdxWO2XvkG+fkYM1SQGFso7pDaRWSU6JJi0nTrqthb8zSs1X9ZE/WLdHZKdx+ENpWlndy6b7g34nVJCMpP0k6aqmdXn+9fN/jfHBKGqroeZSVpZGt5Bv0qSPdw1640QjPg+ X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 457b96d9-6941-4f3c-4c9c-08db82b68ca4 X-MS-Exchange-CrossTenant-AuthSource: GV1PR04MB9151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jul 2023 09:01:15.9687 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: wfi3kIsrv672Hm1aGuVWbcwMH6JiZjR6iLWQhWPoDiFTbg6EIGWkBYU7Hn8rY7y94TtvCjnbGeUqwaH19I8Xog== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8525 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Added support for broadcast sink registration using the UUID for PAC sink. Added support for broadcast source discovery. Added in the endpoint configuration command a new parameter for source address that triggers source synchronization and stream configuration. To test this feature use the following commands: [bluetooth]# endpoint.register 00002bc9-0000-1000-8000-00805f9b34fb 0x06 [/local/endpoint/ep0] Auto Accept (yes/no): y [/local/endpoint/ep0] Max Transports (auto/value): a [/local/endpoint/ep0] unicast/broadcast (u/b): b [/local/endpoint/ep0] BIG (auto/value): a [/local/endpoint/ep0] BIS (auto/value): a [bluetooth]# scan on NOTE! in the list of scanned devices, the broadcast source will be printed in green. [bluetooth]# endpoint.config /org/bluez/hci0/pac_bcast0 /local/endpoint/ep0 16_2_1 --- client/player.c | 187 +++++++++++++++++++++++++++++++++++++++++++++--- client/player.h | 3 + 2 files changed, 181 insertions(+), 9 deletions(-) diff --git a/client/player.c b/client/player.c index e5084967a..fd2c89f0b 100644 --- a/client/player.c +++ b/client/player.c @@ -81,6 +81,7 @@ struct endpoint { struct preset *preset; bool broadcast; struct iovec *bcode; + struct queue *bcast_sources; }; static DBusConnection *dbus_conn; @@ -94,6 +95,11 @@ static GList *local_endpoints = NULL; static GList *transports = NULL; static struct queue *ios = NULL; +struct bcast_source { + GDBusProxy *proxy; + uint32_t bcast_id; +}; + struct transport { GDBusProxy *proxy; int sk; @@ -2285,6 +2291,9 @@ static void register_endpoint_setup(DBusMessageIter *iter, void *user_data) bt_shell_hexdump(ep->meta->iov_base, ep->meta->iov_len); } + g_dbus_dict_append_entry(&dict, "Broadcast", DBUS_TYPE_BOOLEAN, + &ep->broadcast); + dbus_message_iter_close_container(iter, &dict); } @@ -2424,6 +2433,28 @@ static void endpoint_iso_group(const char *input, void *user_data) endpoint_iso_stream, ep); } +static void endpoint_iso_mode(const char *input, void *user_data) +{ + struct endpoint *ep = user_data; + + if (!strcasecmp(input, "u") || !strcasecmp(input, "unicast")) { + ep->broadcast = false; + } else if (!strcasecmp(input, "b") || !strcasecmp(input, "broadcast")) { + ep->broadcast = true; + ep->bcast_sources = queue_new(); + } else { + bt_shell_printf("Invalid input for Auto Accept\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + if (!ep->broadcast) + bt_shell_prompt_input(ep->path, "CIG (auto/value):", + endpoint_iso_group, ep); + else + bt_shell_prompt_input(ep->path, "BIG (auto/value):", + endpoint_iso_group, ep); +} + static void endpoint_max_transports(const char *input, void *user_data) { struct endpoint *ep = user_data; @@ -2445,7 +2476,10 @@ static void endpoint_max_transports(const char *input, void *user_data) if (ep->broadcast) bt_shell_prompt_input(ep->path, "BIG (auto/value):", - endpoint_iso_group, ep); + endpoint_iso_group, ep); + else if (!strcmp(ep->uuid, PAC_SINK_UUID)) + bt_shell_prompt_input(ep->path, "unicast/broadcast (u/b):", + endpoint_iso_mode, ep); else bt_shell_prompt_input(ep->path, "CIG (auto/value):", endpoint_iso_group, ep); @@ -2472,13 +2506,6 @@ static void endpoint_auto_accept(const char *input, void *user_data) bt_shell_printf("Invalid input for Auto Accept\n"); return bt_shell_noninteractive_quit(EXIT_FAILURE); } - - if (ep->broadcast) - bt_shell_prompt_input(ep->path, "BIG (auto/value):", - endpoint_iso_group, ep); - else - bt_shell_prompt_input(ep->path, "CIG (auto/value):", - endpoint_iso_group, ep); } static void endpoint_set_metadata(const char *input, void *user_data) @@ -2714,6 +2741,103 @@ static void endpoint_set_config(struct endpoint_config *cfg) } } +static void sink_create_reply(DBusMessage *message, void *user_data) +{ + DBusError error; + + dbus_error_init(&error); + + if (dbus_set_error_from_message(&error, message) == TRUE) { + bt_shell_printf("Failed to create broadcast sink: %s\n", + error.name); + dbus_error_free(&error); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + return bt_shell_noninteractive_quit(EXIT_SUCCESS); +} + +struct bcast_sink { + uint8_t bc_sid; + uint8_t bc_num_bis; +} bcast_sink = { + .bc_sid = 1, + .bc_num_bis = 1, +}; + +static bool match_bcast_source_by_address( + const void *data, const void *match_data) +{ + const struct bcast_source *source = data; + const char *addr = match_data; + char *source_addr; + DBusMessageIter iter; + + if (!g_dbus_proxy_get_property(source->proxy, "Address", &iter)) + return false; + + dbus_message_iter_get_basic(&iter, &source_addr); + + if (!strcasecmp(addr, source_addr)) + return true; + + return false; +} +static void sink_create_setup(DBusMessageIter *iter, void *user_data) +{ + struct bcast_source *bcast_source = user_data; + DBusMessageIter dict, source_iter; + const char *source_type, *source_address; + + g_dbus_proxy_get_property(bcast_source->proxy, "Address", &source_iter); + + dbus_message_iter_get_basic(&source_iter, &source_address); + + g_dbus_proxy_get_property(bcast_source->proxy, "AddressType", + &source_iter); + + dbus_message_iter_get_basic(&source_iter, &source_type); + + dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, "{sv}", &dict); + + g_dbus_dict_append_entry(&dict, "SourceAddress", DBUS_TYPE_STRING, + &source_address); + + g_dbus_dict_append_entry(&dict, "SourceAddressType", DBUS_TYPE_STRING, + &source_type); + + g_dbus_dict_append_entry(&dict, "BIS", DBUS_TYPE_BYTE, + &bcast_sink.bc_sid); + + g_dbus_dict_append_entry(&dict, "NumBis", DBUS_TYPE_BYTE, + &bcast_sink.bc_num_bis); + + g_dbus_dict_append_entry(&dict, "BcastID", DBUS_TYPE_UINT32, + &bcast_source->bcast_id); + + dbus_message_iter_close_container(iter, &dict); +} + +static void endpoint_bcast_sink_sync(struct endpoint_config *cfg, char *source) +{ + struct bcast_source *bcast_source = NULL; + + bcast_source = queue_find(cfg->ep->bcast_sources, + match_bcast_source_by_address, source); + + if (!bcast_source) { + bt_shell_printf("Source not found\n"); + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } + + + if (g_dbus_proxy_method_call(cfg->proxy, "BcastSinkCreate", + sink_create_setup, sink_create_reply, + bcast_source, NULL) == FALSE) { + return bt_shell_noninteractive_quit(EXIT_FAILURE); + } +} + static void endpoint_config(const char *input, void *user_data) { struct endpoint_config *cfg = user_data; @@ -2771,6 +2895,10 @@ static void cmd_config_endpoint(int argc, char *argv[]) cfg->qos = &preset->qos; endpoint_set_config(cfg); + + if (argv[4]) + endpoint_bcast_sink_sync(cfg, argv[4]); + return; } @@ -3172,7 +3300,7 @@ static const struct bt_shell_menu endpoint_menu = { { "unregister", "", cmd_unregister_endpoint, "Register Endpoint", local_endpoint_generator }, - { "config", " [preset]", + { "config", " [preset] [source]", cmd_config_endpoint, "Configure Endpoint", endpoint_generator }, @@ -4238,3 +4366,44 @@ void player_remove_submenu(void) g_dbus_client_unref(client); queue_destroy(ios, transport_free); } + +void player_add_bcast_source(GDBusProxy *proxy, uint8_t *service_data, int len) +{ + GList *l; + + for (l = local_endpoints; l; l = g_list_next(l)) { + struct endpoint *ep = l->data; + + if (ep->broadcast && ep->bcast_sources) { + struct bcast_source *bcast_source = + new0(struct bcast_source, 1); + + bcast_source->proxy = proxy; + bcast_source->bcast_id = get_le24(service_data); + queue_push_tail(ep->bcast_sources, bcast_source); + } + } + +} +static bool match_bcast_source_by_proxy(const void *data, + const void *user_data) +{ + const struct bcast_source *bcast_source = data; + + if (bcast_source->proxy == user_data) + return true; + + return false; +} +void player_remove_bcast_source(GDBusProxy *proxy) +{ + GList *l; + + for (l = local_endpoints; l; l = g_list_next(l)) { + struct endpoint *ep = l->data; + + if (ep->broadcast && ep->bcast_sources) + queue_remove_if(ep->bcast_sources, + match_bcast_source_by_proxy, proxy); + } +} diff --git a/client/player.h b/client/player.h index e7778cb1e..21e73e8ed 100644 --- a/client/player.h +++ b/client/player.h @@ -10,3 +10,6 @@ void player_add_submenu(void); void player_remove_submenu(void); +void player_add_bcast_source(GDBusProxy *proxy, + uint8_t *service_data, int len); +void player_remove_bcast_source(GDBusProxy *proxy); From patchwork Wed Jul 12 08:58:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudia Draghicescu X-Patchwork-Id: 13309857 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E896CEB64D9 for ; Wed, 12 Jul 2023 09:03:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231975AbjGLJDe (ORCPT ); Wed, 12 Jul 2023 05:03:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233050AbjGLJCk (ORCPT ); Wed, 12 Jul 2023 05:02:40 -0400 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2054.outbound.protection.outlook.com [40.107.7.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CAF24A9 for ; Wed, 12 Jul 2023 02:01:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jOgqEH3n4fxRwqjPX/hC2nRKB03GQ+rVqzv4mUqbFPdewDjdypSxL3/qvsInb+JZsRjCguiZsL51dqVPuPBpqOwj+TvBcl1m/g6NL7R5D3sneVitcm3bVn6QQPHNhWCqiLoir5hNh1RaqXc7k9Q4vtBWnVFceLnbDMLMZZ3Tj97EP010xDMQKmP7gouhyoNgfgL+OJjiZVjZCumbdf45c9wh0n/j71seWiaIPXimXmr4GrXHrptpfGO2lbxvC4RRbVLi7hp0FJDKp6PG+dcj74PcrcoKVG8hXWvxPOnLkE00WHxVWlXfVR4xBoeAy/M8h+S9InfmShDVS4ngjqxCCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=CBO3i7KxxUyhz6uM2auvsfSTOk8uXDuKvkpCnYNZ1No=; b=frnPZnIUGu8zADBNGSFMnH4xxw2E4kIxx8i/GkzqBbmQBZIFkjF6Dt844J4qGzR46+QWXryGuEZsZoDRbqkxZeZ8dt+F+3qjViJMZ2Dd4/amNlyE2XiXVIgB4e+oITVWORxNDO0rkvVffhJwGhALYz05/tsX+CsA4h11alBQXoKhkiOf8Q8JSKRR3mpjyN+4lMPfsIAFKiplEHgSYQot2CcopyT8VbbdROuw1wV/Z0kt27LDYKOwt7K6BsIkBSbLQZzgJOMtlCL0DwCERbRATv2amb3iyPw7pAgDg6oN/OKY0jklPi3LY5fTF10kIWi7GigYBFrIhD3Ck/WeDqEpaw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=CBO3i7KxxUyhz6uM2auvsfSTOk8uXDuKvkpCnYNZ1No=; b=nZ6CEWCfZdrNlWTn4UHR9hf/giB9DIJZRM7otC2LWQgWT+2RSJsuG/XvMUdoMm5olbGyD9zotn9iQeXyHZQTgGEP8jKYOyeAc1q6/aqKtHcwcN0xpEDQl5SazYRrBl3zEXsEeFYn+Ua9gbB9Gqm6Y9SV1ZJ4WyOG6X/brshDh4A= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from GV1PR04MB9151.eurprd04.prod.outlook.com (2603:10a6:150:26::9) by VI1PR04MB6830.eurprd04.prod.outlook.com (2603:10a6:803:132::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.30; Wed, 12 Jul 2023 09:01:18 +0000 Received: from GV1PR04MB9151.eurprd04.prod.outlook.com ([fe80::2cc8:4c5d:9b6f:5cab]) by GV1PR04MB9151.eurprd04.prod.outlook.com ([fe80::2cc8:4c5d:9b6f:5cab%7]) with mapi id 15.20.6588.017; Wed, 12 Jul 2023 09:01:18 +0000 From: Claudia Draghicescu To: linux-bluetooth@vger.kernel.org Cc: iulia.tanasescu@nxp.com, mihai-octavian.urzica@nxp.com, silviu.barbulescu@nxp.com, vlad.pruteanu@nxp.com, andrei.istodorescu@nxp.com, Claudia Draghicescu Subject: [PATCH BlueZ 2/6] client/main: Add broadcast source discovery Date: Wed, 12 Jul 2023 11:58:56 +0300 Message-Id: <20230712085900.5423-3-claudia.rosu@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230712085900.5423-1-claudia.rosu@nxp.com> References: <20230712085900.5423-1-claudia.rosu@nxp.com> X-ClientProxiedBy: AS4P250CA0004.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:5df::12) To GV1PR04MB9151.eurprd04.prod.outlook.com (2603:10a6:150:26::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1PR04MB9151:EE_|VI1PR04MB6830:EE_ X-MS-Office365-Filtering-Correlation-Id: 4572a259-4ee8-41b9-c73c-08db82b68e15 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MnaK5KbdVeHduqRArEe32Q0MzM4vunMNrnb1cEibtzPIl9qpE5ig0EBBHhjoYZ7xQOiFTbQio0G6lbeWAWKa6mVaig09lDWx7jZyl68mCdnzKjdXK9PhmOmW6CGPIcG470LA790Lj5qxFqsRW3Q7MbxWoLCod1DWn5viUnpCl1OB+l+3eycGngPIax2xmhzFkp5jkji3QtpGnppyU4GZI37CVn0CoiBqefFXFDYLvxndlPoKlhnnw9qAo0rSBQYyLFKzg3evy82FK8Cp7IYLQq/9ptYC9O4W5VHkkJLSZ6m9PfsafXk92ZEevzuP4S7KXwJqUXvKBEJTcUGMbNrPNsxNFLtTh8OWnUnCkUY0iwe8umJxYZenFkX4fNxyqDcFa9u07RGOj6ck/vXmhrUt3HTwhZatF0h5/8hsecdBKF2lXsN/5kTYeG735eOIjZrqvjrikwVDovDBO/+kBN7SGcyG0BABxSqIQtktS7AlK/QDT7NT7Tjm6OQuoog7vx3BhUQGwkioQBSnPFU3J+xagEds/LafvqCwkoTy8IAvMpUmOir1yIfWeydIPY3hLdv14cxsps824Z/EDdxUHqfZm//yE7AnboK3QnzoPGD9bddj0LetncSWO7kCG6hX4zr8 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:GV1PR04MB9151.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(346002)(396003)(136003)(366004)(39860400002)(376002)(451199021)(38350700002)(86362001)(38100700002)(36756003)(6666004)(6486002)(52116002)(55236004)(26005)(6506007)(1076003)(186003)(6512007)(478600001)(2616005)(2906002)(316002)(5660300002)(66556008)(66946007)(6916009)(66476007)(8936002)(8676002)(83380400001)(4326008)(41300700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: wSE+R/4iTY0CLLDBny8A4RN2WmmujN3pqhUWCDAXQ4IYVdhg2g96kWvj3s4lXx4kuXYS+1W5nSYRdXrJX/JOjqCdVMtMIg2q+dh7l6JadxaZu6vGCSP5GAXa0XVVuE2WWALux2My/2tiwFiKAK+y0DPWM2up4clTwSjixAy2OWHSd2F+/v7S2EktZfcZuSNosRYU8oRhDG8paqfmTlKrm87FmC2FsF3guSY9weumunRLcptIA86hFWWDAac+q7fvYxq+l0THVJay9ODUqg0FaYEz2vowApPq04vkiBR4AfiRkYcq/3cMEI8/VoCA2EGDUt15yK15h92iHvO4G1DzDeeVVQIEuXLaG97hxhRpdB4vGeauBbzYzkjuLNHnSE7mG5PLDkkkhu/vuJFtq+syhggX58bDQlxWH8nJ/vZOuofJvg5XqGjGDBexxD2RJMtDRzkgoCNmQlp6LXJ/xkpNrxM2jSX0ujEnpylN3a9L7E/7ZpPtZW4UwNg2WEFuDCCC6FEnu0vTetdDU7YGC4QxBTe72lfEia3qeJvzc8ZjXKH4i6jOeYM3nfXXAzdXQdVYUNvhfcVwhYQXskumwdv7nf8QAT6vWW308VexBMn0IQTS/Z4Bu0wUZDp2g62j8uTuNCbYzDVIv5RZ5ZrQpkQA2zbYfSMcVemhX1VGM6q56w3oupX3p2P/1L97Kyhvq6fy6IS+gELlbxLUoH8CF+23zfRNFkgJmeu7cmEa65JuSImR8feWk0BHIpRtYB9qOnI8Ocjnm1KSSjn+xQPcf+78UtQduQzUcff76t25fC9eKX2YW7qU2jJ+ofc12niUneggIglzwcm3RH//KBBrnoBWzduTRz3gcus9xKd2ubj9jEyZmpyLQp9MUPcXWWnOO3MOPeUEKU/yxq+Jp2MCtUZ00Fr5yLpuGrXj2HKnv/k/XOF4kR7+FkTbSdtwT5cmWxYODkoWRZPpT3bq/X3+6kklrfLLQL/OgdQybBYS9du/PCKvGYWY4rzN1tds/TAsl8rNHjZds56yAU4lSQASGL0Bh93kDs8yQOHpEEbVOs80pqZyeXNFXxDRQjBQC/jjUY1fI4lskFdg3UxLvlMHQUme1IOGm7uL7icfY030PcVTj/3hYXv/nxmRRrhY5f6X9yViQmLAqLZl0wbTsND3BTwmdFsItvAgcqYjnRr+KV/5r600TnIvVi8MrNyfECn2e6/p07A2HK5IuOLBqpo4PvMUO6g5xdxU8BddXpOnDKiEp5hVp2wuK3wqau75uA+WbBX3837fMC5zKm9z5YKRzpTLE4QxQ1h7O14NGXmBjCXXNpSBUAb4bjO9bat+CiC7mjTsPB9BdVLS/JHGHG56AeQCiIb0poqyj8pAyl7Bdel72W8S90ANbdJ+35eQal8PYHq+DbJKvEj1Is7NqG+fDdD1C9OTIH//JHktSQltT8JrvapYxhUFMdHFZjjLUKvTD5wbR9dgnK8gUfuU6SG26ckqmu3EvKE9MqAFPRae5+a1DLqmYvLD4F9NYJgJioWxq/RV5xvmDtotklexN6/OZZ5xf7bzYgsBKqGb+FGnLk/wLE/GyVXK8R93ZisGUHe2Lh3E X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4572a259-4ee8-41b9-c73c-08db82b68e15 X-MS-Exchange-CrossTenant-AuthSource: GV1PR04MB9151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jul 2023 09:01:18.4065 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: GAdnxxIrkvT1qBfFpbxLfaCDJokIyMNZBe+aqcZJMZv2wiYtrQcv5+sBC28gCmkYoCsTfJzGq/jD+AmyPFl2fw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB6830 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This checks if the scanned device advertises the Broadcast Audio Announcement service. If it does, the device will be added to a list of broadcast sources to which the adapter can synchronize. To test this feature use the following commands: [bluetooth]# endpoint.register 00002bc9-0000-1000-8000-00805f9b34fb 0x06 [/local/endpoint/ep0] Auto Accept (yes/no): y [/local/endpoint/ep0] Max Transports (auto/value): a [/local/endpoint/ep0] unicast/broadcast (u/b): b [/local/endpoint/ep0] BIG (auto/value): a [/local/endpoint/ep0] BIS (auto/value): a [bluetooth]# scan on [bluetooth]# endpoint.config /org/bluez/hci0/pac_bcast0 /local/endpoint/ep0 16_2_1 --- client/main.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/client/main.c b/client/main.c index b433a2200..8fe537f34 100644 --- a/client/main.c +++ b/client/main.c @@ -198,7 +198,7 @@ static void print_device(GDBusProxy *proxy, const char *description) if (filter.discoverable) return; - bt_shell_printf("%s%s%s" COLOR_BOLDGRAY "Device %s %s" + bt_shell_printf("%s%s%s" COLOR_GREEN "Device %s %s" COLOR_OFF "\n", description ? "[" : "", description ? : "", @@ -304,6 +304,57 @@ static gboolean proxy_is_child(GDBusProxy *device, GDBusProxy *parent) return FALSE; } +static bool parse_service_data(GDBusProxy *proxy) +{ + DBusMessageIter iter, entries; + + if (!g_dbus_proxy_get_property(proxy, "ServiceData", &iter)) + return false; + + if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY) + return false; + + dbus_message_iter_recurse(&iter, &entries); + + while (dbus_message_iter_get_arg_type(&entries) + == DBUS_TYPE_DICT_ENTRY) { + DBusMessageIter value, entry, array; + const char *uuid_str; + uint8_t *service_data; + int len; + + dbus_message_iter_recurse(&entries, &entry); + dbus_message_iter_get_basic(&entry, &uuid_str); + + dbus_message_iter_next(&entry); + + if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_VARIANT) + goto fail; + + dbus_message_iter_recurse(&entry, &value); + + if (dbus_message_iter_get_arg_type(&value) != DBUS_TYPE_ARRAY) + goto fail; + + dbus_message_iter_recurse(&value, &array); + + if (dbus_message_iter_get_arg_type(&array) != DBUS_TYPE_BYTE) + goto fail; + + dbus_message_iter_get_fixed_array(&array, &service_data, &len); + + if (!strcmp(uuid_str, BAA_SERVICE_UUID)) { + player_add_bcast_source(proxy, service_data, len); + return true; + } + + dbus_message_iter_next(&entries); + } + +fail: + return false; +} + static gboolean service_is_child(GDBusProxy *service) { DBusMessageIter iter; @@ -399,6 +450,8 @@ static void device_added(GDBusProxy *proxy) if (connected) set_default_device(proxy, NULL); } + + parse_service_data(proxy); } static struct adapter *find_ctrl(GList *source, const char *path); @@ -531,6 +584,8 @@ static void device_removed(GDBusProxy *proxy) /* TODO: Error */ return; } + /* Check if it was a broadcast source and remove it */ + player_remove_bcast_source(proxy); adapter->devices = g_list_remove(adapter->devices, proxy); From patchwork Wed Jul 12 08:58:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudia Draghicescu X-Patchwork-Id: 13309858 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0C831EB64DA for ; Wed, 12 Jul 2023 09:03:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232251AbjGLJDg (ORCPT ); Wed, 12 Jul 2023 05:03:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232118AbjGLJCl (ORCPT ); Wed, 12 Jul 2023 05:02:41 -0400 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2075.outbound.protection.outlook.com [40.107.8.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0773B10CB for ; Wed, 12 Jul 2023 02:01:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QQUmlhpVdpD+JRRTyXXPV1MtjAL+0Erfv+3M8YunsiThBRf0HIDa4OxOkwaPmxbTX9LCnH9ZHAk7Bf10bhwgtZsx6qFhLRZkgxKXmVf7+YwazIWLadE27lLySnOzuuUOxKxJVPIYIKe41LoWPVCnI2rqPvdbVrcOvlCEL931v76r0utlp9yDSB+aB1SEhGWYWc8kfjU2MpsaGQz/S0ONtaFHux7lx4c3usTF6QpgGnTYMjuuJaUKQH4eex5F3uc1YaiUrJfBXtTEMAZpnnR4cAcWWZtNUl4c6PdH+K53v6u93Wozkzc1Q67X4UDlIfPDjfbkZXBQbN4dZsZsiTQN7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Np+k1+XHKqWhywiSFetxV6QYJVW8tl7zRthk1kwVeAM=; b=FBmk76FFyZTA7XT/9f9R9DrhdOSnPv3D+YOEIusEXXmgxyX3ihZCq02OomAA6AlpWRvBKFua0LkLSFFcWj8iBDF0hDMR0PadbZwTUFaJwcBqVbKZocB/+fOVOEf7AkazNxe9lM9yaEqIIvldtGlZj9LABsBGQmL8IN8Y3KouAkBeh6TdxW8FY1b076KJOC0o3PLM/4UEbJgznW5nWDQPYVtcUCJCrSMqnjY3YZ7skjW5lT87U7PeX4dZCEM6E97FwVuvR/lKfTt/uwqKsiYfN7WTaKJ4AywzoX+jpqKOcRwAGE5xVqav37b4bRoUcGnCfAu7oqZ+1UXq3dJI4fN7YQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Np+k1+XHKqWhywiSFetxV6QYJVW8tl7zRthk1kwVeAM=; b=FnlVA0bqIysR8seaR+eHf9vz1WoWY0a9x5YNEpOAKI6mWDkVdCek0VYf4NxLlNsnIJu73FGZKiSFa2e0JlW5hOtltvOuEnB9S4q3DG9Lon/k9OD4XyzZVF+z0D6xnBeHg/LK7c0x7Qwl9Ofq2WQnj9aa8QrJ7We1qBWcm/SBXhQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from GV1PR04MB9151.eurprd04.prod.outlook.com (2603:10a6:150:26::9) by PAXPR04MB8525.eurprd04.prod.outlook.com (2603:10a6:102:210::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.24; Wed, 12 Jul 2023 09:01:21 +0000 Received: from GV1PR04MB9151.eurprd04.prod.outlook.com ([fe80::2cc8:4c5d:9b6f:5cab]) by GV1PR04MB9151.eurprd04.prod.outlook.com ([fe80::2cc8:4c5d:9b6f:5cab%7]) with mapi id 15.20.6588.017; Wed, 12 Jul 2023 09:01:21 +0000 From: Claudia Draghicescu To: linux-bluetooth@vger.kernel.org Cc: iulia.tanasescu@nxp.com, mihai-octavian.urzica@nxp.com, silviu.barbulescu@nxp.com, vlad.pruteanu@nxp.com, andrei.istodorescu@nxp.com, Claudia Draghicescu Subject: [PATCH BlueZ 3/6] media: Add support for a broadcast sink media endpoint Date: Wed, 12 Jul 2023 11:58:57 +0300 Message-Id: <20230712085900.5423-4-claudia.rosu@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230712085900.5423-1-claudia.rosu@nxp.com> References: <20230712085900.5423-1-claudia.rosu@nxp.com> X-ClientProxiedBy: AS4P250CA0004.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:5df::12) To GV1PR04MB9151.eurprd04.prod.outlook.com (2603:10a6:150:26::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1PR04MB9151:EE_|PAXPR04MB8525:EE_ X-MS-Office365-Filtering-Correlation-Id: b23d01c3-5aad-4154-748a-08db82b68fdf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: igC1vP+hVrUtWHEsvMDEZP0NQHlQj3kawu9p17ZslQhMW4lVv6EaactsM7pXixQCiNpdDkBO5DHJhHN0QBKGvT4MyNZama8e4P/kDNTQlmRnSvvYHEYIeyRCpM+PSlu5LcJkuyM/uJRjvU43Fn3bLZAFsnTb0LdRlFCywwTM/ngKjbZPdek/11pNlTK+K2FBvpfnJp5RhEyj/6i4pArBiqcYKhwIherkk5i2alxrZVwdfynMSK7ru7GfgOJq8FnjrbN3gXhJ5FjKl3xeM00hB8Oupc84WPC/xFnqzu1O0XJ8j23YZo0XnFHi2AYm83RBlYJGSm7dzasJmcVDy492+sspA0DaGGuKCxiBNTYWE07d3UfYMbfT2S2seS+PErj0lHh1SGfDVRFLq+PeP4yRivb8m1RwyOOjNHEOkJrTUTgrIPBl5uz/Qj32UASoPn3YoJBc72A+o16q8DXOPEX+gr8qUoBGrWguVrBfpFEOPBFDCRhcQtObnSREmBiTe1f/LHaXFreOG+Yrk1RlExPSRUZ/SwUhCQ+TrI123HuSOt2FeCkF5nbCVPJS6PHgAOl+YRF3sJFj43sOQf0XbZ6gPTV7jQ3GsLptdecRCJ8gc/wzmOHf1ZifBalhWkpyy9q1 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:GV1PR04MB9151.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(376002)(366004)(39860400002)(346002)(396003)(136003)(451199021)(55236004)(83380400001)(2616005)(2906002)(36756003)(86362001)(38350700002)(38100700002)(41300700001)(4326008)(52116002)(6916009)(6512007)(316002)(6486002)(5660300002)(8676002)(8936002)(478600001)(66946007)(66476007)(6666004)(66556008)(186003)(26005)(1076003)(6506007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: j43OH+WkYjBSvfUfw0Ta/NneMY+fasbPoapM3pOnfci3e7GjjKXUaye/IP3s7GwcNE9tCc25zpoBGfxJ+1dHoDxFT4KAW1NNT5o98+NWhIG2I1I6hlEyus9IWMRyTRMdlc+3fyRlkNgG3f5PzIBvWGYJ1jewVCO/KWcJVnhI1X9PZP0mi4/AwuwwMVJ00OvvIo5/HHtu6so41RXGYRaEtIA8VFNVsDe067JUSRLQanH0ifhvN9X0wqoyesjW72weESv8/HhZo4Dky7LSwSxjkpvFyxCkU8areIbI6iNmlATHUbFNb+kjlxr798QG5Eyy9FRjuxvv92tO/8Zd4qbdHq2wi1IsHy3Z8Z2wWS5lOcCnh8YpbFMP8Dh0wWojoVTDlEmAGav8DNnsT3qzRrsFPfjzJjqZwOnqjTarkHvGMjlOSKyPNGjT4ObMoLJTJCZf0CZfVDWHRsaPR9jKu5/y4rvx+NvwhxIBEaQokAfaroSLBvoJelHqpMFH3aqVctIOcg7oNWpnMkDYfx3b9UV9HUstSVG0z8Sp23xIaWJibRzNJM6L4vUK7ADnH0aT5fd8ETiyZvZcDd+YOHLk0ZcHTMsxY6V7jL/pblXag7m+yfgz7ye0GpGexcLSFcrRslgGMNPMyR94lmERFXGnYVdEK9x88szrI74VliFRhjesjQf1AcfKcaVIrsrbuIMeb4asO2VX2quXsCS3Hj0kWVtGj2Ah0XnhIOWrz2vYyUtdnMyRZGkZlqVpbUX5teFOVyJW46DBUtNXiznoPA/T+1LHZG87jUaCrtkvn5C059vVZelsdTbZViZgVuvFr+z5ImRaKNiDTZvGbYU1Sg7jgPeCYg1e1j2puLs7gHZfziA01Gh3ZD2rGb1HgZfyyubIg07bqRMKxEK1GH/OQp8+IizpvGQc/ZQIJMpb045aitCKDnUMXBQsljOyAdE9JSDsF1QXHNXzCCoc9OYDt7sy6ZE86EVLXJ+pnz2JAj7R2xsmmixa506lXs9dEsK0h0nTaZznqQ6CxIBXgpuoHEgLKO1GSkvteltqLy0lyTA2XmTT6MGf4brAgo1OWnRI6LKHmyhFbMBZf4o9Y7WqD0aVOr8oKJY09zYZ7FRP7e++dkswXr//e/JPMQS9PTUu8bKBj5IherJaqoy2Tcw2A1DpD7Ig7WBsZVjLvRnMC6DIYxhJaq8QFQGYqa/ErYjSX+SkN+98xaseeQZEDsUMrgN5g2Dcz/+5N3/YByQUulsvqq294eNidhyHgHzKK3eGqVSPx6FmeCp3lSBtQHKj7z1PNDJV6ZbPKkHEUxJJrvr3D7h6/f/4U3WnyLYav4dapIwhuE/ySJhcPWv/1519M8SobHoa9LqQQ32O4GU4+8JwkEI+FgvcUmDzT4eHyY9lQ1Klo9nsytm67C/5TmB8ZNLCgF+RQ0qCAX/1hHBL3oelN8AWMoHRf8KVR/fe5sTdpI4VWOWBKo29cTJdR9hS16pf5V1ug6cubsvg6XYz/IcyWXDnuiE0kzicID57decKlLSN2MVnIaH479dVfLKuP8IsJeWDhYHZFi3++TS/fuuKKRhRWuaY1d5m264e/N3p+V9gKPny X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b23d01c3-5aad-4154-748a-08db82b68fdf X-MS-Exchange-CrossTenant-AuthSource: GV1PR04MB9151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jul 2023 09:01:21.4556 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: FT4edPSoNCmi5gL+Y2/zI+vqn9cECzTzOdtM6pqtD6Lw5dmpmAZQgmuZI08l+psKujcyqzivjYp2i70And09uA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8525 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This patch adds the possibility to register a broadcast sink media endpoint if the controller has support for ISO Sync Receiver. --- profiles/audio/media.c | 35 ++++++++++++++++++++++++++++------- profiles/audio/media.h | 2 +- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/profiles/audio/media.c b/profiles/audio/media.c index bcf4eae26..d529a4f60 100644 --- a/profiles/audio/media.c +++ b/profiles/audio/media.c @@ -105,6 +105,7 @@ struct media_endpoint { GSList *requests; struct media_adapter *adapter; GSList *transports; + bool broadcast; }; struct media_player { @@ -1224,6 +1225,9 @@ static bool endpoint_init_pac(struct media_endpoint *endpoint, uint8_t type, static bool endpoint_init_pac_sink(struct media_endpoint *endpoint, int *err) { + if (endpoint->broadcast) + return endpoint_init_pac(endpoint, BT_BAP_BCAST_SINK, err); + return endpoint_init_pac(endpoint, BT_BAP_SINK, err); } @@ -1333,8 +1337,10 @@ static bool experimental_endpoint_supported(struct btd_adapter *adapter) if (!btd_adapter_has_exp_feature(adapter, EXP_FEAT_ISO_SOCKET)) return false; - if (!btd_adapter_has_settings(adapter, MGMT_SETTING_CIS_CENTRAL | + if ((!btd_adapter_has_settings(adapter, MGMT_SETTING_CIS_CENTRAL | MGMT_SETTING_CIS_PERIPHERAL)) + && (!btd_adapter_has_settings(adapter, + MGMT_SETTING_ISO_SYNC_RECEIVER))) return false; return g_dbus_get_flags() & G_DBUS_FLAG_ENABLE_EXPERIMENTAL; @@ -1382,6 +1388,7 @@ media_endpoint_create(struct media_adapter *adapter, int size, uint8_t *metadata, int metadata_size, + bool broadcast, int *err) { struct media_endpoint *endpoint; @@ -1397,6 +1404,7 @@ media_endpoint_create(struct media_adapter *adapter, endpoint->cid = cid; endpoint->vid = vid; endpoint->delay_reporting = delay_reporting; + endpoint->broadcast = broadcast; if (qos) endpoint->qos = *qos; @@ -1462,7 +1470,8 @@ static int parse_properties(DBusMessageIter *props, const char **uuid, uint16_t *cid, uint16_t *vid, struct bt_bap_pac_qos *qos, uint8_t **capabilities, int *size, - uint8_t **metadata, int *metadata_size) + uint8_t **metadata, int *metadata_size, + bool *broadcast) { gboolean has_uuid = FALSE; gboolean has_codec = FALSE; @@ -1546,6 +1555,10 @@ static int parse_properties(DBusMessageIter *props, const char **uuid, if (var != DBUS_TYPE_UINT16) return -EINVAL; dbus_message_iter_get_basic(&value, &qos->ppd_max); + } else if (strcasecmp(key, "Broadcast") == 0) { + if (var != DBUS_TYPE_BOOLEAN) + return -EINVAL; + dbus_message_iter_get_basic(&value, broadcast); } dbus_message_iter_next(props); @@ -1569,6 +1582,7 @@ static DBusMessage *register_endpoint(DBusConnection *conn, DBusMessage *msg, uint8_t *metadata = NULL; int size = 0; int metadata_size = 0; + bool broadcast = false; int err; sender = dbus_message_get_sender(msg); @@ -1587,13 +1601,13 @@ static DBusMessage *register_endpoint(DBusConnection *conn, DBusMessage *msg, if (parse_properties(&props, &uuid, &delay_reporting, &codec, &cid, &vid, &qos, &capabilities, &size, &metadata, - &metadata_size) < 0) + &metadata_size, &broadcast) < 0) return btd_error_invalid_args(msg); if (media_endpoint_create(adapter, sender, path, uuid, delay_reporting, - codec, cid, vid, &qos, capabilities, - size, metadata, metadata_size, - &err) == NULL) { + codec, cid, vid, &qos, capabilities, + size, metadata, metadata_size, broadcast, + &err) == NULL) { if (err == -EPROTONOSUPPORT) return btd_error_not_supported(msg); else @@ -2627,6 +2641,7 @@ static void app_register_endpoint(void *data, void *user_data) int metadata_size = 0; DBusMessageIter iter, array; struct media_endpoint *endpoint; + bool broadcast = false; if (app->err) return; @@ -2741,7 +2756,7 @@ static void app_register_endpoint(void *data, void *user_data) vendor.cid, vendor.vid, &qos, capabilities, size, metadata, metadata_size, - &app->err); + broadcast, &app->err); if (!endpoint) { error("Unable to register endpoint %s:%s: %s", app->sender, path, strerror(-app->err)); @@ -3245,3 +3260,9 @@ struct btd_adapter *media_endpoint_get_btd_adapter( { return endpoint->adapter->btd_adapter; } + +bool media_endpoint_is_broadcast( + struct media_endpoint *endpoint) +{ + return endpoint->broadcast; +} diff --git a/profiles/audio/media.h b/profiles/audio/media.h index 1de84a8ff..2b579877b 100644 --- a/profiles/audio/media.h +++ b/profiles/audio/media.h @@ -22,5 +22,5 @@ const char *media_endpoint_get_uuid(struct media_endpoint *endpoint); uint8_t media_endpoint_get_codec(struct media_endpoint *endpoint); struct btd_adapter *media_endpoint_get_btd_adapter( struct media_endpoint *endpoint); - +bool media_endpoint_is_broadcast(struct media_endpoint *endpoint); int8_t media_player_get_device_volume(struct btd_device *device); From patchwork Wed Jul 12 08:58:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudia Draghicescu X-Patchwork-Id: 13309859 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BB9FAEB64D9 for ; Wed, 12 Jul 2023 09:03:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232822AbjGLJDh (ORCPT ); Wed, 12 Jul 2023 05:03:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232757AbjGLJCl (ORCPT ); Wed, 12 Jul 2023 05:02:41 -0400 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2075.outbound.protection.outlook.com [40.107.8.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A331170E for ; Wed, 12 Jul 2023 02:01:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Bf/qpJjD5RMAjNHgsuac5mlAYY0XDU5iWlk9G38es3Wy8yUVkh7oh6Stx3I4FQpHkjUItVChyhzClv1Yy5hUXhcafaezkH7WP25s7ke8OF1/AQkv02Omm0w7v2t4g6ZL/OL/BKOVuNi22VuWe+k5m0E8JcoMmvXxRWMYRUMqH4n2vLoEZMXNblPl0Rhs9+NLkVLFH/eAr7p4tW05lKnSOfPQjRnlfWLSb4fEe2UCHmTD9xeHCa6mA0cGSGjoqXkGGpZAHdrpYCj3hXp7oeJHmG7a92+ooRc5RSo5jWtlLusA78QcClL6h1THInwGW0IVVhJwMCvYMLGkN6sv8EThtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=cnlVnDTXYHd5IQpCKTicqkBWS3QA9gQp/s5E3zwfSRM=; b=EA/GxgLm1YWB9J98GVmWXOwNGbOFEaWqnxqsbD3+5yo7bI4vxRnH8rme59t3eDFUpjxfg3fI0Z7mGLx4+YadoiSDOooYPkyVvzpo5AOzVnAm+x6a6Xbpjl08DMeKbzx6/UvXkELo9DZIbUk8jGGeqxjGuVj7QfPBl4TxVScwZ7gloSvIZcL4yy6HvmtaFDboI5qJKMcgI+0EGCY4sCWiTGheD8PVv6KY2JUN2iefr5iKVPJDLctGF7kR9WIuLL2g6qs7yFR5LtK7dHm74/K1Hs53O8yFhmKRVsHUEG3mWYWpEGesqDXL8gu6N/2DrrIdGaeeeM2zO3IbDDba33REOg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=cnlVnDTXYHd5IQpCKTicqkBWS3QA9gQp/s5E3zwfSRM=; b=rxyDhtxR5NFgTPrfQUhF0YyNIMNcFQOlg58xNsrPW4+odQ5wFjqVisaqE2RBRgpte6bUcC33i0fuVOZmNlpnTwMnQurG3ljqmFdJE07g//I6yR+YUlUysL8R00eK51bNzaG4zrIWTqZBeHtrlangIWJFNA3S0zqmlbs6T//uyVU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from GV1PR04MB9151.eurprd04.prod.outlook.com (2603:10a6:150:26::9) by PAXPR04MB8525.eurprd04.prod.outlook.com (2603:10a6:102:210::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.24; Wed, 12 Jul 2023 09:01:23 +0000 Received: from GV1PR04MB9151.eurprd04.prod.outlook.com ([fe80::2cc8:4c5d:9b6f:5cab]) by GV1PR04MB9151.eurprd04.prod.outlook.com ([fe80::2cc8:4c5d:9b6f:5cab%7]) with mapi id 15.20.6588.017; Wed, 12 Jul 2023 09:01:23 +0000 From: Claudia Draghicescu To: linux-bluetooth@vger.kernel.org Cc: iulia.tanasescu@nxp.com, mihai-octavian.urzica@nxp.com, silviu.barbulescu@nxp.com, vlad.pruteanu@nxp.com, andrei.istodorescu@nxp.com, Claudia Draghicescu Subject: [PATCH BlueZ 4/6] transport: Update transport properties for a broadcast stream Date: Wed, 12 Jul 2023 11:58:58 +0300 Message-Id: <20230712085900.5423-5-claudia.rosu@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230712085900.5423-1-claudia.rosu@nxp.com> References: <20230712085900.5423-1-claudia.rosu@nxp.com> X-ClientProxiedBy: AS4P250CA0004.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:5df::12) To GV1PR04MB9151.eurprd04.prod.outlook.com (2603:10a6:150:26::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1PR04MB9151:EE_|PAXPR04MB8525:EE_ X-MS-Office365-Filtering-Correlation-Id: bd4dd448-ba2a-441a-6624-08db82b69147 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OzbtjDSyq4MfyU7mlEuyjQC8Ul5d285fv3f2aLNcIRC6rgmbguTPtTxUuz6ESDBo3LDsOlbVVxc00Ux6Z8loz73cBVvWcPt/jeWdES6mVc4pvJrnIs5jOV+8BTwoT9blEbIYF8H631O80AWKRx4pbt0vHRJ9GZlNFbNN4kONBEZDZo+kz98Tzjo6K2dKBeHqfGvFM2um5JhH8DXth7U/ngwzDPUz5ceIIRQXo3I65TcSjvWEmgTHH7Yx+X5Cy0ZsPIMTD8kZnFTDXDM+79GPnspJntF26mZrpp7Gyp6mlnJCB+VBqxgPYAxrnTgeYQyJ4xBZgOSksY6D6bMlwGHL8tf89N8ufJ4Ia8uSw3SRSQ9k/0We1WYg0GT1IoInghbjqzUuVnWycp5zRQ5m1EVt3RE6VW7ITZ7vqFGVTbTULghLmEbDPbGgSCDc6rsEJ/pekkLZIdzK9SHr8HUNDev/fd2K5WDpnlFHRWWWoNOasN/PeWJBX4UL2H32yNGQU/FC9WOL2drC2uvtpt7qexGKpomRWMYc2uRauFiWVzaell7cuAC6MtPN7De5sKGYSF8pE76md7dQVs3DEyFW1wQKcqa1dD1qT+isRZJuPDXk6FlUY469H+9CBGR/XqWcp/NL X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:GV1PR04MB9151.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(376002)(366004)(39860400002)(346002)(396003)(136003)(451199021)(55236004)(83380400001)(30864003)(2616005)(2906002)(36756003)(86362001)(38350700002)(38100700002)(41300700001)(4326008)(52116002)(6916009)(6512007)(316002)(6486002)(5660300002)(8676002)(8936002)(478600001)(66946007)(66476007)(6666004)(66556008)(186003)(26005)(1076003)(6506007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: uBd5Wac3w4Jg4Tw8OS2GkqNrwpQEDiUzSiKFHqe5EYEtycjmndYVjkJOIoBAGTLTryAXTZrp1LeaYgt32ETkS6ABeyKDFBn86qSf9K/AG3OsFbYusK6z3KwkVPTx6tfDULq8Hl60dCkIC1I++V0EnOZ5+oe1RiV9B6C9qlgWqiBq25INIa2n/bpkVtv3gM70zQJtQZNVK3WZxzL0VtrVKdo5VC7jcOG2FC4IJJirECOzndnNt0CxSJOUHZAwpWpkukgefds5c7w48YOYvHOe61E6N9l5d2qnIqbxEp7AumxPtq9H1jkfIygpmoYyxukW05OPSWxV0VljXr2rhgcuzLApkoSBETFn0eytHYNNaIvQijhP+dadaDp6PBrwXY0uMXhIzxUkaFf7yXtwUd87wvsYVLggWFP4/7ltEmrDdeTev1+OwmB/SWtQpqny6XydRMv3p2LB/QW73zFFDmp/YOBqxApLcIxMzwmj1FXh6Hiq/2tG/P43WTE/ae8MQjql94S4/W9yOxfcvK0PPSdbHt1E2yHDewJ1qRPhxhLoM2m8RhATHmBex+TWbW2oWOYTg8tp1pDKbh4AHqtheoIhXnSD1LWV7LK1+VQ5KAspEJIV1KyRu6vwWxjmpEIlmbYR4aT0sll2bxo0xvxP/E9TJb2MRaB/yZ8pRNXEWhiiYXpZrfnWuNMQnghL5/FevubuNAW7cOPE8d81A8JDal/RA0jY1nqiu7A9W20YplgwueiRLcB2yRlkh0ijPUp5AgNd52uJuxono7KQxK5REE/9EhDQ0G2OJi/d7XjJoktl4gQTV1xcz29TSiRnG3tqMVR4hguMcyg1nTOsaCKBTcuSSKdB8hEZ+p2+zUBn+ryaEGGLeLj0VwpFIhmcV3mgK5CvjRN5vSVvSdYORRf6LJyptIWqc7FjzA1o0z6PGWCppaWXcsG2Ezr9szZLweubQ8d3vHXHyWkWsFfaW6j3ZUIGy53tWynO2ldoxb3T4koCj9LY11fyGql78vgVYUt+2IwTksss0c06IF3tHXB+z56w5Arp3BTJaEqxmd/O7bOiQovAx0HdH8fWgsG2pdsEsHGldZjcI5wndwon0JXUndA7rVZp5Dl09C9fSBEZR1WZTWiB1umMaLu2lZSs0FGvIxLpuQf7KAyBr3lHTAIrxiyx0kj/AI7n9RvLKwNoZv2XrbKXcTxMfCgZABOEBVpOix+CW66HdtlFXz9GbPd0M7/eraFnqbqPWDYb2HegaiijJtQlEA1MqcpCpVnkfulsnLC1MXMkgkiSKI2DrBhV+nrfRWk+odg+DsSyCWLotXUuzrGaB29Qhlp/NqDrRlExdj52WEsOgcFFBmG9AmWFf0++y0xqFdWKnCjf+dHn0eqd7PCm99lQgMryNllxQXb9T1ReJ84ViMdkpUW1qzEwBtlg8rR7VpdTnsZTaHuKLTe/Hf2RPByLAhMX06ZJQuUV7RKDa+jRJ2Fnpt+y09B/j4czCX2hHtwAealhEgAhoK4k+vBpLXOzKv422T6OMaJTXdMgl2Ib5xKWSTy/yqsbLimG6VS24DPk/2zCfrjiMKFHmq3PkWWbYQflzAxFMqjPHcQY X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: bd4dd448-ba2a-441a-6624-08db82b69147 X-MS-Exchange-CrossTenant-AuthSource: GV1PR04MB9151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jul 2023 09:01:23.7783 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: sqW6a6pFP7UAftBvuehcmWrYWNzMeafHC9Cc3zhk9aQZJ7jvTlMh3KYq/pRcgv1Y/WnowIVEmB/8YHe92g71LA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8525 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This patch gets the QOS broadcast stream parameters and passes them to upper layers. --- profiles/audio/transport.c | 244 ++++++++++++++++++++++++++++++++++++- 1 file changed, 241 insertions(+), 3 deletions(-) diff --git a/profiles/audio/transport.c b/profiles/audio/transport.c index aa3a718b0..e7f21ff9c 100644 --- a/profiles/audio/transport.c +++ b/profiles/audio/transport.c @@ -551,8 +551,8 @@ static DBusMessage *acquire(DBusConnection *conn, DBusMessage *msg, owner = media_owner_create(msg); - if (!strcmp(media_endpoint_get_uuid(transport->endpoint), - BAA_SERVICE_UUID)) { + if (bt_bap_stream_get_type(get_stream_bap(transport)) == + BT_BAP_STREAM_TYPE_BCAST) { req = media_request_create(msg, 0x00); media_owner_add(owner, req); media_transport_set_owner(transport, owner); @@ -853,6 +853,9 @@ static gboolean qos_exists(const GDBusPropertyTable *property, void *data) struct media_transport *transport = data; struct bap_transport *bap = transport->data; + if (media_endpoint_is_broadcast(transport->endpoint)) + return bap->qos.bcast.io_qos.sdu != 0x00; + return bap->qos.ucast.io_qos.phy != 0x00; } @@ -868,6 +871,18 @@ static gboolean get_cig(const GDBusPropertyTable *property, return TRUE; } +static gboolean get_big(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *data) +{ + struct media_transport *transport = data; + struct bap_transport *bap = transport->data; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_BYTE, + &bap->qos.bcast.big); + + return TRUE; +} + static gboolean get_cis(const GDBusPropertyTable *property, DBusMessageIter *iter, void *data) { @@ -880,6 +895,18 @@ static gboolean get_cis(const GDBusPropertyTable *property, return TRUE; } +static gboolean get_bis(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *data) +{ + struct media_transport *transport = data; + struct bap_transport *bap = transport->data; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_BYTE, + &bap->qos.bcast.bis); + + return TRUE; +} + static gboolean get_interval(const GDBusPropertyTable *property, DBusMessageIter *iter, void *data) { @@ -899,6 +926,9 @@ static gboolean get_framing(const GDBusPropertyTable *property, struct bap_transport *bap = transport->data; dbus_bool_t val = bap->qos.ucast.framing; + if (media_endpoint_is_broadcast(transport->endpoint)) + val = bap->qos.bcast.framing; + dbus_message_iter_append_basic(iter, DBUS_TYPE_BOOLEAN, &val); return TRUE; @@ -910,6 +940,12 @@ static gboolean get_phy(const GDBusPropertyTable *property, struct media_transport *transport = data; struct bap_transport *bap = transport->data; + if (media_endpoint_is_broadcast(transport->endpoint)) { + dbus_message_iter_append_basic(iter, DBUS_TYPE_BYTE, + &bap->qos.bcast.io_qos.phy); + return TRUE; + } + dbus_message_iter_append_basic(iter, DBUS_TYPE_BYTE, &bap->qos.ucast.io_qos.phy); @@ -922,6 +958,12 @@ static gboolean get_sdu(const GDBusPropertyTable *property, struct media_transport *transport = data; struct bap_transport *bap = transport->data; + if (media_endpoint_is_broadcast(transport->endpoint)) { + dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT16, + &bap->qos.bcast.io_qos.sdu); + return TRUE; + } + dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT16, &bap->qos.ucast.io_qos.sdu); @@ -1040,6 +1082,121 @@ static gboolean get_links(const GDBusPropertyTable *property, return TRUE; } +static gboolean get_sync_interval(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *data) +{ + struct media_transport *transport = data; + struct bap_transport *bap = transport->data; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_BYTE, + &bap->qos.bcast.sync_interval); + + return TRUE; +} + +static gboolean get_packing(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *data) +{ + struct media_transport *transport = data; + struct bap_transport *bap = transport->data; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_BYTE, + &bap->qos.bcast.packing); + + return TRUE; +} + +static gboolean get_bcode(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *data) +{ + struct media_transport *transport = data; + struct bap_transport *bap = transport->data; + DBusMessageIter array; + + dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, + DBUS_TYPE_BYTE_AS_STRING, &array); + + if (bap->qos.bcast.bcode && bap->qos.bcast.bcode->iov_len) + dbus_message_iter_append_fixed_array(&array, DBUS_TYPE_BYTE, + &bap->qos.bcast.bcode->iov_base, + bap->qos.bcast.bcode->iov_len); + + dbus_message_iter_close_container(iter, &array); + return TRUE; +} + +static gboolean get_options(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *data) +{ + struct media_transport *transport = data; + struct bap_transport *bap = transport->data; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_BYTE, + &bap->qos.bcast.options); + + return TRUE; +} + +static gboolean get_skip(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *data) +{ + struct media_transport *transport = data; + struct bap_transport *bap = transport->data; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT16, + &bap->qos.bcast.skip); + + return TRUE; +} + +static gboolean get_sync_timeout(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *data) +{ + struct media_transport *transport = data; + struct bap_transport *bap = transport->data; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT16, + &bap->qos.bcast.sync_timeout); + + return TRUE; +} + +static gboolean get_sync_cte_type(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *data) +{ + struct media_transport *transport = data; + struct bap_transport *bap = transport->data; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_BYTE, + &bap->qos.bcast.sync_cte_type); + + return TRUE; +} + +static gboolean get_mse(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *data) +{ + struct media_transport *transport = data; + struct bap_transport *bap = transport->data; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_BYTE, + &bap->qos.bcast.mse); + + return TRUE; +} + +static gboolean get_timeout(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *data) +{ + struct media_transport *transport = data; + struct bap_transport *bap = transport->data; + + dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT16, + &bap->qos.bcast.timeout); + + return TRUE; +} + static const GDBusPropertyTable bap_properties[] = { { "Device", "o", get_device }, { "UUID", "s", get_uuid }, @@ -1059,6 +1216,17 @@ static const GDBusPropertyTable bap_properties[] = { { "Location", "u", get_location }, { "Metadata", "ay", get_metadata }, { "Links", "ao", get_links, NULL, links_exists }, + { "BIG", "y", get_big, NULL, qos_exists }, + { "BIS", "y", get_bis, NULL, qos_exists }, + { "SyncInterval", "y", get_sync_interval, NULL, qos_exists }, + { "Packing", "y", get_packing, NULL, qos_exists }, + { "BCode", "ay", get_bcode, NULL, qos_exists }, + { "Options", "y", get_options, NULL, qos_exists }, + { "Skip", "q", get_skip, NULL, qos_exists }, + { "SyncTimeout", "q", get_sync_timeout, NULL, qos_exists }, + { "SyncCteType", "y", get_sync_cte_type, NULL, qos_exists }, + { "MSE", "y", get_mse, NULL, qos_exists }, + { "Timeout", "q", get_timeout, NULL, qos_exists }, { } }; @@ -1341,6 +1509,71 @@ static gboolean bap_resume_wait_cb(void *data) return FALSE; } +static void bap_update_bcast_qos(const struct media_transport *transport) +{ + struct bap_transport *bap = transport->data; + struct bt_bap_qos *qos; + + qos = bt_bap_stream_get_qos(bap->stream); + + if (!memcmp(qos, &bap->qos, sizeof(struct bt_bap_qos))) + return; + + bap->qos = *qos; + + g_dbus_emit_property_changed(btd_get_dbus_connection(), + transport->path, MEDIA_TRANSPORT_INTERFACE, + "BIG"); + g_dbus_emit_property_changed(btd_get_dbus_connection(), + transport->path, MEDIA_TRANSPORT_INTERFACE, + "BIS"); + g_dbus_emit_property_changed(btd_get_dbus_connection(), + transport->path, MEDIA_TRANSPORT_INTERFACE, + "SyncInterval"); + g_dbus_emit_property_changed(btd_get_dbus_connection(), + transport->path, MEDIA_TRANSPORT_INTERFACE, + "Packing"); + g_dbus_emit_property_changed(btd_get_dbus_connection(), + transport->path, MEDIA_TRANSPORT_INTERFACE, + "Framing"); + g_dbus_emit_property_changed(btd_get_dbus_connection(), + transport->path, MEDIA_TRANSPORT_INTERFACE, + "BCode"); + g_dbus_emit_property_changed(btd_get_dbus_connection(), + transport->path, MEDIA_TRANSPORT_INTERFACE, + "Options"); + g_dbus_emit_property_changed(btd_get_dbus_connection(), + transport->path, MEDIA_TRANSPORT_INTERFACE, + "Skip"); + g_dbus_emit_property_changed(btd_get_dbus_connection(), + transport->path, MEDIA_TRANSPORT_INTERFACE, + "SyncTimeout"); + g_dbus_emit_property_changed(btd_get_dbus_connection(), + transport->path, MEDIA_TRANSPORT_INTERFACE, + "SyncCteType"); + g_dbus_emit_property_changed(btd_get_dbus_connection(), + transport->path, MEDIA_TRANSPORT_INTERFACE, + "MSE"); + g_dbus_emit_property_changed(btd_get_dbus_connection(), + transport->path, MEDIA_TRANSPORT_INTERFACE, + "Timeout"); + g_dbus_emit_property_changed(btd_get_dbus_connection(), + transport->path, MEDIA_TRANSPORT_INTERFACE, + "Interval"); + g_dbus_emit_property_changed(btd_get_dbus_connection(), + transport->path, MEDIA_TRANSPORT_INTERFACE, + "Latency"); + g_dbus_emit_property_changed(btd_get_dbus_connection(), + transport->path, MEDIA_TRANSPORT_INTERFACE, + "PHY"); + g_dbus_emit_property_changed(btd_get_dbus_connection(), + transport->path, MEDIA_TRANSPORT_INTERFACE, + "SDU"); + g_dbus_emit_property_changed(btd_get_dbus_connection(), + transport->path, MEDIA_TRANSPORT_INTERFACE, + "RTN"); +} + static guint resume_bap(struct media_transport *transport, struct media_owner *owner) { @@ -1493,7 +1726,10 @@ static void bap_state_changed(struct bt_bap_stream *stream, uint8_t old_state, if (owner && owner->pending) return; bap_update_links(transport); - bap_update_qos(transport); + if (!media_endpoint_is_broadcast(transport->endpoint)) + bap_update_qos(transport); + else if (bt_bap_stream_io_dir(stream) != BT_BAP_BCAST_SOURCE) + bap_update_bcast_qos(transport); transport_update_playing(transport, FALSE); return; case BT_BAP_STREAM_STATE_DISABLING: @@ -1503,6 +1739,8 @@ static void bap_state_changed(struct bt_bap_stream *stream, uint8_t old_state, return; break; case BT_BAP_STREAM_STATE_STREAMING: + if (bt_bap_stream_io_dir(stream) == BT_BAP_BCAST_SOURCE) + bap_update_bcast_qos(transport); break; } From patchwork Wed Jul 12 08:58:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudia Draghicescu X-Patchwork-Id: 13309861 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B43FEC0015E for ; Wed, 12 Jul 2023 09:03:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233005AbjGLJDj (ORCPT ); Wed, 12 Jul 2023 05:03:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233104AbjGLJCl (ORCPT ); Wed, 12 Jul 2023 05:02:41 -0400 Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2049.outbound.protection.outlook.com [40.107.104.49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F9291724 for ; Wed, 12 Jul 2023 02:01:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nYWfKgXSDNcLeQF9TO/4reHeNAtS1MI/AqLtpC7hw7uJU8PsbFblFf0klGfs6x2FxBaxB+tDXugcu8/EftRkDOmtI0oziPTPlbA6mUeqwsFIJPdnydHikc5vOJJ1LTFOX1Mw2uTIJFHrhZOw4lgnWndZG6OpxAoU1UFnptc58ieyM9NHCT1iUguy8vomIEofzqEmg+odzGYFkHKLa3CiOUjaCx3ta5crUHOFvQ56bXETAnGKtpeNBhrS4y/cWpSYBdW+WpcMmSW3UP7AsSrLWTd0my3SdMWPY4Qc4s51cWc9sYEowwslRtO4/elIJX01V+VNIqrdgn7UdjForHfZaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=IrxBLncj+ZstmuJpGTINckKfaoffvLT9Zud2iiwClqg=; b=fTyVGqjqUGntI8aR+IMWbJ065cauIrexO9YcOk+meJ1VJHcHz/14HXDObUmpbB1Ii7sfPHmtqigORDInLkrzwvLQ4l6mMtcipRU3c8pLBEtNV7zGfGE5wUeyE5FIMc7/7nVjUiibEI6EehZt47AlXwZKDOjkbyijkAStdRO5FltP4SBHs17IOy3piq6uJ8C/43/V2AzhHD2zk9O+0cSc5rzROGhwjNkI9XVcw1It1BzlMn+1s6zvpi/nrPAHgHbYkKboYG8cOGgaR+TGbj6OYSAqPr1bRuuwHAGgtIcSKIy8f9mwDY9lLoIH0mn5qMtZiEjjXufkh7K1GKniCa6QTQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IrxBLncj+ZstmuJpGTINckKfaoffvLT9Zud2iiwClqg=; b=MLhcAUEK8zAX31awWpuZB1sL9Gv74DCNy4tCmvNf1fCSGc9qo6+s2k2m9VkFoY9DIYo+z93zaUmnKBWVYpI55W7Tkp+G6LYGDKaJKu4HLraX+uT0dPceERqSNqEFh7ztIxPEALxA038PZDsNCCMm2THTtZJSuy8WwvJQZtHe/nE= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from GV1PR04MB9151.eurprd04.prod.outlook.com (2603:10a6:150:26::9) by PAXPR04MB8525.eurprd04.prod.outlook.com (2603:10a6:102:210::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.24; Wed, 12 Jul 2023 09:01:27 +0000 Received: from GV1PR04MB9151.eurprd04.prod.outlook.com ([fe80::2cc8:4c5d:9b6f:5cab]) by GV1PR04MB9151.eurprd04.prod.outlook.com ([fe80::2cc8:4c5d:9b6f:5cab%7]) with mapi id 15.20.6588.017; Wed, 12 Jul 2023 09:01:26 +0000 From: Claudia Draghicescu To: linux-bluetooth@vger.kernel.org Cc: iulia.tanasescu@nxp.com, mihai-octavian.urzica@nxp.com, silviu.barbulescu@nxp.com, vlad.pruteanu@nxp.com, andrei.istodorescu@nxp.com, Claudia Draghicescu Subject: [PATCH BlueZ 5/6] btio: Add support for getsockopt(BT_ISO_BASE) Date: Wed, 12 Jul 2023 11:58:59 +0300 Message-Id: <20230712085900.5423-6-claudia.rosu@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230712085900.5423-1-claudia.rosu@nxp.com> References: <20230712085900.5423-1-claudia.rosu@nxp.com> X-ClientProxiedBy: AS4P250CA0004.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:5df::12) To GV1PR04MB9151.eurprd04.prod.outlook.com (2603:10a6:150:26::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1PR04MB9151:EE_|PAXPR04MB8525:EE_ X-MS-Office365-Filtering-Correlation-Id: 96bea680-a563-43d1-2541-08db82b69324 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dDGrklGD4bWWLQj6wN6SBehyMFrB2FczXwnl9mo/GbglCVDjRMwkVhJB74621CHJfx1VDrfYwy6TqYo9GDZZ3rtnB3tYGzhbs51EHq5wnSiXbT+jacSCigr7X93Vh/UNk7FrQthdR1p2LNjYoiS2gT8hFhMyp+qXKr+y4OPLAaNJppottGnZpuhrnEALmKnBLxnBTI2NUumQgL0cngrTItg2H1+sxBKDk2SUo0feGpmlHWnLCKXvT7dG1PXgTkXwPdpkZk8OwmYdAZK5Y+40MRyGF0KKIA7ZYHHydMRUsjE5A3b8fV8Mshq2ITGICjLK6l4eTkH0fWVg0VDBNSN8AHcyPjeDu9oNbSCHx4ReIKf7BFvj2sAscbK7jZEKieZsRAHTje4r3T5+8awkmIMczKNPj5DJBJcFDre4LcDbxa8X3R4+XQyoXyOTBhRnF/1eb4YMDgYb5cthGyk0bLPjTT6coTTKFE2XZXOz7lrzgQNxdTj6xqvtIAGvpay/sQkLlt80qgW5GRNEqzy7HY6/UCzRlzppj5VAzaVcXrcOohsStTesosNBp26I6E1WclGZkt6pUSxqJbBXO2umcMfo4i4JMm+ZrFvPaOHEQtbisjMYaU09t6ty6k0UyZmCt+DQ X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:GV1PR04MB9151.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(376002)(366004)(39860400002)(346002)(396003)(136003)(451199021)(55236004)(83380400001)(2616005)(2906002)(36756003)(86362001)(38350700002)(38100700002)(41300700001)(4326008)(52116002)(6916009)(6512007)(316002)(6486002)(5660300002)(8676002)(8936002)(478600001)(66946007)(66476007)(6666004)(66556008)(186003)(26005)(1076003)(6506007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: UWCB1otFWESrjRKJeMgGlPw71Xjt7N3+9up4PdAXV9s0WxXIWjyYYOI/lK48ZYbm+wpmfZkf3MaMdTJBO2l6yWL0HMzI8KBoHeZzDCl79tbyKtplphf5z9bsW0n4GUOkKrMbgf8diZB+KLvoNVCeaLylnfk3NHnKdqJ7o59D8a5C3JIFd/XunrPNCzBv5hke18BrdKo1HFvRVPedGvPCDRdKKQN0b4v08JkbFUEKYzj+1tzpgaReLdP8Kup0xW0ay+piGFZzAkv5PSbbarAxdsALyBygZgHghqve13Od1UmMurK5b4rm6dXmiPcI1XYOGTP85fG/qvEZArsaZ7hD+gHgXRLYEFsheJaGksBzvNl/tBxJXeDdVwTmNCDLjrPcsxp0yhoIH59fk80u1mG/fFgDOJq4g8nSgD8mAKYPYdHBuTm/ipZK3+geyxhTKkFSUvX+9CsaEU6YPxIJ7ssFrIudElH5YEnlJh62P9FoGxlJVbW8ngFq+tP0NHIzkHmgDYTZWRCvkTHWQfVxHtNJ+6jgheCtyqDJMh9QFOyv0rmXTmjjnofGxqjOn4g6khKUF6EO0LTSWDfgGk691oCai+VpYuOxvk1dZ+Cfrr9kNT+PqxDLzGr1kjDLvFZF1dWY1PNKk/G74hsGjPJs//2aSolDqsTaL1Nv0P2U7XHje0S2yCboWmY3dLEmykW8pINiiChEukHWh9sfgXbWt3IZ8SdMqnCYGFjw3RXje37LcYLz5Vrgba2e4+ptz9lVZSQ1mt+0qpA/TTjzeCpbggw2BMXqVG7aqOgd0YG1EBhc5Mbo0HhgLAHaL2s8U62p4BLij6Sf3TGc7d/i+BHVvnhhUt/XgerCiDjr1+nWI5sdFwMZoK6+fVI+1wOpgDwbwyD1j5LsBq9oXxYebts7QsDh57nu/WmcXxB38yZebJ7wGyBGLj4Q5WIHBuHPmi1UMP71ed0wBEMaq1E8wlh+ke4IfvvBqd8C+uZ/shJ3RCasmtcifSG3ymEcKtHIJfdfCQKR2azVbsa52lQBtvWIsD8wMX72vsbh9CzLrcKrPtIb2pmRBpI6F/bsWSDapLOAEWG/UxEX9a4VJhxCemgBuDfN6oLWpHtTAdIQLx/nYwGSWbKyOem8q72y+ZBU6TCnivZ+Ob77TUXMB2p7d+2SzdLwiA57ihbKHX60nDxYMpISuYFwAEHVqG1x7VXFogNXaYLhCYSPr0NsHiKqXVEn0WUgI/gnk/FJYyq2eRuCRpAGHzRJncnzPYWFTrF6UbttO36ZWOtZvnx/4BgdGxgUxpYe0ruSc1SQB2np+yNYqsJ6tiotGM9GohL94D8SN8p9itsa2C6wjwlYmQZes6mODYVGKb8Wv2I7O1DQ5Pv9yjGAC6iwLZoUkhfBrJrMhCzpDD+pW4n9vpz1CYnmcb8/sAm8lwUkT89ZNBw1o0ORZEOD9AfZ8jrXgocUid5ECkhrGmMQuxExkWiEjzmx158C9bqEas2g1u0filFL/SfQaa4XKthLe1sWf5VwhoFKMaf9HrZsqYC40pRVRzqLnHvQ+3u9c2mnqUsea/hdgo9YHJS0tsbrr1PyrHz4k1MDhGkSGOi1maUDlW0+ZBwhcFIpRY+VPw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 96bea680-a563-43d1-2541-08db82b69324 X-MS-Exchange-CrossTenant-AuthSource: GV1PR04MB9151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jul 2023 09:01:26.9047 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: B6qLlCrXJB7HwCte+/NoB+J5AHj5KCr/+WnOXH5P10nfJB2H3iHlL7Ux5i55xHXqT0s99dsjo2n9kGPG54MBFQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8525 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This adds the posibility for a broadcast sink to retrieve the BASE information received from a source afeter a PA synchronization, using the getsockopt(BT_ISO_BASE) function. This needs the patch from bluetooth-next: Bluetooth: ISO: Add support for periodic adv reports processing --- btio/btio.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/btio/btio.c b/btio/btio.c index 179be6289..8178250d2 100644 --- a/btio/btio.c +++ b/btio/btio.c @@ -1638,6 +1638,7 @@ static gboolean iso_get(int sock, GError **err, BtIOOption opt1, va_list args) BtIOOption opt = opt1; struct sockaddr_iso src, dst; struct bt_iso_qos qos; + struct bt_iso_base base; socklen_t len; uint32_t phy; @@ -1648,6 +1649,11 @@ static gboolean iso_get(int sock, GError **err, BtIOOption opt1, va_list args) return FALSE; } + if (getsockopt(sock, SOL_BLUETOOTH, BT_ISO_BASE, &base, &len) < 0) { + ERROR_FAILED(err, "getsockopt(BT_ISO_BASE)", errno); + return FALSE; + } + if (!get_src(sock, &src, sizeof(src), err)) return FALSE; @@ -1694,6 +1700,8 @@ static gboolean iso_get(int sock, GError **err, BtIOOption opt1, va_list args) *(va_arg(args, struct bt_iso_qos *)) = qos; break; case BT_IO_OPT_BASE: + *(va_arg(args, struct bt_iso_base *)) = base; + break; case BT_IO_OPT_HANDLE: case BT_IO_OPT_CLASS: case BT_IO_OPT_DEFER_TIMEOUT: @@ -1896,8 +1904,9 @@ static GIOChannel *create_io(gboolean server, struct set_opts *opts, goto failed; if (!iso_set_qos(sock, &opts->qos, err)) goto failed; - if (!iso_set_base(sock, &opts->base, err)) - goto failed; + if (opts->base.base_len) + if (!iso_set_base(sock, &opts->base, err)) + goto failed; break; case BT_IO_INVALID: default: From patchwork Wed Jul 12 08:59:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudia Draghicescu X-Patchwork-Id: 13309860 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7CD58EB64DD for ; Wed, 12 Jul 2023 09:03:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232937AbjGLJDi (ORCPT ); Wed, 12 Jul 2023 05:03:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233125AbjGLJCn (ORCPT ); Wed, 12 Jul 2023 05:02:43 -0400 Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2062.outbound.protection.outlook.com [40.107.104.62]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 38E571726 for ; Wed, 12 Jul 2023 02:01:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bEUBGz8wex7UuWZWeIwUO/m5fzm16MuKxtOkCn8jV6HrbEf+QMAD3yRFmUjwV1091AmCVt6yBIf7Tv7AwKAc36dq+RHVCdv7fP7Hs9Y0WuNKITKtL3Wddtc89AUFDozRjtTYJUjKMb+hSdzckjMru30RCZEicVRUkCFngTPx5RylascLoT0Y7mdtuHRX0Pii8l+w3f5n/yj/Aj1XwEWTr4qXhYmMzQjj6YFrvbmUFWz2UuCF4JajCqSvid9gfwZ75z1TLin4eBPJCAKFix8D3IYmv4Xu740niavCrScJQOR6Uj/PzmUFViW9IQo6JMoqQYU2/pGaY+kecTFqRJl8Vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=S0N0ZYtO8OeHHsDbmvViYa1abPb6Z1wfDuv1NAo6qi0=; b=SOGYO1bSU+ZsBkz6zVZ6C6WKqxTcUGU96DMN1kZjdbB85RAzkOP2+247yJtSr3sVbiIHa33Ei4kVWJjAwbX462CR8No3a5FHh2CMPkKZppUsLtw10TCX8+S9zns8R1bENckkG6XFIgF++H6LTgc+QA8sFMW5fwFdISAFgfcQiSBcJcUtoOwNlcXqj/VQiLjraL0/p31n71es9bulf7nPXgGwR5tfY/qJU4j20mhcwfi57b20SLBN+OifHDNeMHZSxiFoawWFxY1txGJk2H5ms9VRP4d0q5zDOa3cxLhEO4Hh7JXGBP5kvr2AdB6ivZyWlscr/zZyC3ryLVY4qVVlKQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=S0N0ZYtO8OeHHsDbmvViYa1abPb6Z1wfDuv1NAo6qi0=; b=QhMZs7yXdLJc0DO/ki/8SLySVxO8dKOIv92px5ZC8ZwQKtrKbesNUOFmYytpe0k3c+jO1lMXY08viIgZLIOhoyssFg1ZvVOTDxhrXda0Z2qBelVW6wa2/8g8HEeORcKSQwmBpFMLMrsHdPyBlI/06qVb+mOA2yIp4LbZuKCVB7Y= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from GV1PR04MB9151.eurprd04.prod.outlook.com (2603:10a6:150:26::9) by PAXPR04MB8525.eurprd04.prod.outlook.com (2603:10a6:102:210::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.24; Wed, 12 Jul 2023 09:01:29 +0000 Received: from GV1PR04MB9151.eurprd04.prod.outlook.com ([fe80::2cc8:4c5d:9b6f:5cab]) by GV1PR04MB9151.eurprd04.prod.outlook.com ([fe80::2cc8:4c5d:9b6f:5cab%7]) with mapi id 15.20.6588.017; Wed, 12 Jul 2023 09:01:29 +0000 From: Claudia Draghicescu To: linux-bluetooth@vger.kernel.org Cc: iulia.tanasescu@nxp.com, mihai-octavian.urzica@nxp.com, silviu.barbulescu@nxp.com, vlad.pruteanu@nxp.com, andrei.istodorescu@nxp.com, Claudia Draghicescu Subject: [PATCH BlueZ 6/6] bap: Add support for BAP broadcast sink Date: Wed, 12 Jul 2023 11:59:00 +0300 Message-Id: <20230712085900.5423-7-claudia.rosu@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230712085900.5423-1-claudia.rosu@nxp.com> References: <20230712085900.5423-1-claudia.rosu@nxp.com> X-ClientProxiedBy: AS4P250CA0004.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:5df::12) To GV1PR04MB9151.eurprd04.prod.outlook.com (2603:10a6:150:26::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1PR04MB9151:EE_|PAXPR04MB8525:EE_ X-MS-Office365-Filtering-Correlation-Id: 36ad1a27-0ed7-4071-792f-08db82b6948e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aXR3pzL/I6TBHR5IOu230aoy5HSBV6PgHgI7t/f3WQt07qZkIEmTWBN1DYUDXy9UyA4rRs6A4hjuhCTGVjQYSr9TbHR6sW25H+a2zsdfBrghcSCtoi8HVJQMpRT96nOrnUlkJZt855AoJYKWovblywh3X1hF3qagEJG6ts3C2Pyn+LsxjkYHg6dCLOnAeSIa19LYD8hlKkdq8dacwdU5e4uqA2UVLPWjpEl4/NtVzrN9E4FOIhRpdzSe6WIuYi8K7ag4AZmv8hyx7uvjfuftkCVZ9vCPPy2wzKZg5Z4mDnkNhVmcLxcSDmQvIjwLObuBZTkNYUCV2MqQ7zD4QBbQq+MA7khqtHCCQqBzK+1MtRgOwqgAUl+MiZVhugJ272mxC6GF+j1VzaHVUIJVNgRw7RBLMfrUH6px5Zq2Nw06ZmJbwYZFoisOflw7+DUMnh3Uvj7Y4iJWMl/9OIgm1IrhxGGX6Ls4sAlDfLOrTSHeNa3uYfi8xUUKj6OPnpUPLpz+UUQZBBLPXjVKxonwr0TpIhzK5NbluqYdkoUUpGZ2zl/NdglUMfgpMuUqwfr56FLkk/97Sr/pbrZ9FY363Oy+J8pg83plGoLS+QWTNnn85lGveghDA2cfMHx6YkorDbc4 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:GV1PR04MB9151.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(376002)(366004)(39860400002)(346002)(396003)(136003)(451199021)(55236004)(83380400001)(30864003)(2616005)(2906002)(36756003)(86362001)(38350700002)(38100700002)(41300700001)(4326008)(52116002)(6916009)(6512007)(316002)(6486002)(5660300002)(8676002)(8936002)(478600001)(66946007)(66476007)(6666004)(66556008)(186003)(26005)(1076003)(6506007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: lD5scFpboZITicT/TaBZ5D3lEjazqGwKb/PokkcbseS4G4LI4w57WZADVwyAyHlJ1wB0a3OCN7zXa6l+fbj1OJoenXuUErgOprbUzYkkNtWiG+Dy0Q+ZBIUGx1znUlJ1heUoy7ryhOEgOWMQkrOkgfXuHbjC9uA2TVbbL4xmhaL0RQLQy6cN+p6eziN/Fegll6445OfEeufBOATTcMM6RfKatuPmPu83qPsKlmo39GgqKBiYtagQHVaOetQpg16aw1gv3d1tbpv0GbnpDNBrdYwaguVzG/nwtFup8Ge8gHBcbntv50hIDdSLAfWjHPkEhW3lBZmiR5CLJWjsTSbB0iUwPrzmdd9VK8GEq1hpPUMYBt1t1Y1XKD4XUOmobbKLh2oOmxn1XL5DckQ0wKCqbqx7aw1Z+gh9LXaOTR7LMgLHcX0VFyA37HNd4JVcCHsITalrEtnjAbsbCsyVg+ewlQZhdMC3Nx720LC6gXsD7mbF9rSNsVYDa31PDkgQ9BEdpnL8zAjYO1mHMG21DD0r72mH3vU3U2LM+v5UwPgAna2ExXBMAPnQVGHdwpndd0wZYuI/syGy8VK1Hqqr5wguUnBFMkWmEJoe+bsuYTBn8ArRNaPKzY420PgRmtjkCXJS6nAEbnea2dLRTpd1DPn+xNpy7jzBbietkEFzv5qT9mI/BMqUCKmS44djokhTfJnmOHPVBw8AFBo9GyarU0w7WLfOXzuSgvzK4HqqSpJsrkNcXWUT/WQtg2H4nhrSsBNUTnXbS4m5Id2AyXpiCEoJiVT4mk/qIg6MGB591MZqn93iS9w97mOqmz7qCuNPNviFjvUfsdizVALxl6JPwRmmKMBtuDHoeI6A0ChjDCYkDyPuHDJemVO5ndH11tSYifttMppEk5KAy1+rCXk944BIRyZP7IrGtrwTdIsjH8MJBGgsg+uTB7lBB2w+YP7G4G67MFeyM706/6NwcdhezHYkvZHQr4sCnowQ5X43gIGzIipCREfRI/8EkboZ8J3OBb65zX7CNjdGNgD5xbgAGT3fRagSzi8wYNbc/dRD7NTy6OJX1Rwc44EkjeDevKbt5GfkavJTw6RgOBhx2fr3DEZCEJHqKqs5bj9aZw/y3cTp51A5meji4Yppz+t2v9k94sePQMoI/c2Jt4j3R1F1a0WAvtah7Q0BtxozVGN0amkykErj7Up6tRNjRUJmH/33kG46me7t6Zf3u9dOIl+8TEhC4fIvzpSqxK1Vffm/UQ6GpuG7xRarcFwfWT+xv3K8JBj4/xUNVKyasKzdDN9muyisQaCrp90KO+43RZlq3yhqFmB7Gn7xABTGSOk8D/dt0UFKzGQHxdUuVcqA5mT980iqutcygof1DSOrYOXfP3drpyJ3gWAyPw/KIHt0Ut+WFsPcISaFNnzPhQkjD+8MVIDH7z2KWTJZqScjEB0o6WECj8pxo/W5l7jkWDKxP/1UhK6MhrGIRAUDs5k2EC3RIwh97gZiM2E8o4k+g6yhUupt1BsL7gJLUeHiKb4uo6dJcke8S5xHUMFfYBq4G/XK4fOv0UFny9dQwqOClNKh/2oZwtwnpJhQoOMK6gcXkXGYMosnsQ6df5gW4SE3FNvyeA7pjw== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 36ad1a27-0ed7-4071-792f-08db82b6948e X-MS-Exchange-CrossTenant-AuthSource: GV1PR04MB9151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jul 2023 09:01:29.4130 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: e6dFlEr6O6DFsL4Y2ynPxAG4QYJR7d2+MFd0yQBkITbUksi584hT3Nafn3GoSxG/N6bbqx7WivKsJW2Iawqctw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8525 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This adds support for BAP broadcast sink, adds a new gdbus method to synchronize to a given source and sets the QOS and capabilities of the stream. This feature was tested using bluetoothctl with the following commands: [bluetooth]# endpoint.register 00002bc9-0000-1000-8000-00805f9b34fb 0x06 [/local/endpoint/ep0] Auto Accept (yes/no): y [/local/endpoint/ep0] Max Transports (auto/value): a [/local/endpoint/ep0] unicast/broadcast (u/b): b [/local/endpoint/ep0] BIG (auto/value): a [/local/endpoint/ep0] BIS (auto/value): a [bluetooth]# scan on [bluetooth]# endpoint.config /org/bluez/hci0/pac_bcast0 /local/endpoint/ep0 16_2_1 --- profiles/audio/bap.c | 347 ++++++++++++++++++++++++++++++++++++++++--- src/shared/bap.c | 50 ++++++- src/shared/bap.h | 4 +- 3 files changed, 370 insertions(+), 31 deletions(-) diff --git a/profiles/audio/bap.c b/profiles/audio/bap.c index d7ce9e038..5cb109950 100644 --- a/profiles/audio/bap.c +++ b/profiles/audio/bap.c @@ -34,6 +34,7 @@ #include "lib/hci.h" #include "lib/sdp.h" #include "lib/uuid.h" +#include "lib/iso.h" #include "src/btd.h" #include "src/dbus-common.h" @@ -185,6 +186,9 @@ static gboolean get_uuid(const GDBusPropertyTable *property, uuid = PAC_SINK_UUID; else if (queue_find(ep->data->srcs, NULL, ep)) uuid = PAC_SOURCE_UUID; + else if ((queue_find(ep->data->bcast, NULL, ep) + && (bt_bap_pac_get_type(ep->lpac) == BT_BAP_BCAST_SINK))) + uuid = PAC_SINK_UUID; else uuid = BAA_SERVICE_UUID; @@ -232,7 +236,8 @@ static gboolean get_device(const GDBusPropertyTable *property, struct bap_ep *ep = data; const char *path; - if (bt_bap_pac_get_type(ep->lpac) == BT_BAP_BCAST_SOURCE) + if ((bt_bap_pac_get_type(ep->lpac) == BT_BAP_BCAST_SOURCE) + || (bt_bap_pac_get_type(ep->lpac) == BT_BAP_BCAST_SINK)) path = adapter_get_path(ep->data->adapter); else path = device_get_path(ep->data->device); @@ -555,7 +560,7 @@ static DBusMessage *set_configuration(DBusConnection *conn, DBusMessage *msg, } if (bt_bap_pac_get_type(ep->lpac) == BT_BAP_BCAST_SOURCE) { - /* Mark CIG and CIS to be auto assigned */ + /* Mark BIG and BIS to be auto assigned */ ep->qos.bcast.big = BT_ISO_QOS_BIG_UNSET; ep->qos.bcast.bis = BT_ISO_QOS_BIS_UNSET; } else { @@ -576,8 +581,12 @@ static DBusMessage *set_configuration(DBusConnection *conn, DBusMessage *msg, ep->stream = bt_bap_stream_new(ep->data->bap, ep->lpac, ep->rpac, &ep->qos, ep->caps); - ep->id = bt_bap_stream_config(ep->stream, &ep->qos, ep->caps, - config_cb, ep); + if (bt_bap_pac_get_type(ep->lpac) == BT_BAP_BCAST_SINK) + ep->id = bt_bap_stream_config(ep->stream, &ep->qos, NULL, + config_cb, ep); + else + ep->id = bt_bap_stream_config(ep->stream, &ep->qos, ep->caps, + config_cb, ep); if (!ep->id) { DBG("Unable to config stream"); free(ep->caps); @@ -603,14 +612,296 @@ static DBusMessage *set_configuration(DBusConnection *conn, DBusMessage *msg, return NULL; } +static void update_bcast_qos(struct bt_iso_qos *qos, + struct bt_bap_qos *bap_qos) +{ + bap_qos->bcast.big = qos->bcast.big; + bap_qos->bcast.bis = qos->bcast.bis; + bap_qos->bcast.sync_interval = qos->bcast.sync_interval; + bap_qos->bcast.packing = qos->bcast.packing; + bap_qos->bcast.framing = qos->bcast.framing; + bap_qos->bcast.encryption = qos->bcast.encryption; + bap_qos->bcast.options = qos->bcast.options; + bap_qos->bcast.skip = qos->bcast.skip; + bap_qos->bcast.sync_timeout = qos->bcast.sync_timeout; + bap_qos->bcast.sync_cte_type = qos->bcast.sync_cte_type; + bap_qos->bcast.mse = qos->bcast.mse; + bap_qos->bcast.timeout = qos->bcast.timeout; + bap_qos->bcast.io_qos.interval = qos->bcast.in.interval; + bap_qos->bcast.io_qos.latency = qos->bcast.in.latency; + bap_qos->bcast.io_qos.phy = qos->bcast.in.phy; + bap_qos->bcast.io_qos.sdu = qos->bcast.in.sdu; + bap_qos->bcast.io_qos.rtn = qos->bcast.in.rtn; + + bap_qos->bcast.bcode = new0(struct iovec, 1); + util_iov_memcpy(bap_qos->bcast.bcode, qos->bcast.bcode, + sizeof(qos->bcast.bcode)); +} + +static bool match_bcast_stream_qos(const void *data, const void *user_data) +{ + + const struct bt_bap_stream *stream = data; + const struct bt_iso_qos *iso_qos = user_data; + struct bt_bap_qos *qos; + + qos = bt_bap_stream_get_qos((void *)stream); + + if (iso_qos->bcast.big != qos->bcast.big) + return false; + + return iso_qos->bcast.bis == qos->bcast.bis; +} + +static void bap_add_stream(struct bap_data *data, + struct bt_bap_stream *stream) +{ + DBG("stream pointer %p", stream); + + if (!data->streams) + data->streams = queue_new(); + + if (!queue_find(data->streams, NULL, stream)) + queue_push_tail(data->streams, stream); +} + +static void iso_bcast_confirm_cb(GIOChannel *io, GError *err, void *user_data) +{ + struct bap_data *data = user_data; + struct bt_bap_stream *stream; + struct bt_iso_qos qos; + struct bt_iso_base base; + char address[18]; + struct queue *queue; + struct bap_ep *ep; + int fd; + struct iovec *base_io; + + bt_io_get(io, &err, + BT_IO_OPT_DEST, address, + BT_IO_OPT_QOS, &qos, + BT_IO_OPT_BASE, &base, + BT_IO_OPT_INVALID); + if (err) { + error("%s", err->message); + g_error_free(err); + goto drop; + } + + g_io_channel_ref(io); + + DBG("BCAST ISO: sync with %s (BIG 0x%02x BIS 0x%02x)", + address, qos.bcast.big, qos.bcast.bis); + + queue = data->bcast; + ep = queue_pop_head(queue); + if (!ep) { + DBG("ep not found"); + return; + } + + update_bcast_qos(&qos, &ep->qos); + + base_io = new0(struct iovec, 1); + util_iov_memcpy(base_io, base.base, base.base_len); + + ep->id = bt_bap_stream_config(ep->stream, &ep->qos, + base_io, NULL, NULL); + data->listen_io = io; + + bt_bap_stream_set_user_data(ep->stream, ep->path); + + stream = queue_remove_if(data->streams, match_bcast_stream_qos, &qos); + if (!stream) { + DBG("stream removed"); + bap_add_stream(data, ep->stream); + stream = ep->stream; + fd = g_io_channel_unix_get_fd(io); + + if (bt_bap_stream_set_io(stream, fd)) { + bt_bap_stream_enable(stream, true, NULL, NULL, NULL); + g_io_channel_set_close_on_unref(io, FALSE); + return; + } + } else + DBG("stream not removed"); + + return; + +drop: + g_io_channel_shutdown(io, TRUE, NULL); + +} + +static bool match_data_bap_data(const void *data, const void *match_data) +{ + const struct bap_data *bdata = data; + const struct btd_adapter *adapter = match_data; + + return bdata->user_data == adapter; +} + +#define DEFAULT_IO_QOS \ +{ \ + .interval = 10000, \ + .latency = 10, \ + .sdu = 40, \ + .phy = 0x02, \ + .rtn = 2, \ +} + +static DBusMessage *bcast_sink_create(DBusConnection *conn, DBusMessage *msg, + void *user_data) +{ + struct bt_iso_qos qos_bcast; + struct sockaddr_iso_bc iso_bc_addr; + DBusMessageIter iter, args; + const char *key; + GIOChannel *io; + GError *err = NULL; + struct bap_ep *ep = user_data; + uint32_t bcastid; + + memset(&qos_bcast, 0, sizeof(struct bt_iso_qos)); + memset(&iso_bc_addr, 0, sizeof(struct sockaddr_iso_bc)); + + DBG("sender %s", dbus_message_get_sender(msg)); + + dbus_message_iter_init(msg, &args); + + if ((dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_ARRAY) || + (dbus_message_iter_get_element_type(&args) != DBUS_TYPE_DICT_ENTRY)) + return btd_error_invalid_args(msg); + + dbus_message_iter_recurse(&args, &iter); + + while (dbus_message_iter_get_arg_type(&iter) == DBUS_TYPE_DICT_ENTRY) { + DBusMessageIter value, entry; + int var; + + dbus_message_iter_recurse(&iter, &entry); + dbus_message_iter_get_basic(&entry, &key); + + dbus_message_iter_next(&entry); + dbus_message_iter_recurse(&entry, &value); + + var = dbus_message_iter_get_arg_type(&value); + + if (!strcasecmp(key, "SourceAddress")) { + const char *str; + + if (var != DBUS_TYPE_STRING) + goto fail; + + dbus_message_iter_get_basic(&value, &str); + DBG("SourceAddress %s", str); + str2ba(str, &iso_bc_addr.bc_bdaddr); + } else if (!strcasecmp(key, "SourceAddressType")) { + const char *type; + + if (var != DBUS_TYPE_STRING) + goto fail; + + dbus_message_iter_get_basic(&value, &type); + + if (!strcasecmp(type, "public")) + iso_bc_addr.bc_bdaddr_type = BDADDR_LE_PUBLIC; + else + iso_bc_addr.bc_bdaddr_type = BDADDR_LE_RANDOM; + + DBG("SourceAddressType %d", iso_bc_addr.bc_bdaddr_type); + } else if (!strcasecmp(key, "BIS")) { + uint8_t bis; + + if (var != DBUS_TYPE_BYTE) + goto fail; + + dbus_message_iter_get_basic(&value, &bis); + iso_bc_addr.bc_bis[0] = bis; + DBG("BIS %d", iso_bc_addr.bc_bis[0]); + } else if (!strcasecmp(key, "NumBis")) { + if (var != DBUS_TYPE_BYTE) + goto fail; + + dbus_message_iter_get_basic(&value, + &iso_bc_addr.bc_num_bis); + DBG("NumBis %d", iso_bc_addr.bc_num_bis); + } else if (!strcasecmp(key, "BcastID")) { + if (var != DBUS_TYPE_UINT32) + goto fail; + + dbus_message_iter_get_basic(&value, &bcastid); + DBG("BcastID 0x%4.4x", bcastid); + } + + dbus_message_iter_next(&iter); + } + + qos_bcast.bcast.big = ep->qos.bcast.big; + qos_bcast.bcast.bis = ep->qos.bcast.bis; + qos_bcast.bcast.encryption = ep->qos.bcast.encryption; + qos_bcast.bcast.framing = ep->qos.bcast.framing; + qos_bcast.bcast.mse = ep->qos.bcast.mse; + qos_bcast.bcast.options = ep->qos.bcast.options; + qos_bcast.bcast.packing = ep->qos.bcast.packing; + qos_bcast.bcast.skip = ep->qos.bcast.skip; + qos_bcast.bcast.sync_cte_type = ep->qos.bcast.sync_cte_type; + qos_bcast.bcast.sync_interval = ep->qos.bcast.sync_interval; + qos_bcast.bcast.sync_timeout = ep->qos.bcast.sync_timeout; + qos_bcast.bcast.timeout = ep->qos.bcast.timeout; + qos_bcast.bcast.in.interval = ep->qos.bcast.io_qos.interval; + qos_bcast.bcast.in.phy = ep->qos.bcast.io_qos.phy; + qos_bcast.bcast.in.sdu = ep->qos.bcast.io_qos.sdu; + qos_bcast.bcast.in.latency = ep->qos.bcast.io_qos.latency; + qos_bcast.bcast.in.rtn = ep->qos.bcast.io_qos.rtn; + + io = bt_io_listen(iso_bcast_confirm_cb, NULL, ep->data, NULL, &err, + BT_IO_OPT_SOURCE_BDADDR, + btd_adapter_get_address(ep->data->adapter), + BT_IO_OPT_DEST_BDADDR, + &iso_bc_addr.bc_bdaddr, + BT_IO_OPT_DEST_TYPE, + iso_bc_addr.bc_bdaddr_type, + BT_IO_OPT_MODE, BT_IO_MODE_ISO, + BT_IO_OPT_QOS, &qos_bcast, + BT_IO_OPT_ISO_BC_NUM_BIS, iso_bc_addr.bc_num_bis, + BT_IO_OPT_ISO_BC_BIS, iso_bc_addr.bc_bis, + BT_IO_OPT_INVALID); + if (!io) { + error("%s", err->message); + g_error_free(err); + return dbus_message_new_method_return(msg); + } + + ep->data->listen_io = io; + return dbus_message_new_method_return(msg); + +fail: + DBG("Failed parsing %s", key); + return dbus_message_new_method_return(msg); + +} + static const GDBusMethodTable ep_methods[] = { { GDBUS_EXPERIMENTAL_ASYNC_METHOD("SetConfiguration", GDBUS_ARGS({ "endpoint", "o" }, - { "properties", "a{sv}" } ), + { "properties", "a{sv}" }), NULL, set_configuration) }, { }, }; +static const GDBusMethodTable bap_bcast_ep_methods[] = { + { GDBUS_EXPERIMENTAL_ASYNC_METHOD("SetConfiguration", + GDBUS_ARGS({ "endpoint", "o" }, + { "properties", "a{sv}" }), + NULL, set_configuration) }, + + { GDBUS_EXPERIMENTAL_ASYNC_METHOD("BcastSinkCreate", + GDBUS_ARGS({ "properties", "a{sv}" }), + NULL, bcast_sink_create) }, + { }, +}; + static void ep_free(void *data) { struct bap_ep *ep = data; @@ -657,6 +948,7 @@ static struct bap_ep *ep_register_bcast(struct bap_data *data, switch (bt_bap_pac_get_type(rpac)) { case BT_BAP_BCAST_SOURCE: + case BT_BAP_BCAST_SINK: queue = data->bcast; i = queue_length(data->bcast); suffix = "bcast"; @@ -683,15 +975,24 @@ static struct bap_ep *ep_register_bcast(struct bap_data *data, return NULL; } - if (g_dbus_register_interface(btd_get_dbus_connection(), + if (bt_bap_pac_get_type(rpac) == BT_BAP_BCAST_SOURCE) { + if (g_dbus_register_interface(btd_get_dbus_connection(), + ep->path, MEDIA_ENDPOINT_INTERFACE, + bap_bcast_ep_methods, NULL, NULL, + ep, ep_free) == FALSE) { + error("Could not register bap bcast interface %s", + ep->path); + } + } else { + if (g_dbus_register_interface(btd_get_dbus_connection(), ep->path, MEDIA_ENDPOINT_INTERFACE, ep_methods, NULL, ep_properties, ep, ep_free) == FALSE) { - error("Could not register remote ep %s", ep->path); - ep_free(ep); - return NULL; + error("Could not register remote ep %s", ep->path); + ep_free(ep); + return NULL; + } } - bt_bap_pac_set_user_data(rpac, ep->path); DBG("ep %p lpac %p rpac %p path %s", ep, ep->lpac, ep->rpac, ep->path); @@ -724,6 +1025,12 @@ static struct bap_ep *ep_register(struct btd_service *service, i = queue_length(data->srcs); suffix = "source"; break; + case BT_BAP_BCAST_SOURCE: + case BT_BAP_BCAST_SINK: + queue = data->bcast; + i = queue_length(data->bcast); + suffix = "bcast"; + break; default: return NULL; } @@ -823,6 +1130,7 @@ done: queue_foreach(ep->data->srcs, bap_config, NULL); queue_foreach(ep->data->snks, bap_config, NULL); + queue_foreach(ep->data->bcast, bap_config, NULL); } static bool pac_found(struct bt_bap_pac *lpac, struct bt_bap_pac *rpac, @@ -1416,6 +1724,10 @@ static void bap_state(struct bt_bap_stream *stream, uint8_t old_state, break; case BT_BAP_STREAM_STATE_CONFIG: if (ep && !ep->id) { + /* For BAP Sink create io when receiving source info */ + if (bt_bap_pac_get_type(ep->lpac) == BT_BAP_BCAST_SINK) + return; + bap_create_io(data, ep, stream, true); if (!ep->io) { error("Unable to create io"); @@ -1423,7 +1735,6 @@ static void bap_state(struct bt_bap_stream *stream, uint8_t old_state, return; } - if (bt_bap_stream_get_type(stream) == BT_BAP_STREAM_TYPE_UCAST) { /* Wait QoS response to respond */ @@ -1479,7 +1790,9 @@ static void pac_added_broadcast(struct bt_bap_pac *pac, void *user_data) bt_bap_foreach_pac(data->bap, BT_BAP_BCAST_SOURCE, pac_found_bcast, data); - } + } else if (bt_bap_pac_get_type(pac) == BT_BAP_BCAST_SINK) + bt_bap_foreach_pac(data->bap, BT_BAP_BCAST_SINK, + pac_found_bcast, data); } static bool ep_match_pac(const void *data, const void *match_data) @@ -1595,14 +1908,6 @@ static bool match_data(const void *data, const void *match_data) return bdata->bap == bap; } -static bool match_data_bap_data(const void *data, const void *match_data) -{ - const struct bap_data *bdata = data; - const struct btd_adapter *adapter = match_data; - - return bdata->user_data == adapter; -} - static bool io_get_qos(GIOChannel *io, struct bt_iso_qos *qos) { GError *err = NULL; @@ -1853,7 +2158,7 @@ static int bap_adapter_probe(struct btd_profile *p, bap_data_add(data); - if (!bt_bap_attach_broadcast(data->bap)) { + if (!bt_bap_attach_broadcast(data->bap, BT_BAP_BCAST_SOURCE)) { error("BAP unable to attach"); return -EINVAL; } diff --git a/src/shared/bap.c b/src/shared/bap.c index 72ce67c08..1f6527b98 100644 --- a/src/shared/bap.c +++ b/src/shared/bap.c @@ -633,14 +633,15 @@ static struct bt_bap_endpoint *bap_endpoint_new(struct bt_bap_db *bdb, return ep; } -static struct bt_bap_endpoint *bap_endpoint_new_broacast(struct bt_bap_db *bdb) +static struct bt_bap_endpoint *bap_endpoint_new_broacast(struct bt_bap_db *bdb, + uint8_t type) { struct bt_bap_endpoint *ep; ep = new0(struct bt_bap_endpoint, 1); ep->bdb = bdb; ep->attr = NULL; - ep->dir = BT_BAP_BCAST_SOURCE; + ep->dir = type; return ep; } @@ -668,7 +669,7 @@ static struct bt_bap_endpoint *bap_get_endpoint(struct queue *endpoints, } static struct bt_bap_endpoint *bap_get_endpoint_bcast(struct queue *endpoints, - struct bt_bap_db *db) + struct bt_bap_db *db, uint8_t type) { struct bt_bap_endpoint *ep; @@ -682,7 +683,7 @@ static struct bt_bap_endpoint *bap_get_endpoint_bcast(struct queue *endpoints, if (queue_length(endpoints) > 0) return queue_peek_head(endpoints); - ep = bap_endpoint_new_broacast(db); + ep = bap_endpoint_new_broacast(db, type); if (!ep) return NULL; @@ -1348,6 +1349,9 @@ static void stream_set_state(struct bt_bap_stream *stream, uint8_t state) ep->old_state = ep->state; ep->state = state; + if (stream->lpac->type == BT_BAP_BCAST_SINK) + goto done; + if (stream->client) goto done; @@ -2518,7 +2522,7 @@ struct bt_bap_pac *bt_bap_add_vendor_pac(struct gatt_db *db, struct iovec *metadata) { struct bt_bap_db *bdb; - struct bt_bap_pac *pac, *pac_brodcast_sink; + struct bt_bap_pac *pac, *pac_brodcast_sink, *pac_brodcast_source; struct bt_bap_codec codec; if (!db) @@ -2551,6 +2555,13 @@ struct bt_bap_pac *bt_bap_add_vendor_pac(struct gatt_db *db, data, metadata); bap_add_broadcast_sink(pac_brodcast_sink); break; + case BT_BAP_BCAST_SINK: + bap_add_broadcast_sink(pac); + pac_brodcast_source = bap_pac_new(bdb, name, + BT_BAP_BCAST_SOURCE, + &codec, qos, data, metadata); + bap_add_broadcast_source(pac_brodcast_source); + break; default: bap_pac_free(pac); return NULL; @@ -3996,7 +4007,7 @@ clone: return true; } -bool bt_bap_attach_broadcast(struct bt_bap *bap) +bool bt_bap_attach_broadcast(struct bt_bap *bap, uint8_t type) { struct bt_bap_endpoint *ep; @@ -4008,7 +4019,7 @@ bool bt_bap_attach_broadcast(struct bt_bap *bap) queue_push_tail(sessions, bap); - ep = bap_get_endpoint_bcast(bap->remote_eps, bap->ldb); + ep = bap_get_endpoint_bcast(bap->remote_eps, bap->ldb, type); if (ep) ep->bap = bap; @@ -4224,6 +4235,10 @@ void bt_bap_foreach_pac(struct bt_bap *bap, uint8_t type, return bap_foreach_pac(bap->ldb->broadcast_sources, bap->ldb->broadcast_sinks, func, user_data); + case BT_BAP_BCAST_SINK: + return bap_foreach_pac(bap->ldb->broadcast_sinks, + bap->ldb->broadcast_sources, + func, user_data); } } @@ -4382,6 +4397,12 @@ unsigned int bt_bap_stream_config(struct bt_bap_stream *stream, return req->id; case BT_BAP_STREAM_TYPE_BCAST: stream->qos = *qos; + if (stream->lpac->type == BT_BAP_BCAST_SINK) { + if (data) + stream_config(stream, data, NULL); + + stream_set_state(stream, BT_BAP_STREAM_STATE_CONFIG); + } return 1; } @@ -4446,13 +4467,19 @@ struct bt_bap_stream *bt_bap_stream_new(struct bt_bap *bap, if (rpac) type = rpac->type; else if (lpac) { - switch(lpac->type) { + switch (lpac->type) { case BT_BAP_SINK: type = BT_BAP_SOURCE; break; case BT_BAP_SOURCE: type = BT_BAP_SINK; break; + case BT_BAP_BCAST_SOURCE: + type = BT_BAP_BCAST_SINK; + break; + case BT_BAP_BCAST_SINK: + type = BT_BAP_BCAST_SOURCE; + break; default: return NULL; } @@ -4913,6 +4940,13 @@ struct io *bt_bap_stream_get_io(struct bt_bap_stream *stream) return io->io; } +bool bt_bap_match_bcast_sink_stream(const void *data, const void *user_data) +{ + const struct bt_bap_stream *stream = data; + + return stream->lpac->type == BT_BAP_BCAST_SINK; +} + static bool stream_io_disconnected(struct io *io, void *user_data) { struct bt_bap_stream *stream = user_data; diff --git a/src/shared/bap.h b/src/shared/bap.h index 50b567663..297ecf0e5 100644 --- a/src/shared/bap.h +++ b/src/shared/bap.h @@ -186,7 +186,7 @@ struct bt_bap *bt_bap_ref(struct bt_bap *bap); void bt_bap_unref(struct bt_bap *bap); bool bt_bap_attach(struct bt_bap *bap, struct bt_gatt_client *client); -bool bt_bap_attach_broadcast(struct bt_bap *bap); +bool bt_bap_attach_broadcast(struct bt_bap *bap, uint8_t type); void bt_bap_detach(struct bt_bap *bap); bool bt_bap_set_debug(struct bt_bap *bap, bt_bap_debug_func_t cb, @@ -289,7 +289,7 @@ struct bt_bap_qos *bt_bap_stream_get_qos(struct bt_bap_stream *stream); struct iovec *bt_bap_stream_get_metadata(struct bt_bap_stream *stream); struct io *bt_bap_stream_get_io(struct bt_bap_stream *stream); - +bool bt_bap_match_bcast_sink_stream(const void *data, const void *user_data); bool bt_bap_stream_set_io(struct bt_bap_stream *stream, int fd); int bt_bap_stream_cancel(struct bt_bap_stream *stream, unsigned int id);