avdt_defs.h 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  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. * This contains constants definitions and other information from the AVDTP
  21. * specification. This file is intended for use internal to AVDT only.
  22. *
  23. ******************************************************************************/
  24. #ifndef AVDT_DEFS_H
  25. #define AVDT_DEFS_H
  26. /*****************************************************************************
  27. * constants
  28. ****************************************************************************/
  29. /* signalling packet type */
  30. #define AVDT_PKT_TYPE_SINGLE 0 /* single packet */
  31. #define AVDT_PKT_TYPE_START 1 /* start packet */
  32. #define AVDT_PKT_TYPE_CONT 2 /* continue packet */
  33. #define AVDT_PKT_TYPE_END 3 /* end packet */
  34. /* signalling message type */
  35. #define AVDT_MSG_TYPE_CMD 0 /* command */
  36. #define AVDT_MSG_TYPE_GRJ 1 /* general reject */
  37. #define AVDT_MSG_TYPE_RSP 2 /* response accept */
  38. #define AVDT_MSG_TYPE_REJ 3 /* response reject */
  39. /* signalling messages */
  40. #define AVDT_SIG_DISCOVER 1 /* discover */
  41. #define AVDT_SIG_GETCAP 2 /* get capabilities */
  42. #define AVDT_SIG_SETCONFIG 3 /* set configuration */
  43. #define AVDT_SIG_GETCONFIG 4 /* get configuration */
  44. #define AVDT_SIG_RECONFIG 5 /* reconfigure */
  45. #define AVDT_SIG_OPEN 6 /* open */
  46. #define AVDT_SIG_START 7 /* start */
  47. #define AVDT_SIG_CLOSE 8 /* close */
  48. #define AVDT_SIG_SUSPEND 9 /* suspend */
  49. #define AVDT_SIG_ABORT 10 /* abort */
  50. #define AVDT_SIG_SECURITY 11 /* security control */
  51. #define AVDT_SIG_GET_ALLCAP 12 /* get all capabilities */
  52. #define AVDT_SIG_DELAY_RPT 13 /* delay report */
  53. /* maximum signal value */
  54. #define AVDT_SIG_MAX AVDT_SIG_DELAY_RPT
  55. /* used for general reject */
  56. #define AVDT_SIG_NONE 0
  57. /* some maximum and minimum sizes of signalling messages */
  58. #define AVDT_DISCOVER_REQ_MIN 1
  59. #define AVDT_DISCOVER_REQ_MAX 124
  60. /* service category information element field values */
  61. #define AVDT_CAT_TRANS 1 /* Media Transport */
  62. #define AVDT_CAT_REPORT 2 /* Reporting */
  63. #define AVDT_CAT_RECOV 3 /* Recovery */
  64. #define AVDT_CAT_PROTECT 4 /* Content Protection */
  65. #define AVDT_CAT_HDRCMP 5 /* Header Compression */
  66. #define AVDT_CAT_MUX 6 /* Multiplexing */
  67. #define AVDT_CAT_CODEC 7 /* Media Codec */
  68. #define AVDT_CAT_DELAY_RPT 8 /* Delay Reporting */
  69. #define AVDT_CAT_MAX_CUR AVDT_CAT_DELAY_RPT
  70. /* min/max lengths of service category information elements */
  71. #define AVDT_LEN_TRANS_MIN 0
  72. #define AVDT_LEN_REPORT_MIN 0
  73. #define AVDT_LEN_RECOV_MIN 3
  74. #define AVDT_LEN_PROTECT_MIN 2
  75. #define AVDT_LEN_HDRCMP_MIN 1
  76. #define AVDT_LEN_MUX_MIN 3
  77. #define AVDT_LEN_CODEC_MIN 2
  78. #define AVDT_LEN_DELAY_RPT_MIN 0
  79. #define AVDT_LEN_TRANS_MAX 0
  80. #define AVDT_LEN_REPORT_MAX 0
  81. #define AVDT_LEN_RECOV_MAX 3
  82. #define AVDT_LEN_PROTECT_MAX 255
  83. #define AVDT_LEN_HDRCMP_MAX 1
  84. #define AVDT_LEN_MUX_MAX 7
  85. #define AVDT_LEN_CODEC_MAX 255
  86. #define AVDT_LEN_DELAY_RPT_MAX 0
  87. /* minimum possible size of configuration or capabilities data */
  88. #define AVDT_LEN_CFG_MIN 2
  89. /* minimum and maximum lengths for different message types */
  90. #define AVDT_LEN_SINGLE 1
  91. #define AVDT_LEN_SETCONFIG_MIN 2
  92. #define AVDT_LEN_RECONFIG_MIN 1
  93. #define AVDT_LEN_MULTI_MIN 1
  94. #define AVDT_LEN_SECURITY_MIN 1
  95. #define AVDT_LEN_DELAY_RPT 3
  96. /* header lengths for different packet types */
  97. #define AVDT_LEN_TYPE_SINGLE 2 /* single packet */
  98. #define AVDT_LEN_TYPE_START 3 /* start packet */
  99. #define AVDT_LEN_TYPE_CONT 1 /* continue packet */
  100. #define AVDT_LEN_TYPE_END 1 /* end packet */
  101. /* length of general reject message */
  102. #define AVDT_LEN_GEN_REJ 2
  103. /* recovery service capabilities information elements */
  104. /* min value for maximum recovery window */
  105. #define AVDT_RECOV_MRWS_MIN 0x01
  106. /* max value for maximum recovery window */
  107. #define AVDT_RECOV_MRWS_MAX 0x18
  108. /* min value for maximum number of media packets */
  109. #define AVDT_RECOV_MNMP_MIN 0x01
  110. /* max value for maximum number of media packets */
  111. #define AVDT_RECOV_MNMP_MAX 0x18
  112. /* SEID value range */
  113. #define AVDT_SEID_MIN 0x01
  114. #define AVDT_SEID_MAX 0x3E
  115. /* first byte of media packet header */
  116. #define AVDT_MEDIA_OCTET1 0x80
  117. /* for adaptation layer header */
  118. /* coding of length field */
  119. #define AVDT_ALH_LCODE_MASK 0x03
  120. /* No length field present. Take length from l2cap */
  121. #define AVDT_ALH_LCODE_NONE 0x00
  122. /* 16bit length field */
  123. #define AVDT_ALH_LCODE_16BIT 0x01
  124. /* 9 bit length field, MSB = 0, 8 LSBs in 1 octet following */
  125. #define AVDT_ALH_LCODE_9BITM0 0x02
  126. /* 9 bit length field, MSB = 1, 8 LSBs in 1 octet following */
  127. #define AVDT_ALH_LCODE_9BITM1 0x03
  128. /* set this for continuation packet */
  129. #define AVDT_ALH_FRAG_MASK 0x04
  130. /*****************************************************************************
  131. * message parsing and building macros
  132. ****************************************************************************/
  133. #define AVDT_MSG_PRS_HDR(p, lbl, pkt, msg) \
  134. do { \
  135. (lbl) = (*(p) >> 4) & 0x0F; \
  136. (pkt) = (*(p) >> 2) & 0x03; \
  137. (msg) = *(p)++ & 0x03; \
  138. } while (0)
  139. #define AVDT_MSG_PRS_DISC(p, seid, in_use, type, tsep) \
  140. do { \
  141. (seid) = *(p) >> 2; \
  142. (in_use) = (*(p)++ >> 1) & 0x01; \
  143. (type) = (*(p) >> 4) & 0x0F; \
  144. (tsep) = (*(p)++ >> 3) & 0x01; \
  145. } while (0)
  146. #define AVDT_MSG_PRS_SIG(p, sig) \
  147. do { \
  148. (sig) = (*(p)++) & 0x3F; \
  149. } while (0)
  150. #define AVDT_MSG_PRS_SEID(p, seid) \
  151. do { \
  152. (seid) = ((*(p)++) >> 2) & 0x3F; \
  153. } while (0)
  154. #define AVDT_MSG_PRS_PKT_TYPE(p, pkt) \
  155. do { \
  156. (pkt) = (*(p) >> 2) & 0x03; \
  157. } while (0)
  158. #define AVDT_MSG_PRS_OCTET1(p, o_v, o_p, o_x, o_cc) \
  159. do { \
  160. (o_v) = (*(p) >> 6) & 0x02; \
  161. (o_p) = (*(p) >> 5) & 0x01; \
  162. (o_x) = (*(p) >> 4) & 0x01; \
  163. (o_cc) = (*(p)++) & 0x0F; \
  164. } while (0)
  165. #define AVDT_MSG_PRS_RPT_OCTET1(p, o_v, o_p, o_cc) \
  166. do { \
  167. (o_v) = (*(p) >> 6) & 0x02; \
  168. (o_p) = (*(p) >> 5) & 0x01; \
  169. (o_cc) = (*(p)++) & 0x1F; \
  170. } while (0)
  171. #define AVDT_MSG_PRS_M_PT(p, m_pt, marker) \
  172. do { \
  173. (marker) = (*(p) >> 7) & 0x01; \
  174. (m_pt) = (*(p)++) & 0x7F; \
  175. } while (0)
  176. #define AVDT_MSG_BLD_HDR(p, lbl, pkt, msg) \
  177. do { \
  178. *(p)++ = (uint8_t)((lbl) << 4) | ((pkt) << 2) | (msg); \
  179. } while (0)
  180. #define AVDT_MSG_BLD_DISC(p, seid, in_use, type, tsep) \
  181. do { \
  182. *(p)++ = (uint8_t)(((seid) << 2) | ((in_use) << 1)); \
  183. *(p)++ = (uint8_t)(((type) << 4) | ((tsep) << 3)); \
  184. } while (0)
  185. #define AVDT_MSG_BLD_SIG(p, sig) \
  186. do { \
  187. *(p)++ = (uint8_t)(sig); \
  188. } while (0)
  189. #define AVDT_MSG_BLD_SEID(p, seid) \
  190. do { \
  191. *(p)++ = (uint8_t)((seid) << 2); \
  192. } while (0)
  193. #define AVDT_MSG_BLD_ERR(p, err) \
  194. do { \
  195. *(p)++ = (uint8_t)(err); \
  196. } while (0)
  197. #define AVDT_MSG_BLD_PARAM(p, param) \
  198. do { \
  199. *(p)++ = (uint8_t)(param); \
  200. } while (0)
  201. #define AVDT_MSG_BLD_NOSP(p, nosp) \
  202. do { \
  203. *(p)++ = (uint8_t)(nosp); \
  204. } while (0)
  205. #endif /* AVDT_DEFS_H */