avrc_int.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /******************************************************************************
  2. *
  3. * Copyright (C) 2003-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. * VRCP internal header file.
  21. *
  22. ******************************************************************************/
  23. #ifndef AVRC_INT_H
  24. #define AVRC_INT_H
  25. #include "avct_defs.h"
  26. #include "stack/avrc_api.h"
  27. #if (AVRC_INCLUDED == TRUE)
  28. /* DEBUG FLAGS
  29. *
  30. * #define META_DEBUG_ENABLED
  31. */
  32. /*****************************************************************************
  33. ** Constants
  34. *****************************************************************************/
  35. /* Number of attributes in AVRC SDP record. */
  36. #define AVRC_NUM_ATTR 6
  37. /* Number of protocol elements in protocol element list. */
  38. #define AVRC_NUM_PROTO_ELEMS 2
  39. #ifndef AVRC_MIN_CMD_LEN
  40. #define AVRC_MIN_CMD_LEN 20
  41. #endif
  42. #define AVRC_UNIT_OPRND_BYTES 5
  43. #define AVRC_SUB_OPRND_BYTES 4
  44. #define AVRC_SUBRSP_OPRND_BYTES 3
  45. #define AVRC_SUB_PAGE_MASK 7
  46. #define AVRC_SUB_PAGE_SHIFT 4
  47. #define AVRC_SUB_EXT_CODE 7
  48. #define AVRC_PASS_OP_ID_MASK 0x7F
  49. #define AVRC_PASS_STATE_MASK 0x80
  50. #define AVRC_CMD_OPRND_PAD 0xFF
  51. #define AVRC_CTYPE_MASK 0x0F
  52. #define AVRC_SUBTYPE_MASK 0xF8
  53. #define AVRC_SUBTYPE_SHIFT 3
  54. #define AVRC_SUBID_MASK 0x07
  55. #define AVRC_SUBID_IGNORE 0x07
  56. #define AVRC_SINGLE_PARAM_SIZE 1
  57. #define AVRC_METADATA_PKT_TYPE_MASK 0x03
  58. #define AVRC_PASS_THOUGH_MSG_MASK 0x80 /* MSB of msg_type indicates the PAS THROUGH msg */
  59. #define AVRC_VENDOR_UNIQUE_MASK 0x70 /* vendor unique id */
  60. /* Company ID is 24-bit integer We can not use the macros in stack/bt_types.h */
  61. #define AVRC_CO_ID_TO_BE_STREAM(p, u32) {*(p)++ = (UINT8)((u32) >> 16); *(p)++ = (UINT8)((u32) >> 8); *(p)++ = (UINT8)(u32); }
  62. #define AVRC_BE_STREAM_TO_CO_ID(u32, p) {u32 = (((UINT32)(*((p) + 2))) + (((UINT32)(*((p) + 1))) << 8) + (((UINT32)(*(p))) << 16)); (p) += 3;}
  63. #define AVRC_AVC_HDR_SIZE 3 /* ctype, subunit*, opcode */
  64. #define AVRC_MIN_META_HDR_SIZE 4 /* pdu id(1), packet type(1), param len(2) */
  65. #define AVRC_MIN_BROWSE_HDR_SIZE 3 /* pdu id(1), param len(2) */
  66. #define AVRC_VENDOR_HDR_SIZE 6 /* ctype, subunit*, opcode, CO_ID */
  67. #define AVRC_MSG_VENDOR_OFFSET 23
  68. #define AVRC_MIN_VENDOR_SIZE (AVRC_MSG_VENDOR_OFFSET + BT_HDR_SIZE + AVRC_MIN_META_HDR_SIZE)
  69. #define AVRC_PASS_THRU_SIZE 8
  70. #define AVRC_MSG_PASS_THRU_OFFSET 25
  71. #define AVRC_MIN_PASS_THRU_SIZE (AVRC_MSG_PASS_THRU_OFFSET + BT_HDR_SIZE + 4)
  72. #define AVRC_MIN_BROWSE_SIZE (AVCT_BROWSE_OFFSET + BT_HDR_SIZE + AVRC_MIN_BROWSE_HDR_SIZE)
  73. #define AVRC_CTRL_PKT_LEN(pf, pk) {pf = (UINT8 *)((pk) + 1) + (pk)->offset + 2;}
  74. #define AVRC_MAX_CTRL_DATA_LEN (AVRC_PACKET_LEN)
  75. /*****************************************************************************
  76. ** Type definitions
  77. *****************************************************************************/
  78. #if (AVRC_METADATA_INCLUDED == TRUE)
  79. /* type for Metadata fragmentation control block */
  80. typedef struct {
  81. BT_HDR *p_fmsg; /* the fragmented message */
  82. UINT8 frag_pdu; /* the PDU ID for fragmentation */
  83. BOOLEAN frag_enabled; /* fragmentation flag */
  84. } tAVRC_FRAG_CB;
  85. /* type for Metadata re-assembly control block */
  86. typedef struct {
  87. BT_HDR *p_rmsg; /* the received message */
  88. UINT16 rasm_offset; /* re-assembly flag, the offset of the start fragment */
  89. UINT8 rasm_pdu; /* the PDU ID for re-assembly */
  90. } tAVRC_RASM_CB;
  91. #endif
  92. typedef struct {
  93. tAVRC_CONN_CB ccb[AVCT_NUM_CONN];
  94. #if (AVRC_METADATA_INCLUDED == TRUE)
  95. tAVRC_FRAG_CB fcb[AVCT_NUM_CONN];
  96. tAVRC_RASM_CB rcb[AVCT_NUM_CONN];
  97. #endif
  98. tAVRC_FIND_CBACK *p_cback; /* pointer to application callback */
  99. tSDP_DISCOVERY_DB *p_db; /* pointer to discovery database */
  100. UINT16 service_uuid; /* service UUID to search */
  101. UINT8 trace_level;
  102. } tAVRC_CB;
  103. #ifdef __cplusplus
  104. extern "C"
  105. {
  106. #endif
  107. /******************************************************************************
  108. ** Main Control Block
  109. *******************************************************************************/
  110. #if AVRC_DYNAMIC_MEMORY == FALSE
  111. extern tAVRC_CB avrc_cb;
  112. #else
  113. extern tAVRC_CB *avrc_cb_ptr;
  114. #define avrc_cb (*avrc_cb_ptr)
  115. #endif
  116. extern BOOLEAN avrc_is_valid_pdu_id(UINT8 pdu_id);
  117. extern BOOLEAN avrc_is_valid_player_attrib_value(UINT8 attrib, UINT8 value);
  118. extern BT_HDR *avrc_alloc_ctrl_pkt (UINT8 pdu);
  119. extern tAVRC_STS avrc_pars_pass_thru(tAVRC_MSG_PASS *p_msg, UINT16 *p_vendor_unique_id);
  120. extern UINT8 avrc_opcode_from_pdu(UINT8 pdu);
  121. extern BOOLEAN avrc_is_valid_opcode(UINT8 opcode);
  122. #ifdef __cplusplus
  123. }
  124. #endif
  125. #endif ///AVRC_INCLUDED == TRUE
  126. #endif /* AVRC_INT_H */