OSDN Git Service

android/avrcp-lib: Add support for parsing SetAddressed response
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Tue, 1 Apr 2014 10:27:51 +0000 (13:27 +0300)
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Wed, 2 Apr 2014 11:25:40 +0000 (14:25 +0300)
android/avrcp-lib.c
android/avrcp-lib.h
unit/test-avrcp.c

index cf7dadf..c218fd7 100644 (file)
@@ -1463,8 +1463,36 @@ int avrcp_get_element_attributes(struct avrcp *session)
                                get_element_attributes_rsp, session);
 }
 
-int avrcp_set_addressed_player(struct avrcp *session, uint16_t player_id,
-                                       avctp_rsp_cb func, void *user_data)
+static gboolean set_addressed_rsp(struct avctp *conn,
+                                       uint8_t code, uint8_t subunit,
+                                       uint8_t *operands, size_t operand_count,
+                                       void *user_data)
+{
+       struct avrcp *session = user_data;
+       struct avrcp_player *player = session->player;
+       struct avrcp_header *pdu;
+       int err;
+
+       DBG("");
+
+       if (!player || !player->cfm || !player->cfm->set_addressed)
+               return FALSE;
+
+       pdu = parse_pdu(operands, operand_count);
+       if (!pdu) {
+               err = -EPROTO;
+               goto done;
+       }
+
+       err = parse_status(pdu);
+
+done:
+       player->cfm->set_addressed(session, err, player->user_data);
+
+       return FALSE;
+}
+
+int avrcp_set_addressed_player(struct avrcp *session, uint16_t player_id)
 {
        uint8_t params[2];
 
@@ -1472,7 +1500,8 @@ int avrcp_set_addressed_player(struct avrcp *session, uint16_t player_id,
 
        return avrcp_send_req(session, AVC_CTYPE_CONTROL, AVC_SUBUNIT_PANEL,
                                AVRCP_SET_ADDRESSED_PLAYER, params,
-                               sizeof(params), func, user_data);
+                               sizeof(params), set_addressed_rsp,
+                               session);
 }
 
 int avrcp_get_capabilities_rsp(struct avrcp *session, uint8_t transaction,
index 0b867aa..5c5790a 100644 (file)
@@ -194,6 +194,8 @@ struct avrcp_control_cfm {
        bool (*register_notification) (struct avrcp *session, int err,
                                        uint8_t code, uint8_t event,
                                        uint8_t *params, void *user_data);
+       void (*set_addressed) (struct avrcp *session, int err,
+                                       void *user_data);
 };
 
 struct avrcp_passthrough_handler {
@@ -237,8 +239,7 @@ int avrcp_get_play_status(struct avrcp *session);
 int avrcp_set_volume(struct avrcp *session, uint8_t volume, avctp_rsp_cb func,
                                                        void *user_data);
 int avrcp_get_element_attributes(struct avrcp *session);
-int avrcp_set_addressed_player(struct avrcp *session, uint16_t player_id,
-                                       avctp_rsp_cb func, void *user_data);
+int avrcp_set_addressed_player(struct avrcp *session, uint16_t player_id);
 
 int avrcp_get_capabilities_rsp(struct avrcp *session, uint8_t transaction,
                                        uint8_t number, uint8_t *events);
index 5b259bd..73fd58d 100644 (file)
@@ -487,8 +487,7 @@ static void test_client(gconstpointer data)
        struct context *context = create_context(0x0100, data);
 
        if (g_str_equal(context->data->test_name, "/TP/MPS/BV-01-C"))
-               avrcp_set_addressed_player(context->session, 0xabcd, NULL,
-                                                                       NULL);
+               avrcp_set_addressed_player(context->session, 0xabcd);
 
        if (g_str_equal(context->data->test_name, "/TP/CFG/BV-01-C"))
                avrcp_get_capabilities(context->session, CAP_EVENTS_SUPPORTED);