Linux bluetooth development
 help / color / mirror / Atom feed
From: Bharat Panda <bharat.panda@samsung.com>
To: linux-bluetooth@vger.kernel.org
Cc: cpgs@samsung.com, Bharat Panda <bharat.panda@samsung.com>
Subject: [PATCH  2/2] audio/avrcp: Set Media Player Properties
Date: Thu, 20 Aug 2015 14:33:10 +0530	[thread overview]
Message-ID: <1440061390-32664-2-git-send-email-bharat.panda@samsung.com> (raw)
In-Reply-To: <1440061390-32664-1-git-send-email-bharat.panda@samsung.com>

Add methods to set missing media player properties value, like
player name, type, sub-type and features.
---
 profiles/audio/media.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 81 insertions(+)

diff --git a/profiles/audio/media.c b/profiles/audio/media.c
index ed441d0..f55ecc1 100644
--- a/profiles/audio/media.c
+++ b/profiles/audio/media.c
@@ -112,6 +112,10 @@ struct media_player {
 	bool			next;
 	bool			previous;
 	bool			control;
+	char			*name;
+	char			*type;
+	char			*subtype;
+	unsigned int		features[16];
 };
 
 static GSList *adapters = NULL;
@@ -1607,6 +1611,71 @@ static gboolean set_flag(struct media_player *mp, DBusMessageIter *iter,
 	return TRUE;
 }
 
+static gboolean set_name(struct media_player *mp, DBusMessageIter *iter)
+{
+	const char *value;
+
+	if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_STRING)
+		return FALSE;
+
+	dbus_message_iter_get_basic(iter, &value);
+
+	if (g_strcmp0(mp->name, value) == 0)
+		return TRUE;
+
+	mp->name = g_strdup(value);
+
+	return TRUE;
+}
+
+static gboolean set_type(struct media_player *mp, DBusMessageIter *iter)
+{
+	const char *value;
+
+	if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_STRING)
+		return FALSE;
+
+	dbus_message_iter_get_basic(iter, &value);
+
+	mp->type = g_strdup(value);
+
+	return TRUE;
+}
+
+static gboolean set_features(struct media_player *mp, DBusMessageIter *iter)
+{
+	const char *value;
+	uint8_t i = 0;
+
+	if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_STRING)
+		return FALSE;
+
+	dbus_message_iter_get_basic(iter, &value);
+
+	memset(&mp->features, 0x00, 16);
+
+	while ((i < (strlen(value)/2))) {
+		sscanf(value+(2*i), "%02x", &mp->features[i]);
+		i++;
+	}
+
+	return TRUE;
+}
+
+static gboolean set_subtype(struct media_player *mp, DBusMessageIter *iter)
+{
+	const char *value;
+
+	if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_STRING)
+		return FALSE;
+
+	dbus_message_iter_get_basic(iter, &value);
+
+	mp->subtype = g_strdup(value);
+
+	return TRUE;
+}
+
 static gboolean set_player_property(struct media_player *mp, const char *key,
 							DBusMessageIter *entry)
 {
@@ -1647,6 +1716,18 @@ static gboolean set_player_property(struct media_player *mp, const char *key,
 	if (strcasecmp(key, "CanControl") == 0)
 		return set_flag(mp, &var, &mp->control);
 
+	if (strcasecmp(key, "DisplayName") == 0)
+		return set_name(mp, &var);
+
+	if (strcasecmp(key, "Type") == 0)
+		return set_type(mp, &var);
+
+	if (strcasecmp(key, "SubType") == 0)
+		return set_subtype(mp, &var);
+
+	if (strcasecmp(key, "Features") == 0)
+		return set_features(mp, &var);
+
 	DBG("%s not supported, ignoring", key);
 
 	return TRUE;
-- 
1.9.1


  reply	other threads:[~2015-08-20  9:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-20  9:03 [PATCH 1/2] test: Add sample media player properties Bharat Panda
2015-08-20  9:03 ` Bharat Panda [this message]
2015-08-26 10:40   ` [PATCH 2/2] audio/avrcp: Set Media Player Properties Luiz Augusto von Dentz
2015-08-20 12:48 ` [PATCH 1/2] test: Add sample media player properties Luiz Augusto von Dentz
2015-08-20 13:01   ` Bharat Bhusan Panda
2015-08-20 13:23     ` 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=1440061390-32664-2-git-send-email-bharat.panda@samsung.com \
    --to=bharat.panda@samsung.com \
    --cc=cpgs@samsung.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