Add remaining AVRCP Browsing commands
Luiz Augusto von Dentz
maintainercover Add remaining AVRCP Browsing commands
From: Luiz Augusto von Dentz <[email protected]>
This adds the following AVRCP Browsing commands with the respective qualification tests:
- GetFolderItems
- ChangePath
- GetItemAttributes
- PlayItem
- Search
- AddToNowPlaying
Luiz Augusto von Dentz (35):
android/avctp: Make browsing handler return ssize_t android/avrcp-lib: Add initial code for handling browsing PDUs android/avctp: Add proper checks for invalid browsing PDUs unit/test-avrcp: Add /TP/INV/BI-02-C test android/avctp: Add avctp_send_browsing function android/avrcp-lib: Add support for parsing GetFolderItems PDU unit/test-avrcp: Add /TP/MPS/BV-09-C test unit/test-avrcp: Add /TP/MCN/CB/BV-02-C test unit/test-avrcp: Add /TP/MCN/CB/BI-01-C test unit/test-avrcp: Add /TP/MCN/CB/BI-02-C test unit/test-avrcp: Add /TP/MCN/CB/BI-03-C test unit/test-avrcp: Add /TP/MCN/SRC/BV-04-C test unit/test-avrcp: Add /TP/MCN/NP/BV-05-C test unit/test-avrcp: Add /TP/MCN/NP/BV-06-C test android/avrcp-lib: Add support for parsing ChangePath PDU unit/test-avrcp: Add /TP/MCN/CB/BV-05-C test unit/test-avrcp: Add /TP/MCN/CB/BV-06-C test unit/test-avrcp: Add /TP/MCN/CB/BI-04-C test android/avrcp-lib: Add support for parsing GetItemAttributes PDU unit/test-avrcp: Add /TP/MCN/CB/BV-08-C test unit/test-avrcp: Add /TP/MCN/SRC/BV-06-C test unit/test-avrcp: Add /TP/MCN/NP/BV-08-C test unit/test-avrcp: Add /TP/MCN/NP/BV-09-C test android/avrcp: Add avrcp_play_item function unit/test-avrcp: Add /TP/MCN/NP/BV-01-C test android/avrcp-lib: Add support for parsing PlayItem PDU unit/test-avrcp: Add /TP/MCN/NP/BV-02-C test unit/test-avrcp: Add /TP/MCN/NP/BI-01-C test android/avrcp-lib: Add support for parsing Search PDU unit/test-avrcp: Add /TP/MCN/SRC/BV-02-C test android/avrcp: Add avrcp_add_to_now_playing function unit/test-avrcp: Add /TP/MCN/NP/BV-03-C test android/avrcp-lib: Add support for parsing AddToNowPlaying PDU unit/test-avrcp: Add /TP/MCN/NP/BV-04-C test unit/test-avrcp: Add /TP/MCN/NP/BI-02-C test
android/avctp.c | 33 ++- android/avctp.h | 4 +- android/avrcp-lib.c | 608 ++++++++++++++++++++++++++++++++++++++++++++++++++-- android/avrcp-lib.h | 43 ++++ unit/test-avrcp.c | 335 ++++++++++++++++++++++++++++- 5 files changed, 1003 insertions(+), 20 deletions(-)
Signature · 1 line
1.9.0
Luiz Augusto von Dentz
maintainerPATCH 1/35 android/avctp: Make browsing handler return ssize_t
From: Luiz Augusto von Dentz <[email protected]>
This makes possible to return errors such as -EAGAIN to indicate the request would block and a response will be sent asynchronously.
--- android/avctp.c | 12 +++++++++--- android/avctp.h | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-)
android/avctp.c +9 -3
@@ -839,9 +839,15 @@ static gboolean session_browsing_cb(GIOChannel *chan, GIOCondition cond, goto send; } - packet_size += handler->cb (session, avctp->transaction, - operands, operand_count, - handler->user_data); + ret = handler->cb (session, avctp->transaction, operands, operand_count, + handler->user_data); +if (ret <0 ) { +if (ret == -EAGAIN ) +return TRUE; + goto failed; + } + + packet_size += ret; send:if (packet_size !=0 ) {
android/avctp.h +1 -1
@@ -128,7 +128,7 @@ typedef gboolean (*avctp_rsp_cb) (struct avctp *session, uint8_t code,typedef gboolean (*avctp_browsing_rsp_cb ) (struct avctp *session,uint8_t *operands,size_t operand_count,void *user_data); -typedef size_t (*avctp_browsing_pdu_cb ) (struct avctp *session, +typedef ssize_t (*avctp_browsing_pdu_cb ) (struct avctp *session,uint8_t transaction,uint8_t *operands,size_t operand_count,void *user_data);
Signature · 1 line
1.9.0
Luiz Augusto von Dentz
maintainerPATCH 2/35 android/avrcp-lib: Add initial code for handling browsing PDUs
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
--- android/avrcp-lib.c | 147 +++++++++++++++++++++++++++++++++++++++++++++++----- android/avrcp-lib.h | 3 ++ 2 files changed, 136 insertions(+), 14 deletions(-)
android/avrcp-lib.c +133 -14
@@ -90,6 +90,12 @@ struct avrcp_control_handler { uint16_t params_len, uint8_t *params, void *user_data); }; +struct avrcp_browsing_handler { +uint8_t id; +ssize_t (*func) (struct avrcp *session,uint8_t transaction, +uint16_t params_len,uint8_t *params,void *user_data); +}; +struct avrcp {struct avctp *conn;struct avrcp_player *player;
@@ -105,6 +111,10 @@ struct avrcp {void *passthrough_data;unsigned int passthrough_id; +const struct avrcp_browsing_handler *browsing_handlers; +void *browsing_data; +unsigned int browsing_id; +avrcp_destroy_cb_t destroy;void *destroy_data; };
@@ -194,6 +204,28 @@ static struct avrcp_browsing_header *parse_browsing_pdu(uint8_t *operands,return pdu; } +static uint8_t errno2status (int err) +{ +switch (err) { +case -ENOSYS : +return AVRCP_STATUS_INVALID_COMMAND ; +case -EINVAL : +return AVRCP_STATUS_INVALID_PARAM ; +case 0 : +return AVRCP_STATUS_SUCCESS ; +case -ENOTDIR : +return AVRCP_STATUS_NOT_DIRECTORY ; +case -EBADRQC : +return AVRCP_STATUS_INVALID_SCOPE ; +case -ERANGE : +return AVRCP_STATUS_OUT_OF_BOUNDS ; +case -ENOENT : +return AVRCP_STATUS_DOES_NOT_EXIST ; +default : +return AVRCP_STATUS_INTERNAL_ERROR ; + } +} + static ssize_t handle_vendordep_pdu(struct avctp *conn, uint8_t transaction, uint8_t *code, uint8_t *subunit, uint8_t *operands, size_t operand_count,
@@ -244,19 +276,10 @@ static ssize_t handle_vendordep_pdu(struct avctp *conn, uint8_t transaction, ret = handler->func (session, transaction, pdu->params_len, pdu->params, session->control_data);if (ret <0 ) { -switch (ret) { -case -EAGAIN : +if (ret == -EAGAIN )return ret; -case -ENOSYS : - pdu->params[0 ] =AVRCP_STATUS_INVALID_COMMAND ; - goto reject; -case -EINVAL : - pdu->params[0 ] =AVRCP_STATUS_INVALID_PARAM ; - goto reject; -default : - pdu->params[0 ] =AVRCP_STATUS_INTERNAL_ERROR ; - goto reject; - } + pdu->params[0 ] =errno2status (ret); + goto reject; } *code = handler->rsp;
@@ -330,10 +353,89 @@ struct avrcp *avrcp_new(int fd, size_t imtu, size_t omtu, uint16_t version)return session; } +static ssize_t handle_browsing_pdu (struct avctp *conn, +uint8_t transaction,uint8_t *operands, +size_t operand_count,void *user_data) +{ +struct avrcp *session = user_data; +const struct avrcp_browsing_handler *handler; +struct avrcp_browsing_header *pdu; +int ret; + + pdu =parse_browsing_pdu (operands, operand_count); +if (!pdu) { + pdu = (void *) operands; + pdu->params[0 ] =AVRCP_STATUS_INVALID_COMMAND ; + goto reject; + } + +DBG ("AVRCP Browsing PDU 0x%02X, len 0x%04X" , pdu->pdu_id, + pdu->params_len); + +if (!session->browsing_handlers) { + pdu->pdu_id =AVRCP_GENERAL_REJECT ; + pdu->params[0 ] =AVRCP_STATUS_INTERNAL_ERROR ; + goto reject; + } + +for (handler = session->browsing_handlers; handler->id; handler++) { +if (handler->id == pdu->pdu_id) +break ; + } + +if (handler->id != pdu->pdu_id) { + pdu->pdu_id =AVRCP_GENERAL_REJECT ; + pdu->params[0 ] =AVRCP_STATUS_INVALID_COMMAND ; + goto reject; + } + +if (!handler->func) { + pdu->params[0 ] =AVRCP_STATUS_INVALID_PARAM ; + goto reject; + } + + ret = handler->func (session, transaction, pdu->params_len, pdu->params, + session->control_data); +if (ret <0 ) { +if (ret == -EAGAIN ) +return ret; + pdu->params[0 ] =errno2status (ret); + goto reject; + } + + pdu->params_len =htons (ret); + +return AVRCP_BROWSING_HEADER_LENGTH + ret; + +reject: + pdu->params_len =htons (1 ); + +return AVRCP_BROWSING_HEADER_LENGTH +1 ; +} + +static void browsing_disconnect_cb (void *data) +{ +struct avrcp *session = data; + + session->browsing_id =0 ; +} +int avrcp_connect_browsing (struct avrcp *session,int fd,size_t imtu,size_t omtu) { -return avctp_connect_browsing (session->conn, fd, imtu, omtu); +int err; + + err =avctp_connect_browsing (session->conn, fd, imtu, omtu); +if (err <0 ) +return err; + + session->browsing_id =avctp_register_browsing_pdu_handler ( + session->conn, + handle_browsing_pdu, + session, + browsing_disconnect_cb); + +return 0 ; } void avrcp_set_destroy_cb(struct avrcp *session, avrcp_destroy_cb_t cb,
@@ -680,6 +782,18 @@ static void avrcp_set_control_handlers(struct avrcp *session, session->control_data = user_data; } +static const struct avrcp_browsing_handler browsing_handlers[] = { + { }, +}; + +static void avrcp_set_browsing_handlers (struct avrcp *session, +const struct avrcp_browsing_handler *handlers, +void *user_data) +{ + session->browsing_handlers = handlers; + session->browsing_data = user_data; +} + void avrcp_register_player(struct avrcp *session, const struct avrcp_control_ind *ind, const struct avrcp_control_cfm *cfm,
@@ -693,6 +807,7 @@ void avrcp_register_player(struct avrcp *session, player->user_data = user_data;avrcp_set_control_handlers (session, player_handlers, player); +avrcp_set_browsing_handlers (session, browsing_handlers, player); session->player = player; }
@@ -747,8 +862,12 @@ static int status2errno(uint8_t status)return -EINVAL ;case AVRCP_STATUS_SUCCESS :return 0 ; +case AVRCP_STATUS_NOT_DIRECTORY : +return -ENOTDIR ; +case AVRCP_STATUS_INVALID_SCOPE : +return -EBADRQC ;case AVRCP_STATUS_OUT_OF_BOUNDS : -return -EOVERFLOW ; +return -ERANGE ;case AVRCP_STATUS_INTERNAL_ERROR :case AVRCP_STATUS_INVALID_PLAYER_ID :case AVRCP_STATUS_PLAYER_NOT_BROWSABLE :
android/avrcp-lib.h +3 -0
@@ -66,6 +66,9 @@#define AVRCP_STATUS_PARAM_NOT_FOUND 0x02#define AVRCP_STATUS_INTERNAL_ERROR 0x03#define AVRCP_STATUS_SUCCESS 0x04 +#define AVRCP_STATUS_NOT_DIRECTORY 0x08 +#define AVRCP_STATUS_DOES_NOT_EXIST 0x09 +#define AVRCP_STATUS_INVALID_SCOPE 0x0a#define AVRCP_STATUS_OUT_OF_BOUNDS 0x0b#define AVRCP_STATUS_INVALID_PLAYER_ID 0x11#define AVRCP_STATUS_PLAYER_NOT_BROWSABLE 0x12
Signature · 1 line
1.9.0
Luiz Augusto von Dentz
maintainerPATCH 3/35 android/avctp: Add proper checks for invalid browsing PDUs
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
--- android/avctp.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
android/avctp.c +8 -1
@@ -814,10 +814,17 @@ static gboolean session_browsing_cb(GIOChannel *chan, GIOCondition cond,if (ret <=0 ) goto failed; +if (ret <AVCTP_HEADER_LENGTH ) { +error ("Too small AVCTP packet" ); + goto failed; + } + avctp = (struct avctp_header *) buf; -if (avctp->packet_type !=AVCTP_PACKET_SINGLE ) +if (avctp->packet_type !=AVCTP_PACKET_SINGLE ) { +error ("Invalid packet type" ); goto failed; + } operands = buf +AVCTP_HEADER_LENGTH ; ret -=AVCTP_HEADER_LENGTH ;
Signature · 1 line
1.9.0
Luiz Augusto von Dentz
maintainerPATCH 4/35 unit/test-avrcp: Add /TP/INV/BI-02-C test
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
To verify the General Reject Response issued by the TG.
--- unit/test-avrcp.c | 6 ++++++ 1 file changed, 6 insertions(+)
unit/test-avrcp.c +6 -0
@@ -1166,6 +1166,12 @@ int main(int argc, char *argv[])0xff ,0x00 ,0x00 ,0x01 , AVRCP_STATUS_INVALID_COMMAND)); +/* Invalid PDU ID - Browsing TG */ +define_test ("/TP/INV/BI-02-C" , test_server, +brs_pdu (0x00 ,0x11 ,0x0e ,0xff ,0x00 ,0x00 ), +brs_pdu (0x02 ,0x11 ,0x0e ,AVRCP_GENERAL_REJECT , +0x00 ,0x01 ,AVRCP_STATUS_INVALID_COMMAND )); +/* Next Group command transfer - CT */ define_test("/TP/BGN/BV-01-I", test_client, raw_pdu(0x00, 0x11, 0x0e, 0x00, 0x48,
Signature · 1 line
1.9.0
Luiz Augusto von Dentz
maintainerPATCH 5/35 android/avctp: Add avctp_send_browsing function
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
This function can be used to send responses over browsing channel.
--- android/avctp.c | 12 ++++++++++++ android/avctp.h | 2 ++ 2 files changed, 14 insertions(+)
android/avctp.c +12 -0
@@ -1208,6 +1208,18 @@ int avctp_send_browsing_req(struct avctp *session,return 0 ; } +int avctp_send_browsing (struct avctp *session,uint8_t transaction, +const struct iovec *iov,int iov_cnt) +{ +struct avctp_channel *browsing = session->browsing; + +if (browsing ==NULL ) +return -ENOTCONN ; + +return avctp_browsing_send (browsing, transaction,AVCTP_RESPONSE , + iov, iov_cnt); +} +static const char *op2str (uint8_t op) {int i;
android/avctp.h +2 -0
@@ -172,6 +172,8 @@ int avctp_send_vendor(struct avctp *session, uint8_t transaction,int avctp_send_vendor_req (struct avctp *session,uint8_t code,uint8_t subunit,const struct iovec *iov,int iov_cnt,avctp_rsp_cb func,void *user_data); +int avctp_send_browsing (struct avctp *session,uint8_t transaction, +const struct iovec *iov,int iov_cnt);int avctp_send_browsing_req (struct avctp *session,const struct iovec *iov,int iov_cnt,avctp_browsing_rsp_cb func,void *user_data);
Signature · 1 line
1.9.0
Luiz Augusto von Dentz
maintainerPATCH 6/35 android/avrcp-lib: Add support for parsing GetFolderItems PDU
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
--- android/avrcp-lib.c | 103 ++++++++++++++++++++++++++++++++++++++++++++++++++++ android/avrcp-lib.h | 9 +++++ 2 files changed, 112 insertions(+)
android/avrcp-lib.c +103 -0
@@ -782,7 +782,52 @@ static void avrcp_set_control_handlers(struct avrcp *session, session->control_data = user_data; } +static ssize_t get_folder_items (struct avrcp *session,uint8_t transaction, +uint16_t params_len,uint8_t *params, +void *user_data) +{ +struct avrcp_player *player = user_data; +uint8_t scope; +uint32_t start, end; +uint16_t number; +uint32_t attrs[AVRCP_MEDIA_ATTRIBUTE_LAST ]; +int i; + +DBG ("" ); + +if (!player->ind || !player->ind->get_folder_items) +return -ENOSYS ; + +if (!params || params_len <10 ) +return -EINVAL ; + + scope = params[0 ]; +if (scope >AVRCP_MEDIA_NOW_PLAYING ) +return -EBADRQC ; + + start =get_be32 (¶ms[1 ]); + end =get_be32 (¶ms[5 ]); + +if (start > end) +return -ERANGE ; + + number =get_be16 (¶ms[9 ]); + +for (i =0 ; i < number; i++) { + attrs[i] =get_be32 (¶ms[11 + i *4 ]); + +if (attrs[i] ==AVRCP_MEDIA_ATTRIBUTE_ILLEGAL || + attrs[i] >AVRCP_MEDIA_ATTRIBUTE_LAST ) +return -EINVAL ; + } + +return player->ind->get_folder_items (session, transaction, scope, start, + end, number, attrs, + player->user_data); +} +static const struct avrcp_browsing_handler browsing_handlers[] = { + {AVRCP_GET_FOLDER_ITEMS , get_folder_items }, { }, };
@@ -951,6 +996,32 @@ static int avrcp_send_browsing_req(struct avrcp *session, uint8_t pdu_id, func, user_data); } +static int avrcp_send_browsing (struct avrcp *session,uint8_t transaction, +uint8_t pdu_id,const struct iovec *iov, +int iov_cnt) +{ +struct iovec pdu[iov_cnt +1 ]; +struct avrcp_browsing_header hdr; +int i; + +memset (&hdr,0 ,sizeof (hdr)); + +for (i =0 ; i < iov_cnt; i++) { + pdu[i +1 ].iov_base = iov[i].iov_base; + pdu[i +1 ].iov_len = iov[i].iov_len; + hdr.params_len += iov[i].iov_len; + } + + hdr.pdu_id = pdu_id; + hdr.params_len =htons (hdr.params_len); + + pdu[0 ].iov_base = &hdr; + pdu[0 ].iov_len =sizeof (hdr); + +return avctp_send_browsing (session->conn, transaction, pdu, + iov_cnt +1 ); +} + static gboolean get_capabilities_rsp(struct avctp *conn, uint8_t code, uint8_t subunit, uint8_t *operands, size_t operand_count,
@@ -2384,6 +2455,38 @@ int avrcp_set_addressed_player_rsp(struct avrcp *session, uint8_t transaction, &iov, 1); } +int avrcp_get_folder_items_rsp (struct avrcp *session,uint8_t transaction, +uint16_t counter,uint8_t number, +uint8_t *type,uint16_t *len, +uint8_t **params) +{ +struct iovec iov[UINT8_MAX *2 +1 ]; +uint8_t pdu[5 ]; +uint8_t item[UINT8_MAX ][3 ]; +int i; + + pdu[0 ] =AVRCP_STATUS_SUCCESS ; +put_be16 (counter, &pdu[1 ]); +put_be16 (number, &pdu[3 ]); + + iov[0 ].iov_base = pdu; + iov[0 ].iov_len =sizeof (pdu); + +for (i =0 ; i < number; i++) { + item[i][0 ] = type[i]; +put_be16 (len[i], &item[i][1 ]); + + iov[i *2 +1 ].iov_base = item[i]; + iov[i *2 +1 ].iov_len =sizeof (item[i]); + + iov[i *2 +2 ].iov_base = params[i]; + iov[i *2 +2 ].iov_len = len[i]; + } + +return avrcp_send_browsing (session, transaction,AVRCP_GET_FOLDER_ITEMS , + iov, number *2 +1 ); +} +int avrcp_send_passthrough (struct avrcp *session,uint32_t vendor,uint8_t op) {uint8_t params[5 ];
android/avrcp-lib.h +9 -0
@@ -159,6 +159,10 @@ struct avrcp_control_ind { uint32_t interval, void *user_data);int (*set_addressed) (struct avrcp *session,uint8_t transaction,uint16_t id,void *user_data); +int (*get_folder_items) (struct avrcp *session,uint8_t transaction, +uint8_t scope,uint32_t start, +uint32_t end,uint16_t number, +uint32_t *attrs,void *user_data); };struct avrcp_control_cfm {
@@ -290,4 +294,9 @@ int avrcp_register_notification_rsp(struct avrcp *session, uint8_t transaction, size_t params_len);int avrcp_set_addressed_player_rsp (struct avrcp *session,uint8_t transaction,uint8_t status); +int avrcp_get_folder_items_rsp (struct avrcp *session,uint8_t transaction, +uint16_t counter,uint8_t number, +uint8_t *type,uint16_t *len, +uint8_t **params); +int avrcp_send_passthrough (struct avrcp *session,uint32_t vendor,uint8_t op);
Signature · 1 line
1.9.0
Luiz Augusto von Dentz
maintainerPATCH 7/35 unit/test-avrcp: Add /TP/MPS/BV-09-C test
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
Verify the GetFolderItems response for the Media Player List issued by the TG.
--- unit/test-avrcp.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-)
unit/test-avrcp.c +25 -1
@@ -231,7 +231,7 @@ static gboolean browse_test_handler(GIOChannel *channel, GIOCondition cond,g_assert (len >0 );if (g_test_verbose ()) -util_hexdump ('>' , buf, len, test_debug,"AVCTP: " ); +util_hexdump ('>' , buf, len, test_debug,"AVRCP: " ); g_assert_cmpint(len, ==, pdu->size);
@@ -545,6 +545,19 @@ static int set_addressed(struct avrcp *session, uint8_t transaction,return -EAGAIN ; } +static int get_folder_items (struct avrcp *session,uint8_t transaction, +uint8_t scope,uint32_t start,uint32_t end, +uint16_t number,uint32_t *attrs, +void *user_data) +{ +DBG ("" ); + +avrcp_get_folder_items_rsp (session, transaction,0xabcd ,0 ,NULL ,NULL , +NULL ); + +return -EAGAIN ; +} +static const struct avrcp_control_ind control_ind = { .get_capabilities = get_capabilities, .list_attributes = list_attributes,
@@ -557,6 +570,7 @@ static const struct avrcp_control_ind control_ind = { .get_element_attributes = get_element_attributes, .register_notification = register_notification, .set_addressed = set_addressed, + .get_folder_items = get_folder_items, };static void test_server (gconstpointer data)
@@ -699,6 +713,16 @@ int main(int argc, char *argv[])0x00 ,0x00 ,0x00 ,0x02 ,/* end */ 0x00)); +/* GetFolderItems - TG */ +define_test ("/TP/MPS/BV-09-C" , test_server, +brs_pdu (0x00 ,0x11 ,0x0e ,AVRCP_GET_FOLDER_ITEMS , +0x00 ,0x0a ,AVRCP_MEDIA_PLAYER_LIST , +0x00 ,0x00 ,0x00 ,0x00 ,/* start */ +0x00 ,0x00 ,0x00 ,0x02 ,/* end */ +0x00 ), +brs_pdu (0x02 ,0x11 ,0x0e ,AVRCP_GET_FOLDER_ITEMS , +0x00 ,0x05 ,0x04 ,0xab ,0xcd ,0x00 ,0x00 )); +/* * Media Content Navigation Commands and Notifications for Content * Browsing.
Signature · 1 line
1.9.0
Luiz Augusto von Dentz
maintainerPATCH 8/35 unit/test-avrcp: Add /TP/MCN/CB/BV-02-C test
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
To verify the GetFolderItems response issued by the TG for a folder.
--- unit/test-avrcp.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
unit/test-avrcp.c +10 -0
@@ -736,6 +736,16 @@ int main(int argc, char *argv[])0x00 ,0x00 ,0x00 ,0x02 ,/* end */ 0x00)); +/* GetFolderItems - Virtual FS - TG */ +define_test ("/TP/MCN/CB/BV-02-C" , test_server, +brs_pdu (0x00 ,0x11 ,0x0e ,AVRCP_GET_FOLDER_ITEMS , +0x00 ,0x0a ,AVRCP_MEDIA_PLAYER_VFS , +0x00 ,0x00 ,0x00 ,0x00 ,/* start */ +0x00 ,0x00 ,0x00 ,0x02 ,/* end */ +0x00 ), +brs_pdu (0x02 ,0x11 ,0x0e ,AVRCP_GET_FOLDER_ITEMS , +0x00 ,0x05 ,0x04 ,0xab ,0xcd ,0x00 ,0x00 )); +/* ChangePath - CT */ define_test("/TP/MCN/CB/BV-04-C", test_client, raw_pdu(0x00, 0x11, 0x0e, AVRCP_CHANGE_PATH,
Signature · 1 line
1.9.0
Luiz Augusto von Dentz
maintainerPATCH 9/35 unit/test-avrcp: Add /TP/MCN/CB/BI-01-C test
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
To verify the GetFolderItems response issued by the TG when the command contains invalid parameters.
--- unit/test-avrcp.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
unit/test-avrcp.c +10 -0
@@ -764,6 +764,16 @@ int main(int argc, char *argv[])0xaa ,0xbb ,/* counter */ 0x00)); /* num attr */ +/* GetFolderItems - Virtual FS - TG */ +define_test ("/TP/MCN/CB/BI-01-C" , test_server, +brs_pdu (0x00 ,0x11 ,0x0e ,AVRCP_GET_FOLDER_ITEMS , +0x00 ,0x0a ,AVRCP_MEDIA_PLAYER_VFS , +0x00 ,0x00 ,0x00 ,0x01 ,/* start */ +0x00 ,0x00 ,0x00 ,0x00 ,/* end */ +0x00 ), +brs_pdu (0x02 ,0x11 ,0x0e ,AVRCP_GET_FOLDER_ITEMS , +0x00 ,0x01 ,0x0b )); +/* Media Content Navigation Commands and Notifications for Search */ /* Search - CT */
Signature · 1 line
1.9.0
Luiz Augusto von Dentz
maintainerPATCH 10/35 unit/test-avrcp: Add /TP/MCN/CB/BI-02-C test
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
To verify the GetFolderItems response issued by the TG for an empty folder when the command contains invalid parameters.
--- unit/test-avrcp.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
unit/test-avrcp.c +16 -0
@@ -539,6 +539,7 @@ static int set_addressed(struct avrcp *session, uint8_t transaction, {DBG ("" ); +avrcp_set_addressed_player_rsp (session, transaction,AVRCP_STATUS_SUCCESS );
@@ -550,8 +551,13 @@ static int get_folder_items(struct avrcp *session, uint8_t transaction, uint16_t number, uint32_t *attrs, void *user_data) { + struct context *context = user_data; +DBG ("" ); +if (g_str_equal (context->data->test_name,"/TP/MCN/CB/BI-02-C" )) +return -ERANGE ; +avrcp_get_folder_items_rsp (session, transaction,0xabcd ,0 ,NULL ,NULL ,NULL );
@@ -774,6 +780,16 @@ int main(int argc, char *argv[])brs_pdu (0x02 ,0x11 ,0x0e ,AVRCP_GET_FOLDER_ITEMS , 0x00, 0x01, 0x0b)); +/* GetFolderItems - Virtual FS - TG */ +define_test ("/TP/MCN/CB/BI-02-C" , test_server, +brs_pdu (0x00 ,0x11 ,0x0e ,AVRCP_GET_FOLDER_ITEMS , +0x00 ,0x0a ,AVRCP_MEDIA_PLAYER_VFS , +0x00 ,0x00 ,0x00 ,0x00 ,/* start */ +0x00 ,0x00 ,0x00 ,0x01 ,/* end */ +0x00 ), +brs_pdu (0x02 ,0x11 ,0x0e ,AVRCP_GET_FOLDER_ITEMS , +0x00 ,0x01 ,0x0b )); +/* Media Content Navigation Commands and Notifications for Search */ /* Search - CT */
Signature · 1 line
1.9.0
Luiz Augusto von Dentz
maintainerPATCH 11/35 unit/test-avrcp: Add /TP/MCN/CB/BI-03-C test
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
To verify the GetFolderItems response issued by the TG when the command contains invalid parameters accessing items beyond the end of a folder.
--- unit/test-avrcp.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
unit/test-avrcp.c +13 -0
@@ -558,6 +558,9 @@ static int get_folder_items(struct avrcp *session, uint8_t transaction,if (g_str_equal (context->data->test_name,"/TP/MCN/CB/BI-02-C" ))return -ERANGE ; +if (start >1 ) +return -ERANGE ; +avrcp_get_folder_items_rsp (session, transaction,0xabcd ,0 ,NULL ,NULL ,NULL );
@@ -790,6 +793,16 @@ int main(int argc, char *argv[])brs_pdu (0x02 ,0x11 ,0x0e ,AVRCP_GET_FOLDER_ITEMS , 0x00, 0x01, 0x0b)); +/* GetFolderItems - Virtual FS - TG */ +define_test ("/TP/MCN/CB/BI-03-C" , test_server, +brs_pdu (0x00 ,0x11 ,0x0e ,AVRCP_GET_FOLDER_ITEMS , +0x00 ,0x0a ,AVRCP_MEDIA_PLAYER_VFS , +0x00 ,0x00 ,0x00 ,0x02 ,/* start */ +0x00 ,0x00 ,0x00 ,0x03 ,/* end */ +0x00 ), +brs_pdu (0x02 ,0x11 ,0x0e ,AVRCP_GET_FOLDER_ITEMS , +0x00 ,0x01 ,0x0b )); +/* Media Content Navigation Commands and Notifications for Search */ /* Search - CT */
Signature · 1 line
1.9.0
Luiz Augusto von Dentz
maintainerPATCH 12/35 unit/test-avrcp: Add /TP/MCN/SRC/BV-04-C test
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
To verify the GetFolderItems response for the Search Folder issued by the TG.
--- unit/test-avrcp.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
unit/test-avrcp.c +10 -0
@@ -820,6 +820,16 @@ int main(int argc, char *argv[])0x00 ,0x00 ,0x00 ,0x02 ,/* end */ 0x00)); +/* GetFolderItems - NowPlaying - TG */ +define_test ("/TP/MCN/SCR/BV-04-C" , test_server, +brs_pdu (0x00 ,0x11 ,0x0e ,AVRCP_GET_FOLDER_ITEMS , +0x00 ,0x0a ,AVRCP_MEDIA_SEARCH , +0x00 ,0x00 ,0x00 ,0x00 ,/* start */ +0x00 ,0x00 ,0x00 ,0x02 ,/* end */ +0x00 ), +brs_pdu (0x02 ,0x11 ,0x0e ,AVRCP_GET_FOLDER_ITEMS , +0x00 ,0x05 ,0x04 ,0xab ,0xcd ,0x00 ,0x00 )); +/* GetItemAttributes - CT */ define_test("/TP/MCN/SRC/BV-05-C", test_client, raw_pdu(0x00, 0x11, 0x0e, AVRCP_GET_ITEM_ATTRIBUTES,
Signature · 1 line
1.9.0
Luiz Augusto von Dentz
maintainerPATCH 13/35 unit/test-avrcp: Add /TP/MCN/NP/BV-05-C test
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
To verify the GetFolderItems command issued by the CT on the NowPlaying folder.
--- unit/test-avrcp.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
unit/test-avrcp.c +14 -0
@@ -637,6 +637,10 @@ static void test_client(gconstpointer data)AVRCP_MEDIA_SEARCH ,0x01 ,0xaabb , 0, NULL); +if (g_str_equal (context->data->test_name,"/TP/MCN/NP/BV-05-C" )) +avrcp_get_folder_items (context->session, +AVRCP_MEDIA_NOW_PLAYING ,0 ,2 ,0 ,NULL ); +if (g_str_equal (context->data->test_name,"/TP/CFG/BV-01-C" ))avrcp_get_capabilities (context->session,CAP_EVENTS_SUPPORTED );
@@ -839,6 +843,16 @@ int main(int argc, char *argv[])0xaa ,0xbb ,/* counter */ 0x00)); /* num attr */ +/* Media Content Navigation Commands and Notifications for NowPlaying */ + +/* GetFolderItems - NowPlaying - CT */ +define_test ("/TP/MCN/NP/BV-05-C" , test_client, +brs_pdu (0x00 ,0x11 ,0x0e ,AVRCP_GET_FOLDER_ITEMS , +0x00 ,0x0a ,AVRCP_MEDIA_NOW_PLAYING , +0x00 ,0x00 ,0x00 ,0x00 ,/* start */ +0x00 ,0x00 ,0x00 ,0x02 ,/* end */ +0x00 )); +/* Media Player Selection IOP tests */ /* Listing of available media players */
Signature · 1 line
1.9.0
Luiz Augusto von Dentz
maintainerPATCH 14/35 unit/test-avrcp: Add /TP/MCN/NP/BV-06-C test
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
To verify the GetFolderItems response for the NowPlaying Folder issued by the TG.
--- unit/test-avrcp.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
unit/test-avrcp.c +11 -0
@@ -853,6 +853,17 @@ int main(int argc, char *argv[])0x00 ,0x00 ,0x00 ,0x02 ,/* end */ 0x00)); +/* GetFolderItems - NowPlaying - TG */ +define_test ("/TP/MCN/NP/BV-06-C" , test_server, +brs_pdu (0x00 ,0x11 ,0x0e ,AVRCP_GET_FOLDER_ITEMS , +0x00 ,0x0a ,AVRCP_MEDIA_NOW_PLAYING , +0x00 ,0x00 ,0x00 ,0x00 ,/* start */ +0x00 ,0x00 ,0x00 ,0x02 ,/* end */ +0x00 ), +brs_pdu (0x02 ,0x11 ,0x0e ,AVRCP_GET_FOLDER_ITEMS , +0x00 ,0x05 ,0x04 ,0xab ,0xcd ,0x00 ,0x00 )); + +/* Media Player Selection IOP tests */ /* Listing of available media players */
Signature · 1 line
1.9.0
Luiz Augusto von Dentz
maintainerPATCH 15/35 android/avrcp-lib: Add support for parsing ChangePath PDU
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
--- android/avrcp-lib.c | 42 ++++++++++++++++++++++++++++++++++++++++++ android/avrcp-lib.h | 5 +++++ 2 files changed, 47 insertions(+)
android/avrcp-lib.c +42 -0
@@ -826,8 +826,34 @@ static ssize_t get_folder_items(struct avrcp *session, uint8_t transaction, player->user_data); } +static ssize_t change_path (struct avrcp *session,uint8_t transaction, +uint16_t params_len,uint8_t *params, +void *user_data) +{ +struct avrcp_player *player = user_data; +uint8_t direction; +uint16_t counter; +uint64_t uid; + +DBG ("" ); + +if (!player->ind || !player->ind->change_path) +return -ENOSYS ; + +if (!params || params_len <11 ) +return -EINVAL ; + + counter =get_be16 (¶ms[0 ]); + direction = params[2 ]; + uid =get_be64 (¶ms[3 ]); + +return player->ind->change_path (session, transaction, counter, + direction, uid, player->user_data); +} +static const struct avrcp_browsing_handler browsing_handlers[] = { {AVRCP_GET_FOLDER_ITEMS , get_folder_items }, + {AVRCP_CHANGE_PATH , change_path }, { }, };
@@ -2487,6 +2513,22 @@ int avrcp_get_folder_items_rsp(struct avrcp *session, uint8_t transaction, iov, number * 2 + 1); } +int avrcp_change_path_rsp (struct avrcp *session,uint8_t transaction, +uint32_t items) +{ +struct iovec iov; +uint8_t pdu[5 ]; + + pdu[0 ] =AVRCP_STATUS_SUCCESS ; +put_be32 (items, &pdu[1 ]); + + iov.iov_base = pdu; + iov.iov_len =sizeof (pdu); + +return avrcp_send_browsing (session, transaction,AVRCP_CHANGE_PATH , + &iov,1 ); +} +int avrcp_send_passthrough (struct avrcp *session,uint32_t vendor,uint8_t op) {uint8_t params[5 ];
android/avrcp-lib.h +5 -0
@@ -163,6 +163,9 @@ struct avrcp_control_ind { uint8_t scope, uint32_t start, uint32_t end, uint16_t number, uint32_t *attrs, void *user_data); +int (*change_path) (struct avrcp *session,uint8_t transaction, +uint16_t counter,uint8_t direction, +uint64_t uid,void *user_data); };struct avrcp_control_cfm {
@@ -298,5 +301,7 @@ int avrcp_get_folder_items_rsp(struct avrcp *session, uint8_t transaction, uint16_t counter, uint8_t number, uint8_t *type, uint16_t *len, uint8_t **params); +int avrcp_change_path_rsp (struct avrcp *session,uint8_t transaction, +uint32_t items);int avrcp_send_passthrough (struct avrcp *session,uint32_t vendor,uint8_t op);
Signature · 1 line
1.9.0
Luiz Augusto von Dentz
maintainerPATCH 16/35 unit/test-avrcp: Add /TP/MCN/CB/BV-05-C test
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
To verify the ChangePath response issued by the TG.
--- unit/test-avrcp.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
unit/test-avrcp.c +23 -0
@@ -567,6 +567,17 @@ static int get_folder_items(struct avrcp *session, uint8_t transaction,return -EAGAIN ; } +static int change_path (struct avrcp *session,uint8_t transaction, +uint16_t counter,uint8_t direction, +uint64_t uid,void *user_data) +{ +DBG ("" ); + +avrcp_change_path_rsp (session, transaction,0 ); + +return -EAGAIN ; +} +static const struct avrcp_control_ind control_ind = { .get_capabilities = get_capabilities, .list_attributes = list_attributes,
@@ -580,6 +591,7 @@ static const struct avrcp_control_ind control_ind = { .register_notification = register_notification, .set_addressed = set_addressed, .get_folder_items = get_folder_items, + .change_path = change_path, };static void test_server (gconstpointer data)
@@ -768,6 +780,17 @@ int main(int argc, char *argv[])0x00 ,0x00 ,0x00 ,0x00 , 0x00, 0x00, 0x00, 0x01 /* Folder UID */)); +/* ChangePath - TG */ +define_test ("/TP/MCN/CB/BV-05-C" , test_server, +brs_pdu (0x00 ,0x11 ,0x0e ,AVRCP_CHANGE_PATH , +0x00 ,0x0b , +0xaa ,0xbb ,/* counter */ +0x01 ,/* direction */ +0x00 ,0x00 ,0x00 ,0x00 , +0x00 ,0x00 ,0x00 ,0x01 /* Folder UID */ ), +brs_pdu (0x02 ,0x11 ,0x0e ,AVRCP_CHANGE_PATH , +0x00 ,0x05 ,0x04 ,0x00 ,0x00 ,0x00 ,0x00 )); +/* GetItemAttributes - CT */ define_test("/TP/MCN/CB/BV-07-C", test_client, raw_pdu(0x00, 0x11, 0x0e, AVRCP_GET_ITEM_ATTRIBUTES,
Signature · 1 line
1.9.0
Luiz Augusto von Dentz
maintainerPATCH 17/35 unit/test-avrcp: Add /TP/MCN/CB/BV-06-C test
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
To verify the ChangePath response issued by the TG when the Direction is FolderUp.
--- unit/test-avrcp.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
unit/test-avrcp.c +11 -0
@@ -791,6 +791,17 @@ int main(int argc, char *argv[])brs_pdu (0x02 ,0x11 ,0x0e ,AVRCP_CHANGE_PATH , 0x00, 0x05, 0x04, 0x00, 0x00, 0x00, 0x00)); +/* ChangePath - TG */ +define_test ("/TP/MCN/CB/BV-06-C" , test_server, +brs_pdu (0x00 ,0x11 ,0x0e ,AVRCP_CHANGE_PATH , +0x00 ,0x0b , +0xaa ,0xbb ,/* counter */ +0x00 ,/* direction */ +0x00 ,0x00 ,0x00 ,0x00 , +0x00 ,0x00 ,0x00 ,0x01 /* Folder UID */ ), +brs_pdu (0x02 ,0x11 ,0x0e ,AVRCP_CHANGE_PATH , +0x00 ,0x05 ,0x04 ,0x00 ,0x00 ,0x00 ,0x00 )); +/* GetItemAttributes - CT */ define_test("/TP/MCN/CB/BV-07-C", test_client, raw_pdu(0x00, 0x11, 0x0e, AVRCP_GET_ITEM_ATTRIBUTES,
Signature · 1 line
1.9.0
Luiz Augusto von Dentz
maintainerPATCH 18/35 unit/test-avrcp: Add /TP/MCN/CB/BI-04-C test
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
To verify the ChangePath response issued by the TG when an invalid Folder UID is requested.
--- unit/test-avrcp.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
unit/test-avrcp.c +14 -0
@@ -573,6 +573,9 @@ static int change_path(struct avrcp *session, uint8_t transaction, {DBG ("" ); +if (!uid) +return -ENOTDIR ; +avrcp_change_path_rsp (session, transaction,0 );return -EAGAIN ;
@@ -841,6 +844,17 @@ int main(int argc, char *argv[])brs_pdu (0x02 ,0x11 ,0x0e ,AVRCP_GET_FOLDER_ITEMS , 0x00, 0x01, 0x0b)); +/* ChangePath - TG */ +define_test ("/TP/MCN/CB/BI-04-C" , test_server, +brs_pdu (0x00 ,0x11 ,0x0e ,AVRCP_CHANGE_PATH , +0x00 ,0x0b , +0xaa ,0xbb ,/* counter */ +0x01 ,/* direction */ +0x00 ,0x00 ,0x00 ,0x00 , +0x00 ,0x00 ,0x00 ,0x00 /* Folder UID */ ), +brs_pdu (0x02 ,0x11 ,0x0e ,AVRCP_CHANGE_PATH , +0x00 ,0x01 ,0x08 )); +/* Media Content Navigation Commands and Notifications for Search */ /* Search - CT */
Signature · 1 line
1.9.0
Luiz Augusto von Dentz
maintainerPATCH 19/35 android/avrcp-lib: Add support for parsing GetItemAttributes PDU
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
--- android/avrcp-lib.c | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++++ android/avrcp-lib.h | 7 +++++ 2 files changed, 93 insertions(+)
android/avrcp-lib.c +86 -0
@@ -851,9 +851,51 @@ static ssize_t change_path(struct avrcp *session, uint8_t transaction, direction, uid, player->user_data); } +static ssize_t get_item_attributes (struct avrcp *session,uint8_t transaction, +uint16_t params_len,uint8_t *params, +void *user_data) +{ +struct avrcp_player *player = user_data; +uint8_t scope; +uint64_t uid; +uint16_t counter; +uint8_t number; +uint32_t attrs[AVRCP_MEDIA_ATTRIBUTE_LAST ]; +int i; + +DBG ("" ); + +if (!player->ind || !player->ind->get_item_attributes) +return -ENOSYS ; + +if (!params || params_len <12 ) +return -EINVAL ; + + scope = params[0 ]; +if (scope >AVRCP_MEDIA_NOW_PLAYING ) +return -EBADRQC ; + + uid =get_be64 (¶ms[1 ]); + counter =get_be16 (¶ms[9 ]); + number = params[11 ]; + +for (i =0 ; i < number; i++) { + attrs[i] =get_be32 (¶ms[12 + i *4 ]); + +if (attrs[i] ==AVRCP_MEDIA_ATTRIBUTE_ILLEGAL || + attrs[i] >AVRCP_MEDIA_ATTRIBUTE_LAST ) +return -EINVAL ; + } + +return player->ind->get_item_attributes (session, transaction, scope, + uid, counter, number, attrs, + player->user_data); +} +static const struct avrcp_browsing_handler browsing_handlers[] = { {AVRCP_GET_FOLDER_ITEMS , get_folder_items }, {AVRCP_CHANGE_PATH , change_path }, + {AVRCP_GET_ITEM_ATTRIBUTES , get_item_attributes }, { }, };
@@ -2529,6 +2571,50 @@ int avrcp_change_path_rsp(struct avrcp *session, uint8_t transaction, &iov, 1); } +int avrcp_get_item_attributes_rsp (struct avrcp *session,uint8_t transaction, +uint8_t number,uint32_t *attrs, +const char **text) +{ +struct iovec iov[AVRCP_MEDIA_ATTRIBUTE_LAST *2 +1 ]; +uint8_t val[AVRCP_MEDIA_ATTRIBUTE_LAST ][8 ]; +uint8_t pdu[2 ]; +int i; + +if (number >AVRCP_MEDIA_ATTRIBUTE_LAST ) +return -EINVAL ; + + pdu[0 ] =AVRCP_STATUS_SUCCESS ; + pdu[1 ] = number; + + iov[0 ].iov_base = pdu; + iov[0 ].iov_len =sizeof (pdu); + +for (i =0 ; i < number; i++) { +uint16_t len =0 ; + +if (attrs[i] >AVRCP_MEDIA_ATTRIBUTE_LAST || + attrs[i] ==AVRCP_MEDIA_ATTRIBUTE_ILLEGAL ) +return -EINVAL ; + +if (text[i]) + len =strlen (text[i]); + +put_be32 (attrs[i], &val[i][0 ]); +put_be16 (AVRCP_CHARSET_UTF8 , &val[i][4 ]); +put_be16 (len, &val[i][6 ]); + + iov[i +1 ].iov_base = val[i]; + iov[i +1 ].iov_len =sizeof (val[i]); + + iov[i +2 ].iov_base = (void *) text[i]; + iov[i +2 ].iov_len = len; + } + +return avrcp_send_browsing (session, transaction, +AVRCP_GET_ITEM_ATTRIBUTES , iov, + number *2 +1 ); +} +int avrcp_send_passthrough (struct avrcp *session,uint32_t vendor,uint8_t op) {uint8_t params[5 ];
android/avrcp-lib.h +7 -0
@@ -166,6 +166,10 @@ struct avrcp_control_ind {int (*change_path) (struct avrcp *session,uint8_t transaction,uint16_t counter,uint8_t direction,uint64_t uid,void *user_data); +int (*get_item_attributes) (struct avrcp *session,uint8_t transaction, +uint8_t scope,uint64_t uid, +uint16_t counter,uint8_t number, +uint32_t *attrs,void *user_data); };struct avrcp_control_cfm {
@@ -303,5 +307,8 @@ int avrcp_get_folder_items_rsp(struct avrcp *session, uint8_t transaction, uint8_t **params);int avrcp_change_path_rsp (struct avrcp *session,uint8_t transaction,uint32_t items); +int avrcp_get_item_attributes_rsp (struct avrcp *session,uint8_t transaction, +uint8_t number,uint32_t *attrs, +const char **text);int avrcp_send_passthrough (struct avrcp *session,uint32_t vendor,uint8_t op);
Signature · 1 line
1.9.0
Luiz Augusto von Dentz
maintainerPATCH 20/35 unit/test-avrcp: Add /TP/MCN/CB/BV-08-C test
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
To verify the GetItemAttributes response issued by the TG on a Media Item in the Media Player Virtual Filesystem other than the currently playing one (UID 0x0).
--- unit/test-avrcp.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
unit/test-avrcp.c +24 -0
@@ -581,6 +581,18 @@ static int change_path(struct avrcp *session, uint8_t transaction,return -EAGAIN ; } +static int get_item_attributes (struct avrcp *session,uint8_t transaction, +uint8_t scope,uint64_t uid, +uint16_t counter,uint8_t number, +uint32_t *attrs,void *user_data) +{ +DBG ("" ); + +avrcp_get_item_attributes_rsp (session, transaction,0 ,NULL ,NULL ); + +return -EAGAIN ; +} +static const struct avrcp_control_ind control_ind = { .get_capabilities = get_capabilities, .list_attributes = list_attributes,
@@ -595,6 +607,7 @@ static const struct avrcp_control_ind control_ind = { .set_addressed = set_addressed, .get_folder_items = get_folder_items, .change_path = change_path, + .get_item_attributes = get_item_attributes, };static void test_server (gconstpointer data)
@@ -814,6 +827,17 @@ int main(int argc, char *argv[])0xaa ,0xbb ,/* counter */ 0x00)); /* num attr */ +/* GetItemAttributes - TG */ +define_test ("/TP/MCN/CB/BV-08-C" , test_server, +brs_pdu (0x00 ,0x11 ,0x0e ,AVRCP_GET_ITEM_ATTRIBUTES , +0x00 ,0x0c ,AVRCP_MEDIA_PLAYER_VFS , +0x00 ,0x00 ,0x00 ,0x00 , +0x00 ,0x00 ,0x00 ,0x01 ,/* uuid */ +0xaa ,0xbb ,/* counter */ +0x00 ),/* num attr */ +brs_pdu (0x02 ,0x11 ,0x0e ,AVRCP_GET_ITEM_ATTRIBUTES , +0x00 ,0x02 ,0x04 ,0x00 )); +/* GetFolderItems - Virtual FS - TG */ define_test("/TP/MCN/CB/BI-01-C", test_server, brs_pdu(0x00, 0x11, 0x0e, AVRCP_GET_FOLDER_ITEMS,
Signature · 1 line
1.9.0
Luiz Augusto von Dentz
maintainerPATCH 21/35 unit/test-avrcp: Add /TP/MCN/SRC/BV-06-C test
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
To verify the GetItemAttributes response issued by the TG on a Media Item in the Search folder other than the currently playing one (UID 0x0).
--- unit/test-avrcp.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
unit/test-avrcp.c +11 -1
@@ -915,6 +915,17 @@ int main(int argc, char *argv[])0xaa ,0xbb ,/* counter */ 0x00)); /* num attr */ +/* GetItemAttributes - TG */ +define_test ("/TP/MCN/SRC/BV-06-C" , test_server, +brs_pdu (0x00 ,0x11 ,0x0e ,AVRCP_GET_ITEM_ATTRIBUTES , +0x00 ,0x0c ,AVRCP_MEDIA_SEARCH , +0x00 ,0x00 ,0x00 ,0x00 , +0x00 ,0x00 ,0x00 ,0x01 ,/* uid */ +0xaa ,0xbb ,/* counter */ +0x00 ),/* num attr */ +brs_pdu (0x02 ,0x11 ,0x0e ,AVRCP_GET_ITEM_ATTRIBUTES , +0x00 ,0x02 ,0x04 ,0x00 )); +/* Media Content Navigation Commands and Notifications for NowPlaying */ /* GetFolderItems - NowPlaying - CT */
@@ -935,7 +946,6 @@ int main(int argc, char *argv[])brs_pdu (0x02 ,0x11 ,0x0e ,AVRCP_GET_FOLDER_ITEMS , 0x00, 0x05, 0x04, 0xab, 0xcd, 0x00, 0x00)); -/* Media Player Selection IOP tests */ /* Listing of available media players */
Signature · 1 line
1.9.0
Luiz Augusto von Dentz
maintainerPATCH 22/35 unit/test-avrcp: Add /TP/MCN/NP/BV-08-C test
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
To verify the GetItemAttributes command issued by the CT on a Media Item in the NowPlaying folder.
--- unit/test-avrcp.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
unit/test-avrcp.c +14 -0
@@ -669,6 +669,11 @@ static void test_client(gconstpointer data)avrcp_get_folder_items (context->session,AVRCP_MEDIA_NOW_PLAYING ,0 ,2 ,0 ,NULL ); +if (g_str_equal (context->data->test_name,"/TP/MCN/NP/BV-08-C" )) +avrcp_get_item_attributes (context->session, +AVRCP_MEDIA_NOW_PLAYING ,0x01 ,0xaabb , +0 ,NULL ); +if (g_str_equal (context->data->test_name,"/TP/CFG/BV-01-C" ))avrcp_get_capabilities (context->session,CAP_EVENTS_SUPPORTED );
@@ -946,6 +951,15 @@ int main(int argc, char *argv[])brs_pdu (0x02 ,0x11 ,0x0e ,AVRCP_GET_FOLDER_ITEMS , 0x00, 0x05, 0x04, 0xab, 0xcd, 0x00, 0x00)); +/* GetItemAttributes - CT */ +define_test ("/TP/MCN/NP/BV-08-C" , test_client, +raw_pdu (0x00 ,0x11 ,0x0e ,AVRCP_GET_ITEM_ATTRIBUTES , +0x00 ,0x0c ,AVRCP_MEDIA_NOW_PLAYING , +0x00 ,0x00 ,0x00 ,0x00 , +0x00 ,0x00 ,0x00 ,0x01 ,/* uid */ +0xaa ,0xbb ,/* counter */ +0x00 ));/* num attr */ +/* Media Player Selection IOP tests */ /* Listing of available media players */
Signature · 1 line
1.9.0
Luiz Augusto von Dentz
maintainerPATCH 23/35 unit/test-avrcp: Add /TP/MCN/NP/BV-09-C test
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
To verify the GetItemAttributes response issued by the TG on a Media Item in the NowPlaying folder.
--- unit/test-avrcp.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
unit/test-avrcp.c +11 -0
@@ -960,6 +960,17 @@ int main(int argc, char *argv[])0xaa ,0xbb ,/* counter */ 0x00)); /* num attr */ +/* GetItemAttributes - TG */ +define_test ("/TP/MCN/CB/BV-09-C" , test_server, +brs_pdu (0x00 ,0x11 ,0x0e ,AVRCP_GET_ITEM_ATTRIBUTES , +0x00 ,0x0c ,AVRCP_MEDIA_NOW_PLAYING , +0x00 ,0x00 ,0x00 ,0x00 , +0x00 ,0x00 ,0x00 ,0x01 ,/* uid */ +0xaa ,0xbb ,/* counter */ +0x00 ),/* num attr */ +brs_pdu (0x02 ,0x11 ,0x0e ,AVRCP_GET_ITEM_ATTRIBUTES , +0x00 ,0x02 ,0x04 ,0x00 )); +/* Media Player Selection IOP tests */ /* Listing of available media players */
Signature · 1 line
1.9.0
Luiz Augusto von Dentz
maintainerPATCH 24/35 android/avrcp: Add avrcp_play_item function
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
--- android/avrcp-lib.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ android/avrcp-lib.h | 3 +++ 2 files changed, 50 insertions(+)
android/avrcp-lib.c +47 -0
@@ -2234,6 +2234,53 @@ int avrcp_get_item_attributes(struct avrcp *session, uint8_t scope, session); } +static gboolean play_item_rsp (struct avctp *conn,uint8_t *operands, +size_t operand_count,void *user_data) +{ +struct avrcp *session = user_data; +struct avrcp_player *player = session->player; +struct avrcp_browsing_header *pdu; +int err; + +DBG ("" ); + +if (!player || !player->cfm || !player->cfm->play_item) +return FALSE; + + pdu =parse_browsing_pdu (operands, operand_count); +if (!pdu) { + err = -EPROTO ; + goto done; + } + + err =parse_browsing_status (pdu); + +done: + player->cfm->play_item (session, err, player->user_data); + +return FALSE; +} + +int avrcp_play_item (struct avrcp *session,uint8_t scope,uint64_t uid, +uint16_t counter) +{ +struct iovec iov; +uint8_t pdu[11 ]; + +if (scope >AVRCP_MEDIA_NOW_PLAYING ) +return -EINVAL ; + + pdu[0 ] = scope; +put_be64 (uid, &pdu[1 ]); +put_be16 (counter, &pdu[9 ]); + + iov.iov_base = pdu; + iov.iov_len =sizeof (pdu); + +return avrcp_send_browsing_req (session,AVRCP_PLAY_ITEM , &iov,1 , + play_item_rsp, session); +} +static gboolean search_rsp (struct avctp *conn,uint8_t *operands,size_t operand_count,void *user_data) {
android/avrcp-lib.h +3 -0
@@ -218,6 +218,7 @@ struct avrcp_control_cfm {void (*get_item_attributes) (struct avrcp *session,int err,uint8_t number,uint32_t *attrs,char **text,void *user_data); +void (*play_item) (struct avrcp *session,int err,void *user_data);void (*search) (struct avrcp *session,int err,uint16_t counter,uint32_t items,void *user_data); };
@@ -274,6 +275,8 @@ int avrcp_change_path(struct avrcp *session, uint8_t direction, uint64_t uid,int avrcp_get_item_attributes (struct avrcp *session,uint8_t scope,uint64_t uid,uint16_t counter,uint8_t number,uint32_t *attrs); +int avrcp_play_item (struct avrcp *session,uint8_t scope,uint64_t uid, +uint16_t counter);int avrcp_search (struct avrcp *session,const char *string); int avrcp_get_capabilities_rsp(struct avrcp *session, uint8_t transaction,
Signature · 1 line
1.9.0
Luiz Augusto von Dentz
maintainerPATCH 25/35 unit/test-avrcp: Add /TP/MCN/NP/BV-01-C test
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
To verify the PlayItem command issued by the CT.
--- unit/test-avrcp.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
unit/test-avrcp.c +11 -0
@@ -665,6 +665,10 @@ static void test_client(gconstpointer data)AVRCP_MEDIA_SEARCH ,0x01 ,0xaabb , 0, NULL); +if (g_str_equal (context->data->test_name,"/TP/MCN/NP/BV-01-C" )) +avrcp_play_item (context->session,AVRCP_MEDIA_NOW_PLAYING ,1 , +1 ); +if (g_str_equal (context->data->test_name,"/TP/MCN/NP/BV-05-C" ))avrcp_get_folder_items (context->session,AVRCP_MEDIA_NOW_PLAYING ,0 ,2 ,0 ,NULL );
@@ -933,6 +937,13 @@ int main(int argc, char *argv[])/* Media Content Navigation Commands and Notifications for NowPlaying */ +/* PlayItem - NowPlaying - CT */ +define_test ("/TP/MCN/NP/BV-01-C" , test_client, +brs_pdu (0x00 ,0x11 ,0x0e ,AVRCP_PLAY_ITEM , +0x00 ,0x0b ,AVRCP_MEDIA_NOW_PLAYING , +0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x01 , +0x00 ,0x01 )); +/* GetFolderItems - NowPlaying - CT */ define_test("/TP/MCN/NP/BV-05-C", test_client, brs_pdu(0x00, 0x11, 0x0e, AVRCP_GET_FOLDER_ITEMS,
Signature · 1 line
1.9.0
Luiz Augusto von Dentz
maintainerPATCH 26/35 android/avrcp-lib: Add support for parsing PlayItem PDU
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
--- android/avrcp-lib.c | 43 +++++++++++++++++++++++++++++++++++++++++++ android/avrcp-lib.h | 4 ++++ 2 files changed, 47 insertions(+)
android/avrcp-lib.c +43 -0
@@ -892,10 +892,39 @@ static ssize_t get_item_attributes(struct avrcp *session, uint8_t transaction, player->user_data); } +static ssize_t play_item (struct avrcp *session,uint8_t transaction, +uint16_t params_len,uint8_t *params, +void *user_data) +{ +struct avrcp_player *player = user_data; +uint8_t scope; +uint64_t uid; +uint16_t counter; + +DBG ("" ); + +if (!player->ind || !player->ind->play_item) +return -ENOSYS ; + +if (!params || params_len <11 ) +return -EINVAL ; + + scope = params[0 ]; +if (scope >AVRCP_MEDIA_NOW_PLAYING ) +return -EBADRQC ; + + uid =get_be64 (¶ms[1 ]); + counter =get_be16 (¶ms[9 ]); + +return player->ind->play_item (session, transaction, scope, uid, + counter, player->user_data); +} +static const struct avrcp_browsing_handler browsing_handlers[] = { {AVRCP_GET_FOLDER_ITEMS , get_folder_items }, {AVRCP_CHANGE_PATH , change_path }, {AVRCP_GET_ITEM_ATTRIBUTES , get_item_attributes }, + {AVRCP_PLAY_ITEM , play_item }, { }, };
@@ -2662,6 +2691,20 @@ int avrcp_get_item_attributes_rsp(struct avrcp *session, uint8_t transaction, number * 2 + 1); } +int avrcp_play_item_rsp (struct avrcp *session,uint8_t transaction) +{ +struct iovec iov; +uint8_t pdu; + + pdu =AVRCP_STATUS_SUCCESS ; + + iov.iov_base = &pdu; + iov.iov_len =sizeof (pdu); + +return avrcp_send_browsing (session, transaction,AVRCP_PLAY_ITEM , + &iov,1 ); +} +int avrcp_send_passthrough (struct avrcp *session,uint32_t vendor,uint8_t op) {uint8_t params[5 ];
android/avrcp-lib.h +4 -0
@@ -170,6 +170,9 @@ struct avrcp_control_ind { uint8_t scope, uint64_t uid, uint16_t counter, uint8_t number, uint32_t *attrs, void *user_data); +int (*play_item) (struct avrcp *session,uint8_t transaction, +uint8_t scope,uint64_t uid, +uint16_t counter,void *user_data); };struct avrcp_control_cfm {
@@ -313,5 +316,6 @@ int avrcp_change_path_rsp(struct avrcp *session, uint8_t transaction,int avrcp_get_item_attributes_rsp (struct avrcp *session,uint8_t transaction,uint8_t number,uint32_t *attrs,const char **text); +int avrcp_play_item_rsp (struct avrcp *session,uint8_t transaction);int avrcp_send_passthrough (struct avrcp *session,uint32_t vendor,uint8_t op);
Signature · 1 line
1.9.0
Luiz Augusto von Dentz
maintainerPATCH 27/35 unit/test-avrcp: Add /TP/MCN/NP/BV-02-C test
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
To verify the PlayItem response issued by the TG.
--- unit/test-avrcp.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
unit/test-avrcp.c +20 -0
@@ -593,6 +593,16 @@ static int get_item_attributes(struct avrcp *session, uint8_t transaction,return -EAGAIN ; } +static int play_item (struct avrcp *session,uint8_t transaction,uint8_t scope, +uint64_t uid,uint16_t counter,void *user_data) +{ +DBG ("" ); + +avrcp_play_item_rsp (session, transaction); + +return -EAGAIN ; +} +static const struct avrcp_control_ind control_ind = { .get_capabilities = get_capabilities, .list_attributes = list_attributes,
@@ -608,6 +618,7 @@ static const struct avrcp_control_ind control_ind = { .get_folder_items = get_folder_items, .change_path = change_path, .get_item_attributes = get_item_attributes, + .play_item = play_item, };static void test_server (gconstpointer data)
@@ -944,6 +955,15 @@ int main(int argc, char *argv[])0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x01 , 0x00, 0x01)); +/* PlayItem - NowPlaying - TG */ +define_test ("/TP/MCN/NP/BV-02-C" , test_server, +brs_pdu (0x00 ,0x11 ,0x0e ,AVRCP_PLAY_ITEM , +0x00 ,0x0b ,AVRCP_MEDIA_NOW_PLAYING , +0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x01 , +0x00 ,0x01 ), +brs_pdu (0x02 ,0x11 ,0x0e ,AVRCP_PLAY_ITEM , +0x00 ,0x01 ,0x04 )); +/* GetFolderItems - NowPlaying - CT */ define_test("/TP/MCN/NP/BV-05-C", test_client, brs_pdu(0x00, 0x11, 0x0e, AVRCP_GET_FOLDER_ITEMS,
Signature · 1 line
1.9.0
Luiz Augusto von Dentz
maintainerPATCH 28/35 unit/test-avrcp: Add /TP/MCN/NP/BI-01-C test
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
To verify the PlayItem response issued by the TG when an invalid UID is requested.
--- unit/test-avrcp.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
unit/test-avrcp.c +13 -0
@@ -598,6 +598,9 @@ static int play_item(struct avrcp *session, uint8_t transaction, uint8_t scope, {DBG ("" ); +if (!uid) +return -ENOENT ; +avrcp_play_item_rsp (session, transaction);return -EAGAIN ;
@@ -1002,6 +1005,16 @@ int main(int argc, char *argv[])brs_pdu (0x02 ,0x11 ,0x0e ,AVRCP_GET_ITEM_ATTRIBUTES , 0x00, 0x02, 0x04, 0x00)); +/* PlayItem - NowPlaying - TG */ +define_test ("/TP/MCN/NP/BI-01-C" , test_server, +brs_pdu (0x00 ,0x11 ,0x0e ,AVRCP_PLAY_ITEM , +0x00 ,0x0b ,AVRCP_MEDIA_NOW_PLAYING , +0x00 ,0x00 ,0x00 ,0x00 , +0x00 ,0x00 ,0x00 ,0x00 ,/* uid */ +0xaa ,0xbb ),/* counter */ +brs_pdu (0x02 ,0x11 ,0x0e ,AVRCP_PLAY_ITEM , +0x00 ,0x01 ,0x09 )); +/* Media Player Selection IOP tests */ /* Listing of available media players */
Signature · 1 line
1.9.0
Luiz Augusto von Dentz
maintainerPATCH 29/35 android/avrcp-lib: Add support for parsing Search PDU
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
--- android/avrcp-lib.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ android/avrcp-lib.h | 4 ++++ 2 files changed, 53 insertions(+)
android/avrcp-lib.c +49 -0
@@ -920,11 +920,43 @@ static ssize_t play_item(struct avrcp *session, uint8_t transaction, counter, player->user_data); } +static ssize_t search (struct avrcp *session,uint8_t transaction, +uint16_t params_len,uint8_t *params, +void *user_data) +{ +struct avrcp_player *player = user_data; +char *string; +uint16_t len; +int ret; + +DBG ("" ); + +if (!player->ind || !player->ind->search) +return -ENOSYS ; + +if (!params || params_len <4 ) +return -EINVAL ; + + len =get_be16 (¶ms[2 ]); +if (!len) +return -EINVAL ; + + string =strndup ((void *) ¶ms[4 ], len); + + ret = player->ind->search (session, transaction, string, + player->user_data); + +free (string); + +return ret; +} +static const struct avrcp_browsing_handler browsing_handlers[] = { {AVRCP_GET_FOLDER_ITEMS , get_folder_items }, {AVRCP_CHANGE_PATH , change_path }, {AVRCP_GET_ITEM_ATTRIBUTES , get_item_attributes }, {AVRCP_PLAY_ITEM , play_item }, + {AVRCP_SEARCH , search }, { }, };
@@ -2705,6 +2737,23 @@ int avrcp_play_item_rsp(struct avrcp *session, uint8_t transaction) &iov, 1); } +int avrcp_search_rsp (struct avrcp *session,uint8_t transaction, +uint16_t counter,uint32_t items) +{ +struct iovec iov; +uint8_t pdu[7 ]; + + pdu[0 ] =AVRCP_STATUS_SUCCESS ; +put_be16 (counter, &pdu[1 ]); +put_be32 (items, &pdu[3 ]); + + iov.iov_base = pdu; + iov.iov_len =sizeof (pdu); + +return avrcp_send_browsing (session, transaction,AVRCP_SEARCH , + &iov,1 ); +} +int avrcp_send_passthrough (struct avrcp *session,uint32_t vendor,uint8_t op) {uint8_t params[5 ];
android/avrcp-lib.h +4 -0
@@ -173,6 +173,8 @@ struct avrcp_control_ind {int (*play_item) (struct avrcp *session,uint8_t transaction,uint8_t scope,uint64_t uid,uint16_t counter,void *user_data); +int (*search) (struct avrcp *session,uint8_t transaction, +const char *string,void *user_data); };struct avrcp_control_cfm {
@@ -317,5 +319,7 @@ int avrcp_get_item_attributes_rsp(struct avrcp *session, uint8_t transaction, uint8_t number, uint32_t *attrs, const char **text);int avrcp_play_item_rsp (struct avrcp *session,uint8_t transaction); +int avrcp_search_rsp (struct avrcp *session,uint8_t transaction, +uint16_t counter,uint32_t items);int avrcp_send_passthrough (struct avrcp *session,uint32_t vendor,uint8_t op);
Signature · 1 line
1.9.0
Luiz Augusto von Dentz
maintainerPATCH 30/35 unit/test-avrcp: Add /TP/MCN/SRC/BV-02-C test
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
To verify the Search response issued by the TG.
--- unit/test-avrcp.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
unit/test-avrcp.c +21 -0
@@ -606,6 +606,16 @@ static int play_item(struct avrcp *session, uint8_t transaction, uint8_t scope,return -EAGAIN ; } +static int search (struct avrcp *session,uint8_t transaction, +const char *string,void *user_data) +{ +DBG ("" ); + +avrcp_search_rsp (session, transaction,0xaabb ,0 ); + +return -EAGAIN ; +} +static const struct avrcp_control_ind control_ind = { .get_capabilities = get_capabilities, .list_attributes = list_attributes,
@@ -622,6 +632,7 @@ static const struct avrcp_control_ind control_ind = { .change_path = change_path, .get_item_attributes = get_item_attributes, .play_item = play_item, + .search = search, };static void test_server (gconstpointer data)
@@ -911,6 +922,16 @@ int main(int argc, char *argv[])0x00 ,0x07 , 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x72, 0x79)); +define_test ("/TP/MCN/SRC/BV-02-C" , test_server, +brs_pdu (0x00 ,0x11 ,0x0e ,AVRCP_SEARCH , +0x00 ,0x0b ,0x00 ,0x6a , +0x00 ,0x07 , +0x43 ,0x6f ,0x75 ,0x6e ,0x74 ,0x72 ,0x79 ), +brs_pdu (0x02 ,0x11 ,0x0e ,AVRCP_SEARCH , +0x00 ,0x07 ,0x04 , +0xaa ,0xbb ,/* counter */ +0x00 ,0x00 ,0x00 ,0x00 )); +/* GetFolderItems - CT */ define_test("/TP/MCN/SRC/BV-03-C", test_client, raw_pdu(0x00, 0x11, 0x0e, AVRCP_GET_FOLDER_ITEMS,
Signature · 1 line
1.9.0
Luiz Augusto von Dentz
maintainerPATCH 31/35 android/avrcp: Add avrcp_add_to_now_playing function
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
--- android/avrcp-lib.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ android/avrcp-lib.h | 4 ++++ 2 files changed, 52 insertions(+)
android/avrcp-lib.c +48 -0
@@ -2407,6 +2407,54 @@ int avrcp_search(struct avrcp *session, const char *string) search_rsp, session); } +static gboolean add_to_now_playing_rsp (struct avctp *conn,uint8_t *operands, +size_t operand_count,void *user_data) +{ +struct avrcp *session = user_data; +struct avrcp_player *player = session->player; +struct avrcp_browsing_header *pdu; +int err; + +DBG ("" ); + +if (!player || !player->cfm || !player->cfm->add_to_now_playing) +return FALSE; + + pdu =parse_browsing_pdu (operands, operand_count); +if (!pdu) { + err = -EPROTO ; + goto done; + } + + err =parse_browsing_status (pdu); + +done: + player->cfm->add_to_now_playing (session, err, player->user_data); + +return FALSE; +} + +int avrcp_add_to_now_playing (struct avrcp *session,uint8_t scope,uint64_t uid, +uint16_t counter) +{ +struct iovec iov; +uint8_t pdu[11 ]; + +if (scope >AVRCP_MEDIA_NOW_PLAYING ) +return -EINVAL ; + + pdu[0 ] = scope; +put_be64 (uid, &pdu[1 ]); +put_be16 (counter, &pdu[9 ]); + + iov.iov_base = pdu; + iov.iov_len =sizeof (pdu); + +return avrcp_send_browsing_req (session,AVRCP_ADD_TO_NOW_PLAYING , + &iov,1 , add_to_now_playing_rsp, + session); +} +int avrcp_get_capabilities_rsp (struct avrcp *session,uint8_t transaction,uint8_t number,uint8_t *events) {
android/avrcp-lib.h +4 -0
@@ -226,6 +226,8 @@ struct avrcp_control_cfm {void (*play_item) (struct avrcp *session,int err,void *user_data);void (*search) (struct avrcp *session,int err,uint16_t counter,uint32_t items,void *user_data); +void (*add_to_now_playing) (struct avrcp *session,int err, +void *user_data); };struct avrcp_passthrough_handler {
@@ -283,6 +285,8 @@ int avrcp_get_item_attributes(struct avrcp *session, uint8_t scope,int avrcp_play_item (struct avrcp *session,uint8_t scope,uint64_t uid,uint16_t counter);int avrcp_search (struct avrcp *session,const char *string); +int avrcp_add_to_now_playing (struct avrcp *session,uint8_t scope,uint64_t uid, +uint16_t counter);int avrcp_get_capabilities_rsp (struct avrcp *session,uint8_t transaction,uint8_t number,uint8_t *events);
Signature · 1 line
1.9.0
Luiz Augusto von Dentz
maintainerPATCH 32/35 unit/test-avrcp: Add /TP/MCN/NP/BV-03-C test
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
To verify the AddToNowPlaying command issued by the CT.
--- unit/test-avrcp.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
unit/test-avrcp.c +12 -0
@@ -694,6 +694,10 @@ static void test_client(gconstpointer data)avrcp_play_item (context->session,AVRCP_MEDIA_NOW_PLAYING ,1 ,1 ); +if (g_str_equal (context->data->test_name,"/TP/MCN/NP/BV-03-C" )) +avrcp_add_to_now_playing (context->session, +AVRCP_MEDIA_NOW_PLAYING ,0x01 ,0xaabb ); +if (g_str_equal (context->data->test_name,"/TP/MCN/NP/BV-05-C" ))avrcp_get_folder_items (context->session,AVRCP_MEDIA_NOW_PLAYING ,0 ,2 ,0 ,NULL );
@@ -988,6 +992,14 @@ int main(int argc, char *argv[])brs_pdu (0x02 ,0x11 ,0x0e ,AVRCP_PLAY_ITEM , 0x00, 0x01, 0x04)); +/* AddToNowPlaying - NowPlaying - CT */ +define_test ("/TP/MCN/NP/BV-03-C" , test_client, +brs_pdu (0x00 ,0x11 ,0x0e ,AVRCP_ADD_TO_NOW_PLAYING , +0x00 ,0x0b ,AVRCP_MEDIA_NOW_PLAYING , +0x00 ,0x00 ,0x00 ,0x00 , +0x00 ,0x00 ,0x00 ,0x01 ,/* uid */ +0xaa ,0xbb )); +/* GetFolderItems - NowPlaying - CT */ define_test("/TP/MCN/NP/BV-05-C", test_client, brs_pdu(0x00, 0x11, 0x0e, AVRCP_GET_FOLDER_ITEMS,
Signature · 1 line
1.9.0
Luiz Augusto von Dentz
maintainerPATCH 33/35 android/avrcp-lib: Add support for parsing AddToNowPlaying PDU
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
--- android/avrcp-lib.c | 43 +++++++++++++++++++++++++++++++++++++++++++ android/avrcp-lib.h | 4 ++++ 2 files changed, 47 insertions(+)
android/avrcp-lib.c +43 -0
@@ -951,12 +951,41 @@ static ssize_t search(struct avrcp *session, uint8_t transaction,return ret; } +static ssize_t add_to_now_playing (struct avrcp *session,uint8_t transaction, +uint16_t params_len,uint8_t *params, +void *user_data) +{ +struct avrcp_player *player = user_data; +uint8_t scope; +uint64_t uid; +uint16_t counter; + +DBG ("" ); + +if (!player->ind || !player->ind->add_to_now_playing) +return -ENOSYS ; + +if (!params || params_len <11 ) +return -EINVAL ; + + scope = params[0 ]; +if (scope >AVRCP_MEDIA_NOW_PLAYING ) +return -EBADRQC ; + + uid =get_be64 (¶ms[1 ]); + counter =get_be16 (¶ms[9 ]); + +return player->ind->add_to_now_playing (session, transaction, scope, uid, + counter, player->user_data); +} +static const struct avrcp_browsing_handler browsing_handlers[] = { {AVRCP_GET_FOLDER_ITEMS , get_folder_items }, {AVRCP_CHANGE_PATH , change_path }, {AVRCP_GET_ITEM_ATTRIBUTES , get_item_attributes }, {AVRCP_PLAY_ITEM , play_item }, {AVRCP_SEARCH , search }, + {AVRCP_ADD_TO_NOW_PLAYING , add_to_now_playing }, { }, };
@@ -2802,6 +2831,20 @@ int avrcp_search_rsp(struct avrcp *session, uint8_t transaction, &iov, 1); } +int avrcp_add_to_now_playing_rsp (struct avrcp *session,uint8_t transaction) +{ +struct iovec iov; +uint8_t pdu; + + pdu =AVRCP_STATUS_SUCCESS ; + + iov.iov_base = &pdu; + iov.iov_len =sizeof (pdu); + +return avrcp_send_browsing (session, transaction, +AVRCP_ADD_TO_NOW_PLAYING , &iov,1 ); +} +int avrcp_send_passthrough (struct avrcp *session,uint32_t vendor,uint8_t op) {uint8_t params[5 ];
android/avrcp-lib.h +4 -0
@@ -175,6 +175,9 @@ struct avrcp_control_ind { uint16_t counter, void *user_data);int (*search) (struct avrcp *session,uint8_t transaction,const char *string,void *user_data); +int (*add_to_now_playing) (struct avrcp *session,uint8_t transaction, +uint8_t scope,uint64_t uid, +uint16_t counter,void *user_data); };struct avrcp_control_cfm {
@@ -325,5 +328,6 @@ int avrcp_get_item_attributes_rsp(struct avrcp *session, uint8_t transaction,int avrcp_play_item_rsp (struct avrcp *session,uint8_t transaction);int avrcp_search_rsp (struct avrcp *session,uint8_t transaction,uint16_t counter,uint32_t items); +int avrcp_add_to_now_playing_rsp (struct avrcp *session,uint8_t transaction);int avrcp_send_passthrough (struct avrcp *session,uint32_t vendor,uint8_t op);
Signature · 1 line
1.9.0
Luiz Augusto von Dentz
maintainerPATCH 34/35 unit/test-avrcp: Add /TP/MCN/NP/BV-04-C test
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
To verify the AddToNowPlaying response issued by the TG.
--- unit/test-avrcp.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
unit/test-avrcp.c +22 -0
@@ -616,6 +616,17 @@ static int search(struct avrcp *session, uint8_t transaction,return -EAGAIN ; } +static int add_to_now_playing (struct avrcp *session,uint8_t transaction, +uint8_t scope,uint64_t uid,uint16_t counter, +void *user_data) +{ +DBG ("" ); + +avrcp_add_to_now_playing_rsp (session, transaction); + +return -EAGAIN ; +} +static const struct avrcp_control_ind control_ind = { .get_capabilities = get_capabilities, .list_attributes = list_attributes,
@@ -633,6 +644,7 @@ static const struct avrcp_control_ind control_ind = { .get_item_attributes = get_item_attributes, .play_item = play_item, .search = search, + .add_to_now_playing = add_to_now_playing, };static void test_server (gconstpointer data)
@@ -1000,6 +1012,16 @@ int main(int argc, char *argv[])0x00 ,0x00 ,0x00 ,0x01 ,/* uid */ 0xaa, 0xbb)); +/* AddToNowPlaying - NowPlaying - TG */ +define_test ("/TP/MCN/NP/BV-04-C" , test_server, +brs_pdu (0x00 ,0x11 ,0x0e ,AVRCP_ADD_TO_NOW_PLAYING , +0x00 ,0x0b ,AVRCP_MEDIA_NOW_PLAYING , +0x00 ,0x00 ,0x00 ,0x00 , +0x00 ,0x00 ,0x00 ,0x01 ,/* uid */ +0xaa ,0xbb ), +brs_pdu (0x02 ,0x11 ,0x0e ,AVRCP_ADD_TO_NOW_PLAYING , +0x00 ,0x01 ,0x04 )); +/* GetFolderItems - NowPlaying - CT */ define_test("/TP/MCN/NP/BV-05-C", test_client, brs_pdu(0x00, 0x11, 0x0e, AVRCP_GET_FOLDER_ITEMS,
Signature · 1 line
1.9.0
Luiz Augusto von Dentz
maintainerPATCH 35/35 unit/test-avrcp: Add /TP/MCN/NP/BI-02-C test
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
To verify the AddToNowPlaying response issued by the TG when an invalid UID is requested.
--- unit/test-avrcp.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
unit/test-avrcp.c +13 -0
@@ -622,6 +622,9 @@ static int add_to_now_playing(struct avrcp *session, uint8_t transaction, {DBG ("" ); +if (!uid) +return -ENOENT ; +avrcp_add_to_now_playing_rsp (session, transaction);return -EAGAIN ;
@@ -1070,6 +1073,16 @@ int main(int argc, char *argv[])brs_pdu (0x02 ,0x11 ,0x0e ,AVRCP_PLAY_ITEM , 0x00, 0x01, 0x09)); +/* AddToNowPlaying - NowPlaying - TG */ +define_test ("/TP/MCN/NP/BI-02-C" , test_server, +brs_pdu (0x00 ,0x11 ,0x0e ,AVRCP_ADD_TO_NOW_PLAYING , +0x00 ,0x0b ,AVRCP_MEDIA_NOW_PLAYING , +0x00 ,0x00 ,0x00 ,0x00 , +0x00 ,0x00 ,0x00 ,0x00 ,/* uid */ +0xaa ,0xbb ),/* counter */ +brs_pdu (0x02 ,0x11 ,0x0e ,AVRCP_ADD_TO_NOW_PLAYING , +0x00 ,0x01 ,0x09 )); +/* Media Player Selection IOP tests */ /* Listing of available media players */
Signature · 1 line
1.9.0