From: Andrei Emeltchenko <[email protected]>
Test verifies that the list player application setting values response
issued from the Target.
---
unit/test-avrcp.c | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/unit/test-avrcp.c b/unit/test-avrcp.c
index db9cb92..51fe064 100644
--- a/unit/test-avrcp.c
+++ b/unit/test-avrcp.c
@@ -355,6 +355,26 @@ static uint8_t avrcp_handle_get_player_attr_text(struct avrcp *session,
return AVC_CTYPE_STABLE;
}
+static uint8_t avrcp_handle_list_player_values(struct avrcp *session,
+ uint8_t transaction, uint16_t *params_len,
+ uint8_t *params, void *user_data)
+{
+ DBG("params[0] %d params_len %d", params[0], *params_len);
+
+ if (*params_len != 1)
+ goto fail;
+
+ *params_len = 1;
+ params[0] = 0;
+ return AVC_CTYPE_STABLE;
+
+fail:
+ *params_len = 1;
+ params[0] = AVRCP_STATUS_INVALID_PARAM;
+
+ return AVC_CTYPE_REJECTED;
+}
+
static const struct avrcp_control_handler control_handlers[] = {
{ AVRCP_GET_CAPABILITIES, AVC_CTYPE_STATUS,
avrcp_handle_get_capabilities },
@@ -362,6 +382,8 @@ static const struct avrcp_control_handler control_handlers[] = {
avrcp_handle_list_attributes },
{ AVRCP_GET_PLAYER_ATTRIBUTE_TEXT, AVC_CTYPE_STATUS,
avrcp_handle_get_player_attr_text },
+ { AVRCP_LIST_PLAYER_VALUES, AVC_CTYPE_STATUS,
+ avrcp_handle_list_player_values },
{ },
};
@@ -518,5 +540,15 @@ int main(int argc, char *argv[])
AVRCP_GET_PLAYER_ATTRIBUTE_TEXT,
0x00, 0x00, 0x01, 0x00));
+ define_test("/TP/PAS/BV-06-C", test_server,
+ raw_pdu(0x00, 0x11, 0x0e, 0x01, 0x48, 0x00,
+ 0x00, 0x19, 0x58,
+ AVRCP_LIST_PLAYER_VALUES,
+ 0x00, 0x00, 0x01, 0x00),
+ raw_pdu(0x02, 0x11, 0x0e, 0x0c, 0x48, 0x00,
+ 0x00, 0x19, 0x58,
+ AVRCP_LIST_PLAYER_VALUES,
+ 0x00, 0x00, 0x01, 0x00));
+
return g_test_run();
}
--
1.8.3.2
Hi Andrei,
On Fri, Feb 28, 2014 at 3:18 PM, Andrei Emeltchenko
<[email protected]> wrote:
> From: Andrei Emeltchenko <[email protected]>
>
> Test verifies that the list player application setting values response
> issued from the Target.
> ---
> unit/test-avrcp.c | 32 ++++++++++++++++++++++++++++++++
> 1 file changed, 32 insertions(+)
>
> diff --git a/unit/test-avrcp.c b/unit/test-avrcp.c
> index db9cb92..51fe064 100644
> --- a/unit/test-avrcp.c
> +++ b/unit/test-avrcp.c
> @@ -355,6 +355,26 @@ static uint8_t avrcp_handle_get_player_attr_text(struct avrcp *session,
> return AVC_CTYPE_STABLE;
> }
>
> +static uint8_t avrcp_handle_list_player_values(struct avrcp *session,
> + uint8_t transaction, uint16_t *params_len,
> + uint8_t *params, void *user_data)
> +{
> + DBG("params[0] %d params_len %d", params[0], *params_len);
> +
> + if (*params_len != 1)
> + goto fail;
> +
> + *params_len = 1;
> + params[0] = 0;
> + return AVC_CTYPE_STABLE;
> +
> +fail:
> + *params_len = 1;
> + params[0] = AVRCP_STATUS_INVALID_PARAM;
> +
> + return AVC_CTYPE_REJECTED;
> +}
> +
> static const struct avrcp_control_handler control_handlers[] = {
> { AVRCP_GET_CAPABILITIES, AVC_CTYPE_STATUS,
> avrcp_handle_get_capabilities },
> @@ -362,6 +382,8 @@ static const struct avrcp_control_handler control_handlers[] = {
> avrcp_handle_list_attributes },
> { AVRCP_GET_PLAYER_ATTRIBUTE_TEXT, AVC_CTYPE_STATUS,
> avrcp_handle_get_player_attr_text },
> + { AVRCP_LIST_PLAYER_VALUES, AVC_CTYPE_STATUS,
> + avrcp_handle_list_player_values },
> { },
> };
>
> @@ -518,5 +540,15 @@ int main(int argc, char *argv[])
> AVRCP_GET_PLAYER_ATTRIBUTE_TEXT,
> 0x00, 0x00, 0x01, 0x00));
>
> + define_test("/TP/PAS/BV-06-C", test_server,
> + raw_pdu(0x00, 0x11, 0x0e, 0x01, 0x48, 0x00,
> + 0x00, 0x19, 0x58,
> + AVRCP_LIST_PLAYER_VALUES,
> + 0x00, 0x00, 0x01, 0x00),
> + raw_pdu(0x02, 0x11, 0x0e, 0x0c, 0x48, 0x00,
> + 0x00, 0x19, 0x58,
> + AVRCP_LIST_PLAYER_VALUES,
> + 0x00, 0x00, 0x01, 0x00));
> +
> return g_test_run();
> }
> --
> 1.8.3.2
Hold on with the unit tests, we need to add the asynchronous response
support otherwise it wont work with Android.
--
Luiz Augusto von Dentz
Hi Andrei,
On Fri, Feb 28, 2014 at 3:18 PM, Andrei Emeltchenko
<[email protected]> wrote:
> From: Andrei Emeltchenko <[email protected]>
>
> Fix size check taking into account that attributes starts from 1 (0 is
> illegal).
> ---
> profiles/audio/avrcp.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c
> index c0e5d07..48c3355 100644
> --- a/profiles/audio/avrcp.c
> +++ b/profiles/audio/avrcp.c
> @@ -1909,7 +1909,7 @@ static void avrcp_get_current_player_value(struct avrcp *session,
> struct avrcp_header *pdu = (void *) buf;
> uint16_t length = AVRCP_HEADER_LENGTH + count + 1;
>
> - if (count > AVRCP_ATTRIBUTE_LAST + 1)
> + if (count > AVRCP_ATTRIBUTE_LAST)
> return;
>
> memset(buf, 0, sizeof(buf));
> --
> 1.8.3.2
This does not apply anymore, there is no check inside
avrcp_get_current_player_value.
--
Luiz Augusto von Dentz
From: Andrei Emeltchenko <[email protected]>
Test verifies that verify the get player application setting values
response issued from the Target.
---
unit/test-avrcp.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/unit/test-avrcp.c b/unit/test-avrcp.c
index 51fe064..b469dfd 100644
--- a/unit/test-avrcp.c
+++ b/unit/test-avrcp.c
@@ -375,6 +375,18 @@ fail:
return AVC_CTYPE_REJECTED;
}
+static uint8_t avrcp_handle_get_player_value_text(struct avrcp *session,
+ uint8_t transaction, uint16_t *params_len,
+ uint8_t *params, void *user_data)
+{
+ DBG("");
+
+ *params_len = 1;
+ params[0] = 0;
+
+ return AVC_CTYPE_STABLE;
+}
+
static const struct avrcp_control_handler control_handlers[] = {
{ AVRCP_GET_CAPABILITIES, AVC_CTYPE_STATUS,
avrcp_handle_get_capabilities },
@@ -384,6 +396,8 @@ static const struct avrcp_control_handler control_handlers[] = {
avrcp_handle_get_player_attr_text },
{ AVRCP_LIST_PLAYER_VALUES, AVC_CTYPE_STATUS,
avrcp_handle_list_player_values },
+ { AVRCP_GET_PLAYER_VALUE_TEXT, AVC_CTYPE_STATUS,
+ avrcp_handle_get_player_value_text },
{ },
};
@@ -550,5 +564,15 @@ int main(int argc, char *argv[])
AVRCP_LIST_PLAYER_VALUES,
0x00, 0x00, 0x01, 0x00));
+ define_test("/TP/PAS/BV-08-C", test_server,
+ raw_pdu(0x00, 0x11, 0x0e, 0x01, 0x48, 0x00,
+ 0x00, 0x19, 0x58,
+ AVRCP_GET_PLAYER_VALUE_TEXT,
+ 0x00, 0x00, 0x01, 0x00),
+ raw_pdu(0x02, 0x11, 0x0e, 0x0c, 0x48, 0x00,
+ 0x00, 0x19, 0x58,
+ AVRCP_GET_PLAYER_VALUE_TEXT,
+ 0x00, 0x00, 0x01, 0x00));
+
return g_test_run();
}
--
1.8.3.2
From: Andrei Emeltchenko <[email protected]>
Update AVRCP test numbers.
---
doc/test-coverage.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/doc/test-coverage.txt b/doc/test-coverage.txt
index d37bcb8..805af68 100644
--- a/doc/test-coverage.txt
+++ b/doc/test-coverage.txt
@@ -18,7 +18,7 @@ test-ringbuf 3 Ring buffer functionality
test-queue 1 Queue handling functionality
test-avdtp 60 AVDTP qualification test cases
test-avctp 9 AVCTP qualification test cases
-test-avrcp 7 AVRCP qualification test cases
+test-avrcp 19 AVRCP qualification test cases
test-gobex 31 Generic OBEX functionality
test-gobex-packet 9 OBEX packet handling
test-gobex-header 28 OBEX header handling
--
1.8.3.2
From: Andrei Emeltchenko <[email protected]>
Test verifies that the get current player application setting value
response issued from the Target.
---
unit/test-avrcp.c | 38 ++++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git a/unit/test-avrcp.c b/unit/test-avrcp.c
index f297efd..0206e19 100644
--- a/unit/test-avrcp.c
+++ b/unit/test-avrcp.c
@@ -387,6 +387,28 @@ static uint8_t avrcp_handle_get_player_value_text(struct avrcp *session,
return AVC_CTYPE_STABLE;
}
+static uint8_t avrcp_handle_get_current_player_value(struct avrcp *session,
+ uint8_t transaction, uint16_t *params_len,
+ uint8_t *params, void *user_data)
+{
+ uint8_t *attributes;
+ int i;
+
+ DBG("num attributes %d", params[0]);
+
+ attributes = g_memdup(¶ms[1], params[0]);
+
+ for (i = 0; i < params[0]; i++) {
+ params[i * 2 + 1] = attributes[i];
+ params[i * 2 + 2] = 0; /* value */
+ }
+
+ params[0] = i;
+ *params_len = params[0] * 2 + 1;
+
+ return AVC_CTYPE_STABLE;
+}
+
static const struct avrcp_control_handler control_handlers[] = {
{ AVRCP_GET_CAPABILITIES, AVC_CTYPE_STATUS,
avrcp_handle_get_capabilities },
@@ -396,6 +418,8 @@ static const struct avrcp_control_handler control_handlers[] = {
avrcp_handle_get_player_attr_text },
{ AVRCP_LIST_PLAYER_VALUES, AVC_CTYPE_STATUS,
avrcp_handle_list_player_values },
+ { AVRCP_GET_CURRENT_PLAYER_VALUE, AVC_CTYPE_STATUS,
+ avrcp_handle_get_current_player_value },
{ AVRCP_GET_PLAYER_VALUE_TEXT, AVC_CTYPE_STATUS,
avrcp_handle_get_player_value_text },
{ },
@@ -590,5 +614,19 @@ int main(int argc, char *argv[])
AVRCP_ATTRIBUTE_EQUALIZER,
AVRCP_ATTRIBUTE_REPEAT_MODE));
+ define_test("/TP/PAS/BV-10-C", test_server,
+ raw_pdu(0x00, 0x11, 0x0e, 0x01, 0x48, 0x00,
+ 0x00, 0x19, 0x58,
+ AVRCP_GET_CURRENT_PLAYER_VALUE,
+ 0x00, 0x00, 0x03, 0x02,
+ AVRCP_ATTRIBUTE_EQUALIZER,
+ AVRCP_ATTRIBUTE_REPEAT_MODE),
+ raw_pdu(0x02, 0x11, 0x0e, 0x0c, 0x48, 0x00,
+ 0x00, 0x19, 0x58,
+ AVRCP_GET_CURRENT_PLAYER_VALUE,
+ 0x00, 0x00, 0x05, 0x02,
+ AVRCP_ATTRIBUTE_EQUALIZER, 0x00,
+ AVRCP_ATTRIBUTE_REPEAT_MODE, 0x00));
+
return g_test_run();
}
--
1.8.3.2
From: Andrei Emeltchenko <[email protected]>
Test verifies that the set player application setting value command
issued from the Controller.
---
unit/test-avrcp.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/unit/test-avrcp.c b/unit/test-avrcp.c
index 0206e19..76fcdaf 100644
--- a/unit/test-avrcp.c
+++ b/unit/test-avrcp.c
@@ -461,6 +461,16 @@ static void test_client(gconstpointer data)
sizeof(attributes), NULL, NULL);
}
+ if (g_str_equal(context->data->test_name, "/TP/PAS/BV-11-C")) {
+ uint8_t attributes[2] = { AVRCP_ATTRIBUTE_EQUALIZER,
+ AVRCP_ATTRIBUTE_REPEAT_MODE };
+ uint8_t values[] = { 0xaa, 0xff };
+
+ avrcp_set_player_value(context->session, attributes,
+ sizeof(attributes), values,
+ NULL, NULL);
+ }
+
execute_context(context);
}
@@ -628,5 +638,13 @@ int main(int argc, char *argv[])
AVRCP_ATTRIBUTE_EQUALIZER, 0x00,
AVRCP_ATTRIBUTE_REPEAT_MODE, 0x00));
+ define_test("/TP/PAS/BV-11-C", test_client,
+ raw_pdu(0x00, 0x11, 0x0e, 0x00, 0x48, 0x00,
+ 0x00, 0x19, 0x58,
+ AVRCP_SET_PLAYER_VALUE,
+ 0x00, 0x00, 0x05, 0x02,
+ AVRCP_ATTRIBUTE_EQUALIZER, 0xaa,
+ AVRCP_ATTRIBUTE_REPEAT_MODE, 0xff));
+
return g_test_run();
}
--
1.8.3.2
From: Andrei Emeltchenko <[email protected]>
Test verifies that get current player application setting value command
issued from the Controller.
---
unit/test-avrcp.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/unit/test-avrcp.c b/unit/test-avrcp.c
index b469dfd..f297efd 100644
--- a/unit/test-avrcp.c
+++ b/unit/test-avrcp.c
@@ -429,6 +429,14 @@ static void test_client(gconstpointer data)
avrcp_get_player_attribute_text(context->session, NULL, 0,
NULL, NULL);
+ if (g_str_equal(context->data->test_name, "/TP/PAS/BV-09-C")) {
+ uint8_t attributes[2] = { AVRCP_ATTRIBUTE_EQUALIZER,
+ AVRCP_ATTRIBUTE_REPEAT_MODE };
+
+ avrcp_get_current_player_value(context->session, attributes,
+ sizeof(attributes), NULL, NULL);
+ }
+
execute_context(context);
}
@@ -574,5 +582,13 @@ int main(int argc, char *argv[])
AVRCP_GET_PLAYER_VALUE_TEXT,
0x00, 0x00, 0x01, 0x00));
+ define_test("/TP/PAS/BV-09-C", test_client,
+ raw_pdu(0x00, 0x11, 0x0e, 0x01, 0x48, 0x00,
+ 0x00, 0x19, 0x58,
+ AVRCP_GET_CURRENT_PLAYER_VALUE,
+ 0x00, 0x00, 0x03, 0x02,
+ AVRCP_ATTRIBUTE_EQUALIZER,
+ AVRCP_ATTRIBUTE_REPEAT_MODE));
+
return g_test_run();
}
--
1.8.3.2
From: Andrei Emeltchenko <[email protected]>
---
android/avrcp-lib.c | 18 ++++++++++++++++++
android/avrcp-lib.h | 3 +++
2 files changed, 21 insertions(+)
diff --git a/android/avrcp-lib.c b/android/avrcp-lib.c
index 053e9e1..41c354c 100644
--- a/android/avrcp-lib.c
+++ b/android/avrcp-lib.c
@@ -340,5 +340,23 @@ int avrcp_get_current_player_value(struct avrcp *session, uint8_t *attributes,
return avrcp_send_req(session, AVC_CTYPE_STATUS, AVC_SUBUNIT_PANEL,
AVRCP_GET_CURRENT_PLAYER_VALUE, buf,
attr_count + 1, func, user_data);
+}
+
+int avrcp_set_player_value(struct avrcp *session, uint8_t *attributes,
+ uint8_t attr_count, uint8_t *values,
+ avctp_rsp_cb func, void *user_data)
+{
+ uint8_t buf[2 * attr_count + 1];
+ int i;
+ buf[0] = attr_count;
+
+ for (i = 0; i < attr_count; i++) {
+ buf[i * 2 + 1] = attributes[i];
+ buf[i * 2 + 2] = values[i];
+ }
+
+ return avrcp_send_req(session, AVC_CTYPE_CONTROL, AVC_SUBUNIT_PANEL,
+ AVRCP_SET_PLAYER_VALUE, buf, 2 * attr_count + 1,
+ func, user_data);
}
diff --git a/android/avrcp-lib.h b/android/avrcp-lib.h
index 1f7eab0..c6d61e4 100644
--- a/android/avrcp-lib.h
+++ b/android/avrcp-lib.h
@@ -124,3 +124,6 @@ int avrcp_get_player_attribute_text(struct avrcp *session, uint8_t *attributes,
int avrcp_get_current_player_value(struct avrcp *session, uint8_t *attributes,
uint8_t attr_count, avctp_rsp_cb func,
void *user_data);
+int avrcp_set_player_value(struct avrcp *session, uint8_t *attributes,
+ uint8_t attr_count, uint8_t *values,
+ avctp_rsp_cb func, void *user_data);
--
1.8.3.2
From: Andrei Emeltchenko <[email protected]>
Fix size check taking into account that attributes starts from 1 (0 is
illegal).
---
profiles/audio/avrcp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c
index c0e5d07..48c3355 100644
--- a/profiles/audio/avrcp.c
+++ b/profiles/audio/avrcp.c
@@ -1909,7 +1909,7 @@ static void avrcp_get_current_player_value(struct avrcp *session,
struct avrcp_header *pdu = (void *) buf;
uint16_t length = AVRCP_HEADER_LENGTH + count + 1;
- if (count > AVRCP_ATTRIBUTE_LAST + 1)
+ if (count > AVRCP_ATTRIBUTE_LAST)
return;
memset(buf, 0, sizeof(buf));
--
1.8.3.2
From: Andrei Emeltchenko <[email protected]>
---
android/avrcp-lib.c | 21 +++++++++++++++++++++
android/avrcp-lib.h | 11 +++++++++++
2 files changed, 32 insertions(+)
diff --git a/android/avrcp-lib.c b/android/avrcp-lib.c
index 52074a7..053e9e1 100644
--- a/android/avrcp-lib.c
+++ b/android/avrcp-lib.c
@@ -321,3 +321,24 @@ int avrcp_get_player_attribute_text(struct avrcp *session, uint8_t *attributes,
AVRCP_GET_PLAYER_ATTRIBUTE_TEXT, attributes,
attr_len, func, user_data);
}
+
+int avrcp_get_current_player_value(struct avrcp *session, uint8_t *attributes,
+ uint8_t attr_count, avctp_rsp_cb func,
+ void *user_data)
+
+{
+ uint8_t buf[AVRCP_ATTRIBUTE_LAST + 1];
+
+ if (attr_count > AVRCP_ATTRIBUTE_LAST)
+ return -EINVAL;
+
+ if (attributes && attr_count) {
+ buf[0] = attr_count;
+ memcpy(buf + 1, attributes, attr_count);
+ }
+
+ return avrcp_send_req(session, AVC_CTYPE_STATUS, AVC_SUBUNIT_PANEL,
+ AVRCP_GET_CURRENT_PLAYER_VALUE, buf,
+ attr_count + 1, func, user_data);
+
+}
diff --git a/android/avrcp-lib.h b/android/avrcp-lib.h
index da8c990..1f7eab0 100644
--- a/android/avrcp-lib.h
+++ b/android/avrcp-lib.h
@@ -74,6 +74,14 @@
#define CAP_COMPANY_ID 0x02
#define CAP_EVENTS_SUPPORTED 0x03
+/* Player Attributes */
+#define AVRCP_ATTRIBUTE_ILEGAL 0x00
+#define AVRCP_ATTRIBUTE_EQUALIZER 0x01
+#define AVRCP_ATTRIBUTE_REPEAT_MODE 0x02
+#define AVRCP_ATTRIBUTE_SHUFFLE 0x03
+#define AVRCP_ATTRIBUTE_SCAN 0x04
+#define AVRCP_ATTRIBUTE_LAST AVRCP_ATTRIBUTE_SCAN
+
/* Company IDs for vendor dependent commands */
#define IEEEID_BTSIG 0x001958
@@ -113,3 +121,6 @@ int avrcp_list_player_attributes(struct avrcp *session, avctp_rsp_cb func,
int avrcp_get_player_attribute_text(struct avrcp *session, uint8_t *attributes,
uint8_t attr_len, avctp_rsp_cb func,
void *user_data);
+int avrcp_get_current_player_value(struct avrcp *session, uint8_t *attributes,
+ uint8_t attr_count, avctp_rsp_cb func,
+ void *user_data);
--
1.8.3.2