summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Ranostay <matt.ranostay@konsulko.com>2017-05-31 02:44:02 -0700
committerMatt Ranostay <matt.ranostay@konsulko.com>2017-05-31 10:11:41 -0700
commite0d6d332bdb69e4635abfbe00e340211eb8c967a (patch)
treeb46c0af51183918b510b7357bcec901327b608b2
parent49b1952b45d45a0dbec2662f26e2cf2e08531b48 (diff)
binding: bluetooth: provide org.bluez.MediaTransport1 access
Allow binding to report transport state and volume levels Bug-AGL: SPEC-642 Change-Id: I5daad68a096b70b6401cde045704ee4226ef368f Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
-rw-r--r--bluetooth-api.c17
-rw-r--r--bluetooth-api.h2
-rw-r--r--bluetooth-manager.c62
-rw-r--r--bluetooth-manager.h3
-rw-r--r--bluez-client.c3
5 files changed, 85 insertions, 2 deletions
diff --git a/bluetooth-api.c b/bluetooth-api.c
index 34caac5..4a7092a 100644
--- a/bluetooth-api.c
+++ b/bluetooth-api.c
@@ -253,6 +253,20 @@ static json_object *new_json_object_from_device(struct btd_device *BDdevice, uns
}
}
+ if (BD_TRANSPORT_STATE & filter)
+ {
+ jstring = BDdevice->transport_state ?
+ json_object_new_string(BDdevice->transport_state) :
+ json_object_new_string("none");
+ json_object_object_add(jresp, "TransportState", jstring);
+ }
+
+ if (BD_TRANSPORT_VOLUME & filter)
+ {
+ json_object_object_add(jresp, "TransportVolume",
+ json_object_new_int(BDdevice->transport_volume));
+ }
+
if (BD_HFPCONNECTED & filter)
{
jstring = (TRUE == BDdevice->hfpconnected) ?
@@ -751,7 +765,8 @@ void bt_broadcast_device_removed(struct btd_device *BDdevice)
void bt_broadcast_device_properties_change(struct btd_device *BDdevice)
{
- unsigned int filter = BD_ADDER|BD_NAME|BD_PAIRED|BD_ACLCONNECTED|BD_AVCONNECTED|BD_HFPCONNECTED|BD_AVRCP_TITLE|BD_AVRCP_ARTIST|BD_AVRCP_STATUS|BD_AVRCP_DURATION|BD_AVRCP_POSITION;
+ unsigned int filter = BD_ADDER|BD_NAME|BD_PAIRED|BD_ACLCONNECTED|BD_AVCONNECTED|BD_HFPCONNECTED|BD_AVRCP_TITLE|BD_AVRCP_ARTIST|BD_AVRCP_STATUS|BD_AVRCP_DURATION|BD_AVRCP_POSITION|BD_TRANSPORT_STATE|BD_TRANSPORT_VOLUME;
+
int ret;
json_object *jresp = new_json_object_from_device(BDdevice, filter);
diff --git a/bluetooth-api.h b/bluetooth-api.h
index 93629d9..4223ae0 100644
--- a/bluetooth-api.h
+++ b/bluetooth-api.h
@@ -38,6 +38,8 @@
#define BD_AVRCP_STATUS LEFT_SHIFT(14)
#define BD_AVRCP_DURATION LEFT_SHIFT(15)
#define BD_AVRCP_POSITION LEFT_SHIFT(16)
+#define BD_TRANSPORT_STATE LEFT_SHIFT(17)
+#define BD_TRANSPORT_VOLUME LEFT_SHIFT(18)
/* -------------- PLUGIN DEFINITIONS ----------------- */
diff --git a/bluetooth-manager.c b/bluetooth-manager.c
index 1f18f8b..7417624 100644
--- a/bluetooth-manager.c
+++ b/bluetooth-manager.c
@@ -175,6 +175,12 @@ void device_free(struct btd_device* device)
device->avrcp_status = NULL;
}
+ if (device->transport_state) {
+ D_PRINTF("transport_state:%s\n",device->transport_state);
+ g_free(device->transport_state);
+ device->transport_state = NULL;
+ }
+
g_free(device);
}
@@ -273,6 +279,58 @@ static int device_update_from_MediaControl1(struct btd_device *device,
return 0;
}
+/*
+ * update device from Interface org.bluez.MediaTransport1 properties
+ */
+static int device_update_from_MediaTransport1(struct btd_device *device,
+ GVariant *value)
+{
+ GVariantIter iter;
+ const gchar *key;
+ GVariant *subValue;
+
+ if ((NULL==device) || (NULL==value))
+ {
+ return -1;
+ }
+
+ g_variant_iter_init (&iter, value);
+ while (g_variant_iter_next (&iter, "{&sv}", &key, &subValue))
+ {
+ //gchar *s = g_variant_print (subValue, TRUE);
+ //g_print (" %s -> %s\n", key, s);
+ //g_free (s);
+
+ //gboolean value_b = FALSE;//b gboolean
+ //gchar value_c = 0;
+ //guchar value_y = 0;//y guchar
+ //gint16 value_n = 0;//n gint16
+ guint16 value_q = 0;//q guint16
+ //gint32 value_i = 0;//i gint32
+ //guint32 value_u = 0;//u guint32
+ //gint64 value_x = 0;//x gint64
+ //guint64 value_t = 0;//t guint64
+ //gint32 value_h = 0;//h gint32
+ //gdouble value_d = 0.0;//d gdouble
+ gchar *str;//d gdouble
+
+ if (0==g_strcmp0(key,"State")) {
+ g_variant_get(subValue, "s", &str);
+ D_PRINTF("State %s\n", str);
+ if (device->transport_state)
+ free(device->transport_state);
+ device->transport_state = g_strdup(str);
+ } else if (0==g_strcmp0(key,"Volume")) {
+ g_variant_get(subValue, "q", &value_q);
+ D_PRINTF("Volume %d\n", value_q);
+ device->transport_volume = value_q;
+ }
+ }
+
+ return 0;
+}
+
+
static int device_update_from_Track(struct btd_device *device,
GVariant *value)
{
@@ -683,6 +741,10 @@ bluez_device_properties_changed_cb (const gchar *pObjecPath,
device_update_from_MediaPlayer1(device, properties);
+ } else if (0 == g_strcmp0(pInterface, MEDIA_TRANSPORT1_INTERFACE)) {
+
+ device_update_from_MediaTransport1(device, properties);
+
}
if (g_RegisterCallback.binding_device_properties_changed)
diff --git a/bluetooth-manager.h b/bluetooth-manager.h
index 9b7eee0..287a0a2 100644
--- a/bluetooth-manager.h
+++ b/bluetooth-manager.h
@@ -92,6 +92,7 @@
#define MEDIA_FOLDER_INTERFACE "org.bluez.MediaFolder"
#define MEDIA_ITEM_INTERFACE "org.bluez.MediaItem"
#define MEDIA_TRANSPORT_INTERFACE "org.bluez.MediaTransport"
+#define MEDIA_TRANSPORT1_INTERFACE "org.bluez.MediaTransport1"
#define MEDIA_CONTROL1_INTERFACE "org.bluez.MediaControl1"
@@ -137,8 +138,10 @@ struct btd_device {
gchar *avrcp_title;
gchar *avrcp_artist;
gchar *avrcp_status;
+ gchar *transport_state;
guint32 avrcp_duration;
guint32 avrcp_position;
+ guint16 transport_volume;
gboolean paired;
gboolean trusted;
gboolean connected;
diff --git a/bluez-client.c b/bluez-client.c
index e70df91..334a2b6 100644
--- a/bluez-client.c
+++ b/bluez-client.c
@@ -656,7 +656,8 @@ on_interface_proxy_properties_changed (GDBusObjectManagerClient *manager,
if( (0 == g_strcmp0(pInterface, DEVICE_INTERFACE)) ||
(0 == g_strcmp0(pInterface, MEDIA_CONTROL1_INTERFACE)) ||
- (0 == g_strcmp0(pInterface, MEDIA_PLAYER1_INTERFACE))) {
+ (0 == g_strcmp0(pInterface, MEDIA_PLAYER1_INTERFACE)) ||
+ (0 == g_strcmp0(pInterface, MEDIA_TRANSPORT1_INTERFACE))) {
if (bluez_RegisterCallback.device_properties_changed)
bluez_RegisterCallback.device_properties_changed(pObjecPath,