diff options
Diffstat (limited to 'stack/avrc/avrc_api.c')
-rw-r--r-- | stack/avrc/avrc_api.c | 557 |
1 files changed, 0 insertions, 557 deletions
diff --git a/stack/avrc/avrc_api.c b/stack/avrc/avrc_api.c index dd7e752..94425af 100644 --- a/stack/avrc/avrc_api.c +++ b/stack/avrc/avrc_api.c @@ -98,354 +98,6 @@ static UINT8 * avrc_get_data_ptr(BT_HDR *p_pkt) return p_data; } -#if (AVRC_METADATA_INCLUDED == TRUE) -/****************************************************************************** -** -** Function avrc_prep_end_frag -** -** Description This function prepares an end response fragment -** -** -** Returns Nothing. -** -******************************************************************************/ -static void avrc_prep_end_frag(UINT8 handle) -{ - tAVRC_FRAG_CB *p_fcb; - BT_HDR *p_pkt_new; - UINT8 *p_data; - - AVRC_TRACE_DEBUG0 ("avrc_prep_end_frag" ); - p_fcb = &avrc_cb.fcb[handle]; - p_pkt_new = p_fcb->p_fmsg; - p_pkt_new->len -= (AVRC_MAX_CTRL_DATA_LEN - AVRC_VENDOR_HDR_SIZE - AVRC_MIN_META_HDR_SIZE); - p_pkt_new->offset += (AVRC_MAX_CTRL_DATA_LEN - AVRC_VENDOR_HDR_SIZE - AVRC_MIN_META_HDR_SIZE); - p_data = (UINT8 *)(p_pkt_new+1) + p_pkt_new->offset; - *p_data++ = (AVRC_RSP_ACCEPT & AVRC_CTYPE_MASK); - *p_data++ = (AVRC_SUB_PANEL << AVRC_SUBTYPE_SHIFT); - *p_data++ = AVRC_OP_VENDOR; - AVRC_CO_ID_TO_BE_STREAM(p_data, AVRC_CO_METADATA); - *p_data++ = p_fcb->frag_pdu; - *p_data++ = AVRC_PKT_END; - UINT16_TO_BE_STREAM(p_data, (p_pkt_new->len - AVRC_VENDOR_HDR_SIZE - AVRC_MIN_META_HDR_SIZE)); /* 4=pdu, pkt_type & len */ -} - -/****************************************************************************** -** -** Function avrc_send_continue_frag -** -** Description This function sends a continue response fragment -** -** -** Returns Nothing. -** -******************************************************************************/ -static void avrc_send_continue_frag(UINT8 handle, UINT8 label) -{ - tAVRC_FRAG_CB *p_fcb; - BT_HDR *p_pkt_old, *p_pkt; - UINT8 *p_old, *p_data; - UINT8 cr = AVCT_RSP; - tAVRC_RSP rej_rsp; - - p_fcb = &avrc_cb.fcb[handle]; - p_pkt = p_fcb->p_fmsg; - - AVRC_TRACE_DEBUG1 ("avrc_send_continue_frag len(%d) / AVRC_MAX_CTRL_DATA_LEN", p_pkt->len ); - if (p_pkt->len > AVRC_MAX_CTRL_DATA_LEN) - { - p_pkt_old = p_fcb->p_fmsg; - p_pkt = (BT_HDR *)GKI_getbuf((UINT16)(AVRC_PACKET_LEN + AVCT_MSG_OFFSET + BT_HDR_SIZE)); - if (p_pkt) - { - p_pkt->len = AVRC_MAX_CTRL_DATA_LEN; - p_pkt->offset = AVCT_MSG_OFFSET; - p_pkt->layer_specific = p_pkt_old->layer_specific; - p_pkt->event = p_pkt_old->event; - p_old = (UINT8 *)(p_pkt_old+1) + p_pkt_old->offset; - p_data = (UINT8 *)(p_pkt+1) + p_pkt->offset; - memcpy (p_data, p_old, AVRC_MAX_CTRL_DATA_LEN); - /* use AVRC continue packet type */ - p_data += AVRC_VENDOR_HDR_SIZE; - p_data++; /* pdu */ - *p_data++ = AVRC_PKT_CONTINUE; - UINT16_TO_BE_STREAM(p_data, (AVRC_MAX_CTRL_DATA_LEN - AVRC_VENDOR_HDR_SIZE - 4)); /* 4=pdu, pkt_type & len */ - - /* prepare the left over for as an end fragment */ - avrc_prep_end_frag (handle); - } - else - { - /* use the current GKI buffer to send Internal error status */ - p_pkt = p_fcb->p_fmsg; - p_fcb->p_fmsg = NULL; - p_fcb->frag_enabled = FALSE; - AVRC_TRACE_ERROR0 ("AVRC_MsgReq no buffers for fragmentation - send internal error" ); - p_data = (UINT8 *)(p_pkt+1) + p_pkt->offset; - *p_data++ = AVRC_PDU_REQUEST_CONTINUATION_RSP; - *p_data++ = 0; - UINT16_TO_BE_STREAM(p_data, 0); - p_pkt->len = 4; - rej_rsp.pdu = AVRC_PDU_REQUEST_CONTINUATION_RSP; - rej_rsp.status = AVRC_STS_INTERNAL_ERR; - AVRC_BldResponse( handle, (tAVRC_RESPONSE *)&rej_rsp, &p_pkt); - cr = AVCT_RSP; - } - } - else - { - /* end fragment. clean the control block */ - p_fcb->frag_enabled = FALSE; - p_fcb->p_fmsg = NULL; - } - AVCT_MsgReq( handle, label, cr, p_pkt); -} - -/****************************************************************************** -** -** Function avrc_proc_vendor_command -** -** Description This function processes received vendor command. -** -** -** Returns if not NULL, the response to send right away. -** -******************************************************************************/ -static BT_HDR * avrc_proc_vendor_command(UINT8 handle, UINT8 label, - BT_HDR *p_pkt, tAVRC_MSG_VENDOR *p_msg) -{ - BT_HDR *p_rsp = NULL; - UINT8 *p_data; - UINT8 *p_begin; - UINT8 pkt_type; - BOOLEAN abort_frag = FALSE; - tAVRC_STS status = AVRC_STS_NO_ERROR; - tAVRC_FRAG_CB *p_fcb; - - p_begin = (UINT8 *)(p_pkt+1) + p_pkt->offset; - p_data = p_begin + AVRC_VENDOR_HDR_SIZE; - pkt_type = *(p_data + 1) & AVRC_PKT_TYPE_MASK; - - if (pkt_type != AVRC_PKT_SINGLE) - { - /* reject - commands can only be in single packets at AVRCP level */ - AVRC_TRACE_ERROR1 ("commands must be in single packet pdu:0x%x", *p_data ); - /* use the current GKI buffer to send the reject */ - status = AVRC_STS_BAD_CMD; - } - /* check if there are fragments waiting to be sent */ - else if (avrc_cb.fcb[handle].frag_enabled) - { - p_fcb = &avrc_cb.fcb[handle]; - if (p_msg->company_id == AVRC_CO_METADATA) - { - switch (*p_data) - { - case AVRC_PDU_ABORT_CONTINUATION_RSP: - /* aborted by CT - send accept response */ - abort_frag = TRUE; - p_begin = (UINT8 *)(p_pkt+1) + p_pkt->offset; - *p_begin = (AVRC_RSP_ACCEPT & AVRC_CTYPE_MASK); - if (*(p_data + 4) != p_fcb->frag_pdu) - { - *p_begin = (AVRC_RSP_REJ & AVRC_CTYPE_MASK); - *(p_data + 4) = AVRC_STS_BAD_PARAM; - } - else - { - p_data = (p_begin + AVRC_VENDOR_HDR_SIZE + 2); - UINT16_TO_BE_STREAM(p_data, 0); - p_pkt->len = (p_data - p_begin); - } - AVCT_MsgReq( handle, label, AVCT_RSP, p_pkt); - p_msg->hdr.opcode = AVRC_OP_DROP; /* used the p_pkt to send response */ - break; - - case AVRC_PDU_REQUEST_CONTINUATION_RSP: - if (*(p_data + 4) == p_fcb->frag_pdu) - { - avrc_send_continue_frag(handle, label); - p_msg->hdr.opcode = AVRC_OP_DROP_N_FREE; - } - else - { - /* the pdu id does not match - reject the command using the current GKI buffer */ - AVRC_TRACE_ERROR2("avrc_proc_vendor_command continue pdu: 0x%x does not match current re-assembly pdu: 0x%x", - *(p_data + 4), p_fcb->frag_pdu); - status = AVRC_STS_BAD_PARAM; - abort_frag = TRUE; - } - break; - - default: - /* implicit abort */ - abort_frag = TRUE; - } - } - else - { - abort_frag = TRUE; - /* implicit abort */ - } - - if (abort_frag) - { - if (p_fcb->p_fmsg) - GKI_freebuf(p_fcb->p_fmsg); - p_fcb->p_fmsg = NULL; - p_fcb->frag_enabled = FALSE; - } - } - - if (status != AVRC_STS_NO_ERROR) - { - /* use the current GKI buffer to build/send the reject message */ - p_data = (UINT8 *)(p_pkt+1) + p_pkt->offset; - *p_data++ = AVRC_RSP_REJ; - p_data += AVRC_VENDOR_HDR_SIZE; /* pdu */ - *p_data++ = 0; /* pkt_type */ - UINT16_TO_BE_STREAM(p_data, 1); /* len */ - *p_data++ = status; /* error code */ - p_pkt->len = AVRC_VENDOR_HDR_SIZE + 5; - p_rsp = p_pkt; - } - - return p_rsp; -} - -/****************************************************************************** -** -** Function avrc_proc_far_msg -** -** Description This function processes vendor command/response fragmetation -** and reassembly -** -** Returns 0, to report the message with msg_cback . -** -******************************************************************************/ -static UINT8 avrc_proc_far_msg(UINT8 handle, UINT8 label, UINT8 cr, BT_HDR **pp_pkt, tAVRC_MSG_VENDOR *p_msg) -{ - BT_HDR *p_pkt = *pp_pkt; - UINT8 *p_data; - BOOLEAN drop = FALSE; - BT_HDR *p_rsp = NULL; - BT_HDR *p_cmd = NULL; - BOOLEAN req_continue = FALSE; - BT_HDR *p_pkt_new = NULL; - UINT8 pkt_type; - UINT16 buf_len; - tAVRC_RASM_CB *p_rcb; - tAVRC_NEXT_CMD avrc_cmd; - - p_data = (UINT8 *)(p_pkt+1) + p_pkt->offset; - pkt_type = *(p_data + 1) & AVRC_PKT_TYPE_MASK; - AVRC_TRACE_DEBUG1 ("pkt_type %d", pkt_type ); - p_rcb = &avrc_cb.rcb[handle]; - if (p_msg->company_id == AVRC_CO_METADATA) - { - /* check if the message needs to be re-assembled */ - if (pkt_type == AVRC_PKT_SINGLE || pkt_type == AVRC_PKT_START) - { - /* previous fragments need to be dropped, when received another new message */ - p_rcb->rasm_offset = 0; - if (p_rcb->p_rmsg) - { - GKI_freebuf(p_rcb->p_rmsg); - p_rcb->p_rmsg = NULL; - } - } - - if (pkt_type != AVRC_PKT_SINGLE && cr == AVCT_RSP) - { - /* not a single response packet - need to re-assemble metadata messages */ - if (pkt_type == AVRC_PKT_START) - { - p_rcb->rasm_offset = p_pkt->offset; - p_rcb->p_rmsg = p_pkt; - /* set offset to point to where to copy next - use the same re-asm logic as AVCT */ - p_rcb->p_rmsg->offset += p_rcb->p_rmsg->len; - p_rcb->rasm_pdu = *p_data; - req_continue = TRUE; - } - else - { - /* get size of buffer holding assembled message */ - buf_len = GKI_get_buf_size (p_rcb->p_rmsg) - sizeof(BT_HDR); - /* adjust offset and len of fragment for header byte */ - p_pkt->offset += (AVRC_VENDOR_HDR_SIZE + AVRC_MIN_META_HDR_SIZE); - p_pkt->len -= (AVRC_VENDOR_HDR_SIZE + AVRC_MIN_META_HDR_SIZE); - /* verify length */ - if ((p_rcb->p_rmsg->offset + p_pkt->len) > buf_len) - { - AVRC_TRACE_WARNING0("Fragmented message too big! - report the partial message"); - p_pkt->len = buf_len - p_rcb->p_rmsg->offset; - pkt_type = AVRC_PKT_END; - } - - /* copy contents of p_pkt to p_rx_msg */ - memcpy((UINT8 *)(p_rcb->p_rmsg + 1) + p_rcb->p_rmsg->offset, - (UINT8 *)(p_pkt + 1) + p_pkt->offset, p_pkt->len); - - if (pkt_type == AVRC_PKT_END) - { - p_rcb->p_rmsg->offset = p_rcb->rasm_offset; - p_rcb->p_rmsg->len += p_pkt->len; - p_pkt_new = p_rcb->p_rmsg; - p_rcb->rasm_offset = 0; - p_rcb->p_rmsg = NULL; - p_msg->p_vendor_data = (UINT8 *)(p_pkt_new+1) + p_pkt_new->offset; - p_msg->hdr.ctype = p_msg->p_vendor_data[0] & AVRC_CTYPE_MASK; - p_msg->p_vendor_data += AVRC_VENDOR_HDR_SIZE; /* 6 = ctype, subunit*, opcode & CO_ID */ - p_msg->vendor_len = p_pkt_new->len - AVRC_VENDOR_HDR_SIZE; - p_data = p_msg->p_vendor_data + 1; /* skip pdu */ - *p_data++ = AVRC_PKT_SINGLE; - UINT16_TO_BE_STREAM(p_data, (p_msg->vendor_len - AVRC_MIN_META_HDR_SIZE)); - AVRC_TRACE_DEBUG3("end frag:%d, total len:%d, offset:%d", p_pkt->len, p_pkt_new->len, p_pkt_new->offset); - } - else - { - p_rcb->p_rmsg->offset += p_pkt->len; - p_rcb->p_rmsg->len += p_pkt->len; - p_pkt_new = NULL; - req_continue = TRUE; - } - GKI_freebuf(p_pkt); - *pp_pkt = p_pkt_new; - } - } - - if (cr == AVCT_CMD) - { - p_rsp = avrc_proc_vendor_command(handle, label, *pp_pkt, p_msg); - if (p_rsp) - { - AVCT_MsgReq( handle, label, AVCT_RSP, p_rsp); - drop = 3; - } - else if (p_msg->hdr.opcode == AVRC_OP_DROP) - { - drop = 1; - } - else if (p_msg->hdr.opcode == AVRC_OP_DROP_N_FREE) - drop = 4; - - } - else if (cr == AVCT_RSP && req_continue == TRUE) - { - avrc_cmd.pdu = AVRC_PDU_REQUEST_CONTINUATION_RSP; - avrc_cmd.status = AVRC_STS_NO_ERROR; - avrc_cmd.target_pdu = p_rcb->rasm_pdu; - if (AVRC_BldCommand ((tAVRC_COMMAND *)&avrc_cmd, &p_cmd) == AVRC_STS_NO_ERROR) - { - cr = AVCT_CMD; - drop = 2; - AVRC_MsgReq (handle, (UINT8)(label+1), cr, p_cmd); - } - } - } - return drop; -} -#endif /* (AVRC_METADATA_INCLUDED == TRUE) */ /****************************************************************************** ** @@ -497,17 +149,6 @@ static void avrc_msg_cback(UINT8 handle, UINT8 label, UINT8 cr, p_data = (UINT8 *)(p_pkt+1) + p_pkt->offset; memset(&msg, 0, sizeof(tAVRC_MSG) ); -#if ((AVRC_ADV_CTRL_INCLUDED == TRUE) && (AVCT_BROWSE_INCLUDED == TRUE)) - if (p_pkt->layer_specific == AVCT_DATA_BROWSE) - { - opcode = AVRC_OP_BROWSE; - msg.browse.hdr.ctype= cr; - msg.browse.p_browse_data = p_data; - msg.browse.browse_len = p_pkt->len; - msg.browse.p_browse_pkt = p_pkt; - } - else -#endif { msg.hdr.ctype = p_data[0] & AVRC_CTYPE_MASK; AVRC_TRACE_DEBUG4("avrc_msg_cback handle:%d, ctype:%d, offset:%d, len: %d", @@ -602,34 +243,6 @@ static void avrc_msg_cback(UINT8 handle, UINT8 label, UINT8 cr, p_msg->p_vendor_data = p_data; p_msg->vendor_len = p_pkt->len - (p_data - p_begin); -#if (AVRC_METADATA_INCLUDED == TRUE) - drop = avrc_proc_far_msg(handle, label, cr, &p_pkt, p_msg); - if (drop) - { - free = FALSE; - if (drop == 4) - free = TRUE; -#if (BT_USE_TRACES == TRUE) - switch (drop) - { - case 1: - p_drop_msg = "sent_frag"; - break; - case 2: - p_drop_msg = "req_cont"; - break; - case 3: - p_drop_msg = "sent_frag3"; - break; - case 4: - p_drop_msg = "sent_frag_free"; - break; - default: - p_drop_msg = "sent_fragd"; - } -#endif - } -#endif /* (AVRC_METADATA_INCLUDED == TRUE) */ break; case AVRC_OP_PASS_THRU: @@ -657,12 +270,6 @@ static void avrc_msg_cback(UINT8 handle, UINT8 label, UINT8 cr, msg.pass.p_pass_data = NULL; break; -#if ((AVRC_ADV_CTRL_INCLUDED == TRUE) && (AVCT_BROWSE_INCLUDED == TRUE)) - case AVRC_OP_BROWSE: - /* the event data is handled already. - * this empty "case" is to keep the message from being rejected by the default case. */ - break; -#endif default: if ((avrc_cb.ccb[handle].control & AVRC_CT_TARGET) && (cr == AVCT_CMD)) @@ -676,9 +283,6 @@ static void avrc_msg_cback(UINT8 handle, UINT8 label, UINT8 cr, } else /* drop the event */ { -#if ((AVRC_ADV_CTRL_INCLUDED == TRUE) && (AVCT_BROWSE_INCLUDED == TRUE)) - if (opcode != AVRC_OP_BROWSE) -#endif drop = TRUE; } @@ -717,12 +321,6 @@ static void avrc_msg_cback(UINT8 handle, UINT8 label, UINT8 cr, } #endif -#if ((AVRC_ADV_CTRL_INCLUDED == TRUE) && (AVCT_BROWSE_INCLUDED == TRUE)) - if (opcode == AVRC_OP_BROWSE && msg.browse.p_browse_pkt == NULL) - { - free = FALSE; - } -#endif if (free) GKI_freebuf(p_pkt); @@ -847,10 +445,6 @@ UINT16 AVRC_Open(UINT8 *p_handle, tAVRC_CONN_CB *p_ccb, BD_ADDR_PTR peer_addr) if (status == AVCT_SUCCESS) { memcpy(&avrc_cb.ccb[*p_handle], p_ccb, sizeof(tAVRC_CONN_CB)); -#if (AVRC_METADATA_INCLUDED == TRUE) - memset(&avrc_cb.fcb[*p_handle], 0, sizeof(tAVRC_FRAG_CB)); - memset(&avrc_cb.rcb[*p_handle], 0, sizeof(tAVRC_RASM_CB)); -#endif } AVRC_TRACE_DEBUG4("AVRC_Open role: %d, control:%d status:%d, handle:%d", cc.role, cc.control, status, *p_handle); @@ -881,43 +475,6 @@ UINT16 AVRC_Close(UINT8 handle) return AVCT_RemoveConn(handle); } -#if ((AVRC_ADV_CTRL_INCLUDED == TRUE) && (AVCT_BROWSE_INCLUDED == TRUE)) -/****************************************************************************** -** -** Function AVRC_OpenBrowse -** -** Description This function is called to open a browsing connection to AVCTP. -** The connection can be either an initiator or acceptor, as -** determined by the p_conn_role. -** The handle is returned by a previous call to AVRC_Open. -** -** Returns AVRC_SUCCESS if successful. -** AVRC_NO_RESOURCES if there are not enough resources to open -** the connection. -** -******************************************************************************/ -UINT16 AVRC_OpenBrowse(UINT8 handle, UINT8 conn_role) -{ - return AVCT_CreateBrowse(handle, conn_role); -} - -/****************************************************************************** -** -** Function AVRC_CloseBrowse -** -** Description Close a connection opened with AVRC_OpenBrowse(). -** This function is called when the -** application is no longer using a connection. -** -** Returns AVRC_SUCCESS if successful. -** AVRC_BAD_HANDLE if handle is invalid. -** -******************************************************************************/ -UINT16 AVRC_CloseBrowse(UINT8 handle) -{ - return AVCT_RemoveBrowse(handle); -} -#endif /****************************************************************************** ** @@ -937,121 +494,7 @@ UINT16 AVRC_CloseBrowse(UINT8 handle) ******************************************************************************/ UINT16 AVRC_MsgReq (UINT8 handle, UINT8 label, UINT8 ctype, BT_HDR *p_pkt) { -#if (AVRC_METADATA_INCLUDED == TRUE) - UINT8 *p_data; - UINT8 cr = AVCT_CMD; - BOOLEAN chk_frag = TRUE; - UINT8 *p_start = NULL; - tAVRC_FRAG_CB *p_fcb; - UINT16 len; - BT_HDR *p_pkt_new; -#if ((AVRC_ADV_CTRL_INCLUDED == TRUE) && (AVCT_BROWSE_INCLUDED == TRUE)) - UINT16 peer_mtu; -#endif - - if (!p_pkt) - return AVRC_BAD_PARAM; - - if (ctype >= AVRC_RSP_NOT_IMPL) - cr = AVCT_RSP; - - if (p_pkt->event == AVRC_OP_VENDOR) - { - /* add AVRCP Vendor Dependent headers */ - p_start = ((UINT8 *)(p_pkt + 1) + p_pkt->offset); - p_pkt->offset -= AVRC_VENDOR_HDR_SIZE; - p_pkt->len += AVRC_VENDOR_HDR_SIZE; - p_data = (UINT8 *)(p_pkt + 1) + p_pkt->offset; - *p_data++ = (ctype & AVRC_CTYPE_MASK); - *p_data++ = (AVRC_SUB_PANEL << AVRC_SUBTYPE_SHIFT); - *p_data++ = AVRC_OP_VENDOR; - AVRC_CO_ID_TO_BE_STREAM(p_data, AVRC_CO_METADATA); - } - else if (p_pkt->event == AVRC_OP_PASS_THRU) - { - /* add AVRCP Pass Through headers */ - p_start = ((UINT8 *)(p_pkt + 1) + p_pkt->offset); - p_pkt->offset -= AVRC_PASS_THRU_SIZE; - p_pkt->len += AVRC_PASS_THRU_SIZE; - p_data = (UINT8 *)(p_pkt + 1) + p_pkt->offset; - *p_data++ = (ctype & AVRC_CTYPE_MASK); - *p_data++ = (AVRC_SUB_PANEL << AVRC_SUBTYPE_SHIFT); - *p_data++ = AVRC_OP_PASS_THRU;/* opcode */ - *p_data++ = AVRC_ID_VENDOR; /* operation id */ - *p_data++ = 5; /* operation data len */ - AVRC_CO_ID_TO_BE_STREAM(p_data, AVRC_CO_METADATA); - } -#if ((AVRC_ADV_CTRL_INCLUDED == TRUE) && (AVCT_BROWSE_INCLUDED == TRUE)) - else - { - chk_frag = FALSE; - peer_mtu = AVCT_GetBrowseMtu (handle); - if (p_pkt->len > (peer_mtu-AVCT_HDR_LEN_SINGLE)) - { - AVRC_TRACE_ERROR3 ("p_pkt->len(%d) > peer_mtu(%d-%d)", p_pkt->len, peer_mtu, AVCT_HDR_LEN_SINGLE ); - GKI_freebuf(p_pkt); - return AVRC_MSG_TOO_BIG; - } - } -#endif - - /* abandon previous fragments */ - p_fcb = &avrc_cb.fcb[handle]; - if (p_fcb->frag_enabled) - p_fcb->frag_enabled = FALSE; - - if (p_fcb->p_fmsg) - { - GKI_freebuf(p_fcb->p_fmsg); - p_fcb->p_fmsg = NULL; - } - - /* AVRCP spec has not defined any control channel commands that needs fragmentation at this level - * check for fragmentation only on the response */ - if ((cr == AVCT_RSP) && (chk_frag == TRUE)) - { - if (p_pkt->len > AVRC_MAX_CTRL_DATA_LEN) - { - AVRC_TRACE_DEBUG1 ("p_pkt->len(%d) > AVRC_MAX_CTRL_DATA_LEN", p_pkt->len ); - p_pkt_new = (BT_HDR *)GKI_getbuf((UINT16)(AVRC_PACKET_LEN + AVCT_MSG_OFFSET + BT_HDR_SIZE)); - if (p_pkt_new) - { - p_fcb->frag_enabled = TRUE; - p_fcb->p_fmsg = p_pkt; - p_fcb->frag_pdu = *p_start; - p_pkt = p_pkt_new; - p_pkt_new = p_fcb->p_fmsg; - p_pkt->len = AVRC_MAX_CTRL_DATA_LEN; - p_pkt->offset = p_pkt_new->offset; - p_pkt->layer_specific = p_pkt_new->layer_specific; - p_pkt->event = p_pkt_new->event; - p_data = (UINT8 *)(p_pkt+1) + p_pkt->offset; - p_start -= AVRC_VENDOR_HDR_SIZE; - memcpy (p_data, p_start, AVRC_MAX_CTRL_DATA_LEN); - /* use AVRC start packet type */ - p_data += AVRC_VENDOR_HDR_SIZE; - p_data++; /* pdu */ - *p_data++ = AVRC_PKT_START; - len = (AVRC_MAX_CTRL_DATA_LEN - AVRC_VENDOR_HDR_SIZE - AVRC_MIN_META_HDR_SIZE); /* 4 pdu, pkt_type & len */ - UINT16_TO_BE_STREAM(p_data, len); - - /* prepare the left over for as an end fragment */ - avrc_prep_end_frag (handle); - AVRC_TRACE_DEBUG3 ("p_pkt len:%d/%d, next len:%d", p_pkt->len, len, p_fcb->p_fmsg->len ); - } - else - { - AVRC_TRACE_ERROR0 ("AVRC_MsgReq no buffers for fragmentation" ); - GKI_freebuf(p_pkt); - return AVRC_NO_RESOURCES; - } - } - } - - return AVCT_MsgReq( handle, label, cr, p_pkt); -#else return AVRC_NO_RESOURCES; -#endif } |