From patchwork Wed Jul 12 12:21:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudia Draghicescu X-Patchwork-Id: 13310299 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 5B9D0EB64DA for ; Wed, 12 Jul 2023 12:23:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231853AbjGLMXx (ORCPT ); Wed, 12 Jul 2023 08:23:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231127AbjGLMXw (ORCPT ); Wed, 12 Jul 2023 08:23:52 -0400 Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2061.outbound.protection.outlook.com [40.107.104.61]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 619AE134 for ; Wed, 12 Jul 2023 05:23:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hXB+tCf8uqog0S+NJEuC2ZlzoO3N1QytL0VB4KdUR+aoe4xevPt2EKmrqhEbqKmTiNoujvYxWIp1yUuxI669F0UdJUd0AkTKMuAV/VA4lUtNNLLrU6a/7VBRKDbJc4cZ4ztV7fYYmwCvsvwNQXCTreWnMG2igm9/Xcr59yyv1IhFDW1lAkyerQ1/UFTIWXW+R7jcupYLxqc84nccdBJnWXph23PUrM0QyeT3U5UPNWyGHxK+TFgpA1gljmOXDrzjqggTOQkSngFpbfPrvmcI9ihItcIjaNfjNWV8BgkQfgP6fBlXj5lhBmR6Dtvwk1/XxiX/uQBDcU/1sVfofIx81Q== 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=HRNPBbvMvEass4jVJ93qq6ghz+gH8A+bX6JAu8VeCM+4y6/43Oe4+KIAln9sfJzIZzAyz9BKBalsSqt/z64h+n3wPdwWZg1XQ3iR4vgTVN+W6mKgsSfN7YeJQHJSWOeNRMcTNSLUhRqmxt1dw3iRgfmzPMfjIBJZUY0j4fRu+kyVY7tgOZD2Ahea3Guza3t/my+f4Vppufd3amBJr7/BSnWTDyTd5bZ0ifgrKE0rT91WK1ZAsds6tnXS9gLG1W9ym+JKL/ofv90YG9j1O2eRbjHedJBXiKHS6/PKXC08wkXWCEStp8lv+7Ynt4Hld4jCF9rNHJWTOiL3yjJ3YeLSyw== 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=rs4EHB74gGev/VMie6iKJsd7FgadLhVTPBM2WlimOtOilM1eNrLzWhGIZbGSMAGI83eE44qDuoaLMfG5jBpsc6w4J+dGUoJ8sMAcC9S0lNWxfLmpm2h5c6DBm0pN6sV4BJLd9HeCvLM3CjKLGqDmFR5xUhZjrdrXgVIUVhwKBSk= 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 GVXPR04MB9877.eurprd04.prod.outlook.com (2603:10a6:150:113::15) 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 12:23:45 +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 12:23:45 +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 v2 1/6] client/main: Add broadcast source discovery Date: Wed, 12 Jul 2023 15:21:30 +0300 Message-Id: <20230712122135.7734-2-claudia.rosu@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230712122135.7734-1-claudia.rosu@nxp.com> References: <20230712122135.7734-1-claudia.rosu@nxp.com> X-ClientProxiedBy: AM0PR03CA0019.eurprd03.prod.outlook.com (2603:10a6:208:14::32) To GV1PR04MB9151.eurprd04.prod.outlook.com (2603:10a6:150:26::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1PR04MB9151:EE_|GVXPR04MB9877:EE_ X-MS-Office365-Filtering-Correlation-Id: 396c2d05-805b-4c13-e3bf-08db82d2d5fe X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EkbFs/wKXgsxc19jOwbrTp5iTb7C4L9dVfIT2x9dqjFhsCHoyxqDYFEVOTMO6YvoAGe/H+44CwIs6nziWetxHISsGXrCEoS8COLP6jTLdR145SC0HD08qTuCoHq/bcMryQyfvLgiolwVGe8qt/8B3js6zmBvbi24pcdy97802gqVRxtFkv+HxaVfDz4rqR1+jfUz2AonkZX4zg3qNArLIgHKOnqQEh3lk0RL7sdrHaAvF8Gb4bP2VABrJwx00SEDF+2JuVYk//0d7spiOTQtqxh/niaixbRFeJVtPXl9iDcGRNFGW344vCwDsHquiamTvS1lVX/1klD9kUZ04B4Ze9m9m6QYqlMWiTBPAsWCRs5aNi9uU+RjAFTxUbpNhlf1vjKxYGHobFr076nR1Zrr0lVCWF238fHFjKvmajRgbuaku4IqyZ3Y0PpTO0hfUr4wwOIMgeIJpjA/qPJi7rnvt1Qoykmu1eUvTcowE0Ir4AZKyFKbzdxPKZ6yAbwajXHuk7/+1Q7WbAQL3lwKzjvFtRzaYtDAldGzi7go/C4+Vwc9ftnOVvS5BLfmQOcFquu3ENiId4R685eyTFx4hH4qcNkY6lLBsZkUTAV8o+bvzR3DglIgauoxUB6qW3Mq+oE+ 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)(396003)(346002)(39860400002)(366004)(136003)(376002)(451199021)(478600001)(52116002)(6666004)(6486002)(6506007)(1076003)(26005)(55236004)(6512007)(186003)(66946007)(2906002)(316002)(41300700001)(6916009)(66556008)(4326008)(66476007)(8676002)(38350700002)(8936002)(5660300002)(38100700002)(86362001)(36756003)(83380400001)(2616005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 0EOEz+3XlStSCBUx6QzeXJFEbYLAWsSBGuFUrfX8og5gknrOf8VYeffqLG8XubsWM6R2IhUIL3a1Hewpw3sYCRKzjKFDDa+3G6zgoJkC6NaHJo+m1otVh5cQIyjOdWwi+dmNHorHTcZ6Qliu/snULSgDfBzR7Tddg5kxg4UkT5QL0RnbjyTxipHqYOViM9j0lAGrczms+4s+H1opYznlVqmkr4EXUM6D4zBDvjytVkv3nl9I9Ia5WXRNqot2KmeLYlrZFYq64SS944Fd7sQe5Eb5kRuIk4kxYdgbpvvdrz25x97MxEju0PlfK0vWZa0B7s5g79SiYFYeLZ04eX5m+UT0FDTmJKjrG2OEkc46ZGP57fey5AxqVZtISYzObC1IHkLYUhdU23xc/lOLlqVs8Q8of34NqLncfmkvYwpGV4RjJuK8RgAvqDBbAKBYXXVtsoiFNhBKH3qmlrfQpqWqg85kd1Owo7oJpZCl+SiX5fyGIDu1GAXRfgoqUVU56+h9uPZb5EmNkPXsOSbGrbhTHZhvFKXr6eHgA0xmMZjOVuXKmxUGqH9Tt7dS76y1kwV+XT2puwuNAW4lUJtTlV1yN7hcU7ntQ30yu/TrS0idkZdXa36XGddWdYyZ9FCjsbvzZPKeN7QdyC6QWJllMAv6OiIYvUKgmdLLnkUp8Ll/Y+AUdmzEHq32CB0Oh5v8dwy08zTuwHyax4z/3UkNwrLJ0RvPjvOLiJxU8UTnaSzMAEke+s6O38W1Vtf6XEcQ/aXqHJWnzDRV0xBjDG6a/96Y1HogoCWG6Y0inDjCAyYbIv+0j3Hsn/fRsNHk8p7z8Pm1mcWe1TIke9+Ogza8Uv7rXLa9fyTkvhGirKCLNQ02wGi9fmGpHOlUdBIvudUvrvvfUrD26MxJsY0bl9y8//uMrWVbbRPjRRKERbFydp7esHw+BBJEmZ3FBT0ch9uwh1392AO1Q1wKYT3Xliao7P4Qy5ICuu5KlFZdRwV5OO59BvlCLbfJSu9IPe++edhaLqm1JCjv4Lh5RG004OBL8ordYT0STZYO2w+kl/77r6/z56EzlnJLA0wRrnlEbsodKKvb2ipYB4rAlnu1kLqEQNpA7Ar1KcMqnUC8CUN1MvsWg7dBMNcQillIj9NnnS5fTZHRyC9uKGJFFN+CsubWx76VKSl2kfJGzZyJbysHcc9/GxbhyS4+4osKCNb9y5AFKPdnQ9lLCUwTpjOIikRsqmdLtlvp4QF1V9RjrC2Kvga14rX9MJEntqo3Wx+mefmAM9xh/3BGSkc16W6dYpnGWocqKb4Wr1JGObw+Xv50PBHn4EtQ4CKNqvGBud0syABt2V+MV+Cq/+J3oFphQneTSNw0qEsz0c+eRGQla8HoFAk/uM4a6aQNKt8tLeFFY2cRyY4msOWFaTbX99bGgIqVsU7qN7hcIP7YhDvMob5fOkKtdnhtBlLUWq+sRqBxNczwmHXPmcv4UVwwmv4m5DTSFzLWJKxnWf/xA2bajhevKuwkimGrCDnUIpYxxbW+gN2GG+f1jNKdqKOGxXgKiieX8JlpaEJ0iMfwROsEJCjSsnVMFHcBeeFtMd4J5ziu3it8NbiEPdvkmuzs0EntYKC4ZrL/zQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 396c2d05-805b-4c13-e3bf-08db82d2d5fe X-MS-Exchange-CrossTenant-AuthSource: GV1PR04MB9151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jul 2023 12:23:44.9761 (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: s2Tmlbt94unSqKUFtEPzwMbPfRWUHBcGUd6Mb9HP0NRKx3eg452kH4o0f8+7ufYYImRRCqmhDpdGcABBX77IPA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVXPR04MB9877 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 12:21:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudia Draghicescu X-Patchwork-Id: 13310300 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 4082DEB64DA for ; Wed, 12 Jul 2023 12:23:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232597AbjGLMX4 (ORCPT ); Wed, 12 Jul 2023 08:23:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231127AbjGLMXz (ORCPT ); Wed, 12 Jul 2023 08:23:55 -0400 Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2048.outbound.protection.outlook.com [40.107.104.48]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47F4710D4 for ; Wed, 12 Jul 2023 05:23:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=O0+0kw5lfDYfs9NUsUNekWQaT8ABLmtyT4QRQPEzXGG1yZUiDC2X4gX8WgWWnIoglXkcKd79emhoBUCHXZF4CRsvu5b2+Lkn8nWUCUDDKha1nLW0DOdgjwinh4DCkSayhdWzfM6vuJtJ+RtQOiIfw41kfftqBl/3GqTbeSBsd2QGoLX55QJn09aTeR8ukhHhMw71DjhqVnY7t4yOcRufAxiPaRfh1RoRhgmR4egYV2Bs2e2Ox/DHxs3wL2kBVqGe/RTMEbCgV38H0sSztLOKyDKdYUElLQyrAUcqauy7C9h6q8nUmoKVNqsSjb/2OJ1DrilyUtDaV4Z6UvVSrh9sSw== 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=ASSiC0WdiZzy0QmsAq6WzXQDgjFT1RlUZdmBINPv2WM=; b=DxkQpAbmKmG1dTAfInU0umsz8/BESSx2RVfNixvN3kKP/QvOHf5QxFr90mJ+QDYlNhZ8LBRZrpUO/KMDAzR1+vIpV2ERdvuds+Kr8mZXE8z4/PR6e7K9wsQm7TRIP8YUmUrkd3nHBUCDqp7iNgQlXnlbex2hC9U8p2qbsBjrsFv6VjvXNEvaGLfzcbnjkZkRRZS3zPa/hYfYxlR6aA/49/V0H0duZ5ewninBU0ZK5JwW7+XuqXAgEk1qwGNQlpIebaDsomeq/INnc4FmUsvc2nSTKjpbDBAD7Q8t9w0Gpfq154sXUL9EUYATSz6cKrQQ/GWkQvX9oG+oEPyNjAxomA== 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=ASSiC0WdiZzy0QmsAq6WzXQDgjFT1RlUZdmBINPv2WM=; b=ezLN0Wobh6oofKgthWUL0dapmi/0UW312cjFKNd9b3H4QOX4XICl+0QZPxcRoBNrLebc8Kkp1y2ZYVlah1CRu2XfZu4M+mB9oZho87EzSYqho58xKCAZnv3JDcjM35cwCFsr6kF6nUSJZRqlC+/LHKR4Rv5lN4mfAI1SXQzNdNQ= 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 AM0PR04MB6835.eurprd04.prod.outlook.com (2603:10a6:208:180::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.20; Wed, 12 Jul 2023 12:23:50 +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 12:23:49 +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 v2 2/6] client/main: Add broadcast source discovery Date: Wed, 12 Jul 2023 15:21:31 +0300 Message-Id: <20230712122135.7734-3-claudia.rosu@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230712122135.7734-1-claudia.rosu@nxp.com> References: <20230712122135.7734-1-claudia.rosu@nxp.com> X-ClientProxiedBy: AM0PR03CA0019.eurprd03.prod.outlook.com (2603:10a6:208:14::32) To GV1PR04MB9151.eurprd04.prod.outlook.com (2603:10a6:150:26::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1PR04MB9151:EE_|AM0PR04MB6835:EE_ X-MS-Office365-Filtering-Correlation-Id: 8e05eb12-bf52-42c9-2c75-08db82d2d8b2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8DeB2vomD3tPY+HGFoAVND4PwJqLrPJfPFQEN2Wyd3oJJEAsWbzWXA5lFg1c4nSa2zotYXGD+qv6BUlW2luHZk6zJSF+nVgp3kYI10pvv1pYz/7tIS+uvLSi8nU8KiK2dgh5cnCEHH6FmVt4VliurprVW1Sdi2CwOCYzPUANrL2nwEHTMFNa6yyNKuAfYJ2MmyGtBsPp1TGjr69FiB04OmhmuKaf3MkLg04N+nhaEjd1QKlMQhC+cdpLmdtDbMpYU7RzmLRxAGxydo9dbKy4CcfUXccsOf18Exb47Kvgzo1tdRuI2z1ZNi8RLoCQrz1PPMfxmtn6/CfOw54ucz2R9f5vETJjXesyt59Ty8IcW8SRvZGiF5aeHQnNWPlf/mm5f60q2DinkukLIgOVrqm2qe0dlElc7ZMtVyMymc7dINdKqLDuVyVU2pkP0xXCTsv0muxpe05TBsgBIK8ahhkVxzUm0MEoDX47wztNIgLvDNLWFk1HZ6CIKyAd6BouPxttL28sz2PP/UWcUdjpydYcmVXVAOtja6yCPJ3ttwwB+qtASyf6EvWJo+WhSHogoI8VUFOH28hslsyE42Q3IqiAoV+CJET3l0FMoPG0XvQ0mGsOut9DPI8wRtI48f99t431 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)(136003)(366004)(396003)(39860400002)(376002)(451199021)(8936002)(8676002)(38100700002)(38350700002)(41300700001)(2616005)(2906002)(316002)(5660300002)(66476007)(4326008)(6916009)(66556008)(66946007)(6666004)(6486002)(52116002)(6512007)(83380400001)(478600001)(36756003)(1076003)(6506007)(55236004)(186003)(26005)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ti/E/sqpqDSyS/l375rg15Ulpz7z64YGb8jEStcE4hHbj5So/aej/QHBXAghUxMVftM3EZfHcdOp68ZzFFdEUKcDlsb6waeK0r4DQyNVHHNKVRZ6Oi6Mm8fEaRS08V/FMEWlWlBya5/Ozv8dXKfZwKYZFoj4ZFBq9Sbi28JYcmuaF61Hh4KgL5Se08RDDrnjrVZemi9D11e/zI0v1MwG5gbYEK4hDwZ41BujiHpSCtenLzTgFPs71HEQuj6C8A/P5yNUVSIV/xXnnSq+K41gBAfUr95RmMi3EdVhPsZvJByh8ZuOV9tBh+T88gBDikD6hrSefPXoxUZqJOr0sIYnfuV812XUVlZHOiBq9658nPPy9N8O7srX5v/XgjEaSk+x0QSLA8GU7mZiUu4kIcgpY3OQPZk9eJLZerxfO2wQgYq0+ySe+miz76GCuvrYF2jSsXYjW86b/PZP2dLXj/G33nDQu5ltuzLKW7wfQXsP629cdPvO+Vd9qdeX/gqXvPj4S1ASajKwfShJWat9qBbUNuGE+jAlDdf49Uk/pbfKrvHtlzwwfuGvcYC7SkBUC98qN1QqLs3eV23aetYDIgDZ56q/x3QJdCMV6rIpyu9+qlt/GdhYaAtAg2yLEczuvnZy7ZKEYohzzyzCu7gw7FRhQomMniIXEbIIjPm/c7PKmYunzCAQnuEaI2JdFBVDVhcjh9RLctThrllYuEXz9Q02qsPIz7gpjaV50dnjZtuNGXK9oOpOIjodNDuSx8U1sqtiu+YopyzmSxGfYw39jAq2u5fVYD4lc4B4+son9GvuDsnu3qxSgQu6BA902FpIq5cqv2rQik7R+bpZR4DoDBvd8Djxxichs8GRDid0lY3J5WsG4ryNabFRxncjjivv0JTgsqFuDX8lYcPPsz6VdKIoWU13//Jr/k6pxdABJx9tUr3JOnp3CkyvK+Klg/FP3j3RZ6+KdHAjtqJ9t97a1PfiELdwO3wps3456ACiW6PQC9DB/JRa1swhhKzdTKvCqcsrTcHALP77/6Ynrelf5Q4i0xnCxmBae10Ox45YTTNVs8OtDhSQh6WjzePFVhg/pIQI5o8Gtuq/9CC6USfAQRc380kwxPVBA5Arsb+DjAulR7B2c9IZrdwaE1JZd4RUvbLDZi/M9KtJL4ZB91c8Tb+ea2WAEg5/kZrF23vDAooP9jfhcMVZP7HMhAEyjosWmACPKMJapSuXJyakEcjWeigMWWOlfxvUAb90MU3NTdXkVVGXclc8bZsJSprRry10Zg5Z7hsL7jbjqyoFcrbqNjAL7toxlMg/mBmAz6VvhrTOYNK+G4RxX8ZosnlAr80qTPWgj1XautZRoph9NLTMHy9Kttj6cupujKB4ehgEErzogxJXxt4Vz69JzGnkv3+YDhamzBGKCr6K2jLmcS11IbcFDeH7P4HrbGsNatB3ZRt7Rj8nsacrwdYEI1DSCj+aUd1OfMboPKrQcow+6rRYeJ3sqpNGnrsqMyhwikv78nJuTaVteYN+Y17ScAD1nHFavhXKnvKLgaXRCmzUT4knnqoWpYMImB7RhkhpR8a7P0+kPNtFB5bIEVvbOc2mxf6NttPVM3/boj0CnjPiFO7qJhrWvQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8e05eb12-bf52-42c9-2c75-08db82d2d8b2 X-MS-Exchange-CrossTenant-AuthSource: GV1PR04MB9151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jul 2023 12:23:49.5267 (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: 28b9b+ECtUYLMG2Hg8U68gFE07O6RY4uzERBD5mbtyoAmHFK6DvKNkT9SU+iW346FQXomozMUyA0uBkiaZ1H3Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB6835 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 12:21:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudia Draghicescu X-Patchwork-Id: 13310301 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 B6AB7EB64DA for ; Wed, 12 Jul 2023 12:23:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232977AbjGLMX7 (ORCPT ); Wed, 12 Jul 2023 08:23:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231127AbjGLMX5 (ORCPT ); Wed, 12 Jul 2023 08:23:57 -0400 Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2048.outbound.protection.outlook.com [40.107.104.48]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5B229B for ; Wed, 12 Jul 2023 05:23:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hvvjj6zvC8RRUK2gg4u+dio3Jol+euUtjor2CrvnAuceP6XL+ViWTaQGrOHLmMxBH0HbvsJvAnuDzocixxyiSPl93kkVFvVwAUJk/NfmFAM21DE3Bio3HoKqZA+jaT235S7TUFy2yJ2gBIkY3fMO0mi9WGRofxS8o5YbsQHITVsaQP3ymVjUBlu1lKKam+57732VQwKH7SBR1fs1eHnUEa4k3XWo5RGYcehHS8w+wU+Rf4xh+mRT9uBqkDBE49ek+sBWGq99pfO3y9SikRvlnuXgFPl3QBC1Aln6tONJrHjGW1g0n0/xNcacPW0QtbHUIEh9WzYqPKsTZpEQbT3P+w== 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=/qa+Zv59T5at1q/7+/NR2AHwZmstxZ56OkMcQTuu3U8=; b=iHqAv2RVhNB1jT4KC7ZACVlSsQm1/d8wpJA5v6oOngenYwcJ78v1bJnra6XdrSGhy7e4whIkbjPTj6TqgOqqWhqlng/5mySIG+MSm026ctatimKszaHEXHS/ZLx06z7tPKIhS6V5PQIs72wxOgmYBHA11KtNUKrDCcJiA4jwRJkCGk3GBfBqSFcbGcMKun0bBKQCe3Au4JUcErInT1DBLApxD0jtXcuKQV1/iMB6KKGmv3QonjuRTHUHUZhl0/SZzdvYh0a48JxtgO9VJJg5EdrvqrD8B2rIrPHNcGah9wt/vgFooVj10b1szdZf0s6d/kPjSQuqjvfTdWKgC85Nfg== 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=/qa+Zv59T5at1q/7+/NR2AHwZmstxZ56OkMcQTuu3U8=; b=WpdZ6PXQwHdE1FqDWfPwlmdinFgnFgvmEZCHPgtvKS15f8HGlIGzARLLsireqPssbYSnIkwSz/5e5791cYrfGhPW6fctY8o2ZE2WENy0jWl389DUAwBGXwzJypAixX6o+JCx8ExLiTpqsHbJOFobKMDl+pQCiecq5xJVWE7DaiI= 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 AM0PR04MB6835.eurprd04.prod.outlook.com (2603:10a6:208:180::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.20; Wed, 12 Jul 2023 12:23:54 +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 12:23:54 +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 v2 3/6] media: Add broadcast sink media endpoint Date: Wed, 12 Jul 2023 15:21:32 +0300 Message-Id: <20230712122135.7734-4-claudia.rosu@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230712122135.7734-1-claudia.rosu@nxp.com> References: <20230712122135.7734-1-claudia.rosu@nxp.com> X-ClientProxiedBy: AM0PR03CA0019.eurprd03.prod.outlook.com (2603:10a6:208:14::32) To GV1PR04MB9151.eurprd04.prod.outlook.com (2603:10a6:150:26::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1PR04MB9151:EE_|AM0PR04MB6835:EE_ X-MS-Office365-Filtering-Correlation-Id: 4e61f009-dddc-4f75-e6bb-08db82d2db99 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oxac9izwFnQ7ahsDlnY09vJ689qsiR8wDScjfjX7Pug92RI7VF+GqC7DLMVuxZd7fnu2ecGnui3WzUmgYwk5ciQ5cRqvkqKGTgoo78xjXXv7U/Wesg5YNsvzkCrpLEuUwHvwWSLC87ppSRR8Zp9XaBUXpSDOGok3JPiExA3UoXKDxUESGWvEbxhh5v0enOHleV7Ls0QLQ1YA1u9g4jLfsD/WhXXxXB87c9aXaYW5yufp8rma0pOVE2deY6voWfqV0CEecl1BMZc0koqCI7woAQ6YTk7g7yoDIzxOBexutGrwsX7ue3xy0Q8CL9UJHUSHBxxbcO3R5dg7UGyKU9zKvU4d0HgA/3xn8LhDflHLrMwL7JExvH6OqcGeXknpzAWhbdnp+dNVk89Mkl0/b86Ix4M7jpRfQBxN0SehaJ5SQUr5kgs1Z94tKI0RSVKJnWCLGfLLl1xPZGw933diUsmWJATpk9+hewefU8xe7Ao8CNW7Y8aoGp0MxP0eAZI3zu4bg55cEQI9UYQUzQ9WZKIcnrivHG2HqSOSyIfEgytZjLw594QYFWWpLjmH6H/+AbCwqPvdDniMlgdh7Jpf2XxjnPSPzI8FeboQaKXnejJ9IXUX1LRyQhCVbN3NQhZ2UWrB 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)(136003)(366004)(396003)(39860400002)(376002)(451199021)(8936002)(8676002)(38100700002)(38350700002)(41300700001)(2616005)(2906002)(316002)(5660300002)(66476007)(4326008)(6916009)(66556008)(66946007)(6666004)(6486002)(52116002)(6512007)(83380400001)(478600001)(36756003)(1076003)(6506007)(55236004)(186003)(26005)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: AqzYA2g+ppwQoGER5AYB0WnSK/fUwO4jH+ALUdVb0r9wsiSnN8wHpgqORH1KOpLdCjVDQdkfq+7y0ShL3aJBofR8MNx/LAzQMfPkTZASlrOSHSAOgYEBqYYQPnMyM3rFPs7AQPy3S7No1/fK9S5DlZMos/5iEcVixwW2nypfNa3grcy2cmok/7AARs3xgF4zqScH/GpkpBxr0EzjNNiDK1OUjzRtAY7BsKPSP0a4Erx3l7l/CaDih4FxSsz7+2PUnPiuuL1HqQIZY0KENw//ZumOtQ3m3EsjwGArWfdyl5taBan+3MnIG3WQ9tJh0QnDo6tx0gEaInSU70TDTynm9uu6yVFaCM3XfeuA1NMZ/esqllWgYF/aJwb/ag1jz1fiiMKIek/t6QecRZPBHRPKlVjQzkQEzvRevixQCADJv035/jyjU9XJAvX+szUKAMkR5LcDDonllel2jmMJWpXeb0L02IlHquo0CbWiJppRRA+8VnAdTSL9/RuhEvloRwrcq7EImmBztyrgCF7t01Nha0rr2fFIu/raK6OeE3PWd16MXCObicU61JvtadZ+JRyK4THA/QSitW9/GUTKxv36giK413OZ/dXyQKBPLAmgIq71WyY+jxEd0IFssYJAOB6ahBsinftPyRrcParSEbYjdMlkv/8t7oEnwaaZci2VEpzPo+uw57jN4ss62JhxgXkxsqMWsqv41wEH7xA7kMgYUaf3h2mDmOZAZrFjtlROr2Nt68p7A3P3NwqEN5ppB9Hs4zA+GCLX+MxozQvWMsd3R8UGxX7u/3ub+MjBqFXpjOhG+scrw1xUQqD7iZE8eY84SoWcLCjAszj9QfeiQxr12qlSFKc3p6u1jJxauf4M+El4TuF/m/+DI4k3x/V9GwSdHvejMJk5JssW8n+qgiQ1xN4VsHXFl4eawXDtd9RaMDgqoWfkaVl5T//eNAKLyzdRsa5dm2ho6u+im1vGxykHDTR6Td7mZG1l39BTwtz268s91XiqdOFJLqKxGX/9hHVTqeQJFCLU40CQvGbQ88I5D2pAYxBaoY1p4MMmmjCQJ7lKa7Z7rz3xbOp3AskDH1J53w2Lj0NGUj7C4EOkWDLVwk1l7b/LM7a+fHqzQfkkGW/EuCh03NYTtepLnQqJat+IIGMbAswcXq7RuwfigZ9/AsmeZWLTzVGy9h86z3w4dewf+QzSwns+zafAEI/+KZisPM12cETyNXRVtiJg4lOPA4MIYP95Iy0g6NbI1wGFvhvmT+uqjyZ1EvFv+f8lKDev129WBBYFilFjFUKY1ujErtbmAcl19inkWiRg8wrA8rLgDU5DZQLn3hcCmzFitxkQ+t2rR/t8Af3iod3XikijzObcoZPeHHuL73sQu/EhqNNUBxvoQmIEj90MqxR8bCquZO/433gFLNl1ehUdSF9Ij8ouwgSfzw1Z5eBh+ZxFrbyu1jPVHBkhDA65FLyxVimsl8mpjcv+7k/tJGXslxWDDn0npd+ijsWenlEFhyyvL6O30stkhwI2Dr7M20GSbu7ZmUUGJVD5Vo5HHjX0fc21xVFGJKoOv41DX/2sbPaEjAP9aNVDfRxpgBG3wiAdhCVzmI9uxs3V5TMo01Yww07cug== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4e61f009-dddc-4f75-e6bb-08db82d2db99 X-MS-Exchange-CrossTenant-AuthSource: GV1PR04MB9151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jul 2023 12:23:54.3411 (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: GvuYwea0L5ZW1AxwyJE8WB606e/iM7qv29htQ8d8FGH0B+Bbvu9VAjnrvMlu4mKjFHWXiBf44mlkN12ptOMbkA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB6835 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This patch adds the possibility to register a broadcast 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 12:21:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudia Draghicescu X-Patchwork-Id: 13310302 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 7B40CEB64D9 for ; Wed, 12 Jul 2023 12:24:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233026AbjGLMYk (ORCPT ); Wed, 12 Jul 2023 08:24:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231742AbjGLMYi (ORCPT ); Wed, 12 Jul 2023 08:24:38 -0400 Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2051.outbound.protection.outlook.com [40.107.104.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 426E01993 for ; Wed, 12 Jul 2023 05:24:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GMDSqPt5Cfrrxi9LzKBmggJwexaX/hGjZ70PFpI61gJEk92h5zvVd2LcmesS3XgCpKI1uVVJ7x9rCDAsoBSri2HRSqmtnSzD8Ipzgj7Lde5D78d+sWm9yybu6vj0icuBblkrttTqaHU1VUT9Bbbz/SJM6PbxzafYmPPiL4A/gioKvh6WaAeXl7yfTDU3SNyKdcygtEwrt3e5F2Q8kMRLhjCaHF0iBZlBmQNYIV6DAmHHLpicnlUSaNgMmaAYhdDvQflHqsckEyuVZdaZFDtfbXw0ITRrTNTwVplOS4LcT5ZIYcLyILyfaHpBMzuLTI13pkG7AcIaVSGMtm6lDmuAwg== 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=mZl8fp63TNur8zamhw+Hn/srzNOMDVE20m2yfUY8ivA8XsV8jVe0ZdGgDzc4YfnPFlDj1sPI0/HRl0YGaWPRi84XUayYXWe6aoM1Nxf+JQ0XOmOUUlUiYBKhQS7aIlVSX5tB3uMYCaA4/gBRebvBh9zK13MqhOBpiUMknxmk6HF664Ffk2PRy5NBFvp7glbb+h9x5myM9UXgRpsbcw/xmLwR323VfNwzyS1qYoiTU7lLkJYCRpfUQf73/QWwoVLc6FBjfyx8Cq3CGytayM1QKsTaoNSgLovTSHWPjC7V6s9mBkC3zQgk3ECD0mzdLs8MkthAZYmrGIxVENPDzGiNpw== 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=cYlAIUmpiXYeKXvW6valXUlAimNXxvfKvd8qquQfwxdPNzl+X7+GAH/7nsVIdSyxSv2DBBoym2++/++wP8BPM6D/StlITJx+tLTTZSJAlT4aRmGw0h1lLJyZFPr7TMKEHnSib8gWiOT13hehMzLlgn3gWx+d8WpoWBJSV5z4m+Y= 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 AM0PR04MB6835.eurprd04.prod.outlook.com (2603:10a6:208:180::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.20; Wed, 12 Jul 2023 12:24:30 +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 12:24:30 +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 v2 4/6] transport: Update transport properties for a broadcast stream Date: Wed, 12 Jul 2023 15:21:33 +0300 Message-Id: <20230712122135.7734-5-claudia.rosu@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230712122135.7734-1-claudia.rosu@nxp.com> References: <20230712122135.7734-1-claudia.rosu@nxp.com> X-ClientProxiedBy: AM0PR03CA0019.eurprd03.prod.outlook.com (2603:10a6:208:14::32) To GV1PR04MB9151.eurprd04.prod.outlook.com (2603:10a6:150:26::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1PR04MB9151:EE_|AM0PR04MB6835:EE_ X-MS-Office365-Filtering-Correlation-Id: a1d048e8-6703-4364-7951-08db82d2f142 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Dv2TLybUEXSRMYaHC/RKKxfSf6Pl1XavcCjWKVUduUkjK0fGRuotTNQ2HOvFuHrOZnLeqk9pgvBIg9SQuf/1A2ySSfnuuod+FSHWCG0QINyqGU6OsTMCOJ1DQIsMNXVdVPFHT3yfJ5W+aWNKi4h8AaoDtj4bMP95ThXLKL2TLTpdMsgd83K2iwq9V4SQZeOqRV1jdmkg4Ppc/9TDFfa8cJxp3vB4MuaqbHGqQ3yVxPPHiTK6BFAkUk5sGWSnA74u3eSN9eETejaNosXwZYmso1WVC+5wVzXFOWq+v78DZeac2kVGiRz48jzs2A5881jhGauBhmDYLHe7z1YplnD1Vac2B+wgoVg+Y+t4ZVQFMj4PbtvGbx8X94on+eC2KyZyPvEB55MEElmfvPZb1DXBYSqNxTKrihLSlIlF7WknEmyxgyDaqwoMS51stahA6uxEp9S9eYXCRT4d+Jkupng9TAmYxVJ7xP4SjHykyblniQBrzQ1Wc26/IxjcE7itpYizXhxa12DwOBTLZmHDjoGgcZY7i4/YUMgq6uWxlMKBGJ1lB1jhf41JxtgNR7Fr6Dw8O+ggJoIXuyIxte1Wm1lii0hxbBtOmvzxQy9TSQaw5IKPW32Kok2JVUBP67/9ZtD4 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)(136003)(366004)(396003)(39860400002)(376002)(451199021)(8936002)(8676002)(38100700002)(38350700002)(41300700001)(2616005)(2906002)(316002)(5660300002)(30864003)(66476007)(4326008)(6916009)(66556008)(66946007)(6486002)(52116002)(6512007)(83380400001)(478600001)(36756003)(1076003)(6506007)(55236004)(186003)(26005)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /BsqvK3dSQ5WT8GSBaDAEM8kRumNbP0pDtPsRKbRYFZ5mKNbfw9WzTtYKCS6Lm0mPnrKZ9WvBu0A4LiObm7ydHlY0D8pLnJlKl00GD7WAdDwGeJEcL5gO8NpMIfDkMaAoxqShMj8x6AK/FXyGvuD1dtsdT9aOE1kYF5+PLXd44z/DpZntFxk6ledG/8iJCAqgR8Q6LT/UHI+9nOWvJRsaxI/VXSi/j3ZqtjgO4D7c9fLux++7mKjOYlAEPdm+RTdwM47Wr4Vw48uLCgpYlqV7JnKkmxc+C0cKkvTX8gjRCt4fF7VT3l4YbJESIvrebdjH//5CrQOyYEtXT36LaLCzwMmaHlw+nKqh34Q9Pr1f2h+nqkgsSn9QruRcucioKS/jO2tTxoyoaCmekMa6UwWlGb3HmhD0UV65u8JESpffaQ7qej35mBf53esvZqvRPAfiaBGjtdG410TYMlPeEPQIrgEwEmKygFD5mjFFc26HPd8DIMd2Q9ofeGtaj5pkMGQ9Pssuz+OWqp9Ga6/T1gEfgW2esKkKcUpM1nu+2TB2yY+DzttAR7WxsYfJVUI5J+MOpPzcGok6w7R8Xu7m8Utente1yi4YFcC7wSn9AMlVVpwZm2I+WIl2i34E48vebVsS0YavGOTxEkvXqvlPOwqYfe+n661S6Lv3+j9kV93o/M5mrwFM07fuOTShMbN/JKXT1wdUgCsDuWN1Qb7hbtOFOa10ghVF5uIwqIme7xkXR2UMSksx+2QU3JlN7Eew0obR9CNIz626U6krj81XPnH96v4mCtTTHsgyWA54bUhm+BOYko14Ib+SD2G27yM5/yQcCoglSZ6jCad1qfYTYC25Bu/9WpItT6xTXxo21oLoRd9mRbmTqHS27eZdoc07qiBELw+LVbKREkQfhvDkGehc0lWYhYTKlcUk9VW7eYNDxIsHB88BhialKcjdbuCEzU2ivI8KkXJFfQPofCk/KAK0CES2tZYeGHQSSAJ/h9O9VaErSZHb90XZE3KgVu7JtEI9IfKsxP6BHPTcUjqCT2lHZzKRnhTQuEG86D2bmvB+VrVvW1NDJiEGrWfElwrg3OSWVCREwveYvKJUcs92RCgCSzbrBH/2QNtHbzXk2YGy9MJf2ZVt6wQI8GPIAUhDcvR2jePyFIZNieIdzrmSGu3aYrDtFyPhHjIQBrdj68gR4/PUlEe5qVWB0rEs/SlItG1KkRps6HQPh6RPsOt1amOauR0U4dxTcAspzVeBD6rie4XkCB6M/5eOnhHe2rb6AYVd5x7MYR1wUREVqV8l3QW2eT7UGZWYUUzDRL/amDBcz2uaDps33DswkEH8aYWGZDlyXOmE2M++EPFFJtm/VMSP3xnhfE1USaLL47FxrZwaCHdgldeK592E8tYBW1zt4snXY7GzeaK1lyv/3trJ7oQCwuNmCVs4KtitaxInaDWq2268W5qRIMct8TfM4g6QR2ewtfka1obx8Os6ifCl/lDtINfsBGBx0ggWuLRBGM9EVgwvKPoL4rRyQbjc7Mx62vfiFnYVHF4twIEc8f5k0eYHHsIPSiL/DeqKKSUw8R87vH7l0bO7r9zUZjDKslcDVOsW9YWCsiggzkoZReyVfyKeQ== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: a1d048e8-6703-4364-7951-08db82d2f142 X-MS-Exchange-CrossTenant-AuthSource: GV1PR04MB9151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jul 2023 12:24:30.6980 (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: pEatzjiyaY2sMlXNQ21Wn3cXxJXttDhTlgQc3otUdnia8w1/R9Zk9PK3nr1JbnYaggNEAMuwk0fJ2URjWRGwUw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB6835 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 12:21:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudia Draghicescu X-Patchwork-Id: 13310303 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 672DCEB64DD for ; Wed, 12 Jul 2023 12:24:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231915AbjGLMYl (ORCPT ); Wed, 12 Jul 2023 08:24:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232206AbjGLMYj (ORCPT ); Wed, 12 Jul 2023 08:24:39 -0400 Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2051.outbound.protection.outlook.com [40.107.104.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA2EE9B for ; Wed, 12 Jul 2023 05:24:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CMytz7PNTu8j62XABKUXQM1Z5GMU+IFv5nnrdco/alXsUxJPqGsJ4KfOG8ObfRMnYFVtfjb9+PJQY3B9M7WFvBUI0fhys4cKRAODPX0dwwm6PvvRB8rQH3VSa3AluMJ8AqjBAHnHfBnBwuAhrQRSWK2JqeZlNwy+n34n+8iDIiAcvx5NN1fLyGxBnr6A2iMe0m3a/J1tPD8XF4PVhDD6dKw2EvfccPEkRGUpATUARsjnHSo2eXmuI7frmgHbhMSVYLERBWF1D/e0QnQDKx6o30Wwrkz0Pmv05PAYqYnAFn5JiV9B0TAFXCWlUIxtSx9B97Yv6X7CTSBPgtqk5cb74A== 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=LB4TF74fj+g/7IGMGbaZ8UVaPv+EY991ThQckKhvD3F29hv9DH07ybqJBK60rtdI+PugxfSfzmOiU1wICpioQWJr3JT92kZNEomFmi7ow/YLxYmWFk5UKLaEdiLFChQxdCUxgKME8/xpACGciEcRSx6IK2K6uwTiKTeil9pQzetkW/6pJ1/7Y6ExPpDzc7pQ+jiNtHrL/WAo10LKLr306l5XN/SpSEPZdFRO5C819acxa+oqMiFk4fRsYaIcwIp51DpapGZZDnmKInVvekz1kwFymXS7ecRq6zugSuOzc3lnkdcjnlJ9euP9CktzarXIq2CT8DcjF6fc/g0uYK0nIQ== 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=FWMsgouKeBWck7MEPfSXJao7j+t1pd8lWf4UZ7S39Cy+wdk1oKqsew1eH2boKGbqp79jK0P6TKyqSQwHUPmujGsbqrj9ARNeskwi2lmu5fjVl4M2xr3RWIxQKdpF5OlRuZ3FXlRP3w0sFIe0fHUTIjeWuSGEoMCy4GHJil2KPi4= 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 AM0PR04MB6835.eurprd04.prod.outlook.com (2603:10a6:208:180::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.20; Wed, 12 Jul 2023 12:24:35 +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 12:24:35 +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 v2 5/6] btio: Add support for getsockopt(BT_ISO_BASE) Date: Wed, 12 Jul 2023 15:21:34 +0300 Message-Id: <20230712122135.7734-6-claudia.rosu@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230712122135.7734-1-claudia.rosu@nxp.com> References: <20230712122135.7734-1-claudia.rosu@nxp.com> X-ClientProxiedBy: AM0PR03CA0019.eurprd03.prod.outlook.com (2603:10a6:208:14::32) To GV1PR04MB9151.eurprd04.prod.outlook.com (2603:10a6:150:26::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1PR04MB9151:EE_|AM0PR04MB6835:EE_ X-MS-Office365-Filtering-Correlation-Id: b9487e86-9021-4954-befc-08db82d2f414 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HNEqcbNIlJ0KScN3RVOgkbdh0kD701/EGzZ92y0yppAx5prC8RZ+Pz+T0xAnv7EWrAqPB/ftNxSr475eIyXcDIcjQ8fqANs+g69wy7D8PxBYtJywR9VTaf5+j6w/TJCWnn28CF5pyViJaaCZFeLNbNwYw2JymEVxyfxGjBgMT3HBthNMxJrh4VApsRkyIORsng2DAw4YF9M6S7Qq/6bzyE8jsysGI+fOPl2c4dWtO+vAGbeJI/mzWEemLVLMLA581SDBBOvBV2xqKINkRqmCh13gOAYVKH64I9p3GtTvbIcOQBodVlAyeiQzVnHqJ9n76qa7Z3QpRZyQTSqfcp1eXZBHW5nhsbRdfOrntaddM8ofrnYMbKu21oJYv4IRn5i/dc6I+5RWOyg/KqyIUB4hg9Yzkc807vqWL/wd/ZVS1AD7FbQmgdJairXhVkmqXcurTjWfxDbGP9NeLw4QPj9InC0B/xPdjo+rP/XrRtmtyWuhd217MOrRcwbYFDqAg6VELY5oN5EUIx1gxfTvktMvAjnnczUKOIzuB1UtF0dxtmLLMmIjiIihXoj6n9LRIvuT+Lfo/A7KKT3Ck4XRQ8COzcDAMM97jLckQOOcprGaNbQMowx1rEgrTEsRY/P8/3cL 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)(136003)(366004)(396003)(39860400002)(376002)(451199021)(8936002)(8676002)(38100700002)(38350700002)(41300700001)(2616005)(2906002)(316002)(5660300002)(66476007)(4326008)(6916009)(66556008)(66946007)(6486002)(52116002)(6512007)(83380400001)(478600001)(36756003)(1076003)(6506007)(55236004)(186003)(26005)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ECNyWuw910q33A8ycJwrjc3PhQYwrEVd+JNP6ucB+aJnHVNjPk8PSu2y98O1Fmi3Y62oQSpNfk7syryJQZHZsCoMy2OF/KUtx2ZQAUonSmYYTqk9uX80X+izLwTkTmI+CtBC9SLF+2r1CSkQpS/0M77lqayhrRVG1J6yfyN5r6/Lrz8NgLnHGTXM66j35nR9yWGK72u+bLrZJ8i2hTcDz1cPtJ74xyB8LJ6k1oHDioPlYMA7bZHXkWlpPtwk86b5TJiqRpCehs4cA11+InlAdQt3Phv8CO/bzOzDwIVPrPsESaB9sCSHHkD66ichJhzhD/Cuw28Lj3QddW1SwDsjxDhWIDO+wQssehbUDLAsr5NudsggTMxjOzqTNgZjmEgoWYJJATak9ThtSnArpUR3EiBrDJVdaKcxnZNWo0/1YjdcvOwMu1YjTa6Q2Ma/NIRFfzOVf2+BbhKc9aKcaS3khuDFQI9GDpJvkyzeItOP3iDsXYOrHUBNYvrKU97/Wch+RAApZNp/F2RvIy60ORwWo5vNgT8LYYhGxNWeLP/xRWfgnLxMYGkDgo2jen9DDWgzbFJjLRV8moF7HlzXmwNTlWzqn7Th6PsjSM7xB1jSVok3kfXk2H2UF+/R8ix3dKHnhb/6682szAtb1PMwJRpjp5WDUuvHb1sow8xi/XhAwgOMU8zIeLO4awJuiuthQS137o4fA6TGz+Tk0LyinVAHDnUQh4ocsBdtpOfAwcBDbhfcvQ11BMfbyLK5vV/iLK3gxlmVlud8eUvBYX+tm3DJjnBnhmd1cIsAM4yFDlo9J0nb9+w3dxFgfW98P7KrxpE9sWaktOKE+/32+k0CEX2IQebCY2wez+YrSG851U4cAWDOlrlN8gRRIBC5FSB0bL6OASkIpC0RZuBc5+7shuFDhl32BLvNmWpxjz/vVtodVaT3VdLd+iGbMaHVVwW/xQMJ+Td3aPrYNlGenfVxGYryYZUz3pLi7R1k1z2Y7q9t8rTPNKz/URrtpGQMVNrnC8qmeBGJXI3ZRDs6ERXKNUjVFHQyWYASkf2BPzr9UthVMSTF7makEZ5Si0ITKNwoF4q9SFPAekJMSxQmMN17MUo5YIivtYC6ZgtbNwh7/kkhRvJ9IeOSdpXS2iw7bYkt2wnqHC+RrmFtpYaXgUi7SjROabSbw4ndOrkdtPq+J/MoE6hvUfH8WcIxCUQ/r9T6aPNYdVsq2cM4wPSteYMfwJTrYkp2pHMfzzpnmmy0ELcne8eZvZBVS0cI9Cd3QHnnOxS4tyg2NrWZNXh8Uxl3M/7BMtV7SugA0QUpLBy4wt5rJw4aCsohpbtn39ZWdqIPQHYs2sID2ETQouSE0DZQuLnj6xUCnAHJmHEPXUnrfXLp6Ge9slKEN/G4Wg2JpyswObuNWsxUSeRRDM3UKmx3Mze/iFa02dWBwlFL4btr1p62VtnpDsoeUh6nrSU9gIUBQ3zSMIDt1+OeOl7xsJFQEET94N1PO5+BPLjIY0OcbVym0BBPBvSyI7n5lGX0RQuqCZYYe574IR8pn9Ed1q9gEHNI0NhNaEfDdO7jhyY4naSws/zsSNuFYlLJFT48SXlcml+OCrMGbCSLWqJyp3bdbifzYA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b9487e86-9021-4954-befc-08db82d2f414 X-MS-Exchange-CrossTenant-AuthSource: GV1PR04MB9151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jul 2023 12:24:35.4305 (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: W4vsW8dufRCqtSaQMDZ97bGSHZg5Z03SEfh7scBsm0nkDnfM2cyBO2a6tQfBJ1N54YI21NwCccGMPGcl35GxZQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB6835 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 12:21:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudia Draghicescu X-Patchwork-Id: 13310304 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 762D6EB64D9 for ; Wed, 12 Jul 2023 12:24:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232163AbjGLMYr (ORCPT ); Wed, 12 Jul 2023 08:24:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233030AbjGLMYp (ORCPT ); Wed, 12 Jul 2023 08:24:45 -0400 Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on2084.outbound.protection.outlook.com [40.107.14.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F079F134 for ; Wed, 12 Jul 2023 05:24:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bSFOgRHxglLg7Ke/lW4VBpvKmklGnAvTiD4DydjIl55+ubsVvNc0A9f6L7LDqcvXM54CUhwWLIPRF72b2Y/jvBaOXx/ksIqfg4Qw33KRudamVP9waxJFQ4Kf22AqK2PuGMQvWHKPvlOXDikkpC/XtIIuWj6RtRn2kZVmnZsmYxns1zF65Ioi406UwdopES53kx3fDY/2/8D8DwcPbdte9temD2d2Sr/hwcj1HyPDLCYATjtsvG7I7b9CGeEMsT8Q4IPZlT+ocWXn8MxP/GOW7TVTfJdSN1dKluAVM+nEi0ujW5Y2VphSJTqOZwiqdbiyHiDopAp8m8DbVtDEtWWujw== 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=OsdKqu13pskuaHNAi1rt9rwsLN+agA/IVEaErVJMNIKnzduvJPx6q3/GNWec79Mdm8UQ3giHIqMJWXfmYAVg3Vxr0IpqMHdLQuI0+/d7MNQhQeErveLZ+aFxZn8NRCxlSBeCfb5NKQCmnWy2hTo/6yBlDqmwbAHuser33NBGrBnjZdIUL2T8Ggr6imUKq0wem7ff8iGIl8e6UTs8ilF3si1d6BgFlt+eiNtyK+4KZb9n4Es4mbm931tS9se35GCSCkz0xdSaqR9jh1zV8gpzcZycuJdKtAypsO0a0Xid6FMJpDvHayvI0k1n+xpRuxN8gmQtW8wWfPP7nKVVbQot3A== 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=IxqlaWNv67NEXjS0VnbVkiMGlLXYT9l1eOI+gJlzqKFTOjv5r7UNI+HMOwtglI8OabBaF7t1EwUCY0JB4o+Ojykbwe0iVPsLLHJjpYS6yjsz5UDqSHKLEtrVLtDVcO1ckWGPhvOiu1OX3x6RAxk0EKFyTiuxdN2cgvBDa2HUnfw= 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 AM0PR04MB6835.eurprd04.prod.outlook.com (2603:10a6:208:180::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6588.20; Wed, 12 Jul 2023 12:24:39 +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 12:24:39 +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 v2 6/6] bap: Add support for BAP broadcast sink Date: Wed, 12 Jul 2023 15:21:35 +0300 Message-Id: <20230712122135.7734-7-claudia.rosu@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230712122135.7734-1-claudia.rosu@nxp.com> References: <20230712122135.7734-1-claudia.rosu@nxp.com> X-ClientProxiedBy: AM0PR03CA0019.eurprd03.prod.outlook.com (2603:10a6:208:14::32) To GV1PR04MB9151.eurprd04.prod.outlook.com (2603:10a6:150:26::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1PR04MB9151:EE_|AM0PR04MB6835:EE_ X-MS-Office365-Filtering-Correlation-Id: 27e363ef-babc-4387-9659-08db82d2f693 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tyHnwmo8pquBPnign4DdZQb7ciYQqA/v+UENJr9HAm19xMIJeSA4c3+tl1HrCm+oPzkLAnikefhEHHVBJHa7gRRa6d1my3Hl1ooYqfzOn3U58RSRcqljF3dBOhb8rzMenELhHoOBGrf2xfOR0TCIz6vo0ydKMkRPHiidwWLxuA8YPUm6YaBLG9QYvUeuU0StrYMeqOql97KkK1oA7hA6dtleNvnz/jrHn0FEYukZjy1SujJGKhnLVINLnyhjUmxqejIiqJzpHf4QD17t1CcNGBobAAI+l9Pefyxh6LkOYsckqfb18431wBViG6veC7DHH9XR6jtHHjIozdSDnlZl5hwBpMeDEpUVfwsttkGmL1CCFPIL/tGde27pdQTrousUzVTCAiFyfV9z13GqDr7YNETBEkp0mMHVgmZzctpLwrss3alyJcH8w1BHtwS3CzvAEe/6HwFSz8UzTt0bQlIduz2PlYmBfG31lKG5BMXkk9DvbMxfox+m6SoX5/J+SjbRTYYF6Uc4EH7G9ao6nyRuij/8bvaTfBSjBjnFfXb2UH4KuxrjxACdmCi7GIsLa1UN6b74+JC6OYo0FBoMCOe4iixNSeLGbtnJp9t+pVlKJk6wmo+XUQsIUnlhvl/mzdIj 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)(136003)(366004)(396003)(39860400002)(376002)(451199021)(8936002)(8676002)(38100700002)(38350700002)(41300700001)(2616005)(2906002)(316002)(5660300002)(30864003)(66476007)(4326008)(6916009)(66556008)(66946007)(6666004)(6486002)(52116002)(6512007)(83380400001)(478600001)(36756003)(1076003)(6506007)(55236004)(186003)(26005)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: x66i2sNe4ladP+KmrMC5BA2qjz691CHpDGfpgJKZMOtL2UyCzSiETlTeSQtB53S4Pxk8K4cwlCldIgLUdIB8n2KRjjrqYZAUsNBz0WIdyaIDiBDn4AFjjSlqH5mX1Ay1TCKbwLNMBsLSYZaypu9ztPFJUO9TBpF2CBinjxleDwPEnERyfilSa2EzWyY2nYLO63Llrk0ciXVLuSNTZhlQUfceQW70jVLc4E3U70xjkJMAQ7GRBgq+vNAoWIBozZ2z9dVZyVifzcJ8IAnSnodj27pJhrROhmebqdqJ5oZcnBQEIyzyIOTKDg3Zbd8A8EKNAOq7Tb95bSl+f/zVC6HGvDrLB/fuN1l5nznzVVfZiaQhDlZmI984ryi3+kSioT904rXJYe/bdeXfJfhAa8asgfAxj1dy3j+KblI8BRUzhLl2xdIzRTN1POEByZHIc0n9lxSSr48ISXucPBMegw7eNy+3OO/OkoAtIo1/s0nZSmTkynWbvBEO4C8qH4TavjTnOUHJI4hxJX8pjZFpXuYYr4aO6BY73hv+Cvv/K1ZP1y6Jha8FzKDrREZzv3lYXs18BmpN38NUsk9BdXQasUzA2EjnYBjtgFdAjKFR/f/7jOGxGdqpunkMv0bVXsX/bDytKrMIXjikA8h/v7fl3FujNR3bTEdd4pt9ZQiaOaCLKIziarx4KlqigXvGjT2LRHtPxRtUg/vPsfYD8hOLfqy+O4UZXNGKEYEg5t6fOWr8Dh7D8BMF/aXN3oD2ZEHnNKCA2QBpTGtz51RYyMJxoCToSpyqNsxWPK1bGcKNRsVRl0klCZHP34e6xMG+ajW8EpSkpooNltmnxodL0E5FQYgANid3+ICSXjkjwphxw/yqHaFQgjpZ6UQnjBI+/y7rNx729Le8/CnOasvbA4KVf9KGJxK15BdCxrmJguL8D9+YpkkzjUHnj5s0/TSiXFJdcU42Q7s6U2nhRnOptXwfmpeqU1H+yX9oCzldVfHmX1XmLXkceaDbfUY44wwx6mwZEjwgTOKWd+Bq3U8dc1s3RbTpcoLMcN1zmfYMnW+46mTZQ9ApdP/+XMDD917SxjUmOiXq6VwCSDMzMU9bCC4bAqSAABJnRqlRFMzNOzlXxKvT8cE+DVkYXdqONmpwIn3n+3m45m6Af765de2abFQ3x2ARzf7CwMQAavQbLqjr9itLAwJSKNCfjhRpKJ73K4Lr9CWTLAr6ailwGeOYOa603OUyNtb6sK5cjKi1/KDSa9MEUWF7RZc9ud4j4Hpl+elkIrGUCgfKYE+D1kSzV9rMxwvfgdbdd3J7FlqyxlI7ZnzKwptL2V2r95W8r0O/h0Tg6JgQ/HU0LXEhiQ3skuj2Vvi/0vpv56kmMj6MVRhgGXm9IMeDu/lNvAUnWpGYjAdNB5NV8z366/VbDNPiNMRLBD324xUEqA17SLKu3bAxNizIt6LCLkJcA6R/iLM+Bt2yac9waxb0KE2cJfgIHDef/tKSVOO3GSWz0AhVPBNjuUgcLnSjJ6zing/4dqg4NW6/rc9UGWNSjGF9YrYylCCk49VenPLUlIkoYltxzT3ckbFtTrPQmuSeXIL3o1zN6/J56nx406QlIX37GmAFmLvcpyAgLA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 27e363ef-babc-4387-9659-08db82d2f693 X-MS-Exchange-CrossTenant-AuthSource: GV1PR04MB9151.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jul 2023 12:24:39.7139 (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: jzMh2Imbzrpj3nA3d1NWlWA9Ii9nP85S4KqMRPsQAtbV7q9rL437c/Y/FnxZdQ9f0dEjeiN/bqNOKXvLm6mBgQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB6835 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);