Linux bluetooth development
 help / color / mirror / Atom feed
From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ 10/12] android/avrcp-lib: Add support for parsing GetElementAttributes PDU
Date: Mon, 17 Mar 2014 10:08:55 +0200	[thread overview]
Message-ID: <1395043737-8905-10-git-send-email-luiz.dentz@gmail.com> (raw)
In-Reply-To: <1395043737-8905-1-git-send-email-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

---
 android/avrcp-lib.c | 37 +++++++++++++++++++++++++++++++++++++
 android/avrcp-lib.h | 15 +++++++++++++++
 2 files changed, 52 insertions(+)

diff --git a/android/avrcp-lib.c b/android/avrcp-lib.c
index 9577bf0..d32f791 100644
--- a/android/avrcp-lib.c
+++ b/android/avrcp-lib.c
@@ -474,6 +474,40 @@ static ssize_t get_play_status(struct avrcp *session, uint8_t transaction,
 							player->user_data);
 }
 
+static ssize_t get_element_attributes(struct avrcp *session,
+						uint8_t transaction,
+						uint16_t params_len,
+						uint8_t *params,
+						void *user_data)
+{
+	struct avrcp_player *player = user_data;
+	uint64_t uid;
+	uint32_t attrs[AVRCP_MEDIA_ATTRIBUTE_LAST];
+	int i;
+
+	DBG("");
+
+	if (!params || params_len != 9 + params[8] * 4)
+		return -EINVAL;
+
+	uid = bt_get_be64(params);
+
+	for (i = 0; i < params[8]; i++) {
+		attrs[i] = bt_get_be32(&params[9 + i * 4]);
+
+		if (attrs[i] < AVRCP_MEDIA_ATTRIBUTE_TITLE ||
+				attrs[i] > AVRCP_MEDIA_ATTRIBUTE_DURATION)
+			return -EINVAL;
+	}
+
+	if (!player->ind || !player->ind->get_element_attributes)
+		return -ENOSYS;
+
+	return player->ind->get_element_attributes(session, transaction, uid,
+							params[8], attrs,
+							player->user_data);
+}
+
 static const struct avrcp_control_handler player_handlers[] = {
 		{ AVRCP_GET_CAPABILITIES,
 					AVC_CTYPE_STATUS, AVC_CTYPE_STABLE,
@@ -499,6 +533,9 @@ static const struct avrcp_control_handler player_handlers[] = {
 		{ AVRCP_GET_PLAY_STATUS,
 					AVC_CTYPE_STATUS, AVC_CTYPE_STABLE,
 					get_play_status },
+		{ AVRCP_GET_ELEMENT_ATTRIBUTES,
+					AVC_CTYPE_STATUS, AVC_CTYPE_STABLE,
+					get_element_attributes },
 		{ },
 };
 
diff --git a/android/avrcp-lib.h b/android/avrcp-lib.h
index 71d710f..9257de7 100644
--- a/android/avrcp-lib.h
+++ b/android/avrcp-lib.h
@@ -104,6 +104,17 @@
 #define AVRCP_SCAN_ALL			0x02
 #define AVRCP_SCAN_GROUP		0x03
 
+/* media attributes */
+#define AVRCP_MEDIA_ATTRIBUTE_ILLEGAL	0x00
+#define AVRCP_MEDIA_ATTRIBUTE_TITLE	0x01
+#define AVRCP_MEDIA_ATTRIBUTE_ARTIST	0x02
+#define AVRCP_MEDIA_ATTRIBUTE_ALBUM	0x03
+#define AVRCP_MEDIA_ATTRIBUTE_TRACK	0x04
+#define AVRCP_MEDIA_ATTRIBUTE_N_TRACKS	0x05
+#define AVRCP_MEDIA_ATTRIBUTE_GENRE	0x06
+#define AVRCP_MEDIA_ATTRIBUTE_DURATION	0x07
+#define AVRCP_MEDIA_ATTRIBUTE_LAST	AVRCP_MEDIA_ATTRIBUTE_DURATION
+
 /* Company IDs for vendor dependent commands */
 #define IEEEID_BTSIG		0x001958
 
@@ -141,6 +152,10 @@ struct avrcp_control_ind {
 					void *user_data);
 	int (*get_play_status) (struct avrcp *session, uint8_t transaction,
 					void *user_data);
+	int (*get_element_attributes) (struct avrcp *session,
+					uint8_t transaction, uint64_t uid,
+					uint8_t number, uint32_t *attrs,
+					void *user_data);
 };
 
 struct avrcp_control_cfm {
-- 
1.8.5.3


  parent reply	other threads:[~2014-03-17  8:08 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-17  8:08 [PATCH BlueZ 01/12] android/avrcp-lib: Change API to register callbacks instead of PDU handlers Luiz Augusto von Dentz
2014-03-17  8:08 ` [PATCH BlueZ 02/12] android/avrcp-lib: Add support for parsing GetCapabilities PDU Luiz Augusto von Dentz
2014-03-17  8:42   ` Andrei Emeltchenko
2014-03-17  9:25     ` Luiz Augusto von Dentz
2014-03-17  8:08 ` [PATCH BlueZ 03/12] android/avrcp-lib: Add support for parsing ListPlayerAttributes PDU Luiz Augusto von Dentz
2014-03-17  8:47   ` Andrei Emeltchenko
2014-03-17  8:54     ` Andrei Emeltchenko
2014-03-17  8:08 ` [PATCH BlueZ 04/12] android/avrcp-lib: Add support for parsing GetPlayerAttributeText PDU Luiz Augusto von Dentz
2014-03-17  8:08 ` [PATCH BlueZ 05/12] android/avrcp-lib: Add support for parsing ListPlayerValues PDU Luiz Augusto von Dentz
2014-03-17  8:08 ` [PATCH BlueZ 06/12] android/avrcp-lib: Add support for parsing GetPlayerValueText PDU Luiz Augusto von Dentz
2014-03-17  8:08 ` [PATCH BlueZ 07/12] android/avrcp-lib: Add support for parsing GetCurrentPlayerValue PDU Luiz Augusto von Dentz
2014-03-17  8:08 ` [PATCH BlueZ 08/12] android/avrcp-lib: Add support for parsing SetPlayerValue PDU Luiz Augusto von Dentz
2014-03-17  8:08 ` [PATCH BlueZ 09/12] android/avrcp-lib: Add support for parsing GetPlayStatus PDU Luiz Augusto von Dentz
2014-03-17  8:08 ` Luiz Augusto von Dentz [this message]
2014-03-17  8:08 ` [PATCH BlueZ 11/12] android/avrcp-lib: Add support for parsing ResgisterNotification PDU Luiz Augusto von Dentz
2014-03-17  8:08 ` [PATCH BlueZ 12/12] android/avrcp-lib: Add support for parsing SetAddressedPlayer PDU Luiz Augusto von Dentz
2014-03-17  8:38 ` [PATCH BlueZ 01/12] android/avrcp-lib: Change API to register callbacks instead of PDU handlers Andrei Emeltchenko
2014-03-17  9:22   ` Luiz Augusto von Dentz
2014-03-17 13:01     ` Luiz Augusto von Dentz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1395043737-8905-10-git-send-email-luiz.dentz@gmail.com \
    --to=luiz.dentz@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox