summaryrefslogtreecommitdiffstats
path: root/binding-bluetooth/bluetooth-manager.c
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
commit37aacabc67fc2d3b759cdc85eb46705f729f8682 (patch)
treea5b47bb1156ad77417900a94ddcf2084a1eb68f7 /binding-bluetooth/bluetooth-manager.c
parentcaea8eb4305404f0a03e089e7e625833ef66d95f (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>
Diffstat (limited to 'binding-bluetooth/bluetooth-manager.c')
-rw-r--r--binding-bluetooth/bluetooth-manager.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/binding-bluetooth/bluetooth-manager.c b/binding-bluetooth/bluetooth-manager.c
index 1f18f8b..7417624 100644
--- a/binding-bluetooth/bluetooth-manager.c
+++ b/binding-bluetooth/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)