2014-03-03 12:53:39

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCH 1/9] unit/avrcp: Add /TP/PAS/BV-06-C test

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 302c331..44dc2f2 100644
--- a/unit/test-avrcp.c
+++ b/unit/test-avrcp.c
@@ -342,6 +342,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 },
@@ -349,6 +369,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 },
{ },
};

@@ -505,5 +527,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



2014-03-10 09:04:41

by Szymon Janc

[permalink] [raw]
Subject: Re: [PATCH 9/9] doc: Update test coverage document

Hi Andrei,

On Monday 03 of March 2014 14:53:47 Andrei Emeltchenko wrote:
> 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 7965f8e..89d884f 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 23 AVRCP qualification test cases
> test-gobex 31 Generic OBEX functionality
> test-gobex-packet 9 OBEX packet handling
> test-gobex-header 28 OBEX header handling
>

Total tests count should be updated as well.

--
Best regards,
Szymon Janc

2014-03-03 12:53:44

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCH 6/9] unit/avrcp: Add /TP/PAS/BV-10-C test

From: Andrei Emeltchenko <[email protected]>

Test verifies that the get current player application setting value
response issued from the Target.
---
unit/test-avrcp.c | 40 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+)

diff --git a/unit/test-avrcp.c b/unit/test-avrcp.c
index 823c750..2675bdf 100644
--- a/unit/test-avrcp.c
+++ b/unit/test-avrcp.c
@@ -374,6 +374,30 @@ 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(&params[1], params[0]);
+
+ for (i = 0; i < params[0]; i++) {
+ params[i * 2 + 1] = attributes[i];
+ params[i * 2 + 2] = 0; /* value */
+ }
+
+ g_free(attributes);
+
+ 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 },
@@ -383,6 +407,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 },
{ },
@@ -577,5 +603,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


2014-03-03 12:53:47

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCH 9/9] doc: Update test coverage document

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 7965f8e..89d884f 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 23 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


2014-03-03 12:53:43

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCH 5/9] unit/avrcp: Add /TP/PAS/BV-09-C test

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 e45d995..823c750 100644
--- a/unit/test-avrcp.c
+++ b/unit/test-avrcp.c
@@ -416,6 +416,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);
}

@@ -561,5 +569,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


2014-03-03 12:53:46

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCH 8/9] unit/avrcp: Add /TP/PAS/BV-11-C test

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 2675bdf..359359b 100644
--- a/unit/test-avrcp.c
+++ b/unit/test-avrcp.c
@@ -450,6 +450,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);
}

@@ -617,5 +627,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


2014-03-03 12:53:45

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCH 7/9] android/avrcp: Add avrcp_set_player_value() function

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 39d8d9a..63f87da 100644
--- a/android/avrcp-lib.c
+++ b/android/avrcp-lib.c
@@ -327,5 +327,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


2014-03-03 12:53:40

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCH 2/9] unit/avrcp: Add /TP/PAS/BV-08-C test

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 44dc2f2..e45d995 100644
--- a/unit/test-avrcp.c
+++ b/unit/test-avrcp.c
@@ -362,6 +362,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 },
@@ -371,6 +383,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 },
{ },
};

@@ -537,5 +551,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


2014-03-03 12:53:42

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCH 4/9] android/avrcp: Add avrcp_get_current_player_value() function

From: Andrei Emeltchenko <[email protected]>

---
android/avrcp-lib.c | 21 +++++++++++++++++++++
android/avrcp-lib.h | 14 ++++++++++++++
2 files changed, 35 insertions(+)

diff --git a/android/avrcp-lib.c b/android/avrcp-lib.c
index 97259d5..39d8d9a 100644
--- a/android/avrcp-lib.c
+++ b/android/avrcp-lib.c
@@ -308,3 +308,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 0407cb4..1f7eab0 100644
--- a/android/avrcp-lib.h
+++ b/android/avrcp-lib.h
@@ -74,6 +74,17 @@
#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
+
struct avrcp;

struct avrcp_control_handler {
@@ -110,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


2014-03-03 12:53:41

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCH 3/9] avrcp: Fix buffer size check

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 bea2dd2..aa932e0 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