From: Andrei Emeltchenko <[email protected]>
Combined set of AVRCP function implementation and unit tests.
Andrei Emeltchenko (9):
android/avrcp: Refactor get_caps() to allow parameter
unit/avrcp: Fix lengths byte order
unit/avrcp: Add /TP/CFG/BI-01-C test
android/avrcp: Add list player attributes command
unit/avrcp: Add /TP/PAS/BV-01-C test
unit/avrcp: Add /TP/PAS/BV-02-C test
android/avrcp: Implement get player attributes text
unit/avrcp: Add /TP/PAS/BV-03-C test
unit/avrcp: Add /TP/PAS/BV-04-C test
android/avrcp-lib.c | 23 ++++++++++++---
android/avrcp-lib.h | 7 ++++-
unit/test-avrcp.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++--
3 files changed, 105 insertions(+), 7 deletions(-)
--
1.8.3.2
Hi Andrei,
On Fri, Feb 28, 2014 at 9:22 AM, Andrei Emeltchenko
<[email protected]> wrote:
> From: Andrei Emeltchenko <[email protected]>
>
> Combined set of AVRCP function implementation and unit tests.
>
> Andrei Emeltchenko (9):
> android/avrcp: Refactor get_caps() to allow parameter
> unit/avrcp: Fix lengths byte order
> unit/avrcp: Add /TP/CFG/BI-01-C test
> android/avrcp: Add list player attributes command
> unit/avrcp: Add /TP/PAS/BV-01-C test
> unit/avrcp: Add /TP/PAS/BV-02-C test
> android/avrcp: Implement get player attributes text
> unit/avrcp: Add /TP/PAS/BV-03-C test
> unit/avrcp: Add /TP/PAS/BV-04-C test
>
> android/avrcp-lib.c | 23 ++++++++++++---
> android/avrcp-lib.h | 7 ++++-
> unit/test-avrcp.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++--
> 3 files changed, 105 insertions(+), 7 deletions(-)
>
> --
> 1.8.3.2
Applied, thanks.
--
Luiz Augusto von Dentz
From: Andrei Emeltchenko <[email protected]>
Test verifies that the List Player Application Setting Attributes
response issued from the Target.
---
unit/test-avrcp.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/unit/test-avrcp.c b/unit/test-avrcp.c
index c65f743..c4faca3 100644
--- a/unit/test-avrcp.c
+++ b/unit/test-avrcp.c
@@ -331,9 +331,23 @@ fail:
return AVC_CTYPE_REJECTED;
}
+static uint8_t avrcp_handle_list_attributes(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 },
+ { AVRCP_LIST_PLAYER_ATTRIBUTES, AVC_CTYPE_STATUS,
+ avrcp_handle_list_attributes },
{ },
};
@@ -462,5 +476,13 @@ int main(int argc, char *argv[])
0x00, 0x19, 0x58, 0x11, 0x00, 0x00,
0x00));
+ define_test("/TP/PAS/BV-02-C", test_server,
+ raw_pdu(0x00, 0x11, 0x0e, 0x01, 0x48, 0x00,
+ 0x00, 0x19, 0x58, 0x11, 0x00, 0x00,
+ 0x00),
+ raw_pdu(0x02, 0x11, 0x0e, 0x0c, 0x48, 0x00,
+ 0x00, 0x19, 0x58, 0x11, 0x00, 0x00,
+ 0x01, 0x00));
+
return g_test_run();
}
--
1.8.3.2
From: Andrei Emeltchenko <[email protected]>
Allow passing parameter specifying capability ID.
---
android/avrcp-lib.c | 6 ++----
android/avrcp-lib.h | 4 ++--
unit/test-avrcp.c | 3 ++-
3 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/android/avrcp-lib.c b/android/avrcp-lib.c
index 1b5a294..6ae8df8 100644
--- a/android/avrcp-lib.c
+++ b/android/avrcp-lib.c
@@ -297,11 +297,9 @@ static int avrcp_send_req(struct avrcp *session, uint8_t code, uint8_t subunit,
session->tx_buf, len, func, user_data);
}
-int avrcp_get_capabilities(struct avrcp *session, avctp_rsp_cb func,
- void *user_data)
+int avrcp_get_capabilities(struct avrcp *session, uint8_t param,
+ avctp_rsp_cb func, void *user_data)
{
- uint8_t param = CAP_EVENTS_SUPPORTED;
-
return avrcp_send_req(session, AVC_CTYPE_STATUS, AVC_SUBUNIT_PANEL,
AVRCP_GET_CAPABILITIES, ¶m, sizeof(param),
func, user_data);
diff --git a/android/avrcp-lib.h b/android/avrcp-lib.h
index 75802b9..e6e12c1 100644
--- a/android/avrcp-lib.h
+++ b/android/avrcp-lib.h
@@ -106,5 +106,5 @@ void avrcp_set_passthrough_handlers(struct avrcp *session,
int avrcp_init_uinput(struct avrcp *session, const char *name,
const char *address);
-int avrcp_get_capabilities(struct avrcp *session, avctp_rsp_cb func,
- void *user_data);
+int avrcp_get_capabilities(struct avrcp *session, uint8_t param,
+ avctp_rsp_cb func, void *user_data);
diff --git a/unit/test-avrcp.c b/unit/test-avrcp.c
index bcd8f88..f222df8 100644
--- a/unit/test-avrcp.c
+++ b/unit/test-avrcp.c
@@ -353,7 +353,8 @@ static void test_client(gconstpointer data)
struct context *context = create_context(0x0100, data);
if (g_str_equal(context->data->test_name, "/TP/CFG/BV-01-C"))
- avrcp_get_capabilities(context->session, NULL, NULL);
+ avrcp_get_capabilities(context->session, CAP_EVENTS_SUPPORTED,
+ NULL, NULL);
execute_context(context);
}
--
1.8.3.2
From: Andrei Emeltchenko <[email protected]>
Test verifies that the Get Player Application Setting Attribute Text
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 a75165b..db9cb92 100644
--- a/unit/test-avrcp.c
+++ b/unit/test-avrcp.c
@@ -343,11 +343,25 @@ static uint8_t avrcp_handle_list_attributes(struct avrcp *session,
return AVC_CTYPE_STABLE;
}
+static uint8_t avrcp_handle_get_player_attr_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 },
{ AVRCP_LIST_PLAYER_ATTRIBUTES, AVC_CTYPE_STATUS,
avrcp_handle_list_attributes },
+ { AVRCP_GET_PLAYER_ATTRIBUTE_TEXT, AVC_CTYPE_STATUS,
+ avrcp_handle_get_player_attr_text },
{ },
};
@@ -494,5 +508,15 @@ int main(int argc, char *argv[])
AVRCP_GET_PLAYER_ATTRIBUTE_TEXT,
0x00, 0x00, 0x00));
+ define_test("/TP/PAS/BV-04-C", test_server,
+ raw_pdu(0x00, 0x11, 0x0e, 0x01, 0x48, 0x00,
+ 0x00, 0x19, 0x58,
+ AVRCP_GET_PLAYER_ATTRIBUTE_TEXT,
+ 0x00, 0x00, 0x00),
+ raw_pdu(0x02, 0x11, 0x0e, 0x0c, 0x48, 0x00,
+ 0x00, 0x19, 0x58,
+ AVRCP_GET_PLAYER_ATTRIBUTE_TEXT,
+ 0x00, 0x00, 0x01, 0x00));
+
return g_test_run();
}
--
1.8.3.2
From: Andrei Emeltchenko <[email protected]>
Test verifies that the List Player Application Setting Attributes command
issued from the Controller.
---
unit/test-avrcp.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/unit/test-avrcp.c b/unit/test-avrcp.c
index 0924a7e..c65f743 100644
--- a/unit/test-avrcp.c
+++ b/unit/test-avrcp.c
@@ -358,6 +358,9 @@ static void test_client(gconstpointer data)
avrcp_get_capabilities(context->session, CAP_EVENTS_SUPPORTED,
NULL, NULL);
+ if (g_str_equal(context->data->test_name, "/TP/PAS/BV-01-C"))
+ avrcp_list_player_attributes(context->session, NULL, NULL);
+
execute_context(context);
}
@@ -452,5 +455,12 @@ int main(int argc, char *argv[])
0x00, 0x00, 0x01,
AVRCP_STATUS_INVALID_PARAM));
+ /* Player Application Settings tests */
+
+ define_test("/TP/PAS/BV-01-C", test_client,
+ raw_pdu(0x00, 0x11, 0x0e, 0x01, 0x48, 0x00,
+ 0x00, 0x19, 0x58, 0x11, 0x00, 0x00,
+ 0x00));
+
return g_test_run();
}
--
1.8.3.2
From: Andrei Emeltchenko <[email protected]>
---
android/avrcp-lib.c | 9 +++++++++
android/avrcp-lib.h | 3 +++
2 files changed, 12 insertions(+)
diff --git a/android/avrcp-lib.c b/android/avrcp-lib.c
index 3db5bda..52074a7 100644
--- a/android/avrcp-lib.c
+++ b/android/avrcp-lib.c
@@ -312,3 +312,12 @@ int avrcp_list_player_attributes(struct avrcp *session, avctp_rsp_cb func,
AVRCP_LIST_PLAYER_ATTRIBUTES, NULL, 0,
func, user_data);
}
+
+int avrcp_get_player_attribute_text(struct avrcp *session, uint8_t *attributes,
+ uint8_t attr_len, avctp_rsp_cb func,
+ void *user_data)
+{
+ return avrcp_send_req(session, AVC_CTYPE_STATUS, AVC_SUBUNIT_PANEL,
+ AVRCP_GET_PLAYER_ATTRIBUTE_TEXT, attributes,
+ attr_len, func, user_data);
+}
diff --git a/android/avrcp-lib.h b/android/avrcp-lib.h
index 7283203..da8c990 100644
--- a/android/avrcp-lib.h
+++ b/android/avrcp-lib.h
@@ -110,3 +110,6 @@ int avrcp_get_capabilities(struct avrcp *session, uint8_t param,
avctp_rsp_cb func, void *user_data);
int avrcp_list_player_attributes(struct avrcp *session, avctp_rsp_cb func,
void *user_data);
+int avrcp_get_player_attribute_text(struct avrcp *session, uint8_t *attributes,
+ uint8_t attr_len, avctp_rsp_cb func,
+ void *user_data);
--
1.8.3.2
From: Andrei Emeltchenko <[email protected]>
Test verifies that the get player application settings attribute text
command issued from the Controller.
---
unit/test-avrcp.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/unit/test-avrcp.c b/unit/test-avrcp.c
index c4faca3..a75165b 100644
--- a/unit/test-avrcp.c
+++ b/unit/test-avrcp.c
@@ -375,6 +375,10 @@ static void test_client(gconstpointer data)
if (g_str_equal(context->data->test_name, "/TP/PAS/BV-01-C"))
avrcp_list_player_attributes(context->session, NULL, NULL);
+ if (g_str_equal(context->data->test_name, "/TP/PAS/BV-03-C"))
+ avrcp_get_player_attribute_text(context->session, NULL, 0,
+ NULL, NULL);
+
execute_context(context);
}
@@ -484,5 +488,11 @@ int main(int argc, char *argv[])
0x00, 0x19, 0x58, 0x11, 0x00, 0x00,
0x01, 0x00));
+ define_test("/TP/PAS/BV-03-C", test_client,
+ raw_pdu(0x00, 0x11, 0x0e, 0x01, 0x48, 0x00,
+ 0x00, 0x19, 0x58,
+ AVRCP_GET_PLAYER_ATTRIBUTE_TEXT,
+ 0x00, 0x00, 0x00));
+
return g_test_run();
}
--
1.8.3.2
From: Andrei Emeltchenko <[email protected]>
Test verifies the get capabilities response issued from the Target when
an invalid capability is requested (0x7f).
---
unit/test-avrcp.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/unit/test-avrcp.c b/unit/test-avrcp.c
index a43985a..0924a7e 100644
--- a/unit/test-avrcp.c
+++ b/unit/test-avrcp.c
@@ -311,6 +311,8 @@ static uint8_t avrcp_handle_get_capabilities(struct avrcp *session,
{
uint32_t id = 0x001958;
+ DBG("params[0] %d params_len %d", params[0], *params_len);
+
if (*params_len != 1)
goto fail;
@@ -441,5 +443,14 @@ int main(int argc, char *argv[])
0x00, 0x19, 0x58, 0x10, 0x00, 0x00,
0x05, 0x02, 0x01, 0x00, 0x19, 0x58));
+ define_test("/TP/CFG/BI-01-C", test_server,
+ raw_pdu(0x00, 0x11, 0x0e, 0x01, 0x48, 0x00,
+ 0x00, 0x19, 0x58, 0x10, 0x00, 0x00,
+ 0x01, 0x7f),
+ raw_pdu(0x02, 0x11, 0x0e, AVC_CTYPE_REJECTED,
+ 0x48, 0x00, 0x00, 0x19, 0x58, 0x10,
+ 0x00, 0x00, 0x01,
+ AVRCP_STATUS_INVALID_PARAM));
+
return g_test_run();
}
--
1.8.3.2
From: Andrei Emeltchenko <[email protected]>
params_len is passed as function argument and needs to be in host byte
order.
---
unit/test-avrcp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/unit/test-avrcp.c b/unit/test-avrcp.c
index f222df8..a43985a 100644
--- a/unit/test-avrcp.c
+++ b/unit/test-avrcp.c
@@ -323,7 +323,7 @@ static uint8_t avrcp_handle_get_capabilities(struct avrcp *session,
}
fail:
- *params_len = htons(1);
+ *params_len = 1;
params[0] = AVRCP_STATUS_INVALID_PARAM;
return AVC_CTYPE_REJECTED;
--
1.8.3.2
From: Andrei Emeltchenko <[email protected]>
---
android/avrcp-lib.c | 8 ++++++++
android/avrcp-lib.h | 2 ++
2 files changed, 10 insertions(+)
diff --git a/android/avrcp-lib.c b/android/avrcp-lib.c
index 6ae8df8..3db5bda 100644
--- a/android/avrcp-lib.c
+++ b/android/avrcp-lib.c
@@ -304,3 +304,11 @@ int avrcp_get_capabilities(struct avrcp *session, uint8_t param,
AVRCP_GET_CAPABILITIES, ¶m, sizeof(param),
func, user_data);
}
+
+int avrcp_list_player_attributes(struct avrcp *session, avctp_rsp_cb func,
+ void *user_data)
+{
+ return avrcp_send_req(session, AVC_CTYPE_STATUS, AVC_SUBUNIT_PANEL,
+ AVRCP_LIST_PLAYER_ATTRIBUTES, NULL, 0,
+ func, user_data);
+}
diff --git a/android/avrcp-lib.h b/android/avrcp-lib.h
index e6e12c1..7283203 100644
--- a/android/avrcp-lib.h
+++ b/android/avrcp-lib.h
@@ -108,3 +108,5 @@ int avrcp_init_uinput(struct avrcp *session, const char *name,
int avrcp_get_capabilities(struct avrcp *session, uint8_t param,
avctp_rsp_cb func, void *user_data);
+int avrcp_list_player_attributes(struct avrcp *session, avctp_rsp_cb func,
+ void *user_data);
--
1.8.3.2