Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp4035010rdg; Wed, 18 Oct 2023 12:57:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHhQmCKS6LVUuT69lRSThkBJ1p4rRjNlErJuDdXj3PeJXADc4src58uNp4VIteN9wkJUJJ+ X-Received: by 2002:a17:902:c404:b0:1c5:d8a3:8789 with SMTP id k4-20020a170902c40400b001c5d8a38789mr477168plk.4.1697659039960; Wed, 18 Oct 2023 12:57:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697659039; cv=none; d=google.com; s=arc-20160816; b=xufxyqoq+gU+no6LahAEQje1JiOlIjAt85V0s/MfNm4CFD7Tu4ExoOYBeKHOY2MgDP klaHJk1OpBVDvAZrbddKg5rhQeT7Rtw3Kv5OSgDPAj/3O8oXe+GTEmVedlo0SiHJOJ3u h2DhkIYl3G4edARGR5LICKMIYZrMlXTF360hkzI//5rNs5LOJ5Jldgl2lA/tYYD7bboc 3d5M6+DS9/SXs5jH493FyetN3EoUEjUOCmeocINmFNYYJL69uxqkaKlYC355/STxykjj R6yp8YFK5YD4Tqjmm/VwwpDuiWtj28rvfm769vhr0cKef2E7FSrggaWvRua9cxezQPxp COmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=cwt/O4BE9qXnQZw8zoFRGFUPhkxOc2BZrusO3xMXvaQ=; fh=4lGQI6056MBa4/oovMyIYaKLn+Wz/24RGvUivMmQP8E=; b=Ww0QuhMzIuEmpnsNknl1et6+4ulkFbkDogmZN9qh7JsFizz+Uaa8bGt7kjyIah9RYF sCjYabDsfJzt+jcBmnQY8kWO/D46oYSREwUBYh4+qZyw/Su5NNwYyEGnY36VCh2g2+3q PjpqHtJfKHLySG6Quu42o4O1XOgVZXnjxIcKDDrFE5/5FU8eqoVyOHw7G389GhccZ55K KGaDXDhn2UYXiND+bD7d1Y4ZWF0uohbZp6zz1CUvhgUOYfjvGMtHigdYcq7LMq9oWopp 9uiBh9dcAWK2wCSBG/MG+sL2rQa/i4MmYzsZ5ORQrZTTAiQdPNTzeDvsYagMRc2wnqfw UKHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="UNlHfD/X"; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id x8-20020a170902ec8800b001c4401a7e18si595148plg.382.2023.10.18.12.57.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 12:57:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="UNlHfD/X"; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id AC2D180DA9AA; Wed, 18 Oct 2023 12:57:16 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231670AbjJRT5H (ORCPT + 99 others); Wed, 18 Oct 2023 15:57:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231933AbjJRT5E (ORCPT ); Wed, 18 Oct 2023 15:57:04 -0400 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33FBD12C for ; Wed, 18 Oct 2023 12:57:03 -0700 (PDT) Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1ca82f015e4so25927375ad.1 for ; Wed, 18 Oct 2023 12:57:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697659022; x=1698263822; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=cwt/O4BE9qXnQZw8zoFRGFUPhkxOc2BZrusO3xMXvaQ=; b=UNlHfD/XhQP2K7Ijv8e1YjGITOBtXpYn0RRPccyd4juvdlj6GNiTagm/XM+5+1YIEd SIiXpJPEXnPoHJ/Jv5efKK4ogLtFn56uRrudv+r9lDmTgKglBYQydbiJcBVlEPDlMvVl ectHMoxXvgid5ku9hwJcgCr/bH9hScIthy6YuF2G2GmAjYk98zHJvScUO9QOkOJjB4Ti D3548TIV3qN0MxKyB7rPlEIk9oZO3lNK1L5ldEmC9/PdubUfgv319n1YRFd0LPrsvee2 mot1AI0Ax8AJoHtzyWSfkGaTiJlVAF4RRuMoJ4H3EF/H6E6vT68h93PvE7XXJjhCknlb RrUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697659022; x=1698263822; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cwt/O4BE9qXnQZw8zoFRGFUPhkxOc2BZrusO3xMXvaQ=; b=QT9mjFDJhart92gfT7aqRBjm1pd7FoGaSXFbCdjCPQyNPm2ccHPyfDs7I7dMYrgF3N uiKsAMCAUhjMEmn0xNmcDv3I3tiQpaLAFkQYzr20a3cfuXT2s9OtwqQLZ5GdE3Li6hqA 75sEenbM0l6O15GavhyWcbVQvV7evNK75mWTt9FP+dZWor6WlIu2Jqzu1R+1u6PJV9hL Jjl0GysnqpAhGRqfbLiBSDjUwg1j01uwh7xA+pqB/Aw6iFSjqiYI8RhNgmoN5cUG8Lid VLu1BAFXf5cTebO5j2hAALemKGeII2mEjHrg2v5/Blj7/Ap3ge4KDm34jW9NnYq87pkA agKw== X-Gm-Message-State: AOJu0YyMHBY5qF77yEeQ9wVJ6DNzzN5uQH5i0C97W0mccxnXRjx68oqO Cda79sWLeX7VnV4hkofMW6W91FvJfbrgI8NYz0I= X-Received: by 2002:a17:902:e88e:b0:1ca:505:8c86 with SMTP id w14-20020a170902e88e00b001ca05058c86mr435059plg.20.1697659021769; Wed, 18 Oct 2023 12:57:01 -0700 (PDT) Received: from lvondent-mobl4.. (c-98-232-221-87.hsd1.or.comcast.net. [98.232.221.87]) by smtp.gmail.com with ESMTPSA id jk8-20020a170903330800b001b3bf8001a9sm329739plb.48.2023.10.18.12.57.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 12:57:00 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ 4/4] client: Make use of bap-debug functions Date: Wed, 18 Oct 2023 12:56:53 -0700 Message-ID: <20231018195653.2532882-4-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231018195653.2532882-1-luiz.dentz@gmail.com> References: <20231018195653.2532882-1-luiz.dentz@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Wed, 18 Oct 2023 12:57:16 -0700 (PDT) From: Luiz Augusto von Dentz This make use of bap-debug functions to decode Capabilities, Configuration and Metadata. --- client/player.c | 124 ++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 116 insertions(+), 8 deletions(-) diff --git a/client/player.c b/client/player.c index d1809f24fd27..603447a9df46 100644 --- a/client/player.c +++ b/client/player.c @@ -42,6 +42,7 @@ #include "src/shared/shell.h" #include "src/shared/io.h" #include "src/shared/queue.h" +#include "src/shared/bap-debug.h" #include "print.h" #include "player.h" @@ -1451,6 +1452,34 @@ static struct codec_preset lc3_presets[] = { LC3_10_UNFRAMED(155u, 13u, 100u, 40000u)), }; +static void print_ltv(const char *str, void *user_data) +{ + const char *label = user_data; + + bt_shell_printf("\t%s.%s\n", label, str); +} + +static void print_lc3_caps(uint8_t *data, int len) +{ + const char *label = "Capabilities"; + + bt_bap_debug_caps(data, len, print_ltv, (void *)label); +} + +static void print_lc3_cfg(void *data, int len) +{ + const char *label = "Configuration"; + + bt_bap_debug_config(data, len, print_ltv, (void *)label); +} + +static void print_lc3_meta(void *data, int len) +{ + const char *label = "Metadata"; + + bt_bap_debug_metadata(data, len, print_ltv, (void *)label); +} + #define PRESET(_uuid, _codec, _presets, _default_index) \ { \ .uuid = _uuid, \ @@ -1941,8 +1970,12 @@ static void append_properties(DBusMessageIter *iter, dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, "{sv}", &dict); - bt_shell_printf("Capabilities: "); - bt_shell_hexdump(cfg->caps->iov_base, cfg->caps->iov_len); + if (cfg->ep->codec == LC3_ID) { + print_lc3_cfg(cfg->caps->iov_base, cfg->caps->iov_len); + } else { + bt_shell_printf("Capabilities: "); + bt_shell_hexdump(cfg->caps->iov_base, cfg->caps->iov_len); + } g_dbus_dict_append_basic_array(&dict, DBUS_TYPE_STRING, &key, DBUS_TYPE_BYTE, &cfg->caps->iov_base, @@ -1955,8 +1988,13 @@ static void append_properties(DBusMessageIter *iter, DBUS_TYPE_BYTE, &cfg->meta->iov_base, cfg->meta->iov_len); - bt_shell_printf("Metadata:\n"); - bt_shell_hexdump(cfg->meta->iov_base, cfg->meta->iov_len); + if (cfg->ep->codec == LC3_ID) { + print_lc3_meta(cfg->meta->iov_base, cfg->meta->iov_len); + } else { + bt_shell_printf("Metadata:\n"); + bt_shell_hexdump(cfg->meta->iov_base, + cfg->meta->iov_len); + } } append_qos(&dict, cfg); @@ -2124,6 +2162,42 @@ static struct endpoint *endpoint_find(const char *pattern) return NULL; } +static void print_capabilities(GDBusProxy *proxy) +{ + DBusMessageIter iter, subiter; + uint8_t codec; + uint8_t *data; + int len; + + if (!g_dbus_proxy_get_property(proxy, "Codec", &iter)) + return; + + dbus_message_iter_get_basic(&iter, &codec); + + if (codec != LC3_ID) { + print_property(proxy, "Capabilities"); + return; + } + + if (!g_dbus_proxy_get_property(proxy, "Capabilities", &iter)) + return; + + dbus_message_iter_recurse(&iter, &subiter); + + dbus_message_iter_get_fixed_array(&subiter, &data, &len); + + print_lc3_caps(data, len); + + if (!g_dbus_proxy_get_property(proxy, "Metadata", &iter)) + return; + + dbus_message_iter_recurse(&iter, &subiter); + + dbus_message_iter_get_fixed_array(&subiter, &data, &len); + + print_lc3_meta(data, len); +} + static void cmd_show_endpoint(int argc, char *argv[]) { GDBusProxy *proxy; @@ -2139,7 +2213,7 @@ static void cmd_show_endpoint(int argc, char *argv[]) print_property(proxy, "UUID"); print_property(proxy, "Codec"); - print_property(proxy, "Capabilities"); + print_capabilities(proxy); print_property(proxy, "Device"); print_property(proxy, "DelayReporting"); print_property(proxy, "Locations"); @@ -3817,6 +3891,42 @@ static void cmd_list_transport(int argc, char *argv[]) return bt_shell_noninteractive_quit(EXIT_SUCCESS); } +static void print_configuration(GDBusProxy *proxy) +{ + DBusMessageIter iter, subiter; + uint8_t codec; + uint8_t *data; + int len; + + if (!g_dbus_proxy_get_property(proxy, "Codec", &iter)) + return; + + dbus_message_iter_get_basic(&iter, &codec); + + if (codec != LC3_ID) { + print_property(proxy, "Configuration"); + return; + } + + if (!g_dbus_proxy_get_property(proxy, "Configuration", &iter)) + return; + + dbus_message_iter_recurse(&iter, &subiter); + + dbus_message_iter_get_fixed_array(&subiter, &data, &len); + + print_lc3_cfg(data, len); + + if (!g_dbus_proxy_get_property(proxy, "Metadata", &iter)) + return; + + dbus_message_iter_recurse(&iter, &subiter); + + dbus_message_iter_get_fixed_array(&subiter, &data, &len); + + print_lc3_meta(data, len); +} + static void cmd_show_transport(int argc, char *argv[]) { GDBusProxy *proxy; @@ -3832,16 +3942,14 @@ static void cmd_show_transport(int argc, char *argv[]) print_property(proxy, "UUID"); print_property(proxy, "Codec"); - print_property(proxy, "Configuration"); + print_configuration(proxy); print_property(proxy, "Device"); print_property(proxy, "State"); print_property(proxy, "Delay"); print_property(proxy, "Volume"); print_property(proxy, "Endpoint"); - print_property(proxy, "QoS"); print_property(proxy, "Location"); - print_property(proxy, "Metadata"); print_property(proxy, "Links"); return bt_shell_noninteractive_quit(EXIT_SUCCESS); -- 2.41.0