diff options
author | Matt Ranostay <matt.ranostay@konsulko.com> | 2018-11-06 23:02:11 -0800 |
---|---|---|
committer | Matt Ranostay <matt.ranostay@konsulko.com> | 2018-11-12 03:58:47 -0800 |
commit | a5fe25e7496cf4a8369e1f34e66c9e55d2c95ed1 (patch) | |
tree | b999b55195278036550836f1336eb9f805cc00a6 /binding/bluetooth-api.c | |
parent | 50078d83552f02051a5706b3dfea0953eff3a02b (diff) |
binding: bluetooth: add new avrcp controls verb
Since MediaPlayer1 controls are part of bluez it makes sense
to keep them here for now
Bug-AGL: SPEC-1630
Change-Id: Ia02341179a322082357b0e7eff07264e34197d57
Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
Diffstat (limited to 'binding/bluetooth-api.c')
-rw-r--r-- | binding/bluetooth-api.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/binding/bluetooth-api.c b/binding/bluetooth-api.c index 5d26f3a..7e3e1eb 100644 --- a/binding/bluetooth-api.c +++ b/binding/bluetooth-api.c @@ -1029,6 +1029,44 @@ out_free: } +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; + GVariant *reply; + GError *error = NULL; + + if (!action) { + afb_req_fail(request, "failed", "No action given"); + return; + } + + device = return_bluez_path(request); + if (!device) { + afb_req_fail(request, "failed", "No path given"); + return; + } + + /* TODO: handle multiple players per device */ + player = g_strconcat(device, "/player0", NULL); + g_free(device); + + reply = mediaplayer_call(ns, player, action, NULL, &error); + + if (!reply) { + afb_req_fail_f(request, "failed", + "mediaplayer %s method %s error %s", + player, action, BLUEZ_ERRMSG(error)); + g_free(player); + g_error_free(error); + return; + } + + g_free(player); + afb_req_success(request, NULL, "Bluetooth - AVRCP controls"); +} + static void bluetooth_version(afb_req_t request) { json_object *jresp = json_object_new_object(); @@ -1090,6 +1128,11 @@ static const struct afb_verb_v3 bluetooth_verbs[] = { .callback = bluetooth_remove_device, .info = "Removed paired device", }, { + .verb = "avrcp_controls", + .session = AFB_SESSION_NONE, + .callback = bluetooth_avrcp_controls, + .info = "AVRCP controls" + }, { .verb = "version", .session = AFB_SESSION_NONE, .callback = bluetooth_version, |