summaryrefslogtreecommitdiffstats
path: root/binding
diff options
context:
space:
mode:
authorsaman <mahmoudi.saman1@gmail.com>2020-11-29 17:25:42 +0330
committerScott Murray <scott.murray@konsulko.com>2021-01-05 14:26:46 +0000
commitb4ebff5a25cf1346b9ea86379a8d25275bb64a32 (patch)
tree40d38cca5ff22f24612b2968870c97828338bd2f /binding
parent494ce56f88fc377e703896723fdd80c26aa64550 (diff)
More attention to bluez player propertieskoi_10.93.0koi_10.92.0koi/10.93.0koi/10.92.010.93.010.92.0
It is possible the bluez player does not assign to default bluez player (player0) and assign to other player such as playerN. For fixing this issue we can access to correct bluez player from "Player" property in "org.bluez.MediaControl1" interface. By reading Player property on "org.bluez.MediaControl1" interface we could access to player path and ther is not need to define a const string variable like "player0"! Bug-AGL: SPEC-3722 Signed-off-by: saman <mahmoudi.saman1@gmail.com> Change-Id: I8a5f948c511bbb61ccc67db09ad17aeb02ab5bd1
Diffstat (limited to 'binding')
-rw-r--r--binding/bluetooth-api.c12
-rw-r--r--binding/bluetooth-api.h2
-rw-r--r--binding/bluetooth-bluez.c16
3 files changed, 26 insertions, 4 deletions
diff --git a/binding/bluetooth-api.c b/binding/bluetooth-api.c
index 33b5cac..49ae4e7 100644
--- a/binding/bluetooth-api.c
+++ b/binding/bluetooth-api.c
@@ -1367,9 +1367,10 @@ static void bluetooth_avrcp_controls(afb_req_t request)
{
struct bluetooth_state *ns = bluetooth_get_userdata(request);
const char *action = afb_req_value(request, "action");
- gchar *device, *player;
+ gchar *device, *player = NULL;
GVariant *reply;
GError *error = NULL;
+ json_object *jval = NULL;
if (!action) {
afb_req_fail(request, "failed", "No action given");
@@ -1379,7 +1380,14 @@ static void bluetooth_avrcp_controls(afb_req_t request)
device = return_bluez_path(request);
if (device) {
/* TODO: handle multiple players per device */
- player = g_strconcat(device, "/", BLUEZ_DEFAULT_PLAYER, NULL);
+ jval = bluez_get_property(ns, BLUEZ_AT_MEDIACONTROL, device, FALSE, "Player", NULL);
+ if (jval) {
+ player = (gchar *)json_object_get_string(jval);
+ json_object_put(jval);
+ jval = NULL;
+ }
+ if (!player)
+ player = g_strconcat(device, "/", BLUEZ_DEFAULT_PLAYER, NULL);
g_free(device);
} else {
player = g_strdup(ns->mediaplayer_path);
diff --git a/binding/bluetooth-api.h b/binding/bluetooth-api.h
index a0b807b..aecbad0 100644
--- a/binding/bluetooth-api.h
+++ b/binding/bluetooth-api.h
@@ -35,6 +35,7 @@
#define BLUEZ_DEVICE_INTERFACE BLUEZ_SERVICE ".Device1"
#define BLUEZ_MEDIAPLAYER_INTERFACE BLUEZ_SERVICE ".MediaPlayer1"
#define BLUEZ_MEDIATRANSPORT_INTERFACE BLUEZ_SERVICE ".MediaTransport1"
+#define BLUEZ_MEDIACONTROL_INTERFACE BLUEZ_SERVICE ".MediaControl1"
#define BLUEZ_OBJECT_PATH "/"
#define BLUEZ_PATH "/org/bluez"
@@ -70,6 +71,7 @@
#define BLUEZ_AT_AGENTMANAGER "agent-manager"
#define BLUEZ_AT_MEDIAPLAYER "mediaplayer"
#define BLUEZ_AT_MEDIATRANSPORT "mediatransport"
+#define BLUEZ_AT_MEDIACONTROL "mediacontrol"
#define BLUEZ_DEFAULT_ADAPTER "hci0"
#define BLUEZ_DEFAULT_PLAYER "player0"
diff --git a/binding/bluetooth-bluez.c b/binding/bluetooth-bluez.c
index 18194d5..de4bc0f 100644
--- a/binding/bluetooth-bluez.c
+++ b/binding/bluetooth-bluez.c
@@ -99,6 +99,12 @@ static const struct property_info mediatransport_props[] = {
{ },
};
+static const struct property_info mediacontrol_props[] = {
+ { .name = "Connected", .fmt = "b", },
+ { .name = "Player", .fmt = "s", },
+ { },
+};
+
const struct property_info *bluez_get_property_info(
const char *access_type, GError **error)
{
@@ -112,6 +118,8 @@ const struct property_info *bluez_get_property_info(
pi = mediaplayer_props;
else if (!strcmp(access_type, BLUEZ_AT_MEDIATRANSPORT))
pi = mediatransport_props;
+ else if (!strcmp(access_type, BLUEZ_AT_MEDIACONTROL))
+ pi = mediacontrol_props;
else
g_set_error(error, NB_ERROR, NB_ERROR_ILLEGAL_ARGUMENT,
"illegal %s argument", access_type);
@@ -357,7 +365,8 @@ json_object *bluez_get_properties(struct bluetooth_state *ns,
if (!strcmp(access_type, BLUEZ_AT_DEVICE) ||
!strcmp(access_type, BLUEZ_AT_MEDIAPLAYER) ||
!strcmp(access_type, BLUEZ_AT_MEDIATRANSPORT) ||
- !strcmp(access_type, BLUEZ_AT_ADAPTER)) {
+ !strcmp(access_type, BLUEZ_AT_ADAPTER) ||
+ !strcmp(access_type, BLUEZ_AT_MEDIACONTROL)) {
pi = bluez_get_property_info(access_type, error);
if (!pi)
@@ -380,6 +389,8 @@ json_object *bluez_get_properties(struct bluetooth_state *ns,
interface2 = BLUEZ_MEDIATRANSPORT_INTERFACE;
else if (!strcmp(access_type, BLUEZ_AT_ADAPTER))
interface2 = BLUEZ_ADAPTER_INTERFACE;
+ else if (!strcmp(access_type, BLUEZ_AT_MEDIACONTROL))
+ interface2 = BLUEZ_MEDIACONTROL_INTERFACE;
else if (!strcmp(access_type, BLUEZ_AT_OBJECT))
interface2 = NULL;
else
@@ -404,7 +415,8 @@ json_object *bluez_get_properties(struct bluetooth_state *ns,
if (!strcmp(access_type, BLUEZ_AT_DEVICE) ||
!strcmp(access_type, BLUEZ_AT_MEDIAPLAYER) ||
!strcmp(access_type, BLUEZ_AT_MEDIATRANSPORT) ||
- !strcmp(access_type, BLUEZ_AT_ADAPTER)) {
+ !strcmp(access_type, BLUEZ_AT_ADAPTER) ||
+ !strcmp(access_type, BLUEZ_AT_MEDIACONTROL)) {
jprop = json_object_new_object();
g_variant_get(reply, "(a{sv})", &array);
while (g_variant_iter_loop(array, "{sv}", &key, &var)) {