From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ v2 12/13] AVRCP: Add support for AddToNowPlaying command
Date: Tue, 28 May 2013 15:51:30 +0300 [thread overview]
Message-ID: <1369745491-23897-13-git-send-email-luiz.dentz@gmail.com> (raw)
In-Reply-To: <1369745491-23897-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds support for AddToNowPlaying command via player callback.
---
profiles/audio/avrcp.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
profiles/audio/player.h | 2 ++
2 files changed, 50 insertions(+)
diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c
index e9e2645..234cd3a 100644
--- a/profiles/audio/avrcp.c
+++ b/profiles/audio/avrcp.c
@@ -105,6 +105,7 @@
#define AVRCP_CHANGE_PATH 0x72
#define AVRCP_GET_ITEM_ATTRIBUTES 0x73
#define AVRCP_PLAY_ITEM 0x74
+#define AVRCP_ADD_TO_NOW_PLAYING 0x90
#define AVRCP_GENERAL_REJECT 0xA0
/* Capabilities for AVRCP_GET_CAPABILITIES pdu */
@@ -2580,6 +2581,52 @@ static int ct_play_item(struct media_player *mp, const char *name,
return 0;
}
+static void avrcp_add_to_nowplaying(struct avrcp *session, uint64_t uid)
+{
+ uint8_t buf[AVRCP_HEADER_LENGTH + 11];
+ struct avrcp_player *player = session->player;
+ struct avrcp_header *pdu = (void *) buf;
+ uint16_t length;
+
+ memset(buf, 0, sizeof(buf));
+
+ set_company_id(pdu->company_id, IEEEID_BTSIG);
+ pdu->pdu_id = AVRCP_ADD_TO_NOW_PLAYING;
+ pdu->params_len = htons(11);
+ pdu->packet_type = AVRCP_PACKET_TYPE_SINGLE;
+
+ pdu->params[0] = player->scope;
+ bt_put_be64(uid, &pdu->params[1]);
+ bt_put_be16(player->uid_counter, &pdu->params[9]);
+
+ length = AVRCP_HEADER_LENGTH + ntohs(pdu->params_len);
+
+ avctp_send_vendordep_req(session->conn, AVC_CTYPE_STATUS,
+ AVC_SUBUNIT_PANEL, buf, length,
+ NULL, session);
+}
+
+static int ct_add_to_nowplaying(struct media_player *mp, const char *name,
+ uint64_t uid, void *user_data)
+{
+ struct avrcp_player *player = user_data;
+ struct avrcp *session;
+
+ if (player->p != NULL)
+ return -EBUSY;
+
+ session = player->sessions->data;
+
+ if (g_strrstr(name, "/NowPlaying"))
+ player->scope = 0x03;
+ else
+ player->scope = 0x01;
+
+ avrcp_add_to_nowplaying(session, uid);
+
+ return 0;
+}
+
static const struct media_player_callback ct_cbs = {
.set_setting = ct_set_setting,
.play = ct_play,
@@ -2592,6 +2639,7 @@ static const struct media_player_callback ct_cbs = {
.list_items = ct_list_items,
.change_folder = ct_change_folder,
.play_item = ct_play_item,
+ .add_to_nowplaying = ct_add_to_nowplaying,
};
static struct avrcp_player *create_ct_player(struct avrcp *session,
diff --git a/profiles/audio/player.h b/profiles/audio/player.h
index a8732f5..259110f 100644
--- a/profiles/audio/player.h
+++ b/profiles/audio/player.h
@@ -60,6 +60,8 @@ struct media_player_callback {
uint64_t uid, void *user_data);
int (*play_item) (struct media_player *mp, const char *name,
uint64_t uid, void *user_data);
+ int (*add_to_nowplaying) (struct media_player *mp, const char *name,
+ uint64_t uid, void *user_data);
};
struct media_player *media_player_controller_create(const char *path,
--
1.8.1.4
next prev parent reply other threads:[~2013-05-28 12:51 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-28 12:51 [PATCH BlueZ v2 00/13] MediaFolder and MediaItem implementation Luiz Augusto von Dentz
2013-05-28 12:51 ` [PATCH BlueZ v2 01/13] player: Split item creation Luiz Augusto von Dentz
2013-05-28 12:51 ` [PATCH BlueZ v2 02/13] AVRCP: Add browsed flag to player Luiz Augusto von Dentz
2013-05-28 12:51 ` [PATCH BlueZ v2 03/13] AVRCP: Add support for GetFolderItems command Luiz Augusto von Dentz
2013-05-28 12:51 ` [PATCH BlueZ v2 04/13] player: Add implementation of MediaFolder.ListItems Luiz Augusto von Dentz
2013-05-28 12:51 ` [PATCH BlueZ v2 05/13] player: Add support for setting current Item object Luiz Augusto von Dentz
2013-05-28 12:51 ` [PATCH BlueZ v2 06/13] player: Add function media_item_set_playable Luiz Augusto von Dentz
2013-05-28 12:51 ` [PATCH BlueZ v2 07/13] player: Add support for MediaItem.Metadata property Luiz Augusto von Dentz
2013-05-28 12:51 ` [PATCH BlueZ v2 08/13] AVRCP: Add support for ChangePath command Luiz Augusto von Dentz
2013-05-28 12:51 ` [PATCH BlueZ v2 09/13] player: Add implementation of MediaFolder.ChangeFolder Luiz Augusto von Dentz
2013-05-28 12:51 ` [PATCH BlueZ v2 10/13] AVRCP: Add support for PlayItem command Luiz Augusto von Dentz
2013-05-28 12:51 ` [PATCH BlueZ v2 11/13] player: Add implementation of MediaItem.Play Luiz Augusto von Dentz
2013-05-28 12:51 ` Luiz Augusto von Dentz [this message]
2013-05-28 12:51 ` [PATCH BlueZ v2 13/13] player: Add implementation of MediaItem.AddToNowPlaying 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=1369745491-23897-13-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;
as well as URLs for NNTP newsgroup(s).