[RFC v2 17/18] bluetooth: parse MediaTransport.Codecs property

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 src/modules/bluetooth/bluetooth-util.c |   16 +++++++++++++---
 src/modules/bluetooth/bluetooth-util.h |    1 +
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/src/modules/bluetooth/bluetooth-util.c b/src/modules/bluetooth/bluetooth-util.c
index 0dbf143..a7cd783 100644
--- a/src/modules/bluetooth/bluetooth-util.c
+++ b/src/modules/bluetooth/bluetooth-util.c
@@ -1199,6 +1199,8 @@ static DBusMessage *endpoint_set_configuration(DBusConnection *conn, DBusMessage
     const char *path, *dev_path = NULL, *uuid = NULL;
     uint8_t *config = NULL;
     int size = 0;
+    uint8_t *codecs = NULL;
+    int i, ncodecs = 0;
     pa_bool_t nrec = FALSE;
     enum profile p;
     DBusMessageIter args, props;
@@ -1245,6 +1247,12 @@ static DBusMessage *endpoint_set_configuration(DBusConnection *conn, DBusMessage
                 goto fail;
             dbus_message_iter_recurse(&value, &array);
             dbus_message_iter_get_fixed_array(&array, &config, &size);
+        } else if (strcasecmp(key, "Codecs") == 0) {
+            DBusMessageIter array;
+            if (var != DBUS_TYPE_ARRAY)
+                goto fail;
+            dbus_message_iter_recurse(&value, &array);
+            dbus_message_iter_get_fixed_array(&array, &codecs, &ncodecs);
         }
 
         dbus_message_iter_next(&props);
@@ -1266,12 +1274,14 @@ static DBusMessage *endpoint_set_configuration(DBusConnection *conn, DBusMessage
     t = transport_new(y, path, p, config, size);
     if (nrec)
         t->nrec = nrec;
-    if (dbus_message_has_path(m, A2DP_SOURCE_ENDPOINT_MPEG) || dbus_message_has_path(m, A2DP_SINK_ENDPOINT_MPEG))
-        t->codec = 1;
+    for (i=0; i<ncodecs; i++) {
+        if (codecs[i] == A2DP_CODEC_MPEG12)
+            t->has_mpeg = TRUE;
+    }
 
     pa_hashmap_put(d->transports, t->path, t);
 
-    pa_log_debug("Transport %s profile %d available", t->path, t->profile);
+    pa_log_debug("Transport %s profile %d available (has_mpeg %d)", t->path, t->profile, t->has_mpeg);
 
     pa_assert_se(r = dbus_message_new_method_return(m));
 
diff --git a/src/modules/bluetooth/bluetooth-util.h b/src/modules/bluetooth/bluetooth-util.h
index b446cbe..02bfaa6 100644
--- a/src/modules/bluetooth/bluetooth-util.h
+++ b/src/modules/bluetooth/bluetooth-util.h
@@ -70,6 +70,7 @@ struct pa_bluetooth_transport {
     uint8_t codec;
     uint8_t *config;
     int config_size;
+    pa_bool_t has_mpeg;
     pa_bool_t nrec;
 };
 
-- 
1.7.5.4



[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux