119e95205Sopenharmony_ci/*
219e95205Sopenharmony_ci * Copyright (C) 2021 Huawei Device Co., Ltd.
319e95205Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
419e95205Sopenharmony_ci * you may not use this file except in compliance with the License.
519e95205Sopenharmony_ci * You may obtain a copy of the License at
619e95205Sopenharmony_ci *
719e95205Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
819e95205Sopenharmony_ci *
919e95205Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
1019e95205Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
1119e95205Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1219e95205Sopenharmony_ci * See the License for the specific language governing permissions and
1319e95205Sopenharmony_ci * limitations under the License.
1419e95205Sopenharmony_ci */
1519e95205Sopenharmony_ci/**
1619e95205Sopenharmony_ci * @addtogroup Bluetooth
1719e95205Sopenharmony_ci * @{
1819e95205Sopenharmony_ci *
1919e95205Sopenharmony_ci * @brief This file is a part of BTStack.
2019e95205Sopenharmony_ci * @since 6.0
2119e95205Sopenharmony_ci */
2219e95205Sopenharmony_ci
2319e95205Sopenharmony_ci/**
2419e95205Sopenharmony_ci * @file avdtp.h
2519e95205Sopenharmony_ci *
2619e95205Sopenharmony_ci * @brief AVDT protocol Interface.
2719e95205Sopenharmony_ci *
2819e95205Sopenharmony_ci * @since 6.0
2919e95205Sopenharmony_ci */
3019e95205Sopenharmony_ci#ifndef AVDTP_H
3119e95205Sopenharmony_ci#define AVDTP_H
3219e95205Sopenharmony_ci
3319e95205Sopenharmony_ci#include <stdbool.h>
3419e95205Sopenharmony_ci#include <stddef.h>
3519e95205Sopenharmony_ci#include <stdint.h>
3619e95205Sopenharmony_ci
3719e95205Sopenharmony_ci#include "btstack.h"
3819e95205Sopenharmony_ci#include "packet.h"
3919e95205Sopenharmony_ci
4019e95205Sopenharmony_ci#ifdef __cplusplus
4119e95205Sopenharmony_ciextern "C" {
4219e95205Sopenharmony_ci#endif
4319e95205Sopenharmony_ci/**
4419e95205Sopenharmony_ci *  Constants
4519e95205Sopenharmony_ci */
4619e95205Sopenharmony_ci#define AVDT_VERSION_1_3 0x0103  // AVDTP.ICS #Table 14a-3,15a-3 version 1.3
4719e95205Sopenharmony_ci
4819e95205Sopenharmony_ci#ifndef AVDT_NUM_SEPS
4919e95205Sopenharmony_ci#define AVDT_NUM_SEPS 6  // SOW Max Number of stream endpoints
5019e95205Sopenharmony_ci#endif
5119e95205Sopenharmony_ci
5219e95205Sopenharmony_ci#ifndef AVDT_NUM_LINKS
5319e95205Sopenharmony_ci#define AVDT_NUM_LINKS 6  // SOW Max Number of link devices
5419e95205Sopenharmony_ci#endif
5519e95205Sopenharmony_ci
5619e95205Sopenharmony_ci/**
5719e95205Sopenharmony_ci * AVDTP.ICS #Table 14-1, 15-1 Basics Service.
5819e95205Sopenharmony_ci * The Max size of the codec capabilities information element.
5919e95205Sopenharmony_ci */
6019e95205Sopenharmony_ci#define AVDT_CODEC_SIZE 20
6119e95205Sopenharmony_ci
6219e95205Sopenharmony_ci/**
6319e95205Sopenharmony_ci * The return value of the API function
6419e95205Sopenharmony_ci */
6519e95205Sopenharmony_ci#define AVDT_SUCCESS 0       // Successful
6619e95205Sopenharmony_ci#define AVDT_BAD_PARAMS 1    // Invalid parameters
6719e95205Sopenharmony_ci#define AVDT_NO_RESOURCES 2  // Not resources
6819e95205Sopenharmony_ci#define AVDT_BAD_HANDLE 3    // Invalid handle
6919e95205Sopenharmony_ci#define AVDT_BUSY 4          // A procedure is doing,such as discovery seps
7019e95205Sopenharmony_ci#define AVDT_FAILED 5        // Procedure failed
7119e95205Sopenharmony_ci
7219e95205Sopenharmony_ci/**
7319e95205Sopenharmony_ci * AVDTP.ICS #Table 1-1,1-2 SEP Type.
7419e95205Sopenharmony_ci */
7519e95205Sopenharmony_ci#define AVDT_SEP_SRC 0      // Source SEP
7619e95205Sopenharmony_ci#define AVDT_SEP_SNK 1      // Sink SEP
7719e95205Sopenharmony_ci#define AVDT_SEP_INVALID 2  // Invalid SEP
7819e95205Sopenharmony_ci
7919e95205Sopenharmony_ci/**
8019e95205Sopenharmony_ci * AVDTP Initiator(INT)and Acceptor(ACP).
8119e95205Sopenharmony_ci */
8219e95205Sopenharmony_ci#define AVDT_INT 0  // Initiator
8319e95205Sopenharmony_ci#define AVDT_ACP 1  // Acceptor
8419e95205Sopenharmony_ci
8519e95205Sopenharmony_ci/**
8619e95205Sopenharmony_ci * AVDTP Source(SRC)and Sink(SNK)
8719e95205Sopenharmony_ci */
8819e95205Sopenharmony_ci#define AVDT_ROLE_SRC 0     // source
8919e95205Sopenharmony_ci#define AVDT_ROLE_SNK 1     // sink
9019e95205Sopenharmony_ci#define AVDT_ROLE_UNKOWN 2  // unknown
9119e95205Sopenharmony_ci
9219e95205Sopenharmony_ci/**
9319e95205Sopenharmony_ci * Media Type of the SEP
9419e95205Sopenharmony_ci */
9519e95205Sopenharmony_ci#define AVDT_MEDIA_TYPE_AUDIO 0  // Audio SEP
9619e95205Sopenharmony_ci#define AVDT_MEDIA_TYPE_VIDEO 1  // Retain: Video SEP
9719e95205Sopenharmony_ci
9819e95205Sopenharmony_ci/**
9919e95205Sopenharmony_ci * Error codes defined in the AVDTP and GAVDP specifications.
10019e95205Sopenharmony_ci * AVDTP.ICS #Table 16-1, Reporting Capability Error
10119e95205Sopenharmony_ci */
10219e95205Sopenharmony_ci#define AVDT_ERR_BAD_HEADER_FORMAT 0x01           // Packet header format is error
10319e95205Sopenharmony_ci#define AVDT_ERR_BAD_LENGTH 0x11                  // The length of packet is error
10419e95205Sopenharmony_ci#define AVDT_ERR_BAD_ACP_SEID 0x12                // Invalid SEID
10519e95205Sopenharmony_ci#define AVDT_ERR_SEP_IN_USE 0x13                  // The SEP use
10619e95205Sopenharmony_ci#define AVDT_ERR_SEP_NOT_IN_USE 0x14              // The SEP used
10719e95205Sopenharmony_ci#define AVDT_ERR_BAD_SERV_CATEGORY 0x17           // The service category is error
10819e95205Sopenharmony_ci#define AVDT_ERR_BAD_PAYLOAD_FORMAT 0x18          // The payload format is error
10919e95205Sopenharmony_ci#define AVDT_ERR_UNSUPPORTED_COMMAND 0x19         // Requested command is not supported
11019e95205Sopenharmony_ci#define AVDT_ERR_INVALID_CAPABILITIES 0x1A        // Invalid capabilities
11119e95205Sopenharmony_ci#define AVDT_ERR_BAD_RECOVERY_TYPE 0x22           // The requested Recovery Type is not defined in AVDTP.
11219e95205Sopenharmony_ci#define AVDT_ERR_BAD_MEDIA_TRANSPORT_FORMAT 0x23  // Media transport capability is error
11319e95205Sopenharmony_ci#define AVDT_ERR_BAD_RECOVERY_FORMAT 0x25         // The format of Recovery Service Capability is not correct.
11419e95205Sopenharmony_ci#define AVDT_ERR_UNSUPPORTED_CONFIGURATION 0x29   // Configuration is not supported
11519e95205Sopenharmony_ci#define AVDT_ERR_BAD_STATE 0x31                   // Message can't be processed in this state
11619e95205Sopenharmony_ci#define AVDT_ERR_SERVICE 0x80                     // Invalid service category
11719e95205Sopenharmony_ci#define AVDT_ERR_RESOURCE 0x81                    // Not enough resources
11819e95205Sopenharmony_ci#define AVDT_ERR_INVALID_MCT 0xC1                 // Invalid Media Codec Type
11919e95205Sopenharmony_ci#define AVDT_ERR_UNSUP_MCT 0xC2                   // Unsupported Media Codec Type
12019e95205Sopenharmony_ci
12119e95205Sopenharmony_ci/**
12219e95205Sopenharmony_ci * AVDTP 13.1.1 Control callback events
12319e95205Sopenharmony_ci */
12419e95205Sopenharmony_ci#define AVDT_DISCOVER_CFM_EVT 0       // Discover confirm
12519e95205Sopenharmony_ci#define AVDT_DISCOVER_IND_EVT 1       // Discover indication
12619e95205Sopenharmony_ci#define AVDT_GETCAP_CFM_EVT 2         // Get capabilities confirm
12719e95205Sopenharmony_ci#define AVDT_GETCAP_IND_EVT 3         // Get capabilities indication
12819e95205Sopenharmony_ci#define AVDT_OPEN_CFM_EVT 4           // Open confirm
12919e95205Sopenharmony_ci#define AVDT_OPEN_IND_EVT 5           // Open indication
13019e95205Sopenharmony_ci#define AVDT_CONFIG_CFM_EVT 6         // Configuration confirm
13119e95205Sopenharmony_ci#define AVDT_CONFIG_IND_EVT 7         // Configuration indication
13219e95205Sopenharmony_ci#define AVDT_START_CFM_EVT 8          // Start confirm
13319e95205Sopenharmony_ci#define AVDT_START_IND_EVT 9          // Start indication
13419e95205Sopenharmony_ci#define AVDT_SUSPEND_CFM_EVT 10       // Suspend confirm
13519e95205Sopenharmony_ci#define AVDT_SUSPEND_IND_EVT 11       // Suspend indication
13619e95205Sopenharmony_ci#define AVDT_CLOSE_CFM_EVT 12         // Close confirm
13719e95205Sopenharmony_ci#define AVDT_CLOSE_IND_EVT 13         // Close indication
13819e95205Sopenharmony_ci#define AVDT_RECONFIG_CFM_EVT 14      // Reconfiguration confirm
13919e95205Sopenharmony_ci#define AVDT_RECONFIG_IND_EVT 15      // Reconfiguration indication
14019e95205Sopenharmony_ci#define AVDT_WRITE_CFM_EVT 16         // Write confirm
14119e95205Sopenharmony_ci#define AVDT_READ_IND_EVT 17          // Read indication
14219e95205Sopenharmony_ci#define AVDT_CONNECT_CFM_EVT 18       // Connected confirm
14319e95205Sopenharmony_ci#define AVDT_CONNECT_IND_EVT 19       // Connected indication
14419e95205Sopenharmony_ci#define AVDT_DISCONNECT_CFM_EVT 20    // Disconnected confirm
14519e95205Sopenharmony_ci#define AVDT_DISCONNECT_IND_EVT 21    // Disconnected indication
14619e95205Sopenharmony_ci#define AVDT_DELAY_REPORT_IND_EVT 22  // Delay report indication
14719e95205Sopenharmony_ci#define AVDT_DELAY_REPORT_CFM_EVT 23  // Delay report confirm
14819e95205Sopenharmony_ci#define AVDT_ABORT_CFM_EVT 24         // Abort confirm
14919e95205Sopenharmony_ci#define AVDT_ABORT_IND_EVT 25         // Abort indication
15019e95205Sopenharmony_ci#define AVDT_GETCONFIG_CFM_EVT 26     // get Configuration confirm
15119e95205Sopenharmony_ci#define AVDT_GETCONFIG_IND_EVT 27     // get Configuration indication
15219e95205Sopenharmony_ci#define AVDT_GET_ALLCAP_CFM_EVT 28    // Get all capabilities confirm
15319e95205Sopenharmony_ci#define AVDT_GET_ALLCAP_IND_EVT 29    // Get all capabilities indication
15419e95205Sopenharmony_ci#define AVDT_CLOSE_TRANS_IND_EVT 30   // Receive transport released inication
15519e95205Sopenharmony_ci#define AVDT_MAX_EVT (AVDT_CLOSE_TRANS_IND_EVT)
15619e95205Sopenharmony_ci
15719e95205Sopenharmony_ci#define AVDT_PSM 0x0019  // PSM for AVDT
15819e95205Sopenharmony_ci/**
15919e95205Sopenharmony_ci * Capability mask
16019e95205Sopenharmony_ci * AVDTP.ICS #Table 14-1, 15-1 AVDT protocol service capabilities
16119e95205Sopenharmony_ci */
16219e95205Sopenharmony_ci
16319e95205Sopenharmony_ci#define AVDT_PSC_MSK_TRANS (1 << 0)      // Media Transport
16419e95205Sopenharmony_ci#define AVDT_PSC_MSK_REPORT (1 << 1)     // Reporting
16519e95205Sopenharmony_ci#define AVDT_PSC_MSK_RECOV (1 << 2)      // Recovery
16619e95205Sopenharmony_ci#define AVDT_PSC_MSK_PROTECT (1 << 3)    // Content Protection
16719e95205Sopenharmony_ci#define AVDT_PSC_MSK_HDRCMP (1 << 4)     // Header Compression
16819e95205Sopenharmony_ci#define AVDT_PSC_MSK_MUX (1 << 5)        // Header Compression
16919e95205Sopenharmony_ci#define AVDT_PSC_MSK_CODEC (1 << 6)      // Media Codec
17019e95205Sopenharmony_ci#define AVDT_PSC_MSK_DELAY_RPT (1 << 7)  // Delay Reporting
17119e95205Sopenharmony_ci/**
17219e95205Sopenharmony_ci * Type Definitions
17319e95205Sopenharmony_ci */
17419e95205Sopenharmony_ci
17519e95205Sopenharmony_ci/**
17619e95205Sopenharmony_ci * Service category
17719e95205Sopenharmony_ci */
17819e95205Sopenharmony_citypedef struct {
17919e95205Sopenharmony_ci    uint8_t errCode;   // error code
18019e95205Sopenharmony_ci    uint8_t category;  // category
18119e95205Sopenharmony_ci} AvdtCatetory;
18219e95205Sopenharmony_ci
18319e95205Sopenharmony_ci/**
18419e95205Sopenharmony_ci * SEP information. transportred during the discovery procedure.
18519e95205Sopenharmony_ci */
18619e95205Sopenharmony_citypedef struct {
18719e95205Sopenharmony_ci    uint8_t seid;       // The identifier of SEP
18819e95205Sopenharmony_ci    uint8_t mediaType;  // Media type: AVDT_MEDIA_TYPE_AUDIO
18919e95205Sopenharmony_ci    uint8_t sepType;    // SEP type
19019e95205Sopenharmony_ci    uint8_t role;       // actor role
19119e95205Sopenharmony_ci    bool isUsed;        // true if stream is used
19219e95205Sopenharmony_ci} AvdtSepInfo;
19319e95205Sopenharmony_ci
19419e95205Sopenharmony_ci/**
19519e95205Sopenharmony_ci * Reject error information.
19619e95205Sopenharmony_ci */
19719e95205Sopenharmony_citypedef struct {
19819e95205Sopenharmony_ci    uint8_t errCode;   // error code
19919e95205Sopenharmony_ci    uint8_t errParam;  // error param
20019e95205Sopenharmony_ci} AvdtRejErrInfo;
20119e95205Sopenharmony_ci
20219e95205Sopenharmony_ci/*
20319e95205Sopenharmony_ci * AVDTP SEP Configuration.
20419e95205Sopenharmony_ci */
20519e95205Sopenharmony_citypedef struct {
20619e95205Sopenharmony_ci    uint8_t codecInfo[AVDT_CODEC_SIZE];  // Codec capabilities
20719e95205Sopenharmony_ci    uint8_t numCodec;                    // Number of media codec information elements
20819e95205Sopenharmony_ci    uint8_t mediaType;                   // AVDT_MEDIA_TYPE
20919e95205Sopenharmony_ci    uint16_t pscMask;                    // Protocol service capabilities mask
21019e95205Sopenharmony_ci} AvdtSepConfig;
21119e95205Sopenharmony_ci
21219e95205Sopenharmony_ci/**
21319e95205Sopenharmony_ci * Header structure for callback event parameters
21419e95205Sopenharmony_ci */
21519e95205Sopenharmony_citypedef struct {
21619e95205Sopenharmony_ci    uint8_t errCode;    // Zero if operation succeeded;otherwise failed
21719e95205Sopenharmony_ci    uint8_t errParam;   // Error parameter included for some events
21819e95205Sopenharmony_ci    uint8_t label;      // Transaction label
21919e95205Sopenharmony_ci    uint8_t seid;       // Used inner AVDTp only
22019e95205Sopenharmony_ci    uint8_t sigId;      // Used inner AVDTponly
22119e95205Sopenharmony_ci    uint8_t sigHandle;  // Used inner AVDTponly
22219e95205Sopenharmony_ci    uint16_t mtu;       // Mtu size
22319e95205Sopenharmony_ci} AvdtEvtHeader;
22419e95205Sopenharmony_ci
22519e95205Sopenharmony_ci/**
22619e95205Sopenharmony_ci * Configure structure
22719e95205Sopenharmony_ci * * */
22819e95205Sopenharmony_citypedef struct {
22919e95205Sopenharmony_ci    AvdtEvtHeader hdr;  // Event header
23019e95205Sopenharmony_ci    AvdtSepConfig cfg;  // Pointer to configuration for this SEP
23119e95205Sopenharmony_ci} AvdtConfig;
23219e95205Sopenharmony_ci
23319e95205Sopenharmony_ci/**
23419e95205Sopenharmony_ci * Set Configure structure
23519e95205Sopenharmony_ci * * */
23619e95205Sopenharmony_citypedef struct {
23719e95205Sopenharmony_ci    AvdtEvtHeader hdr;  // Event header
23819e95205Sopenharmony_ci    AvdtSepConfig cfg;  // Pointer to configuration for this SEP
23919e95205Sopenharmony_ci    uint8_t intSeid;    // The SEP ID initiated
24019e95205Sopenharmony_ci    uint8_t acpSeid;    // The SEP ID acceptor
24119e95205Sopenharmony_ci} AvdtSetConfig;
24219e95205Sopenharmony_ci
24319e95205Sopenharmony_ci/**
24419e95205Sopenharmony_ci * Open stream structure
24519e95205Sopenharmony_ci */
24619e95205Sopenharmony_citypedef struct {
24719e95205Sopenharmony_ci    AvdtEvtHeader hdr;  // Event header
24819e95205Sopenharmony_ci    uint16_t peerMtu;   // L2CAP MTU of the peer
24919e95205Sopenharmony_ci    uint16_t lcid;      // L2CAP LCID for media channel.recorded by AVDTP
25019e95205Sopenharmony_ci} AvdtOpen;
25119e95205Sopenharmony_ci
25219e95205Sopenharmony_ci/**
25319e95205Sopenharmony_ci * Seps structure
25419e95205Sopenharmony_ci */
25519e95205Sopenharmony_citypedef struct {
25619e95205Sopenharmony_ci    AvdtEvtHeader hdr;                // Event header
25719e95205Sopenharmony_ci    uint8_t seidList[AVDT_NUM_SEPS];  // Array of SEID values
25819e95205Sopenharmony_ci    uint8_t numSeps;                  // Number of values in array
25919e95205Sopenharmony_ci} AvdtMulti;
26019e95205Sopenharmony_ci
26119e95205Sopenharmony_citypedef struct {
26219e95205Sopenharmony_ci    AvdtEvtHeader hdr;                // Event header
26319e95205Sopenharmony_ci    AvdtSepInfo seps[AVDT_NUM_SEPS];  // Pointer to SEP information
26419e95205Sopenharmony_ci    uint8_t numSeps;                  // Number of stream endpoints
26519e95205Sopenharmony_ci} AvdtDiscover;
26619e95205Sopenharmony_ci
26719e95205Sopenharmony_citypedef struct {
26819e95205Sopenharmony_ci    AvdtEvtHeader hdr;  // Event header
26919e95205Sopenharmony_ci    uint16_t delay;     // Delay value
27019e95205Sopenharmony_ci} AvdtDelayRpt;
27119e95205Sopenharmony_ci
27219e95205Sopenharmony_ci/**
27319e95205Sopenharmony_ci * Union of all control callback event data structures
27419e95205Sopenharmony_ci */
27519e95205Sopenharmony_citypedef union {
27619e95205Sopenharmony_ci    AvdtEvtHeader hdr;
27719e95205Sopenharmony_ci    AvdtDiscover discoverCfm;
27819e95205Sopenharmony_ci    AvdtDiscover discoverInd;
27919e95205Sopenharmony_ci    AvdtConfig getCapCfm;
28019e95205Sopenharmony_ci    AvdtConfig getCapInd;
28119e95205Sopenharmony_ci    AvdtOpen openCfm;
28219e95205Sopenharmony_ci    AvdtOpen openInd;
28319e95205Sopenharmony_ci    AvdtSetConfig configInd;
28419e95205Sopenharmony_ci    AvdtSetConfig configCfm;
28519e95205Sopenharmony_ci    AvdtEvtHeader startCfm;
28619e95205Sopenharmony_ci    AvdtEvtHeader startInd;
28719e95205Sopenharmony_ci    AvdtEvtHeader suspendCfm;
28819e95205Sopenharmony_ci    AvdtEvtHeader suspendInd;
28919e95205Sopenharmony_ci    AvdtEvtHeader closeCfm;
29019e95205Sopenharmony_ci    AvdtEvtHeader closeInd;
29119e95205Sopenharmony_ci    AvdtConfig reconfigCfm;
29219e95205Sopenharmony_ci    AvdtConfig reconfigInd;
29319e95205Sopenharmony_ci    AvdtConfig getconfigCfm;
29419e95205Sopenharmony_ci    AvdtConfig getconfigInd;
29519e95205Sopenharmony_ci    AvdtEvtHeader connectInd;
29619e95205Sopenharmony_ci    AvdtEvtHeader connectCfm;
29719e95205Sopenharmony_ci    AvdtEvtHeader disconnectInd;
29819e95205Sopenharmony_ci    AvdtEvtHeader disconnectCfm;
29919e95205Sopenharmony_ci    AvdtDelayRpt delayRptInd;
30019e95205Sopenharmony_ci    AvdtDelayRpt delayRptCfm;
30119e95205Sopenharmony_ci    AvdtEvtHeader abortInd;
30219e95205Sopenharmony_ci    AvdtEvtHeader abortCfm;
30319e95205Sopenharmony_ci} AvdtCtrlData;
30419e95205Sopenharmony_ci
30519e95205Sopenharmony_ci/**
30619e95205Sopenharmony_ci * @brief       Protocol Message data callback function
30719e95205Sopenharmony_ci * @details     This is the callback function used by AVDTP to report received AV control messages.
30819e95205Sopenharmony_ci * @param[in]   handle    Stream handle
30919e95205Sopenharmony_ci * @param[in]   bdAddr    Peer device address
31019e95205Sopenharmony_ci * @param[in]   event     Indication/Confirm event of message
31119e95205Sopenharmony_ci * @param[in]   data      Avdt event data
31219e95205Sopenharmony_ci * @param[in]   role      Local instance role
31319e95205Sopenharmony_ci * @return      @c void
31419e95205Sopenharmony_ci */
31519e95205Sopenharmony_citypedef void (*AvdtCtrlCallback)(
31619e95205Sopenharmony_ci    uint16_t handle, const BtAddr *bdAddr, uint8_t event, const AvdtCtrlData *data, uint8_t role);
31719e95205Sopenharmony_ci
31819e95205Sopenharmony_ci/**
31919e95205Sopenharmony_ci * @brief       Callback function for sink to read MediaData
32019e95205Sopenharmony_ci * @details     This is the callback function used by AVDTP to report sink to received AV stream data.
32119e95205Sopenharmony_ci * @param[in]   handle          Block handle
32219e95205Sopenharmony_ci * @param[in]   pkt             Stream data
32319e95205Sopenharmony_ci * @param[in]   timeStamp       Timestamp of frame
32419e95205Sopenharmony_ci * @param[in]   pt              Packet type
32519e95205Sopenharmony_ci * @param[in]   streamHandle    Stream handle
32619e95205Sopenharmony_ci * @return      @c void
32719e95205Sopenharmony_ci */
32819e95205Sopenharmony_citypedef void (*AVDT_SinkDataCallback)(
32919e95205Sopenharmony_ci    uint16_t handle, Packet *pkt, uint32_t timeStamp, uint8_t pt, uint16_t streamHandle);
33019e95205Sopenharmony_ci
33119e95205Sopenharmony_ci/**
33219e95205Sopenharmony_ci * AVDT Registration Control Block.
33319e95205Sopenharmony_ci */
33419e95205Sopenharmony_citypedef struct {
33519e95205Sopenharmony_ci    uint16_t mtu;                   // L2CAP MTU for AVDT signaling channel
33619e95205Sopenharmony_ci    uint8_t role;                   // Source or Sink
33719e95205Sopenharmony_ci    AvdtCtrlCallback ctrlCallback;  // Control Callback function
33819e95205Sopenharmony_ci} AvdtRegisterParam;
33919e95205Sopenharmony_ci
34019e95205Sopenharmony_ci/**
34119e95205Sopenharmony_ci * Used before to create a stream
34219e95205Sopenharmony_ci */
34319e95205Sopenharmony_citypedef struct {
34419e95205Sopenharmony_ci    AvdtSepConfig cfg;                    // SEP configuration
34519e95205Sopenharmony_ci    uint16_t codecIndex;                  // The handle to the a2dp stream control entry
34619e95205Sopenharmony_ci    AVDT_SinkDataCallback sinkDataCback;  // Sink data callback function
34719e95205Sopenharmony_ci    uint16_t mtu;                         // The L2CAP MTU of the transport channel
34819e95205Sopenharmony_ci    uint16_t flushTo;                     // The L2CAP flush timeout of the transport channel
34919e95205Sopenharmony_ci    uint8_t sepType;                      // SEP type
35019e95205Sopenharmony_ci    uint16_t nscMask;                     // Protocol command messages is not supported
35119e95205Sopenharmony_ci} AvdtStreamConfig;
35219e95205Sopenharmony_ci
35319e95205Sopenharmony_ci/**
35419e95205Sopenharmony_ci *
35519e95205Sopenharmony_ci * @brief       Function AVDT_Register
35619e95205Sopenharmony_ci * @details     This function initializes AVDTP and prepares the protocol stack for its use.
35719e95205Sopenharmony_ci *              It must be called once by the system or platform using AVDT before the other functions of the API an be
35819e95205Sopenharmony_ci *              used.
35919e95205Sopenharmony_ci * @param[in]   reg  Register information
36019e95205Sopenharmony_ci * @return      void
36119e95205Sopenharmony_ci *
36219e95205Sopenharmony_ci */
36319e95205Sopenharmony_ciBTSTACK_API void AVDT_Register(const AvdtRegisterParam *reg);
36419e95205Sopenharmony_ci
36519e95205Sopenharmony_ci/**
36619e95205Sopenharmony_ci *
36719e95205Sopenharmony_ci * @brief   Function AVDT_Deregister
36819e95205Sopenharmony_ci * @details This function is called to deregister AVDTP protocol.
36919e95205Sopenharmony_ci *          This function can be called after all streams must be removed.
37019e95205Sopenharmony_ci * @return  void
37119e95205Sopenharmony_ci *
37219e95205Sopenharmony_ci */
37319e95205Sopenharmony_ciBTSTACK_API void AVDT_Deregister(void);
37419e95205Sopenharmony_ci
37519e95205Sopenharmony_ci/**
37619e95205Sopenharmony_ci *
37719e95205Sopenharmony_ci * @brief       Function AVDT_AbortReq
37819e95205Sopenharmony_ci * @details     This function is called to request to pass AVDT Abort.
37919e95205Sopenharmony_ci *              AVDTP.ICS #Table 5-5, 5b-5 Abort stream command.
38019e95205Sopenharmony_ci * @param[in]   handle      Handle of stream
38119e95205Sopenharmony_ci * @param[out]  transLabel  The label of this message
38219e95205Sopenharmony_ci * @return      AVDT_SUCCESS if successful, otherwise error.
38319e95205Sopenharmony_ci *
38419e95205Sopenharmony_ci */
38519e95205Sopenharmony_ciBTSTACK_API uint16_t AVDT_AbortReq(uint16_t handle, uint8_t *transLabel);
38619e95205Sopenharmony_ci
38719e95205Sopenharmony_ci/**
38819e95205Sopenharmony_ci *
38919e95205Sopenharmony_ci * @brief       Function AVDT_AbortRsp
39019e95205Sopenharmony_ci * @details     The response of  Abort request from peer device.
39119e95205Sopenharmony_ci *              AVDTP.ICS #Table 11-5, 11b-5 Abort stream response
39219e95205Sopenharmony_ci * @param[in]   handle      Handle of stream
39319e95205Sopenharmony_ci * @param[in]   transLabel  The label of this message
39419e95205Sopenharmony_ci * @param[in]   errCode     Error code
39519e95205Sopenharmony_ci * @return      AVDT_SUCCESS if successful, otherwise error.
39619e95205Sopenharmony_ci *
39719e95205Sopenharmony_ci */
39819e95205Sopenharmony_ciBTSTACK_API uint16_t AVDT_AbortRsp(uint16_t handle, uint8_t transLabel, uint8_t errCode);
39919e95205Sopenharmony_ci
40019e95205Sopenharmony_ci/**
40119e95205Sopenharmony_ci *
40219e95205Sopenharmony_ci * @brief       Function AVDT_CreateStream
40319e95205Sopenharmony_ci * @details     Create a stream endpoint. An application can initiate a connection between this endpoint and an endpoint
40419e95205Sopenharmony_ci *              on a peer device after a stream endpoint is created.
40519e95205Sopenharmony_ci * @param[in]   bdAddr              Peer device address
40619e95205Sopenharmony_ci * @param[in]   avdtStreamConfig    Stream  endpoint configure information
40719e95205Sopenharmony_ci * @param[out]  handle              Sep handle
40819e95205Sopenharmony_ci * @return      AVDT_SUCCESS if successful, otherwise error.
40919e95205Sopenharmony_ci *
41019e95205Sopenharmony_ci */
41119e95205Sopenharmony_ciBTSTACK_API uint16_t AVDT_CreateStream(const BtAddr *bdAddr, uint16_t *handle, uint16_t codeIndex);
41219e95205Sopenharmony_ci
41319e95205Sopenharmony_ci/**
41419e95205Sopenharmony_ci *
41519e95205Sopenharmony_ci * @brief       Function AVDT_RegisterLocalSEP
41619e95205Sopenharmony_ci * @details     Register local stream endpoint information.
41719e95205Sopenharmony_ci * @param[in]   avdtStreamConfig  Stream  endpoint configure information
41819e95205Sopenharmony_ci * @return      AVDT_SUCCESS if successful, otherwise error.
41919e95205Sopenharmony_ci *
42019e95205Sopenharmony_ci */
42119e95205Sopenharmony_ciBTSTACK_API uint16_t AVDT_RegisterLocalSEP(AvdtStreamConfig *avdtStreamConfig, uint8_t number);
42219e95205Sopenharmony_ci
42319e95205Sopenharmony_ci/**
42419e95205Sopenharmony_ci *
42519e95205Sopenharmony_ci * @brief       Function AVDT_RemoveStream (Retain)
42619e95205Sopenharmony_ci * @details     Remove a stream endpoint.
42719e95205Sopenharmony_ci * @param[in]   handle   Handle of stream.
42819e95205Sopenharmony_ci * @return      AVDT_SUCCESS if successful, otherwise error.
42919e95205Sopenharmony_ci *
43019e95205Sopenharmony_ci */
43119e95205Sopenharmony_ciBTSTACK_API uint16_t AVDT_RemoveStream(uint16_t handle);
43219e95205Sopenharmony_ci
43319e95205Sopenharmony_ci/**
43419e95205Sopenharmony_ci *
43519e95205Sopenharmony_ci * @brief       Function AVDT_DiscoverReq
43619e95205Sopenharmony_ci * @details     This function send AVDT_DISCOVER_CMD from INT to ACP and it request to get the overview of all SEP
43719e95205Sopenharmony_ci *              information of the ACP. When discovery is complete, an AVDT_DISCOVER_CFM_EVT is sent to the application
43819e95205Sopenharmony_ci *              via its callback function.The application must not call AVDT_GetCapReq() or AVDT_DiscoverReq() again to
43919e95205Sopenharmony_ci *              the same device until discovery is complete. AVDTP.ICS #Table 4-1, 4b-1 Stream discover command
44019e95205Sopenharmony_ci * @param[in]   bdAddr        Peer device address
44119e95205Sopenharmony_ci * @param[in]   maxSeps       Max number to get SEP
44219e95205Sopenharmony_ci * @param[out]  transLabel    Label of this message
44319e95205Sopenharmony_ci * @return      AVDT_SUCCESS if successful, otherwise error.
44419e95205Sopenharmony_ci *
44519e95205Sopenharmony_ci */
44619e95205Sopenharmony_ciBTSTACK_API uint16_t AVDT_DiscoverReq(const BtAddr *bdAddr, uint8_t maxSeps, uint8_t *transLabel);
44719e95205Sopenharmony_ci
44819e95205Sopenharmony_ci/**
44919e95205Sopenharmony_ci *
45019e95205Sopenharmony_ci * @brief       Function AVDT_DiscoverRsp(Retain)
45119e95205Sopenharmony_ci * @details     Respond to a discover request from ACP.
45219e95205Sopenharmony_ci *              AVDTP.ICS #Table 10-1, 10b-1 Stream discover response
45319e95205Sopenharmony_ci * @param[in]   bdAddr        Peer device address
45419e95205Sopenharmony_ci * @param[in]   transLabel    Label of Disvover message
45519e95205Sopenharmony_ci * @param[in]   errCode       Error code
45619e95205Sopenharmony_ci * @param[in]   sepInfo       SEP information
45719e95205Sopenharmony_ci * @param[in]   numSeps       Number of SEP
45819e95205Sopenharmony_ci * @return      AVDT_SUCCESS if successful, otherwise error.
45919e95205Sopenharmony_ci *
46019e95205Sopenharmony_ci */
46119e95205Sopenharmony_ciBTSTACK_API uint16_t AVDT_DiscoverRsp(
46219e95205Sopenharmony_ci    const BtAddr *bdAddr, uint8_t transLabel, uint8_t errCode, AvdtSepInfo *sepInfo, uint8_t numSeps);
46319e95205Sopenharmony_ci
46419e95205Sopenharmony_ci/**
46519e95205Sopenharmony_ci *
46619e95205Sopenharmony_ci * @brief       Function AVDT_GetCapReq
46719e95205Sopenharmony_ci * @details     This function send AVDT_GETCAP_REQ from INT to ACP and it used to get the information of a SEP of
46819e95205Sopenharmony_ci *              ACP.When the procedure is complete, an AVDT_GETCAP_CFM_EVT is sent to the application via its callback
46919e95205Sopenharmony_ci *              function.  The application must not call AVDT_GetCapReq() or AVDT_DiscoverReq() again until the
47019e95205Sopenharmony_ci *              procedure is complete. AVDTP.ICS #Table 4-2, 4b-2 Stream get capabilities command AVDTP.ICS #Table 4-6,
47119e95205Sopenharmony_ci *              4b-6 Stream get all capabilities command.
47219e95205Sopenharmony_ci * @param[in]   bdAddr        Peer device address
47319e95205Sopenharmony_ci * @param[in]   acpSeid       Seid of Acceptor
47419e95205Sopenharmony_ci * @param[out]  transLabel    Label of this message
47519e95205Sopenharmony_ci * @return      AVDT_SUCCESS if successful, otherwise error.
47619e95205Sopenharmony_ci *
47719e95205Sopenharmony_ci */
47819e95205Sopenharmony_ciBTSTACK_API uint16_t AVDT_GetCapReq(const BtAddr *bdAddr, uint8_t acpSeid, uint8_t *transLabel);
47919e95205Sopenharmony_ci
48019e95205Sopenharmony_ci/**
48119e95205Sopenharmony_ci *
48219e95205Sopenharmony_ci * @brief       Function AVDT_GetCapRsp(Retain)
48319e95205Sopenharmony_ci * @details     Respond to a getcap request from ACP.
48419e95205Sopenharmony_ci *              AVDTP.ICS #Table 10-2, 10b-2 Stream get capabilities response.
48519e95205Sopenharmony_ci * @param[in]   bdAddr        Peer device address
48619e95205Sopenharmony_ci * @param[in]   transLabel    Lable of getcapability cmd
48719e95205Sopenharmony_ci * @param[in]   errCode       Error code
48819e95205Sopenharmony_ci * @param[in]   sepCap        SEP capability information
48919e95205Sopenharmony_ci * @return      AVDT_SUCCESS if successful, otherwise error.
49019e95205Sopenharmony_ci *
49119e95205Sopenharmony_ci */
49219e95205Sopenharmony_ciBTSTACK_API uint16_t AVDT_GetCapRsp(const BtAddr *bdAddr, uint8_t transLabel, uint8_t errCode, AvdtSepConfig *sepCap);
49319e95205Sopenharmony_ci
49419e95205Sopenharmony_ci/**
49519e95205Sopenharmony_ci *
49619e95205Sopenharmony_ci * @brief       Function AVDT_GetAllCapReq
49719e95205Sopenharmony_ci * @details     This function send AVDT_GETALLCAP_REQ from INT to ACP and it used to get the information of a SEP of
49819e95205Sopenharmony_ci *              ACP.When the procedure is complete, an AVDT_GETALLCAP_CFM_EVT is sent to the application via its
49919e95205Sopenharmony_ci *              callback function. The application must not call AVDT_GetAllCapReq() or AVDT_DiscoverReq() again until
50019e95205Sopenharmony_ci *              the procedure is complete. AVDTP.ICS #Table 4-2, 4b-2 Stream get capabilities command AVDTP.ICS #Table
50119e95205Sopenharmony_ci *              4-6, 4b-6 Stream get all capabilities command.
50219e95205Sopenharmony_ci * @param[in]   bdAddr        Peer device address
50319e95205Sopenharmony_ci * @param[in]   acpSeid       Seid of Acceptor
50419e95205Sopenharmony_ci * @param[out]  transLabel    Label of this message
50519e95205Sopenharmony_ci * @return      AVDT_SUCCESS if successful, otherwise error.
50619e95205Sopenharmony_ci *
50719e95205Sopenharmony_ci */
50819e95205Sopenharmony_ciBTSTACK_API uint16_t AVDT_GetAllCapReq(const BtAddr *bdAddr, uint8_t acpSeid, uint8_t *transLabel);
50919e95205Sopenharmony_ci
51019e95205Sopenharmony_ci/**
51119e95205Sopenharmony_ci *
51219e95205Sopenharmony_ci * @brief       Function AVDT_GetAllCapRsp(Retain)
51319e95205Sopenharmony_ci * @details     Respond to a getcap request from ACP.
51419e95205Sopenharmony_ci *              AVDTP.ICS #Table 10-2, 10b-2 Stream get capabilities response.
51519e95205Sopenharmony_ci * @param[in]   bdAddr        Peer device address
51619e95205Sopenharmony_ci * @param[in]   transLabel    Lable of getcapability cmd
51719e95205Sopenharmony_ci * @param[in]   errCode       Error code
51819e95205Sopenharmony_ci * @param[in]   sepCap        SEP capability information
51919e95205Sopenharmony_ci * @return      AVDT_SUCCESS if successful, otherwise error.
52019e95205Sopenharmony_ci *
52119e95205Sopenharmony_ci */
52219e95205Sopenharmony_ciBTSTACK_API uint16_t AVDT_GetAllCapRsp(
52319e95205Sopenharmony_ci    const BtAddr *bdAddr, uint8_t transLabel, uint8_t errCode, AvdtSepConfig *sepCap);
52419e95205Sopenharmony_ci
52519e95205Sopenharmony_ci/**
52619e95205Sopenharmony_ci *
52719e95205Sopenharmony_ci * @brief       Function AVDT_DelayReq
52819e95205Sopenharmony_ci * @details     This functions sends a Delay Report to ACP that is associated with a particular SEID.This function is
52919e95205Sopenharmony_ci *              called by SNK device. AVDTP.ICS #Table 15-6 Delay Reporting
53019e95205Sopenharmony_ci * @param[in]   bdAddr        Peer device address
53119e95205Sopenharmony_ci * @param[in]   delayValue    Delay data
53219e95205Sopenharmony_ci * @param[out]  transLabel    Label of this message
53319e95205Sopenharmony_ci * @return      AVDT_SUCCESS if successful, otherwise error.
53419e95205Sopenharmony_ci *
53519e95205Sopenharmony_ci */
53619e95205Sopenharmony_ciBTSTACK_API uint16_t AVDT_DelayReq(uint16_t handle, uint8_t *transLabel, uint16_t delayValue);
53719e95205Sopenharmony_ci
53819e95205Sopenharmony_ci/**
53919e95205Sopenharmony_ci *
54019e95205Sopenharmony_ci * @brief       Function AVDT_DelayRsp(Retain)
54119e95205Sopenharmony_ci * @details     Respond to a delay request from the peer device.
54219e95205Sopenharmony_ci *              AVDTP.ICS #Table 14-6 Delay Reporting.
54319e95205Sopenharmony_ci * @param[in]   handle        Handle of stream
54419e95205Sopenharmony_ci * @param[in]   transLabel    Label of delay cmd
54519e95205Sopenharmony_ci * @param[in]   errCode       Error code
54619e95205Sopenharmony_ci * @return      AVDT_SUCCESS if successful, otherwise error.
54719e95205Sopenharmony_ci *
54819e95205Sopenharmony_ci */
54919e95205Sopenharmony_ciBTSTACK_API uint16_t AVDT_DelayRsp(uint16_t handle, uint8_t transLabel, uint8_t errCode);
55019e95205Sopenharmony_ci
55119e95205Sopenharmony_ci/**
55219e95205Sopenharmony_ci *
55319e95205Sopenharmony_ci * @brief       Function AVDT_OpenReq
55419e95205Sopenharmony_ci * @details     This function send the AVDT_OPEN_REQ from INT to ACP and create the stream between INT and ACP.When the
55519e95205Sopenharmony_ci *              connection is completed, an AVDT _OPEN_CFM_EVT is sent to the application via the control callback
55619e95205Sopenharmony_ci *              function for this handle. AVDTP.ICS #Table 5-1,5b-1 Open stream command
55719e95205Sopenharmony_ci * @param[in]   handle        Handle of stream
55819e95205Sopenharmony_ci * @param[out]   transLabel    Label of this message
55919e95205Sopenharmony_ci * @return      AVDT_SUCCESS if successful, otherwise error.
56019e95205Sopenharmony_ci *
56119e95205Sopenharmony_ci */
56219e95205Sopenharmony_ciBTSTACK_API uint16_t AVDT_OpenReq(uint16_t handle, uint8_t *transLabel);
56319e95205Sopenharmony_ci
56419e95205Sopenharmony_ci/**
56519e95205Sopenharmony_ci *
56619e95205Sopenharmony_ci * @brief       Function AVDT_OpenRsp(Retain)
56719e95205Sopenharmony_ci * @details     Respond to an open request from ACP.
56819e95205Sopenharmony_ci *              AVDTP.ICS #Table 11-1, 11b-1 Open stream response
56919e95205Sopenharmony_ci * @param[in]   handle        Handle of stream
57019e95205Sopenharmony_ci * @param[in]   transLabel    Label of this message
57119e95205Sopenharmony_ci * @param[in]   errCode       Error code
57219e95205Sopenharmony_ci * @return      AVDT_SUCCESS if successful, otherwise error.
57319e95205Sopenharmony_ci *
57419e95205Sopenharmony_ci */
57519e95205Sopenharmony_ciBTSTACK_API uint16_t AVDT_OpenRsp(uint16_t handle, uint8_t transLabel, uint8_t errCode);
57619e95205Sopenharmony_ci
57719e95205Sopenharmony_ci/**
57819e95205Sopenharmony_ci *
57919e95205Sopenharmony_ci * @brief       Function AVDT_SetConfigReq
58019e95205Sopenharmony_ci * @details     This function send AVDT_CONFIG_CMD from INT to ACP. When the config is completed, an AVDT_CONFIG_CFM_EVT
58119e95205Sopenharmony_ci *              is sent to the application via the control callback function for this handle. AVDTP.ICS #Table 4-3, 4b-3
58219e95205Sopenharmony_ci *              Set configuration command
58319e95205Sopenharmony_ci * @param[in]   handle        Handle of stream
58419e95205Sopenharmony_ci * @param[in]   seid          The id of SEP in acceptor
58519e95205Sopenharmony_ci * @param[in]   sepConfig     Configure information
58619e95205Sopenharmony_ci * @param[out]   transLabel    Label of this message
58719e95205Sopenharmony_ci * @return      AVDT_SUCCESS if successful, otherwise error.
58819e95205Sopenharmony_ci *
58919e95205Sopenharmony_ci */
59019e95205Sopenharmony_ciBTSTACK_API uint16_t AVDT_SetConfigReq(uint16_t handle, uint8_t seid, AvdtSepConfig *sepConfig, uint8_t *transLabel);
59119e95205Sopenharmony_ci
59219e95205Sopenharmony_ci/**
59319e95205Sopenharmony_ci *
59419e95205Sopenharmony_ci * @brief       AVDT_SetConfigRsp
59519e95205Sopenharmony_ci * @details     Respond to a configure request from ACP.  This function must be called if the application receives an
59619e95205Sopenharmony_ci *              AVDT_CONFIG_IND_EVT through its control callback. AVDTP.ICS #Table 10-3, 10b-3 Set configuration
59719e95205Sopenharmony_ci *              response
59819e95205Sopenharmony_ci * @param[in]   handle        Handle of stream
59919e95205Sopenharmony_ci * @param[in]   transLabel    Lable of setconfigure cmd
60019e95205Sopenharmony_ci * @param[in]   category      Configure result information
60119e95205Sopenharmony_ci * @return      AVDT_SUCCESS if successful, otherwise error.
60219e95205Sopenharmony_ci *
60319e95205Sopenharmony_ci */
60419e95205Sopenharmony_ciBTSTACK_API uint16_t AVDT_SetConfigRsp(uint16_t handle, uint8_t transLabel, AvdtCatetory category);
60519e95205Sopenharmony_ci
60619e95205Sopenharmony_ci/**
60719e95205Sopenharmony_ci *
60819e95205Sopenharmony_ci * @brief       Function AVDT_GetConfigReq
60919e95205Sopenharmony_ci * @details     This function send AVDT_GETCONFIG_CMD from INT to ACP to get the current configuration of a SEP in ACP.
61019e95205Sopenharmony_ci *              When the config is completed, an AVDT_GETCONFIG_CFM _EVT is sent to the application via the control
61119e95205Sopenharmony_ci *              callback function. AVDTP.ICS #Table 4-4, 4b-4 Get configuration command
61219e95205Sopenharmony_ci * @param[in]   handle        Handle of stream
61319e95205Sopenharmony_ci * @param[out]  transLabel    Label of this message
61419e95205Sopenharmony_ci * @return      AVDT_SUCCESS if successful, otherwise error.
61519e95205Sopenharmony_ci *
61619e95205Sopenharmony_ci */
61719e95205Sopenharmony_ciBTSTACK_API uint16_t AVDT_GetConfigReq(uint16_t handle, uint8_t *transLabel);
61819e95205Sopenharmony_ci
61919e95205Sopenharmony_ci/**
62019e95205Sopenharmony_ci *
62119e95205Sopenharmony_ci * @brief       Function AVDT_StartReq
62219e95205Sopenharmony_ci * @details     Start one or more stream endpoints(audio/video). All stream endpoints must previously be opened.  When
62319e95205Sopenharmony_ci *              the streams are started, an AVDT_START_CFM_EVT is sent to the application via the control callback
62419e95205Sopenharmony_ci *              function for each stream. AVDTP.ICS #Table 5-2, 5b-2 Start stream command
62519e95205Sopenharmony_ci * @param[in]   handles       Handles of stream, use the first one usually
62619e95205Sopenharmony_ci * @param[in]   numHandles    Number of stream
62719e95205Sopenharmony_ci * @param[out]  transLabel    Lable of this message
62819e95205Sopenharmony_ci * @return      AVDT_SUCCESS if successful, otherwise error.
62919e95205Sopenharmony_ci *
63019e95205Sopenharmony_ci */
63119e95205Sopenharmony_ciBTSTACK_API uint16_t AVDT_StartReq(const uint16_t *handles, uint8_t numHandles, uint8_t *transLabel);
63219e95205Sopenharmony_ci
63319e95205Sopenharmony_ci/**
63419e95205Sopenharmony_ci *
63519e95205Sopenharmony_ci * @brief       Function AVDT_StartRsp
63619e95205Sopenharmony_ci * @details     Respond to a start request from ACP.  This function must be called if the application receives an
63719e95205Sopenharmony_ci *              AVDT_START_IND_EVT through its control callback. AVDTP.ICS #Table 11-2, 11b-2 Start stream command
63819e95205Sopenharmony_ci * @param[in]   firstHandle       First stream handle successful
63919e95205Sopenharmony_ci * @param[in]   transLabel        Label of start cmd
64019e95205Sopenharmony_ci * @param[in]   firstFailHandle   First stream handle failed
64119e95205Sopenharmony_ci * @param[in]   errCode           Error code ot the failed handle
64219e95205Sopenharmony_ci * @return      AVDT_SUCCESS if successful, otherwise error.
64319e95205Sopenharmony_ci *
64419e95205Sopenharmony_ci */
64519e95205Sopenharmony_ciBTSTACK_API uint16_t AVDT_StartRsp(uint16_t firstHandle, uint8_t transLabel, uint16_t firstFailHandle, uint8_t errCode);
64619e95205Sopenharmony_ci
64719e95205Sopenharmony_ci/**
64819e95205Sopenharmony_ci *
64919e95205Sopenharmony_ci * @brief       Function AVDT_SuspendReq
65019e95205Sopenharmony_ci * @details     Suspend one or more stream endpoints. This suspends the transport of media packets for the streams.  All
65119e95205Sopenharmony_ci *              stream endpoints must previously be open and started.  When the streams are suspended, an
65219e95205Sopenharmony_ci *              AVDT_SUSPEND_CFM_EVT is sent to the application via the control callback function for each stream.
65319e95205Sopenharmony_ci *              AVDTP.ICS #Table 5-4, 5b-4 Suspend command
65419e95205Sopenharmony_ci * @param[in]   handles       Handles of stream, use the first one usually
65519e95205Sopenharmony_ci * @param[in]   numHandles    Number of stream
65619e95205Sopenharmony_ci * @param[out]  transLabel    Lable of this message
65719e95205Sopenharmony_ci * @return      AVDT_SUCCESS if successful, otherwise error.
65819e95205Sopenharmony_ci *
65919e95205Sopenharmony_ci */
66019e95205Sopenharmony_ciBTSTACK_API uint16_t AVDT_SuspendReq(const uint16_t *handles, uint8_t numHandles, uint8_t *transLabel);
66119e95205Sopenharmony_ci
66219e95205Sopenharmony_ci/**
66319e95205Sopenharmony_ci *
66419e95205Sopenharmony_ci * @brief       Function AVDT_SuspendRsp
66519e95205Sopenharmony_ci * @details     Respond to a suspend request from ACP.  This function must be called if the application receives an
66619e95205Sopenharmony_ci *              AVDT_SUSPEND_IND_EVT through its control callback. AVDTP.ICS #Table 11-4, 11b-4 Suspend response
66719e95205Sopenharmony_ci * @param[in]   firstHandle       First stream handle successful
66819e95205Sopenharmony_ci * @param[in]   transLabel        Label of start cmd
66919e95205Sopenharmony_ci * @param[in]   firstFailHandle   First stream handle failed
67019e95205Sopenharmony_ci * @param[in]   errCode           Error code ot the failed handle
67119e95205Sopenharmony_ci * @return      AVDT_SUCCESS if successful, otherwise error.
67219e95205Sopenharmony_ci *
67319e95205Sopenharmony_ci */
67419e95205Sopenharmony_ciBTSTACK_API uint16_t AVDT_SuspendRsp(
67519e95205Sopenharmony_ci    uint16_t firstHandle, uint8_t transLabel, uint16_t firstFailHandle, uint8_t errCode);
67619e95205Sopenharmony_ci
67719e95205Sopenharmony_ci/**
67819e95205Sopenharmony_ci *
67919e95205Sopenharmony_ci * @brief       Function AVDT_CloseReq
68019e95205Sopenharmony_ci * @details     It stops the transport of media packets and close the transport channel associated with this stream
68119e95205Sopenharmony_ci *              endpoint.  When the stream is closed,an AVDT_CLOSE_CFM _EVT is sent to the application via the control
68219e95205Sopenharmony_ci *              callback function for this handle. AVDTP.ICS #Table 5-3, 5b-3 Close stream command
68319e95205Sopenharmony_ci * @param[in]   handle       Handle of stream
68419e95205Sopenharmony_ci * @return      AVDT_SUCCESS if successful, otherwise error.
68519e95205Sopenharmony_ci *
68619e95205Sopenharmony_ci */
68719e95205Sopenharmony_ciBTSTACK_API uint16_t AVDT_CloseReq(uint16_t handle);
68819e95205Sopenharmony_ci
68919e95205Sopenharmony_ci/**
69019e95205Sopenharmony_ci *
69119e95205Sopenharmony_ci * @brief       Function AVDT_CloseRsp
69219e95205Sopenharmony_ci * @details     Respond to a close request from ACP.  This function must be called if the application receives an
69319e95205Sopenharmony_ci *              AVDT_CLOSE_IND_EVT through its control callback. AVDTP.ICS #Table 11-3, 11b-c Close stream response
69419e95205Sopenharmony_ci * @param[in]   handle       Handle of stream
69519e95205Sopenharmony_ci * @param[in]   transLabel   Label of close cmd
69619e95205Sopenharmony_ci * @param[in]   errCode      Error code
69719e95205Sopenharmony_ci * @return      AVDT_SUCCESS if successful, otherwise error.
69819e95205Sopenharmony_ci *
69919e95205Sopenharmony_ci */
70019e95205Sopenharmony_ciBTSTACK_API uint16_t AVDT_CloseRsp(uint16_t handle, uint8_t transLabel, uint8_t errCode);
70119e95205Sopenharmony_ci
70219e95205Sopenharmony_ci/**
70319e95205Sopenharmony_ci *
70419e95205Sopenharmony_ci * @brief       Function AVDT_ReconfigReq
70519e95205Sopenharmony_ci * @details     Reconfigure a stream endpoint.  It allows the application can only be called if the stream is opened but
70619e95205Sopenharmony_ci *              not started to change the codec capabilities of a stream endpoint after it has been opened.  When the
70719e95205Sopenharmony_ci *              procedure is completed, an AVDT_RECONFIG _CFM_EVT is sent to the application via the control callback
70819e95205Sopenharmony_ci *              function for this handle. AVDTP.ICS #Table 4-5, 4b-5 Reconfigure command
70919e95205Sopenharmony_ci * @param[in]   handle       Handle of stream
71019e95205Sopenharmony_ci * @param[in]   cfg          Reconfigure information
71119e95205Sopenharmony_ci * @param[out]  transLabel   Label of this message
71219e95205Sopenharmony_ci * @return      AVDT_SUCCESS if successful, otherwise error.
71319e95205Sopenharmony_ci *
71419e95205Sopenharmony_ci */
71519e95205Sopenharmony_ciBTSTACK_API uint16_t AVDT_ReconfigReq(uint16_t handle, AvdtSepConfig *cfg, uint8_t *transLabel);
71619e95205Sopenharmony_ci
71719e95205Sopenharmony_ci/**
71819e95205Sopenharmony_ci *
71919e95205Sopenharmony_ci * @brief       Funciton AVDT_ReconfigRsp
72019e95205Sopenharmony_ci * @details     Respond to a reconfigure request from ACP.This function must be called if the application receives an
72119e95205Sopenharmony_ci *              AVDT_RECONFIG_IND_EVT through its control callback. AVDTP.ICS #Table 10-5, 10b-5 Reconfigure response
72219e95205Sopenharmony_ci * @param[in]   handle       Handle of stream
72319e95205Sopenharmony_ci * @param[in]   transLabel   Label of reconfigure cmd
72419e95205Sopenharmony_ci * @param[in]   errCode      Error code
72519e95205Sopenharmony_ci * @return      AVDT_SUCCESS if successful, otherwise error.
72619e95205Sopenharmony_ci *
72719e95205Sopenharmony_ci */
72819e95205Sopenharmony_ciBTSTACK_API uint16_t AVDT_ReconfigRsp(uint16_t handle, uint8_t transLabel, AvdtCatetory category);
72919e95205Sopenharmony_ci
73019e95205Sopenharmony_ci/**
73119e95205Sopenharmony_ci *
73219e95205Sopenharmony_ci * @brief       Function AVDT_WriteReq
73319e95205Sopenharmony_ci * @details     Send a media packet from SOURCE to the SINK and the status of the stream must be streaming. AVDTP 13.2.1
73419e95205Sopenharmony_ci * @param[in]   handle       Handle of stream
73519e95205Sopenharmony_ci * @param[in]   pkt          Stream data
73619e95205Sopenharmony_ci * @param[in]   timeStamp    Timestamp of this stream data sent
73719e95205Sopenharmony_ci * @param[in]   payloadType  Payload type
73819e95205Sopenharmony_ci * @param[in]   marker       Marker: such ad frame boundaries in the data stream
73919e95205Sopenharmony_ci * @return      AVDT_SUCCESS if successful, otherwise error.
74019e95205Sopenharmony_ci *
74119e95205Sopenharmony_ci */
74219e95205Sopenharmony_ciBTSTACK_API uint16_t AVDT_WriteReq(
74319e95205Sopenharmony_ci    uint16_t handle, const Packet *pkt, uint32_t timeStamp, uint8_t payloadType, uint16_t marker);
74419e95205Sopenharmony_ci/**
74519e95205Sopenharmony_ci *
74619e95205Sopenharmony_ci * @brief       Function AVDT_ConnectRsp(Retain)
74719e95205Sopenharmony_ci * @details     Respond to a connect request from ACP. AVDTP.ICS #Table 9-1, 9b-1 Establish signaling channel
74819e95205Sopenharmony_ci * @param[in]   bdAddr       Peer device address
74919e95205Sopenharmony_ci * @param[in]   errCode      Error code
75019e95205Sopenharmony_ci * @return      AVDT_SUCCESS if successful, otherwise error.
75119e95205Sopenharmony_ci *
75219e95205Sopenharmony_ci */
75319e95205Sopenharmony_ciBTSTACK_API uint16_t AVDT_ConnectRsp(const BtAddr *bdAddr, uint8_t errCode);
75419e95205Sopenharmony_ci
75519e95205Sopenharmony_ci/**
75619e95205Sopenharmony_ci *
75719e95205Sopenharmony_ci * @brief       Function AVDT_ConnectReq
75819e95205Sopenharmony_ci * @details     This function send an AVDT_CONNECT_REQ from INT to ACP.When the connection is completed, an
75919e95205Sopenharmony_ci *              AVDT_CONNECT_CFM_EVT is sent to the application via its control callback function. AVDTP.ICS #Table 3-1,
76019e95205Sopenharmony_ci *              3b-1 Establish signaling channel
76119e95205Sopenharmony_ci * @param[in]   bdAddr   Peer device address
76219e95205Sopenharmony_ci * @param[in]   role     Local role
76319e95205Sopenharmony_ci * @return      AVDT_SUCCESS if successful, otherwise error.
76419e95205Sopenharmony_ci *
76519e95205Sopenharmony_ci */
76619e95205Sopenharmony_ciBTSTACK_API uint16_t AVDT_ConnectReq(const BtAddr *bdAddr, uint8_t role);
76719e95205Sopenharmony_ci
76819e95205Sopenharmony_ci/**
76919e95205Sopenharmony_ci *
77019e95205Sopenharmony_ci * @brief       Function AVDT_DisconnectReq
77119e95205Sopenharmony_ci * @details     This function send an AVDT_DISCONNECT_REQ from INT to ACP.When the connection is completed, an
77219e95205Sopenharmony_ci *              AVDT_DISCONNECT_CFM_EVT is sent to the application via its control callback function. AVDTP.ICS #Table
77319e95205Sopenharmony_ci *              3-2, 3b-2 Establish signaling channel
77419e95205Sopenharmony_ci * @param[in]   bdAddr       Peer device address
77519e95205Sopenharmony_ci * @return      AVDT_SUCCESS if successful, otherwise error.
77619e95205Sopenharmony_ci *
77719e95205Sopenharmony_ci */
77819e95205Sopenharmony_ciBTSTACK_API uint16_t AVDT_DisconnectReq(const BtAddr *bdAddr);
77919e95205Sopenharmony_ci
78019e95205Sopenharmony_ci/**
78119e95205Sopenharmony_ci *
78219e95205Sopenharmony_ci * @brief       Function AVDT_DisconnectRsp(Retain)
78319e95205Sopenharmony_ci * @details     Respond to a disconnect request from ACP.
78419e95205Sopenharmony_ci *              AVDTP.ICS #Table 9-2, 9b-2 Establish signaling channel
78519e95205Sopenharmony_ci * @param[in]   bdAddr       Peer device address
78619e95205Sopenharmony_ci * @param[in]   errCode      Error code
78719e95205Sopenharmony_ci * @return      AVDT_SUCCESS if successful, otherwise error.
78819e95205Sopenharmony_ci *
78919e95205Sopenharmony_ci */
79019e95205Sopenharmony_ciBTSTACK_API uint16_t AVDT_DisconnectRsp(const BtAddr *bdAddr, uint8_t errCode);
79119e95205Sopenharmony_ci
79219e95205Sopenharmony_ci/**
79319e95205Sopenharmony_ci *
79419e95205Sopenharmony_ci * @brief       Function AVDT_GetL2capChannel(Retain)
79519e95205Sopenharmony_ci * @details     Get the L2CAP CID used by the handle.
79619e95205Sopenharmony_ci * @param[in]   handle       Handle of stream
79719e95205Sopenharmony_ci * @return      return channel id if successful, otherwise 0.
79819e95205Sopenharmony_ci *
79919e95205Sopenharmony_ci */
80019e95205Sopenharmony_ciBTSTACK_API uint16_t AVDT_GetL2capChannel(uint16_t handle);
80119e95205Sopenharmony_ci
80219e95205Sopenharmony_ci/**
80319e95205Sopenharmony_ci *
80419e95205Sopenharmony_ci * @brief       Function AVDT_Rej(Retain)
80519e95205Sopenharmony_ci * @details     Send a reject message from ACP to INT.
80619e95205Sopenharmony_ci *              AVDTP.ICS #Table 11-6,11b-6,16-3 General Reject Response Includes Signal ID,General reject message
80719e95205Sopenharmony_ci * @param[in]   handle       Handle of stream
80819e95205Sopenharmony_ci * @param[in]   bdAddr       Peer device address
80919e95205Sopenharmony_ci * @param[in]   cmd          Signaling of AVDT
81019e95205Sopenharmony_ci * @param[in]   transLabel    Label of cmd received
81119e95205Sopenharmony_ci * @param[in]   errInfo      Error info rejected for command received
81219e95205Sopenharmony_ci * @return      void
81319e95205Sopenharmony_ci *
81419e95205Sopenharmony_ci */
81519e95205Sopenharmony_ciBTSTACK_API void AVDT_Rej(
81619e95205Sopenharmony_ci    uint16_t handle, const BtAddr *bdAddr, uint8_t cmd, uint8_t transLabel, AvdtRejErrInfo errInfo);
81719e95205Sopenharmony_ci
81819e95205Sopenharmony_ci#ifdef __cplusplus
81919e95205Sopenharmony_ci}
82019e95205Sopenharmony_ci#endif
82119e95205Sopenharmony_ci
82219e95205Sopenharmony_ci#endif /* AVDTP_H */
823