1 /* 2 * Copyright (C) 2015-2020 Alibaba Group Holding Limited 3 */ 4 #ifndef _AVDTP_API_H 5 #define _AVDTP_API_H 6 7 #include "stdint.h" 8 #include "bluetooth.h" 9 10 /* Signal Commands */ 11 #define BTIF_AVDTP_SIG_DISCOVER 0x01 12 #define BTIF_AVDTP_SIG_GET_CAPABILITIES 0x02 13 #define BTIF_AVDTP_SIG_SET_CONFIG 0x03 14 #define BTIF_AVDTP_SIG_GET_CONFIG 0x04 15 #define BTIF_AVDTP_SIG_RECONFIG 0x05 16 #define BTIF_AVDTP_SIG_OPEN 0x06 17 #define BTIF_AVDTP_SIG_START 0x07 18 #define BTIF_AVDTP_SIG_CLOSE 0x08 19 #define BTIF_AVDTP_SIG_SUSPEND 0x09 20 #define BTIF_AVDTP_SIG_ABORT 0x0A 21 #define BTIF_AVDTP_SIG_SECURITY_CTRL 0x0B 22 #define BTIF_AVDTP_SIG_GET_ALL_CAPABILITIES 0x0C 23 #define BTIF_AVDTP_SIG_DELAYREPORT 0x0D 24 25 #ifndef avdtp_codec_t 26 #define avdtp_codec_t void 27 #endif 28 #ifndef avdtp_channel_t 29 #define avdtp_channel_t void 30 #endif 31 32 typedef uint8_t btif_avdtp_codec_type_t; 33 typedef uint16_t btif_avdtp_content_prot_type_t; 34 typedef uint8_t btif_avdtp_capability_type_t; 35 36 #define BTIF_AVDTP_CP_TYPE_DTCP 0x0001 37 38 #define BTIF_AVDTP_CP_TYPE_SCMS_T 0x0002 39 40 #define BTIF_AVDTP_SRV_CAT_MEDIA_TRANSPORT 0x01 41 #define BTIF_AVDTP_SRV_CAT_REPORTING 0x02 42 #define BTIF_AVDTP_SRV_CAT_RECOVERY 0x03 43 #define BTIF_AVDTP_SRV_CAT_CONTENT_PROTECTION 0x04 44 #define BTIF_AVDTP_SRV_CAT_HEADER_COMPRESSION 0x05 45 #define BTIF_AVDTP_SRV_CAT_MULTIPLEXING 0x06 46 #define BTIF_AVDTP_SRV_CAT_MEDIA_CODEC 0x07 47 #define BTIF_AVDTP_SRV_CAT_DELAY_REPORTING 0x08 48 49 typedef uint16_t btif_avdtp_codec_sample_rate_t; 50 51 #define BTIF_AVDTP_CODEC_TYPE_SBC 0x00 52 53 #define BTIF_AVDTP_CODEC_TYPE_MPEG1_2_AUDIO 0x01 54 55 #define BTIF_AVDTP_CODEC_TYPE_MPEG2_4_AAC 0x02 56 57 #define BTIF_AVDTP_CODEC_TYPE_ATRAC 0x04 58 59 #define BTIF_AVDTP_CODEC_TYPE_OPUS 0x08 60 61 #define BTIF_AVDTP_CODEC_TYPE_H263 0x01 62 63 #define BTIF_AVDTP_CODEC_TYPE_MPEG4_VSP 0x02 64 65 #define BTIF_AVDTP_CODEC_TYPE_H263_PROF3 0x03 66 67 #define BTIF_AVDTP_CODEC_TYPE_H263_PROF8 0x04 68 69 #define BTIF_AVDTP_CODEC_TYPE_LHDC 0xFF 70 71 #define BTIF_AVDTP_CODEC_TYPE_NON_A2DP 0xFF 72 73 #define BTIF_AVDTP_MAX_CODEC_ELEM_SIZE 10 74 75 #define BTIF_AVDTP_MAX_CP_VALUE_SIZE 10 76 77 typedef uint8_t btif_avdtp_stream_state_t; 78 79 /** The stream is idle and not configured. Streaming is not possible. 80 */ 81 #define BTIF_AVDTP_STRM_STATE_IDLE 0 82 83 /** A stream is configured, but not open. This state will only occur in 84 * certain cases where a request to open the stream is rejected, and the 85 * operation cannot be aborted. 86 * 87 * AVDTP_AbortStream() must be called to exit this state. 88 */ 89 #define BTIF_AVDTP_STRM_STATE_CONFIGURED 1 90 91 /** The stream is open and configured. Streaming can be initiated after the 92 * stream is open by calling AVDTP_StartStream(). 93 */ 94 #define BTIF_AVDTP_STRM_STATE_OPEN 2 95 96 /** The stream is active. Stream data (media packets) can be sent only in 97 * this state. 98 */ 99 #define BTIF_AVDTP_STRM_STATE_STREAMING 3 100 101 #define BTIF_AVDTP_STRM_STATE_CLOSING 4 102 103 #define BTIF_AVDTP_STRM_STATE_ABORTING 5 104 105 typedef U8 btif_avdtp_error_t; 106 107 #define BTIF_AVDTP_ERR_NO_ERROR 0x00 108 109 #define BTIF_AVDTP_ERR_BAD_HEADER_FORMAT 0x01 110 111 #define BTIF_AVDTP_ERR_BAD_LENGTH 0x11 112 113 #define BTIF_AVDTP_ERR_BAD_ACP_SEID 0x12 114 115 #define BTIF_AVDTP_ERR_IN_USE 0x13 116 117 #define BTIF_AVDTP_ERR_NOT_IN_USE 0x14 118 119 #define BTIF_AVDTP_ERR_BAD_SERV_CATEGORY 0x17 120 121 #define BTIF_AVDTP_ERR_BAD_PAYLOAD_FORMAT 0x18 122 123 #define BTIF_AVDTP_ERR_NOT_SUPPORTED_COMMAND 0x19 124 125 #define BTIF_AVDTP_ERR_INVALID_CAPABILITIES 0x1A 126 127 #define BTIF_AVDTP_ERR_BAD_RECOVERY_TYPE 0x22 128 129 #define BTIF_AVDTP_ERR_BAD_MEDIA_TRANSPORT_FORMAT 0x23 130 131 #define BTIF_AVDTP_ERR_BAD_RECOVERY_FORMAT 0x25 132 133 #define BTIF_AVDTP_ERR_BAD_ROHC_FORMAT 0x26 134 135 #define BTIF_AVDTP_ERR_BAD_CP_FORMAT 0x27 136 137 #define BTIF_AVDTP_ERR_BAD_MULTIPLEXING_FORMAT 0x28 138 139 #define BTIF_AVDTP_ERR_UNSUPPORTED_CONFIGURATION 0x29 140 141 #define BTIF_AVDTP_ERR_BAD_STATE 0x31 142 143 #define BTIF_AVDTP_ERR_NOT_SUPPORTED_CODEC_TYPE 0xC2 144 145 #define BTIF_AVDTP_ERR_UNKNOWN_ERROR 0xFF 146 147 typedef struct { 148 btif_avdtp_content_prot_type_t cpType; 149 uint8_t dataLen; 150 uint8_t *data; 151 }__attribute__((packed)) btif_avdtp_content_prot_t; 152 153 typedef struct { 154 btif_avdtp_codec_type_t codecType; 155 uint8_t elemLen; 156 uint8_t *elements; 157 uint8_t *pstreamflags; 158 bool discoverable; 159 }__attribute__((packed)) btif_avdtp_codec_t ; 160 161 typedef struct { 162 btif_avdtp_capability_type_t type; 163 union { 164 btif_avdtp_codec_t codec; 165 btif_avdtp_content_prot_t cp; 166 } p; 167 } btif_avdtp_capability_t; 168 169 typedef struct { 170 btif_avdtp_codec_t codec; 171 btif_avdtp_content_prot_t cp; 172 BOOL delayReporting; 173 } btif_avdtp_config_request_t; 174 175 176 typedef uint8_t btif_avdtp_streamId_t; 177 typedef uint8_t btif_avdtp_media_type; 178 typedef uint8_t btif_avdtp_strm_endpoint_type_t; 179 180 typedef struct { 181 btif_avdtp_streamId_t id; 182 bool inUse; 183 btif_avdtp_media_type mediaType; 184 btif_avdtp_strm_endpoint_type_t streamType; 185 } btif_avdtp_stream_info_t; 186 187 typedef struct { 188 U8 version; 189 U8 padding; 190 U8 marker; 191 U8 payloadType; 192 U16 sequenceNumber; 193 U32 timestamp; 194 U32 ssrc; 195 U8 csrcCount; 196 U32 csrcList[15]; 197 } btif_avdtp_media_header_t; 198 typedef btif_avdtp_media_header_t btif_media_header_t; 199 200 typedef void btif_avdtp_stream_t; 201 202 #ifdef __cplusplus 203 extern "C" { 204 205 #endif 206 btif_avdtp_codec_type_t btif_avdtp_get_stream_codec_type(btif_avdtp_stream_t * stream); 207 208 #ifdef __cplusplus 209 } 210 #endif /* */ 211 #endif /* */ 212