From ec6e9a9e1368a12301ef54bfbb9ec4c1f4b2372d Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Fri, 28 Feb 2014 11:18:45 +0200 Subject: [PATCH] android/avrcp-lib: Add avrcp_send function This adds avrcp_send function which can be used to response to outstanding requests. --- android/avrcp-lib.c | 27 +++++++++++++++++++++++++++ android/avrcp-lib.h | 4 +++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/android/avrcp-lib.c b/android/avrcp-lib.c index c5cfa12c8..394485a4f 100644 --- a/android/avrcp-lib.c +++ b/android/avrcp-lib.c @@ -275,6 +275,33 @@ int avrcp_init_uinput(struct avrcp *session, const char *name, return avctp_init_uinput(session->conn, name, address); } +int avrcp_send(struct avrcp *session, uint8_t transaction, uint8_t code, + uint8_t subunit, uint8_t pdu_id, + uint8_t *params, size_t params_len) +{ + struct avrcp_header *pdu = (void *) session->tx_buf; + size_t len = sizeof(*pdu); + + memset(pdu, 0, len); + + hton24(pdu->company_id, IEEEID_BTSIG); + pdu->pdu_id = pdu_id; + pdu->packet_type = AVRCP_PACKET_TYPE_SINGLE; + + if (params_len > 0) { + len += params_len; + + if (len > session->tx_mtu) + return -ENOBUFS; + + memcpy(pdu->params, params, params_len); + pdu->params_len = htons(params_len); + } + + return avctp_send_vendordep(session->conn, transaction, code, subunit, + session->tx_buf, len); +} + static int avrcp_send_req(struct avrcp *session, uint8_t code, uint8_t subunit, uint8_t pdu_id, uint8_t *params, size_t params_len, avctp_rsp_cb func, diff --git a/android/avrcp-lib.h b/android/avrcp-lib.h index 0407cb4a7..a33bdfe37 100644 --- a/android/avrcp-lib.h +++ b/android/avrcp-lib.h @@ -102,7 +102,9 @@ void avrcp_set_passthrough_handlers(struct avrcp *session, void *user_data); int avrcp_init_uinput(struct avrcp *session, const char *name, const char *address); - +int avrcp_send(struct avrcp *session, uint8_t transaction, uint8_t code, + uint8_t subunit, uint8_t pdu_id, + uint8_t *params, size_t params_len); int avrcp_get_capabilities(struct avrcp *session, uint8_t param, avctp_rsp_cb func, void *user_data); int avrcp_list_player_attributes(struct avrcp *session, avctp_rsp_cb func,