LCOV - code coverage report
Current view: top level - zephyr/bluetooth/classic - a2dp.h Coverage Total Hit
Test: new.info Lines: 95.7 % 92 88
Test Date: 2025-10-20 12:20:01

            Line data    Source code
       1            1 : /** @file
       2              :  * @brief Advanced Audio Distribution Profile header.
       3              :  */
       4              : 
       5              : /*
       6              :  * Copyright (c) 2015-2016 Intel Corporation
       7              :  * Copyright 2024 NXP
       8              :  *
       9              :  * SPDX-License-Identifier: Apache-2.0
      10              :  */
      11              : #ifndef ZEPHYR_INCLUDE_BLUETOOTH_A2DP_H_
      12              : #define ZEPHYR_INCLUDE_BLUETOOTH_A2DP_H_
      13              : 
      14              : /**
      15              :  * @file
      16              :  * @brief Advanced Audio Distribution Profile (A2DP)
      17              :  * @defgroup bt_a2dp Advanced Audio Distribution Profile (A2DP)
      18              :  * @ingroup bluetooth
      19              :  * @{
      20              :  */
      21              : 
      22              : #include <stdint.h>
      23              : 
      24              : #include <zephyr/bluetooth/bluetooth.h>
      25              : #include <zephyr/bluetooth/l2cap.h>
      26              : #include <zephyr/bluetooth/classic/avdtp.h>
      27              : 
      28              : #ifdef __cplusplus
      29              : extern "C" {
      30              : #endif
      31              : 
      32              : /** SBC IE length */
      33            1 : #define BT_A2DP_SBC_IE_LENGTH      (4U)
      34              : /** MPEG1,2 IE length */
      35            1 : #define BT_A2DP_MPEG_1_2_IE_LENGTH (4U)
      36              : /** MPEG2,4 IE length */
      37            1 : #define BT_A2DP_MPEG_2_4_IE_LENGTH (6U)
      38              : /** The max IE (Codec Info Element) length */
      39            1 : #define BT_A2DP_MAX_IE_LENGTH      (8U)
      40              : 
      41              : /** @brief define the audio endpoint
      42              :  *  @param _role BT_AVDTP_SOURCE or BT_AVDTP_SINK.
      43              :  *  @param _codec value of enum bt_a2dp_codec_id.
      44              :  *  @param _capability the codec capability.
      45              :  *  @param _delay_report delay report capability
      46              :  */
      47            1 : #define BT_A2DP_EP_INIT(_role, _codec, _capability, _delay_report)                                 \
      48              :         {                                                                                          \
      49              :                 .codec_type = _codec,                                                              \
      50              :                 .sep = {.sep_info = {.media_type = BT_AVDTP_AUDIO, .tsep = _role}},                \
      51              :                 .codec_cap = _capability, .stream = NULL,                                          \
      52              :                 .delay_report = _delay_report,                                                     \
      53              :         }
      54              : 
      55              : /** @brief define the audio sink endpoint
      56              :  *  @param _codec value of enum bt_a2dp_codec_id.
      57              :  *  @param _capability the codec capability.
      58              :  *  @param _delay_report delay report capability
      59              :  */
      60            1 : #define BT_A2DP_SINK_EP_INIT(_codec, _capability, _delay_report)                                   \
      61              :         BT_A2DP_EP_INIT(BT_AVDTP_SINK, _codec, _capability, _delay_report)
      62              : 
      63              : /** @brief define the audio source endpoint
      64              :  *  @param _codec value of enum bt_a2dp_codec_id.
      65              :  *  @param _capability the codec capability.
      66              :  *  @param _delay_report delay report capability
      67              :  */
      68            1 : #define BT_A2DP_SOURCE_EP_INIT(_codec, _capability, _delay_report)                                 \
      69              :         BT_A2DP_EP_INIT(BT_AVDTP_SOURCE, _codec, _capability, _delay_report)
      70              : 
      71              : /** @brief define the SBC sink endpoint that can be used as
      72              :  * bt_a2dp_register_endpoint's parameter.
      73              :  *
      74              :  * SBC is mandatory as a2dp specification, BT_A2DP_SBC_SINK_EP_DEFAULT
      75              :  * is more convenient for user to register SBC endpoint.
      76              :  *
      77              :  *  @param _name unique structure name postfix.
      78              :  *  @param _freq sbc codec frequency.
      79              :  *               for example: A2DP_SBC_SAMP_FREQ_44100 | A2DP_SBC_SAMP_FREQ_48000
      80              :  *  @param _ch_mode sbc codec channel mode.
      81              :  *               for example: A2DP_SBC_CH_MODE_MONO | A2DP_SBC_CH_MODE_STEREO
      82              :  *  @param _blk_len sbc codec block length.
      83              :  *               for example: A2DP_SBC_BLK_LEN_16
      84              :  *  @param _subband sbc codec subband.
      85              :  *               for example: A2DP_SBC_SUBBAND_8
      86              :  *  @param _alloc_mthd sbc codec allocate method.
      87              :  *               for example: A2DP_SBC_ALLOC_MTHD_LOUDNESS
      88              :  *  @param _min_bitpool sbc codec min bit pool. for example: 18
      89              :  *  @param _max_bitpool sbc codec max bit pool. for example: 35
      90              :  *  @param _delay_report delay report capability
      91              :  *  @
      92              :  */
      93              : #define BT_A2DP_SBC_SINK_EP(_name, _freq, _ch_mode, _blk_len, _subband, _alloc_mthd, _min_bitpool, \
      94            1 :                             _max_bitpool, _delay_report)                                           \
      95              :         static struct bt_a2dp_codec_ie bt_a2dp_ep_cap_ie##_name = {                                \
      96              :                 .len = BT_A2DP_SBC_IE_LENGTH,                                                      \
      97              :                 .codec_ie = {_freq | _ch_mode, _blk_len | _subband | _alloc_mthd, _min_bitpool,    \
      98              :                              _max_bitpool}};                                                       \
      99              :         static struct bt_a2dp_ep _name =                                                           \
     100              :                 BT_A2DP_SINK_EP_INIT(BT_A2DP_SBC, (&bt_a2dp_ep_cap_ie##_name), _delay_report)
     101              : 
     102              : /** @brief define the SBC source endpoint that can be used as bt_a2dp_register_endpoint's
     103              :  * parameter.
     104              :  *
     105              :  * SBC is mandatory as a2dp specification, BT_A2DP_SBC_SOURCE_EP_DEFAULT
     106              :  * is more convenient for user to register SBC endpoint.
     107              :  *
     108              :  *  @param _name the endpoint variable name.
     109              :  *  @param _freq sbc codec frequency.
     110              :  *               for example: A2DP_SBC_SAMP_FREQ_44100 | A2DP_SBC_SAMP_FREQ_48000
     111              :  *  @param _ch_mode sbc codec channel mode.
     112              :  *               for example: A2DP_SBC_CH_MODE_MONO | A2DP_SBC_CH_MODE_STEREO
     113              :  *  @param _blk_len sbc codec block length.
     114              :  *               for example: A2DP_SBC_BLK_LEN_16
     115              :  *  @param _subband sbc codec subband.
     116              :  *               for example: A2DP_SBC_SUBBAND_8
     117              :  *  @param _alloc_mthd sbc codec allocate method.
     118              :  *               for example: A2DP_SBC_ALLOC_MTHD_LOUDNESS
     119              :  *  @param _min_bitpool sbc codec min bit pool. for example: 18
     120              :  *  @param _max_bitpool sbc codec max bit pool. for example: 35
     121              :  *  @param _delay_report delay report capability
     122              :  */
     123              : #define BT_A2DP_SBC_SOURCE_EP(_name, _freq, _ch_mode, _blk_len, _subband, _alloc_mthd,             \
     124            1 :                               _min_bitpool, _max_bitpool, _delay_report)                           \
     125              :         static struct bt_a2dp_codec_ie bt_a2dp_ep_cap_ie##_name = {                                \
     126              :                 .len = BT_A2DP_SBC_IE_LENGTH,                                                      \
     127              :                 .codec_ie = {_freq | _ch_mode, _blk_len | _subband | _alloc_mthd, _min_bitpool,    \
     128              :                              _max_bitpool}};                                                       \
     129              :         static struct bt_a2dp_ep _name =                                                           \
     130              :                 BT_A2DP_SOURCE_EP_INIT(BT_A2DP_SBC, &bt_a2dp_ep_cap_ie##_name, _delay_report)
     131              : 
     132              : /** @brief define the default SBC sink endpoint that can be used as
     133              :  * bt_a2dp_register_endpoint's parameter.
     134              :  *
     135              :  * SBC is mandatory as a2dp specification, BT_A2DP_SBC_SINK_EP_DEFAULT
     136              :  * is more convenient for user to register SBC endpoint.
     137              :  *
     138              :  *  @param _name the endpoint variable name.
     139              :  */
     140            1 : #define BT_A2DP_SBC_SINK_EP_DEFAULT(_name)                                                         \
     141              :         static struct bt_a2dp_codec_ie bt_a2dp_ep_cap_ie##_name = {                                \
     142              :                 .len = BT_A2DP_SBC_IE_LENGTH,                                                      \
     143              :                 .codec_ie = {A2DP_SBC_SAMP_FREQ_44100 | A2DP_SBC_SAMP_FREQ_48000 |                 \
     144              :                                      A2DP_SBC_CH_MODE_MONO | A2DP_SBC_CH_MODE_STEREO |             \
     145              :                                      A2DP_SBC_CH_MODE_JOINT,                                       \
     146              :                              A2DP_SBC_BLK_LEN_16 | A2DP_SBC_SUBBAND_8 |                            \
     147              :                                      A2DP_SBC_ALLOC_MTHD_LOUDNESS,                                 \
     148              :                              18U, 35U}};                                                           \
     149              :         static struct bt_a2dp_ep _name =                                                           \
     150              :                 BT_A2DP_SINK_EP_INIT(BT_A2DP_SBC, &bt_a2dp_ep_cap_ie##_name, true)
     151              : 
     152              : /** @brief define the default SBC source endpoint that can be used as bt_a2dp_register_endpoint's
     153              :  * parameter.
     154              :  *
     155              :  * SBC is mandatory as a2dp specification, BT_A2DP_SBC_SOURCE_EP_DEFAULT
     156              :  * is more convenient for user to register SBC endpoint.
     157              :  *
     158              :  *  @param _name the endpoint variable name.
     159              :  */
     160            1 : #define BT_A2DP_SBC_SOURCE_EP_DEFAULT(_name)                                                       \
     161              :         static struct bt_a2dp_codec_ie bt_a2dp_ep_cap_ie##_name = {                                \
     162              :                 .len = BT_A2DP_SBC_IE_LENGTH,                                                      \
     163              :                 .codec_ie = {A2DP_SBC_SAMP_FREQ_44100 | A2DP_SBC_SAMP_FREQ_48000 |                 \
     164              :                                      A2DP_SBC_CH_MODE_MONO | A2DP_SBC_CH_MODE_STEREO |             \
     165              :                                      A2DP_SBC_CH_MODE_JOINT,                                       \
     166              :                              A2DP_SBC_BLK_LEN_16 | A2DP_SBC_SUBBAND_8 |                            \
     167              :                                      A2DP_SBC_ALLOC_MTHD_LOUDNESS,                                 \
     168              :                              18U, 35U},                                                            \
     169              :         };                                                                                         \
     170              :         static struct bt_a2dp_ep _name =                                                           \
     171              :                 BT_A2DP_SOURCE_EP_INIT(BT_A2DP_SBC, &bt_a2dp_ep_cap_ie##_name, false)
     172              : 
     173              : /** @brief define the SBC default configuration.
     174              :  *
     175              :  *  @param _name unique structure name postfix.
     176              :  *  @param _freq_cfg sbc codec frequency.
     177              :  *               for example: A2DP_SBC_SAMP_FREQ_44100
     178              :  *  @param _ch_mode_cfg sbc codec channel mode.
     179              :  *               for example: A2DP_SBC_CH_MODE_JOINT
     180              :  *  @param _blk_len_cfg sbc codec block length.
     181              :  *               for example: A2DP_SBC_BLK_LEN_16
     182              :  *  @param _subband_cfg sbc codec subband.
     183              :  *               for example: A2DP_SBC_SUBBAND_8
     184              :  *  @param _alloc_mthd_cfg sbc codec allocate method.
     185              :  *               for example: A2DP_SBC_ALLOC_MTHD_LOUDNESS
     186              :  *  @param _min_bitpool_cfg sbc codec min bit pool. for example: 18
     187              :  *  @param _max_bitpool_cfg sbc codec max bit pool. for example: 35
     188              :  */
     189              : #define BT_A2DP_SBC_EP_CFG(_name, _freq_cfg, _ch_mode_cfg, _blk_len_cfg, _subband_cfg,             \
     190            1 :                            _alloc_mthd_cfg, _min_bitpool_cfg, _max_bitpool_cfg)                    \
     191              :         static struct bt_a2dp_codec_ie bt_a2dp_codec_ie##_name = {                                 \
     192              :                 .len = BT_A2DP_SBC_IE_LENGTH,                                                      \
     193              :                 .codec_ie = {_freq_cfg | _ch_mode_cfg,                                             \
     194              :                              _blk_len_cfg | _subband_cfg | _alloc_mthd_cfg, _min_bitpool_cfg,      \
     195              :                              _max_bitpool_cfg},                                                    \
     196              :         };                                                                                         \
     197              :         struct bt_a2dp_codec_cfg _name = {                                                         \
     198              :                 .codec_config = &bt_a2dp_codec_ie##_name,                                          \
     199              :         }
     200              : 
     201              : /** @brief define the SBC default configuration.
     202              :  *
     203              :  *  @param _name unique structure name postfix.
     204              :  *  @param _freq_cfg the frequency to configure the remote same codec type endpoint.
     205              :  */
     206            1 : #define BT_A2DP_SBC_EP_CFG_DEFAULT(_name, _freq_cfg)                                               \
     207              :         static struct bt_a2dp_codec_ie bt_a2dp_codec_ie##_name = {                                 \
     208              :                 .len = BT_A2DP_SBC_IE_LENGTH,                                                      \
     209              :                 .codec_ie = {_freq_cfg | A2DP_SBC_CH_MODE_JOINT,                                   \
     210              :                              A2DP_SBC_BLK_LEN_16 | A2DP_SBC_SUBBAND_8 |                            \
     211              :                                      A2DP_SBC_ALLOC_MTHD_LOUDNESS,                                 \
     212              :                              18U, 35U},                                                            \
     213              :         };                                                                                         \
     214              :         struct bt_a2dp_codec_cfg _name = {                                                         \
     215              :                 .codec_config = &bt_a2dp_codec_ie##_name,                                          \
     216              :         }
     217              : 
     218              : /**
     219              :  * @brief A2DP error code
     220              :  */
     221            1 : enum bt_a2dp_err_code {
     222              :         /** Media Codec Type is not valid */
     223              :         BT_A2DP_INVALID_CODEC_TYPE = 0xC1,
     224              :         /** Media Codec Type is not supported */
     225              :         BT_A2DP_NOT_SUPPORTED_CODEC_TYPE = 0xC2,
     226              :         /** Sampling Frequency is not valid or multiple values have been selected */
     227              :         BT_A2DP_INVALID_SAMPLING_FREQUENCY = 0xC3,
     228              :         /** Sampling Frequency is not supported */
     229              :         BT_A2DP_NOT_SUPPORTED_SAMPLING_FREQUENCY = 0xC4,
     230              :         /** Channel Mode is not valid or multiple values have been selected */
     231              :         BT_A2DP_INVALID_CHANNEL_MODE = 0xC5,
     232              :         /** Channel Mode is not supported */
     233              :         BT_A2DP_NOT_SUPPORTED_CHANNEL_MODE = 0xC6,
     234              :         /** None or multiple values have been selected for Number of Subbands */
     235              :         BT_A2DP_INVALID_SUBBANDS = 0xC7,
     236              :         /** Number of Subbands is not supported */
     237              :         BT_A2DP_NOT_SUPPORTED_SUBBANDS = 0xC8,
     238              :         /** None or multiple values have been selected for Allocation Method */
     239              :         BT_A2DP_INVALID_ALLOCATION_METHOD = 0xC9,
     240              :         /** Allocation Method is not supported */
     241              :         BT_A2DP_NOT_SUPPORTED_ALLOCATION_METHOD = 0xCA,
     242              :         /** Minimum Bitpool Value is not valid */
     243              :         BT_A2DP_INVALID_MINIMUM_BITPOOL_VALUE = 0xCB,
     244              :         /** Minimum Bitpool Value is not supported */
     245              :         BT_A2DP_NOT_SUPPORTED_MINIMUM_BITPOOL_VALUE = 0xCC,
     246              :         /** Maximum Bitpool Value is not valid */
     247              :         BT_A2DP_INVALID_MAXIMUM_BITPOOL_VALUE = 0xCD,
     248              :         /** Maximum Bitpool Value is not supported */
     249              :         BT_A2DP_NOT_SUPPORTED_MAXIMUM_BITPOOL_VALUE = 0xCE,
     250              :         /** None or multiple values have been selected for Layer */
     251              :         BT_A2DP_INVALID_LAYER = 0xCF,
     252              :         /** Layer is not supported */
     253              :         BT_A2DP_NOT_SUPPORTED_LAYER = 0xD0,
     254              :         /** CRC is not supported */
     255              :         BT_A2DP_NOT_SUPPORTED_CRC = 0xD1,
     256              :         /** MPF-2 is not supported */
     257              :         BT_A2DP_NOT_SUPPORTED_MPF = 0xD2,
     258              :         /** VBR is not supported */
     259              :         BT_A2DP_NOT_SUPPORTED_VBR = 0xD3,
     260              :         /** None or multiple values have been selected for Bit Rate */
     261              :         BT_A2DP_INVALID_BIT_RATE = 0xD4,
     262              :         /** Bit Rate is not supported */
     263              :         BT_A2DP_NOT_SUPPORTED_BIT_RATE = 0xD5,
     264              :         /** Either 1) Object type is not valid or
     265              :          * 2) None or multiple values have been selected for Object Type
     266              :          */
     267              :         BT_A2DP_INVALID_OBJECT_TYPE = 0xD6,
     268              :         /** Object Type is not supported */
     269              :         BT_A2DP_NOT_SUPPORTED_OBJECT_TYPE = 0xD7,
     270              :         /** Either 1) Channels is not valid or
     271              :          * 2) None or multiple values have been selected for Channels
     272              :          */
     273              :         BT_A2DP_INVALID_CHANNELS = 0xD8,
     274              :         /** Channels is not supported */
     275              :         BT_A2DP_NOT_SUPPORTED_CHANNELS = 0xD9,
     276              :         /** Version is not valid */
     277              :         BT_A2DP_INVALID_VERSION = 0xDA,
     278              :         /** Version is not supported */
     279              :         BT_A2DP_NOT_SUPPORTED_VERSION = 0xDB,
     280              :         /** Maximum SUL is not acceptable for the Decoder in the SNK */
     281              :         BT_A2DP_NOT_SUPPORTED_MAXIMUM_SUL = 0xDC,
     282              :         /** None or multiple values have been selected for Block Length */
     283              :         BT_A2DP_INVALID_BLOCK_LENGTH = 0xDD,
     284              :         /** The requested CP Type is not supported */
     285              :         BT_A2DP_INVALID_CP_TYPE = 0xE0,
     286              :         /** The format of Content Protection Service Capability/Content
     287              :          * Protection Scheme Dependent Data is not correct
     288              :          */
     289              :         BT_A2DP_INVALID_CP_FORMAT = 0xE1,
     290              :         /** The codec parameter is invalid.
     291              :          * Used if a more specific error code does not exist for the codec in use
     292              :          */
     293              :         BT_A2DP_INVALID_CODEC_PARAMETER = 0xE2,
     294              :         /** The codec parameter is not supported.
     295              :          * Used if a more specific error code does not exist for the codec in use
     296              :          */
     297              :         BT_A2DP_NOT_SUPPORTED_CODEC_PARAMETER = 0xE3,
     298              :         /** Combination of Object Type and DRC is invalid */
     299              :         BT_A2DP_INVALID_DRC = 0xE4,
     300              :         /** DRC is not supported */
     301              :         BT_A2DP_NOT_SUPPORTED_DRC = 0xE5,
     302              : };
     303              : 
     304              : /** @brief Codec Type */
     305            1 : enum bt_a2dp_codec_type {
     306              :         /** Codec SBC */
     307              :         BT_A2DP_SBC = 0x00,
     308              :         /** Codec MPEG-1 */
     309              :         BT_A2DP_MPEG1 = 0x01,
     310              :         /** Codec MPEG-2 */
     311              :         BT_A2DP_MPEG2 = 0x02,
     312              :         /** Codec MPEG-D */
     313              :         BT_A2DP_MPEGD = 0x03,
     314              :         /** Codec ATRAC */
     315              :         BT_A2DP_ATRAC = 0x04,
     316              :         /** Codec Non-A2DP */
     317              :         BT_A2DP_VENDOR = 0xff
     318              : };
     319              : 
     320              : /** @brief A2DP structure */
     321              : struct bt_a2dp;
     322              : 
     323              : /* Internal to pass build */
     324              : struct bt_a2dp_stream;
     325              : 
     326              : /** @brief codec information elements for the endpoint */
     327            1 : struct bt_a2dp_codec_ie {
     328              :         /** Length of codec_cap */
     329            1 :         uint8_t len;
     330              :         /** codec information element */
     331            1 :         uint8_t codec_ie[BT_A2DP_MAX_IE_LENGTH];
     332              : };
     333              : 
     334              : /** @brief The endpoint configuration */
     335            1 : struct bt_a2dp_codec_cfg {
     336              :         /** the delay reporting configured state */
     337            1 :         bool delay_report;
     338              :         /** The media codec configuration content */
     339            1 :         struct bt_a2dp_codec_ie *codec_config;
     340              : };
     341              : 
     342              : /** @brief Stream End Point */
     343            1 : struct bt_a2dp_ep {
     344              :         /** Code Type @ref bt_a2dp_codec_type */
     345            1 :         uint8_t codec_type;
     346              :         /** Whether the endpoint has delay reporting service */
     347            1 :         bool delay_report;
     348              :         /** Capabilities */
     349            1 :         struct bt_a2dp_codec_ie *codec_cap;
     350              :         /** AVDTP Stream End Point Identifier */
     351            1 :         struct bt_avdtp_sep sep;
     352              :         /* Internally used stream object pointer */
     353            0 :         struct bt_a2dp_stream *stream;
     354              : };
     355              : 
     356            0 : struct bt_a2dp_ep_info {
     357              :         /** Code Type @ref bt_a2dp_codec_type */
     358            1 :         uint8_t codec_type;
     359              :         /** Whether the endpoint has delay reporting service */
     360            1 :         bool delay_report;
     361              :         /** Codec capabilities, if SBC, use function of a2dp_codec_sbc.h to parse it */
     362            1 :         struct bt_a2dp_codec_ie codec_cap;
     363              :         /** Stream End Point Information */
     364            1 :         struct bt_avdtp_sep_info *sep_info;
     365              : };
     366              : 
     367              : /** @brief Helper enum to be used as return value of bt_a2dp_discover_ep_cb.
     368              :  *  The value informs the caller to perform further pending actions or stop them.
     369              :  */
     370            0 : enum {
     371              :         BT_A2DP_DISCOVER_EP_STOP = 0,
     372              :         BT_A2DP_DISCOVER_EP_CONTINUE,
     373              : };
     374              : 
     375              : /** @typedef bt_a2dp_discover_ep_cb
     376              :  *
     377              :  *  @brief Called when a stream endpoint is discovered.
     378              :  *
     379              :  *  A function of this type is given by the user to the bt_a2dp_discover_param
     380              :  *  object. It'll be called on each valid stream endpoint discovery completion.
     381              :  *  When no more endpoint then NULL is passed to the user. Otherwise user can get
     382              :  *  valid endpoint information from parameter info, user can set parameter ep to
     383              :  *  get the endpoint after the callback is return.
     384              :  *  The returned function value allows the user to control retrieving follow-up
     385              :  *  endpoints if any. If the user doesn't want to read more endpoints since
     386              :  *  current found endpoints fulfill its requirements then should return
     387              :  *  BT_A2DP_DISCOVER_EP_STOP. Otherwise returned value means
     388              :  *  more subcall iterations are allowable.
     389              :  *
     390              :  *  @param a2dp a2dp connection object identifying a2dp connection to queried remote.
     391              :  *  @param info Object pointing to the information of the callbacked endpoint.
     392              :  *  @param ep If the user want to use this found endpoint, user can set value to it
     393              :  *  to get the endpoint that can be used further in other A2DP APIs. It is NULL if info
     394              :  *  is NULL (no more endpoint is found).
     395              :  *
     396              :  *  @return BT_A2DP_DISCOVER_EP_STOP in case of no more need to continue discovery
     397              :  *  for next endpoint. By returning BT_A2DP_DISCOVER_EP_STOP user allows this
     398              :  *  discovery continuation.
     399              :  */
     400            1 : typedef uint8_t (*bt_a2dp_discover_ep_cb)(struct bt_a2dp *a2dp, struct bt_a2dp_ep_info *info,
     401              :                                           struct bt_a2dp_ep **ep);
     402              : 
     403            0 : struct bt_a2dp_discover_param {
     404              :         /** discover callback */
     405            1 :         bt_a2dp_discover_ep_cb cb;
     406              :         /** The discovered endpoint info that is callbacked by cb */
     407            1 :         struct bt_a2dp_ep_info info;
     408              :         /** The max count of remote endpoints that can be got,
     409              :          *  it save endpoint info internally.
     410              :          */
     411            1 :         struct bt_avdtp_sep_info *seps_info;
     412              :         /** The AVDTP version of the peer's A2DP sdp service.
     413              :          *  Stack uses it to determine using get_all_cap or get_cap cmd. When both
     414              :          *  versions are v1.3 or bigger version, get_all_cap is used, otherwise
     415              :          *  get_cap is used.
     416              :          *  It is the same value of the avdtp sepcificaiton's version value.
     417              :          *  For example: 0x0103 means version 1.3
     418              :          *  If the value is 0 (unknown), stack process it as less than v1.3
     419              :          */
     420            1 :         uint16_t avdtp_version;
     421              :         /** The max count of seps (stream endpoint) that can be got in this call route */
     422            1 :         uint8_t sep_count;
     423              : };
     424              : 
     425              : /** @brief The connecting callback */
     426            1 : struct bt_a2dp_cb {
     427              :         /** @brief A a2dp connection has been established.
     428              :          *
     429              :          *  This callback notifies the application of a a2dp connection.
     430              :          *  It means the AVDTP L2CAP connection.
     431              :          *  In case the err parameter is non-zero it means that the
     432              :          *  connection establishment failed.
     433              :          *
     434              :          *  @param a2dp a2dp connection object.
     435              :          *  @param err error code.
     436              :          */
     437            1 :         void (*connected)(struct bt_a2dp *a2dp, int err);
     438              :         /** @brief A a2dp connection has been disconnected.
     439              :          *
     440              :          *  This callback notifies the application that a a2dp connection
     441              :          *  has been disconnected.
     442              :          *
     443              :          *  @param a2dp a2dp connection object.
     444              :          */
     445            1 :         void (*disconnected)(struct bt_a2dp *a2dp);
     446              :         /**
     447              :          * @brief Endpoint config request callback
     448              :          *
     449              :          * The callback is called whenever an endpoint is requested to be
     450              :          * configured.
     451              :          *
     452              :          *  @param a2dp a2dp connection object.
     453              :          *  @param[in]  ep        Local Audio Endpoint being configured.
     454              :          *  @param[in]  codec_cfg Codec configuration.
     455              :          *  @param[out] stream    Pointer to stream that will be configured for the endpoint.
     456              :          *  @param[out] rsp_err_code  give the error code if response error.
     457              :          *                          bt_a2dp_err_code or bt_avdtp_err_code
     458              :          *
     459              :          * @return 0 in case of success or negative value in case of error.
     460              :          */
     461            1 :         int (*config_req)(struct bt_a2dp *a2dp, struct bt_a2dp_ep *ep,
     462              :                           struct bt_a2dp_codec_cfg *codec_cfg, struct bt_a2dp_stream **stream,
     463              :                           uint8_t *rsp_err_code);
     464              :         /**
     465              :          * @brief Endpoint config request callback
     466              :          *
     467              :          * The callback is called whenever an endpoint is requested to be
     468              :          * reconfigured.
     469              :          *
     470              :          *  @param[in] stream    Pointer to stream object.
     471              :          *  @param[out] rsp_err_code  give the error code if response error.
     472              :          *                          bt_a2dp_err_code or bt_avdtp_err_code
     473              :          *
     474              :          * @return 0 in case of success or negative value in case of error.
     475              :          */
     476            1 :         int (*reconfig_req)(struct bt_a2dp_stream *stream, struct bt_a2dp_codec_cfg *codec_cfg,
     477              :                             uint8_t *rsp_err_code);
     478              :         /** @brief Callback function for bt_a2dp_stream_config() and bt_a2dp_stream_reconfig()
     479              :          *
     480              :          *  Called when the codec configure operation is completed.
     481              :          *
     482              :          *  @param[in] stream    Pointer to stream object.
     483              :          *  @param[in] rsp_err_code the remote responded error code
     484              :          *                          bt_a2dp_err_code or bt_avdtp_err_code
     485              :          */
     486            1 :         void (*config_rsp)(struct bt_a2dp_stream *stream, uint8_t rsp_err_code);
     487              :         /**
     488              :          * @brief Stream establishment request callback
     489              :          *
     490              :          * The callback is called whenever an stream is requested to be
     491              :          * established (open cmd and create the stream l2cap channel).
     492              :          *
     493              :          *  @param[in] stream    Pointer to stream object.
     494              :          *  @param[out] rsp_err_code  give the error code if response error.
     495              :          *                          bt_a2dp_err_code or bt_avdtp_err_code
     496              :          *
     497              :          * @return 0 in case of success or negative value in case of error.
     498              :          */
     499            1 :         int (*establish_req)(struct bt_a2dp_stream *stream, uint8_t *rsp_err_code);
     500              :         /** @brief Callback function for bt_a2dp_stream_establish()
     501              :          *
     502              :          *  Called when the establishment operation is completed.
     503              :          *  (open cmd and create the stream l2cap channel).
     504              :          *
     505              :          *  @param[in] stream    Pointer to stream object.
     506              :          *  @param[in] rsp_err_code the remote responded error code
     507              :          *                          bt_a2dp_err_code or bt_avdtp_err_code
     508              :          */
     509            1 :         void (*establish_rsp)(struct bt_a2dp_stream *stream, uint8_t rsp_err_code);
     510              :         /**
     511              :          * @brief Stream release request callback
     512              :          *
     513              :          * The callback is called whenever an stream is requested to be
     514              :          * released (release cmd and release the l2cap channel)
     515              :          *
     516              :          *  @param[in] stream    Pointer to stream object.
     517              :          *  @param[out] rsp_err_code  give the error code if response error.
     518              :          *                          bt_a2dp_err_code or bt_avdtp_err_code
     519              :          *
     520              :          * @return 0 in case of success or negative value in case of error.
     521              :          */
     522            1 :         int (*release_req)(struct bt_a2dp_stream *stream, uint8_t *rsp_err_code);
     523              :         /** @brief Callback function for bt_a2dp_stream_release()
     524              :          *
     525              :          *  Called when the release operation is completed.
     526              :          *  (release cmd and release the l2cap channel)
     527              :          *
     528              :          *  @param[in] stream    Pointer to stream object.
     529              :          *  @param[in] rsp_err_code the remote responded error code
     530              :          *                          bt_a2dp_err_code or bt_avdtp_err_code
     531              :          */
     532            1 :         void (*release_rsp)(struct bt_a2dp_stream *stream, uint8_t rsp_err_code);
     533              :         /**
     534              :          * @brief Stream start request callback
     535              :          *
     536              :          * The callback is called whenever an stream is requested to be
     537              :          * started.
     538              :          *
     539              :          *  @param[in] stream    Pointer to stream object.
     540              :          *  @param[out] rsp_err_code  give the error code if response error.
     541              :          *                          bt_a2dp_err_code or bt_avdtp_err_code
     542              :          *
     543              :          * @return 0 in case of success or negative value in case of error.
     544              :          */
     545            1 :         int (*start_req)(struct bt_a2dp_stream *stream, uint8_t *rsp_err_code);
     546              :         /** @brief Callback function for bt_a2dp_stream_start()
     547              :          *
     548              :          *  Called when the start operation is completed.
     549              :          *
     550              :          *  @param[in] stream    Pointer to stream object.
     551              :          *  @param[in] rsp_err_code the remote responded error code
     552              :          *                          bt_a2dp_err_code or bt_avdtp_err_code
     553              :          */
     554            1 :         void (*start_rsp)(struct bt_a2dp_stream *stream, uint8_t rsp_err_code);
     555              :         /**
     556              :          * @brief Stream suspend request callback
     557              :          *
     558              :          * The callback is called whenever an stream is requested to be
     559              :          * suspended.
     560              :          *
     561              :          *  @param[in] stream    Pointer to stream object.
     562              :          *  @param[out] rsp_err_code  give the error code if response error.
     563              :          *                          bt_a2dp_err_code or bt_avdtp_err_code
     564              :          *
     565              :          * @return 0 in case of success or negative value in case of error.
     566              :          */
     567            1 :         int (*suspend_req)(struct bt_a2dp_stream *stream, uint8_t *rsp_err_code);
     568              :         /** @brief Callback function for bt_a2dp_stream_suspend()
     569              :          *
     570              :          *  Called when the suspend operation is completed.
     571              :          *
     572              :          *  @param[in] stream    Pointer to stream object.
     573              :          *  @param[in] rsp_err_code the remote responded error code
     574              :          *                          bt_a2dp_err_code or bt_avdtp_err_code
     575              :          */
     576            1 :         void (*suspend_rsp)(struct bt_a2dp_stream *stream, uint8_t rsp_err_code);
     577              :         /**
     578              :          * @brief Stream abort request callback
     579              :          *
     580              :          * The callback is called whenever an stream is requested to be
     581              :          * aborted.
     582              :          *
     583              :          *  @param[in] stream    Pointer to stream object.
     584              :          *  @param[out] rsp_err_code  give the error code if response error.
     585              :          *                          bt_a2dp_err_code or bt_avdtp_err_code
     586              :          *
     587              :          * @return 0 in case of success or negative value in case of error.
     588              :          */
     589            1 :         int (*abort_req)(struct bt_a2dp_stream *stream, uint8_t *rsp_err_code);
     590              :         /** @brief Callback function for bt_a2dp_stream_abort()
     591              :          *
     592              :          *  Called when the abort operation is completed.
     593              :          *
     594              :          *  @param[in] stream    Pointer to stream object.
     595              :          *  @param[in] rsp_err_code the remote responded error code
     596              :          *                          bt_a2dp_err_code or bt_avdtp_err_code
     597              :          */
     598            1 :         void (*abort_rsp)(struct bt_a2dp_stream *stream, uint8_t rsp_err_code);
     599              :         /**
     600              :          * @brief Stream get config callback
     601              :          *
     602              :          * The callback is called whenever an stream is requested to response
     603              :          * configured configuration.
     604              :          *
     605              :          *  @param[in] stream    Pointer to stream object.
     606              :          *  @param[out] rsp_err_code  give the error code if response error.
     607              :          *                          bt_a2dp_err_code or bt_avdtp_err_code
     608              :          *
     609              :          * @return 0 in case of success or negative value in case of error.
     610              :          */
     611            1 :         int (*get_config_req)(struct bt_a2dp_stream *stream, uint8_t *rsp_err_code);
     612              :         /** @brief Callback function for bt_a2dp_stream_get_config()
     613              :          *
     614              :          *  Called when the get configuration operation is completed.
     615              :          *
     616              :          *  @param[in] stream    Pointer to stream object.
     617              :          *  @param[in] codec_cfg the codec configuration that is got
     618              :          *  @param[in] rsp_err_code the remote responded error code
     619              :          *                          bt_a2dp_err_code or bt_avdtp_err_code
     620              :          */
     621            1 :         void (*get_config_rsp)(struct bt_a2dp_stream *stream, struct bt_a2dp_codec_cfg *codec_cfg,
     622              :                                uint8_t rsp_err_code);
     623              : #ifdef CONFIG_BT_A2DP_SOURCE
     624              :         /**
     625              :          * @brief Stream delay report is received
     626              :          *
     627              :          * The callback is called whenever an stream's delay report is received.
     628              :          *
     629              :          *  @param[in] stream    Pointer to stream object.
     630              :          *  @param[in] value     The delay report value in 1/10 milliseconds.
     631              :          *  @param[out] rsp_err_code  give the error code if response error.
     632              :          *                          bt_a2dp_err_code or bt_avdtp_err_code
     633              :          *
     634              :          * @return 0 in case of success or negative value in case of error.
     635              :          */
     636              :         int (*delay_report_req)(struct bt_a2dp_stream *stream, uint16_t value,
     637              :                                 uint8_t *rsp_err_code);
     638              : #endif
     639              : #ifdef CONFIG_BT_A2DP_SINK
     640              :         /** @brief Callback function for bt_a2dp_stream_delay_report()
     641              :          *
     642              :          *  Called when the delay report sending is completed.
     643              :          *
     644              :          *  @param[in] stream    Pointer to stream object.
     645              :          *  @param[in] rsp_err_code the remote responded error code
     646              :          *                          bt_a2dp_err_code or bt_avdtp_err_code
     647              :          */
     648              :         void (*delay_report_rsp)(struct bt_a2dp_stream *stream, uint8_t rsp_err_code);
     649              : #endif
     650              : };
     651              : 
     652              : /** @brief A2DP Connect.
     653              :  *
     654              :  *  This function is to be called after the conn parameter is obtained by
     655              :  *  performing a GAP procedure. The API is to be used to establish A2DP
     656              :  *  connection between devices.
     657              :  *  This function only establish AVDTP L2CAP Signaling connection.
     658              :  *  After connection success, the callback that is registered by
     659              :  *  bt_a2dp_register_connect_callback is called.
     660              :  *
     661              :  *  @param conn Pointer to bt_conn structure.
     662              :  *
     663              :  *  @return pointer to struct bt_a2dp in case of success or NULL in case
     664              :  *  of error.
     665              :  */
     666            1 : struct bt_a2dp *bt_a2dp_connect(struct bt_conn *conn);
     667              : 
     668              : /** @brief disconnect l2cap a2dp
     669              :  *
     670              :  * This function close AVDTP L2CAP Signaling connection.
     671              :  * It closes the AVDTP L2CAP Media connection too if it is established.
     672              :  *
     673              :  *  @param a2dp The a2dp instance.
     674              :  *
     675              :  *  @return 0 in case of success and error code in case of error.
     676              :  */
     677            1 : int bt_a2dp_disconnect(struct bt_a2dp *a2dp);
     678              : 
     679              : /** @brief Endpoint Registration.
     680              :  *
     681              :  *  @param ep Pointer to bt_a2dp_ep structure.
     682              :  *  @param media_type Media type that the Endpoint is, #bt_avdtp_media_type.
     683              :  *  @param sep_type Stream endpoint type, #bt_avdtp_sep_type.
     684              :  *
     685              :  *  @return 0 in case of success and error code in case of error.
     686              :  */
     687            1 : int bt_a2dp_register_ep(struct bt_a2dp_ep *ep, uint8_t media_type, uint8_t sep_type);
     688              : 
     689              : /** @brief register callback.
     690              :  *
     691              :  *  The cb is called when bt_a2dp_connect is called or it is operated by remote device.
     692              :  *
     693              :  *  @param cb The callback function.
     694              :  *
     695              :  *  @return 0 in case of success and error code in case of error.
     696              :  */
     697            1 : int bt_a2dp_register_cb(struct bt_a2dp_cb *cb);
     698              : 
     699              : /** @brief Obtain the ACL connection corresponding to A2DP.
     700              :  *
     701              :  *  @param a2dp The A2DP instance.
     702              :  *
     703              :  *  @return Connection object associated with the A2DP context. The caller gets a new
     704              :  *  reference to the connection object which must be released with bt_conn_unref()
     705              :  *  once done using the object.
     706              :  */
     707            1 : struct bt_conn *bt_a2dp_get_conn(struct bt_a2dp *a2dp);
     708              : 
     709              : /** @brief Discover remote endpoints.
     710              :  *
     711              :  *  @param a2dp The a2dp instance.
     712              :  *  @param param the discover used param.
     713              :  *
     714              :  *  @return 0 in case of success and error code in case of error.
     715              :  */
     716            1 : int bt_a2dp_discover(struct bt_a2dp *a2dp, struct bt_a2dp_discover_param *param);
     717              : 
     718              : /** @brief A2DP Stream */
     719            1 : struct bt_a2dp_stream {
     720              :         /** local endpoint */
     721            1 :         struct bt_a2dp_ep *local_ep;
     722              :         /** remote endpoint */
     723            1 :         struct bt_a2dp_ep *remote_ep;
     724              :         /** remote endpoint's Stream End Point ID */
     725            1 :         uint8_t remote_ep_id;
     726              :         /** whether the delay report is configured on the stream */
     727            1 :         bool delay_report;
     728              :         /** Audio stream operations */
     729            1 :         struct bt_a2dp_stream_ops *ops;
     730              :         /** the a2dp connection */
     731            1 :         struct bt_a2dp *a2dp;
     732              :         /** the stream current configuration */
     733            1 :         struct bt_a2dp_codec_ie codec_config;
     734              : };
     735              : 
     736              : /** @brief The stream endpoint related operations */
     737            1 : struct bt_a2dp_stream_ops {
     738              :         /**
     739              :          * @brief Stream configured callback
     740              :          *
     741              :          * The callback is called whenever an Audio Stream has been configured or reconfigured.
     742              :          *
     743              :          * @param stream Stream object that has been configured.
     744              :          */
     745            1 :         void (*configured)(struct bt_a2dp_stream *stream);
     746              :         /**
     747              :          * @brief Stream establishment callback
     748              :          *
     749              :          * The callback is called whenever an Audio Stream has been established.
     750              :          *
     751              :          * @param stream Stream object that has been established.
     752              :          */
     753            1 :         void (*established)(struct bt_a2dp_stream *stream);
     754              :         /**
     755              :          * @brief Stream release callback
     756              :          *
     757              :          * The release procedure (bt_a2dp_stream_release, release_req, release_rsp and
     758              :          * disconnect l2cap media channel), the abort procedure (bt_a2dp_stream_abort, abort_req,
     759              :          * abort_rsp and disconnect l2cap media channel) and the error procedure (for example,
     760              :          * the l2cap channel disconnected unexpectedly) will cause the stream to be released.
     761              :          * The callback is called whenever an Audio Stream has been released.
     762              :          * After released, the stream becomes invalid to control.
     763              :          *
     764              :          * @param stream Stream object that has been released.
     765              :          */
     766            1 :         void (*released)(struct bt_a2dp_stream *stream);
     767              :         /**
     768              :          * @brief Stream start callback
     769              :          *
     770              :          * The callback is called whenever an Audio Stream has been started.
     771              :          *
     772              :          * @param stream Stream object that has been started.
     773              :          */
     774            1 :         void (*started)(struct bt_a2dp_stream *stream);
     775              :         /**
     776              :          * @brief Stream suspend callback
     777              :          *
     778              :          * The callback is called whenever an Audio Stream has been suspended.
     779              :          *
     780              :          * @param stream Stream object that has been suspended.
     781              :          */
     782            1 :         void (*suspended)(struct bt_a2dp_stream *stream);
     783              : #if defined(CONFIG_BT_A2DP_SINK)
     784              :         /** @brief the media streaming data, only for sink
     785              :          *
     786              :          *  @param buf the data buf
     787              :          *  @param seq_num the sequence number
     788              :          *  @param ts the time stamp
     789              :          */
     790              :         void (*recv)(struct bt_a2dp_stream *stream, struct net_buf *buf, uint16_t seq_num,
     791              :                      uint32_t ts);
     792              : #endif
     793              : #if defined(CONFIG_BT_A2DP_SOURCE)
     794              :         /**
     795              :          * @brief Stream audio HCI sent callback
     796              :          *
     797              :          * This callback will be called once the controller marks the SDU
     798              :          * as completed. When the controller does so is implementation
     799              :          * dependent. It could be after the SDU is enqueued for transmission,
     800              :          * or after it is sent on air or flushed.
     801              :          *
     802              :          * This callback is only used if the ISO data path is HCI.
     803              :          *
     804              :          * @param stream Stream object.
     805              :          */
     806              :         void (*sent)(struct bt_a2dp_stream *stream);
     807              :         /**
     808              :          * @brief The delay report value is received
     809              :          *
     810              :          * This callback will be called once delay report is replied with accept
     811              :          * (If `delay_report_req` is not set or `delay_report_req` reply success).
     812              :          *
     813              :          * @param stream Stream object.
     814              :          * @param value The delay report value in 1/10 milliseconds.
     815              :          */
     816              :         void (*delay_report)(struct bt_a2dp_stream *stream, uint16_t value);
     817              : #endif
     818              : };
     819              : 
     820              : /**
     821              :  * @brief Register Audio callbacks for a stream.
     822              :  *
     823              :  * Register Audio callbacks for a stream.
     824              :  *
     825              :  * @param stream Stream object.
     826              :  * @param ops    Stream operations structure.
     827              :  */
     828            1 : void bt_a2dp_stream_cb_register(struct bt_a2dp_stream *stream, struct bt_a2dp_stream_ops *ops);
     829              : 
     830              : /** @brief configure endpoint.
     831              :  *
     832              :  *  bt_a2dp_discover can be used to find remote's endpoints.
     833              :  *  This function to configure the selected endpoint that is found by
     834              :  *  bt_a2dp_discover.
     835              :  *  This function sends AVDTP_SET_CONFIGURATION.
     836              :  *
     837              :  *  @param a2dp The a2dp instance.
     838              :  *  @param stream Stream object.
     839              :  *  @param local_ep The configured endpoint that is registered.
     840              :  *  @param remote_ep The remote endpoint.
     841              :  *  @param config The config to configure the endpoint.
     842              :  *
     843              :  *  @return 0 in case of success and error code in case of error.
     844              :  */
     845            1 : int bt_a2dp_stream_config(struct bt_a2dp *a2dp, struct bt_a2dp_stream *stream,
     846              :                           struct bt_a2dp_ep *local_ep, struct bt_a2dp_ep *remote_ep,
     847              :                           struct bt_a2dp_codec_cfg *config);
     848              : 
     849              : /** @brief get config of the stream
     850              :  *
     851              :  * This function sends the AVDTP_GET_CONFIGURATION command.
     852              :  *
     853              :  *  @param stream The stream object.
     854              :  *
     855              :  *  @return 0 in case of success and error code in case of error.
     856              :  */
     857            1 : int bt_a2dp_stream_get_config(struct bt_a2dp_stream *stream);
     858              : 
     859              : /** @brief establish a2dp streamer.
     860              :  *
     861              :  * This function sends the AVDTP_OPEN command and create the l2cap channel.
     862              :  *
     863              :  *  @param stream The stream object.
     864              :  *
     865              :  *  @return 0 in case of success and error code in case of error.
     866              :  */
     867            1 : int bt_a2dp_stream_establish(struct bt_a2dp_stream *stream);
     868              : 
     869              : /** @brief release a2dp streamer.
     870              :  *
     871              :  * This function sends the AVDTP_CLOSE command and release the l2cap channel.
     872              :  * After release, the stream becomes invalid.
     873              :  *
     874              :  *  @param stream The stream object.
     875              :  *
     876              :  *  @return 0 in case of success and error code in case of error.
     877              :  */
     878            1 : int bt_a2dp_stream_release(struct bt_a2dp_stream *stream);
     879              : 
     880              : /** @brief start a2dp streamer.
     881              :  *
     882              :  * This function sends the AVDTP_START command.
     883              :  *
     884              :  *  @param stream The stream object.
     885              :  *
     886              :  *  @return 0 in case of success and error code in case of error.
     887              :  */
     888            1 : int bt_a2dp_stream_start(struct bt_a2dp_stream *stream);
     889              : 
     890              : /** @brief suspend a2dp streamer.
     891              :  *
     892              :  * This function sends the AVDTP_SUSPEND command.
     893              :  *
     894              :  *  @param stream The stream object.
     895              :  *
     896              :  *  @return 0 in case of success and error code in case of error.
     897              :  */
     898            1 : int bt_a2dp_stream_suspend(struct bt_a2dp_stream *stream);
     899              : 
     900              : /** @brief re-configure a2dp streamer
     901              :  *
     902              :  * This function sends the AVDTP_RECONFIGURE command.
     903              :  *
     904              :  *  @param stream The stream object.
     905              :  *  @param config The config to configure the stream.
     906              :  *
     907              :  *  @return 0 in case of success and error code in case of error.
     908              :  */
     909            1 : int bt_a2dp_stream_reconfig(struct bt_a2dp_stream *stream, struct bt_a2dp_codec_cfg *config);
     910              : 
     911              : /** @brief abort a2dp streamer.
     912              :  *
     913              :  * This function sends the AVDTP_ABORT command.
     914              :  * After abort, the stream becomes invalid.
     915              :  *
     916              :  *  @param stream The stream object.
     917              :  *
     918              :  *  @return 0 in case of success and error code in case of error.
     919              :  */
     920            1 : int bt_a2dp_stream_abort(struct bt_a2dp_stream *stream);
     921              : 
     922              : /** @brief get the stream l2cap mtu
     923              :  *
     924              :  *  @param stream The stream object.
     925              :  *
     926              :  *  @return mtu value
     927              :  */
     928            1 : uint32_t bt_a2dp_get_mtu(struct bt_a2dp_stream *stream);
     929              : 
     930              : /** @brief send a2dp media data
     931              :  *
     932              :  * Only A2DP source side can call this function.
     933              :  *
     934              :  *  @param stream The stream object.
     935              :  *  @param buf  The data.
     936              :  *  @param seq_num The sequence number.
     937              :  *  @param ts The time stamp.
     938              :  *
     939              :  *  @return 0 in case of success and error code in case of error.
     940              :  */
     941            1 : int bt_a2dp_stream_send(struct bt_a2dp_stream *stream, struct net_buf *buf, uint16_t seq_num,
     942              :                         uint32_t ts);
     943              : 
     944              : /**
     945              :  * @brief Allocate a net_buf for bt_a2dp_stream_send
     946              :  *
     947              :  * This function allocates a buffer from the specified pool, reserves
     948              :  * sufficient headroom for protocol headers required by L2CAP over Bluetooth, fills
     949              :  * the AVDTP header.
     950              :  *
     951              :  * @param pool    The buffer pool to allocate from.
     952              :  * @param timeout Non-negative waiting period to obtain a buffer or one of
     953              :  *                the special values K_NO_WAIT and K_FOREVER.
     954              :  *
     955              :  * @return A newly allocated net_buf.
     956              :  */
     957            1 : struct net_buf *bt_a2dp_stream_create_pdu(struct net_buf_pool *pool, k_timeout_t timeout);
     958              : 
     959              : /** @brief send delay report
     960              :  *
     961              :  * Only A2DP sink side can call this function.
     962              :  *
     963              :  *  @param stream The stream object.
     964              :  *  @param delay Value in 1/10 milliseconds.
     965              :  *
     966              :  *  @return 0 in case of success and error code in case of error.
     967              :  */
     968            1 : int bt_a2dp_stream_delay_report(struct bt_a2dp_stream *stream, uint16_t delay);
     969              : 
     970              : #ifdef __cplusplus
     971              : }
     972              : #endif
     973              : 
     974              : /**
     975              :  * @}
     976              :  */
     977              : 
     978              : #endif /* ZEPHYR_INCLUDE_BLUETOOTH_A2DP_H_ */
        

Generated by: LCOV version 2.0-1