1 /****************************************************************************** 2 * 3 * Copyright 2002-2012 Broadcom Corporation 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at: 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 ******************************************************************************/ 18 19 /****************************************************************************** 20 * 21 * This contains constants definitions and other information from the AVDTP 22 * specification. This file is intended for use internal to AVDT only. 23 * 24 ******************************************************************************/ 25 #ifndef AVDT_DEFS_H 26 #define AVDT_DEFS_H 27 28 /***************************************************************************** 29 * constants 30 ****************************************************************************/ 31 32 /* signalling packet type */ 33 #define AVDT_PKT_TYPE_SINGLE 0 /* single packet */ 34 #define AVDT_PKT_TYPE_START 1 /* start packet */ 35 #define AVDT_PKT_TYPE_CONT 2 /* continue packet */ 36 #define AVDT_PKT_TYPE_END 3 /* end packet */ 37 38 /* signalling message type */ 39 #define AVDT_MSG_TYPE_CMD 0 /* command */ 40 #define AVDT_MSG_TYPE_GRJ 1 /* general reject */ 41 #define AVDT_MSG_TYPE_RSP 2 /* response accept */ 42 #define AVDT_MSG_TYPE_REJ 3 /* response reject */ 43 44 /* signalling messages */ 45 #define AVDT_SIG_DISCOVER 1 /* discover */ 46 #define AVDT_SIG_GETCAP 2 /* get capabilities */ 47 #define AVDT_SIG_SETCONFIG 3 /* set configuration */ 48 #define AVDT_SIG_GETCONFIG 4 /* get configuration */ 49 #define AVDT_SIG_RECONFIG 5 /* reconfigure */ 50 #define AVDT_SIG_OPEN 6 /* open */ 51 #define AVDT_SIG_START 7 /* start */ 52 #define AVDT_SIG_CLOSE 8 /* close */ 53 #define AVDT_SIG_SUSPEND 9 /* suspend */ 54 #define AVDT_SIG_ABORT 10 /* abort */ 55 #define AVDT_SIG_SECURITY 11 /* security control */ 56 #define AVDT_SIG_GET_ALLCAP 12 /* get all capabilities */ 57 #define AVDT_SIG_DELAY_RPT 13 /* delay report */ 58 59 /* maximum signal value */ 60 #define AVDT_SIG_MAX AVDT_SIG_DELAY_RPT 61 62 /* used for general reject */ 63 #define AVDT_SIG_NONE 0 64 65 /* service category information element field values */ 66 #define AVDT_CAT_TRANS 1 /* Media Transport */ 67 #define AVDT_CAT_REPORT 2 /* Reporting */ 68 #define AVDT_CAT_RECOV 3 /* Recovery */ 69 #define AVDT_CAT_PROTECT 4 /* Content Protection */ 70 #define AVDT_CAT_HDRCMP 5 /* Header Compression */ 71 #define AVDT_CAT_MUX 6 /* Multiplexing */ 72 #define AVDT_CAT_CODEC 7 /* Media Codec */ 73 #define AVDT_CAT_DELAY_RPT 8 /* Delay Reporting */ 74 #define AVDT_CAT_MAX_CUR AVDT_CAT_DELAY_RPT 75 76 /* min/max lengths of service category information elements */ 77 #define AVDT_LEN_TRANS_MIN 0 78 #define AVDT_LEN_REPORT_MIN 0 79 #define AVDT_LEN_RECOV_MIN 3 80 #define AVDT_LEN_PROTECT_MIN 2 81 #define AVDT_LEN_HDRCMP_MIN 1 82 #define AVDT_LEN_MUX_MIN 3 83 #define AVDT_LEN_CODEC_MIN 2 84 #define AVDT_LEN_DELAY_RPT_MIN 0 85 86 #define AVDT_LEN_TRANS_MAX 0 87 #define AVDT_LEN_REPORT_MAX 0 88 #define AVDT_LEN_RECOV_MAX 3 89 #define AVDT_LEN_PROTECT_MAX 255 90 #define AVDT_LEN_HDRCMP_MAX 1 91 #define AVDT_LEN_MUX_MAX 7 92 #define AVDT_LEN_CODEC_MAX 255 93 #define AVDT_LEN_DELAY_RPT_MAX 0 94 95 /* minimum possible size of configuration or capabilities data */ 96 #define AVDT_LEN_CFG_MIN 2 97 98 /* minimum and maximum lengths for different message types */ 99 #define AVDT_LEN_SINGLE 1 100 #define AVDT_LEN_SETCONFIG_MIN 2 101 #define AVDT_LEN_RECONFIG_MIN 1 102 #define AVDT_LEN_MULTI_MIN 1 103 #define AVDT_LEN_SECURITY_MIN 1 104 #define AVDT_LEN_DELAY_RPT 3 105 106 /* header lengths for different packet types */ 107 #define AVDT_LEN_TYPE_SINGLE 2 /* single packet */ 108 #define AVDT_LEN_TYPE_START 3 /* start packet */ 109 #define AVDT_LEN_TYPE_CONT 1 /* continue packet */ 110 #define AVDT_LEN_TYPE_END 1 /* end packet */ 111 112 /* length of general reject message */ 113 #define AVDT_LEN_GEN_REJ 2 114 115 /* recovery service capabilities information elements */ 116 /* min value for maximum recovery window */ 117 #define AVDT_RECOV_MRWS_MIN 0x01 118 /* max value for maximum recovery window */ 119 #define AVDT_RECOV_MRWS_MAX 0x18 120 /* min value for maximum number of media packets */ 121 #define AVDT_RECOV_MNMP_MIN 0x01 122 /* max value for maximum number of media packets */ 123 #define AVDT_RECOV_MNMP_MAX 0x18 124 125 /* SEID value range */ 126 #define AVDT_SEID_MIN 0x01 127 #define AVDT_SEID_MAX 0x3E 128 129 /* first byte of media packet header */ 130 #define AVDT_MEDIA_OCTET1 0x80 131 132 /***************************************************************************** 133 * message parsing and building macros 134 ****************************************************************************/ 135 136 #define AVDT_MSG_PRS_HDR(p, lbl, pkt, msg) \ 137 do { \ 138 (lbl) = (*(p) >> 4) & 0x0F; \ 139 (pkt) = (*(p) >> 2) & 0x03; \ 140 (msg) = *(p)++ & 0x03; \ 141 } while (0) 142 143 #define AVDT_MSG_PRS_DISC(p, seid, in_use, type, tsep) \ 144 do { \ 145 (seid) = *(p) >> 2; \ 146 (in_use) = (*(p)++ >> 1) & 0x01; \ 147 (type) = (*(p) >> 4) & 0x0F; \ 148 (tsep) = (*(p)++ >> 3) & 0x01; \ 149 } while (0) 150 151 #define AVDT_MSG_PRS_SIG(p, sig) \ 152 do { \ 153 (sig) = (*(p)++) & 0x3F; \ 154 } while (0) 155 156 #define AVDT_MSG_PRS_SEID(p, seid) \ 157 do { \ 158 (seid) = ((*(p)++) >> 2) & 0x3F; \ 159 } while (0) 160 161 #define AVDT_MSG_PRS_PKT_TYPE(p, pkt) \ 162 do { \ 163 (pkt) = (*(p) >> 2) & 0x03; \ 164 } while (0) 165 166 #define AVDT_MSG_PRS_OCTET1(p, o_v, o_p, o_x, o_cc) \ 167 do { \ 168 (o_v) = (*(p) >> 6) & 0x02; \ 169 (o_p) = (*(p) >> 5) & 0x01; \ 170 (o_x) = (*(p) >> 4) & 0x01; \ 171 (o_cc) = (*(p)++) & 0x0F; \ 172 } while (0) 173 174 #define AVDT_MSG_PRS_RPT_OCTET1(p, o_v, o_p, o_cc) \ 175 do { \ 176 (o_v) = (*(p) >> 6) & 0x02; \ 177 (o_p) = (*(p) >> 5) & 0x01; \ 178 (o_cc) = (*(p)++) & 0x1F; \ 179 } while (0) 180 181 #define AVDT_MSG_PRS_M_PT(p, m_pt, marker) \ 182 do { \ 183 (marker) = (*(p) >> 7) & 0x01; \ 184 (m_pt) = (*(p)++) & 0x7F; \ 185 } while (0) 186 187 #define AVDT_MSG_BLD_HDR(p, lbl, pkt, msg) \ 188 do { \ 189 *(p)++ = (uint8_t)((lbl) << 4) | ((pkt) << 2) | (msg); \ 190 } while (0) 191 192 #define AVDT_MSG_BLD_DISC(p, seid, in_use, type, tsep) \ 193 do { \ 194 *(p)++ = (uint8_t)(((seid) << 2) | ((in_use) << 1)); \ 195 *(p)++ = (uint8_t)(((type) << 4) | ((tsep) << 3)); \ 196 } while (0) 197 198 #define AVDT_MSG_BLD_SIG(p, sig) \ 199 do { \ 200 *(p)++ = (uint8_t)(sig); \ 201 } while (0) 202 203 #define AVDT_MSG_BLD_SEID(p, seid) \ 204 do { \ 205 *(p)++ = (uint8_t)((seid) << 2); \ 206 } while (0) 207 208 #define AVDT_MSG_BLD_ERR(p, err) \ 209 do { \ 210 *(p)++ = (uint8_t)(err); \ 211 } while (0) 212 213 #define AVDT_MSG_BLD_PARAM(p, param) \ 214 do { \ 215 *(p)++ = (uint8_t)(param); \ 216 } while (0) 217 218 #define AVDT_MSG_BLD_NOSP(p, nosp) \ 219 do { \ 220 *(p)++ = (uint8_t)(nosp); \ 221 } while (0) 222 223 #endif /* AVDT_DEFS_H */ 224