Linux bluetooth development
 help / color / mirror / Atom feed
From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [RFC hcidump 6/8] AVRCP: Add parsing for PlayItem PDU
Date: Wed, 15 Aug 2012 16:32:07 +0300	[thread overview]
Message-ID: <1345037529-1828-6-git-send-email-luiz.dentz@gmail.com> (raw)
In-Reply-To: <1345037529-1828-1-git-send-email-luiz.dentz@gmail.com>

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

---
 parser/avrcp.c | 73 +++++++++++++++++++++++++++++++++++++++++++++-------------
 1 file changed, 57 insertions(+), 16 deletions(-)

diff --git a/parser/avrcp.c b/parser/avrcp.c
index 046368c..47dfc9b 100644
--- a/parser/avrcp.c
+++ b/parser/avrcp.c
@@ -1342,6 +1342,60 @@ response:
 	}
 }
 
+static const char *scope2str(uint8_t scope)
+{
+	switch (scope) {
+	case AVRCP_MEDIA_PLAYER_LIST:
+		return "Media Player List";
+	case AVRCP_MEDIA_PLAYER_VFS:
+		return "Media Player Virtual Filesystem";
+	case AVRCP_MEDIA_SEARCH:
+		return "Search";
+	case AVRCP_MEDIA_NOW_PLAYING:
+		return "Now Playing";
+	default:
+		return "Unknown";
+	}
+}
+
+static void avrcp_play_item_dump(int level, struct frame *frm,
+						uint8_t ctype, uint16_t len)
+{
+	uint64_t uid;
+	uint32_t uidcounter;
+	uint8_t scope, status;
+
+	p_indent(level, frm);
+
+	if (ctype > AVC_CTYPE_GENERAL_INQUIRY)
+		goto response;
+
+	if (len < 13) {
+		printf("PDU Malformed\n");
+		raw_dump(level, frm);
+		return;
+	}
+
+	scope = get_u8(frm);
+	printf("Scope: 0x%02x (%s)", scope, scope2str(scope));
+
+	p_indent(level, frm);
+
+	uid = get_u64(frm);
+	printf("UID: 0x%16" PRIx64 " (%" PRIu64 ")\n", uid, uid);
+
+	p_indent(level, frm);
+
+	uidcounter = get_u16(frm);
+	printf("UIDCounter: 0x%04x (%u)\n", uidcounter, uidcounter);
+
+	return;
+
+response:
+	status = get_u8(frm);
+	printf("Status: 0x%02x (%s)\n", status, error2str(status));
+}
+
 static void avrcp_pdu_dump(int level, struct frame *frm, uint8_t ctype)
 {
 	uint8_t pduid, pt;
@@ -1414,6 +1468,9 @@ static void avrcp_pdu_dump(int level, struct frame *frm, uint8_t ctype)
 	case AVRCP_SET_ADDRESSED_PLAYER:
 		avrcp_set_addressed_player(level + 1, frm, ctype, len);
 		break;
+	case AVRCP_PLAY_ITEM:
+		avrcp_play_item_dump(level + 1, frm, ctype, len);
+		break;
 	default:
 		raw_dump(level, frm);
 	}
@@ -1507,22 +1564,6 @@ static const char *subunit2str(uint8_t subunit)
 	}
 }
 
-static const char *scope2str(uint8_t scope)
-{
-	switch (scope) {
-	case AVRCP_MEDIA_PLAYER_LIST:
-		return "Media Player List";
-	case AVRCP_MEDIA_PLAYER_VFS:
-		return "Media Player Virtual Filesystem";
-	case AVRCP_MEDIA_SEARCH:
-		return "Search";
-	case AVRCP_MEDIA_NOW_PLAYING:
-		return "Now Playing";
-	default:
-		return "Unknown";
-	}
-}
-
 static const char *playertype2str(uint8_t type)
 {
 	switch (type & 0x0F) {
-- 
1.7.11.2


  parent reply	other threads:[~2012-08-15 13:32 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-15 13:32 [RFC hcidump 1/8] AVRCP: Add initial support for browsing channel Luiz Augusto von Dentz
2012-08-15 13:32 ` [RFC hcidump 2/8] AVRCP: Fix parsing SetBrowsedPlayer as AV/C pdu Luiz Augusto von Dentz
2012-08-15 13:32 ` [RFC hcidump 3/8] AVRCP: Add parsing for GetFolderItems PDU Luiz Augusto von Dentz
2012-08-15 13:32 ` [RFC hcidump 4/8] AVRCP: Add parsing for ChangePath PDU Luiz Augusto von Dentz
2012-08-15 13:32 ` [RFC hcidump 5/8] AVRCP: Add parsing for GetItemAttributes PDU Luiz Augusto von Dentz
2012-08-15 13:32 ` Luiz Augusto von Dentz [this message]
2012-08-15 13:32 ` [RFC hcidump 7/8] AVRCP: Add parsing for Search PDU Luiz Augusto von Dentz
2012-08-15 13:32 ` [RFC hcidump 8/8] AVRCP: Add parsing for AddToNowPlaying PDU 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=1345037529-1828-6-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