LCOV - code coverage report
Current view: top level - zephyr/bluetooth/audio - pacs.h Hit Total Coverage
Test: new.info Lines: 13 13 100.0 %
Date: 2024-12-22 00:14:23

          Line data    Source code
       1           1 : /**
       2             :  * @file
       3             :  * @brief Bluetooth Published Audio Capabilities Service (PACS) APIs
       4             :  */
       5             : 
       6             : /* Copyright (c) 2021 Intel Corporation
       7             :  * Copyright (c) 2021-2024 Nordic Semiconductor ASA
       8             :  *
       9             :  * SPDX-License-Identifier: Apache-2.0
      10             :  */
      11             : 
      12             : #ifndef ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_PACS_H_
      13             : #define ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_PACS_H_
      14             : 
      15             : /**
      16             :  * @brief Published Audio Capabilities Service (PACS)
      17             :  *
      18             :  * @defgroup bt_pacs Published Audio Capabilities Service (PACS)
      19             :  *
      20             :  * @since 3.0
      21             :  * @version 0.8.0
      22             :  *
      23             :  * @ingroup bluetooth
      24             :  * @{
      25             :  *
      26             :  * The Published Audio Capabilities Service (PACS) is used to expose capabilities to remote devices.
      27             :  */
      28             : 
      29             : #include <stdbool.h>
      30             : 
      31             : #include <zephyr/bluetooth/audio/audio.h>
      32             : #include <zephyr/bluetooth/conn.h>
      33             : #include <zephyr/sys/slist.h>
      34             : 
      35             : #ifdef __cplusplus
      36             : extern "C" {
      37             : #endif
      38             : 
      39             : /** @brief Published Audio Capability structure. */
      40           1 : struct bt_pacs_cap {
      41             :         /** Codec capability reference */
      42           1 :         const struct bt_audio_codec_cap *codec_cap;
      43             : 
      44             :         /** @internal Internally used list node */
      45             :         sys_snode_t _node;
      46             : };
      47             : 
      48             : /**
      49             :  * @typedef bt_pacs_cap_foreach_func_t
      50             :  * @brief Published Audio Capability iterator callback.
      51             :  *
      52             :  * @param cap Capability found.
      53             :  * @param user_data Data given.
      54             :  *
      55             :  * @return true to continue to the next capability
      56             :  * @return false to stop the iteration
      57             :  */
      58           1 : typedef bool (*bt_pacs_cap_foreach_func_t)(const struct bt_pacs_cap *cap,
      59             :                                            void *user_data);
      60             : 
      61             : /**
      62             :  * @brief Published Audio Capability iterator.
      63             :  *
      64             :  * Iterate capabilities with endpoint direction specified.
      65             :  *
      66             :  * @param dir Direction of the endpoint to look capability for.
      67             :  * @param func Callback function.
      68             :  * @param user_data Data to pass to the callback.
      69             :  */
      70           1 : void bt_pacs_cap_foreach(enum bt_audio_dir dir,
      71             :                          bt_pacs_cap_foreach_func_t func,
      72             :                          void *user_data);
      73             : 
      74             : /**
      75             :  * @brief Register Published Audio Capability.
      76             :  *
      77             :  * Register Audio Local Capability.
      78             :  *
      79             :  * @param dir Direction of the endpoint to register capability for.
      80             :  * @param cap Capability structure.
      81             :  *
      82             :  * @return 0 in case of success or negative value in case of error.
      83             :  */
      84           1 : int bt_pacs_cap_register(enum bt_audio_dir dir, struct bt_pacs_cap *cap);
      85             : 
      86             : /**
      87             :  * @brief Unregister Published Audio Capability.
      88             :  *
      89             :  * Unregister Audio Local Capability.
      90             :  *
      91             :  * @param dir Direction of the endpoint to unregister capability for.
      92             :  * @param cap Capability structure.
      93             :  *
      94             :  * @return 0 in case of success or negative value in case of error.
      95             :  */
      96           1 : int bt_pacs_cap_unregister(enum bt_audio_dir dir, struct bt_pacs_cap *cap);
      97             : 
      98             : /**
      99             :  * @brief Set the location for an endpoint type
     100             :  *
     101             :  * @param dir      Direction of the endpoints to change location for.
     102             :  * @param location The location to be set.
     103             :  *
     104             :  * @return 0 in case of success or negative value in case of error.
     105             :  */
     106           1 : int bt_pacs_set_location(enum bt_audio_dir dir,
     107             :                          enum bt_audio_location location);
     108             : 
     109             : /**
     110             :  * @brief Set the available contexts for an endpoint type
     111             :  *
     112             :  * @param dir      Direction of the endpoints to change available contexts for.
     113             :  * @param contexts The contexts to be set.
     114             :  *
     115             :  * @return 0 in case of success or negative value in case of error.
     116             :  */
     117           1 : int bt_pacs_set_available_contexts(enum bt_audio_dir dir,
     118             :                                    enum bt_audio_context contexts);
     119             : 
     120             : /**
     121             :  * @brief Get the available contexts for an endpoint type
     122             :  *
     123             :  * @param dir      Direction of the endpoints to get contexts for.
     124             :  *
     125             :  * @return Bitmask of available contexts.
     126             :  */
     127           1 : enum bt_audio_context bt_pacs_get_available_contexts(enum bt_audio_dir dir);
     128             : 
     129             : /**
     130             :  * @brief Set the available contexts for a given connection
     131             :  *
     132             :  * This function sets the available contexts value for a given @p conn connection object.
     133             :  * If the @p contexts parameter is NULL the available contexts value is reset to default.
     134             :  * The default value of the available contexts is set using @ref bt_pacs_set_available_contexts
     135             :  * function.
     136             :  * The Available Context Value is reset to default on ACL disconnection.
     137             :  *
     138             :  * @param conn     Connection object.
     139             :  * @param dir      Direction of the endpoints to change available contexts for.
     140             :  * @param contexts The contexts to be set or NULL to reset to default.
     141             :  *
     142             :  * @return 0 in case of success or negative value in case of error.
     143             :  */
     144           1 : int bt_pacs_conn_set_available_contexts_for_conn(struct bt_conn *conn, enum bt_audio_dir dir,
     145             :                                                  enum bt_audio_context *contexts);
     146             : 
     147             : /**
     148             :  * @brief Get the available contexts for a given connection
     149             :  *
     150             :  * This server function returns the available contexts value for a given @p conn connection object.
     151             :  * The value returned is the one set with @ref bt_pacs_conn_set_available_contexts_for_conn function
     152             :  * or the default value set with @ref bt_pacs_set_available_contexts function.
     153             :  *
     154             :  * @param conn     Connection object.
     155             :  * @param dir      Direction of the endpoints to get contexts for.
     156             :  *
     157             :  * @return Bitmask of available contexts.
     158             :  * @retval BT_AUDIO_CONTEXT_TYPE_PROHIBITED if @p conn or @p dir are invalid
     159             :  */
     160           1 : enum bt_audio_context bt_pacs_get_available_contexts_for_conn(struct bt_conn *conn,
     161             :                                                               enum bt_audio_dir dir);
     162             : 
     163             : /**
     164             :  * @brief Set the supported contexts for an endpoint type
     165             :  *
     166             :  * @param dir      Direction of the endpoints to change available contexts for.
     167             :  * @param contexts The contexts to be set.
     168             :  *
     169             :  * @return 0 in case of success or negative value in case of error.
     170             :  */
     171           1 : int bt_pacs_set_supported_contexts(enum bt_audio_dir dir,
     172             :                                    enum bt_audio_context contexts);
     173             : 
     174             : #ifdef __cplusplus
     175             : }
     176             : #endif
     177             : 
     178             : /** @} */
     179             : 
     180             : #endif /* ZEPHYR_INCLUDE_BLUETOOTH_AUDIO_PACS_H_ */

Generated by: LCOV version 1.14