diff options
author | Matt Ranostay <matt.ranostay@konsulko.com> | 2017-05-15 12:59:55 -0700 |
---|---|---|
committer | Matt Ranostay <matt.ranostay@konsulko.com> | 2017-05-15 19:51:02 -0700 |
commit | e8dd76c1c44567b917a7ff081d6ed80b8ef9f722 (patch) | |
tree | 9c5c4dba53f4943c7fb9c0686dc51d9fdd6476c4 /binding-bluetooth/bluetooth-api.c | |
parent | 062bc304e68f54ed13d44c39ec055e08cfd4e883 (diff) |
binding: bluetooth: add support for avrcp metadata reporting
Add binding support for reporting avrcp metadata, and status events.
Bug-AGL: SPEC-596
Change-Id: I33a1045db5aa421a01e28c7bda254085b107e4f1
Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
Diffstat (limited to 'binding-bluetooth/bluetooth-api.c')
-rw-r--r-- | binding-bluetooth/bluetooth-api.c | 67 |
1 files changed, 66 insertions, 1 deletions
diff --git a/binding-bluetooth/bluetooth-api.c b/binding-bluetooth/bluetooth-api.c index 520d9e2..31d179a 100644 --- a/binding-bluetooth/bluetooth-api.c +++ b/binding-bluetooth/bluetooth-api.c @@ -115,6 +115,65 @@ static int event_push(struct json_object *args, const char *tag) return e ? afb_event_push(e->event, json_object_get(args)) : -1; } +static json_object *new_json_object_parse_avrcp(struct btd_device *BDdevice, unsigned int filter) +{ + json_object *jresp = json_object_new_object(); + json_object *jstring = NULL; + + if (BD_AVRCP_TITLE & filter) + { + if (BDdevice->avrcp_title) + { + jstring = json_object_new_string(BDdevice->avrcp_title); + } + else + { + jstring = json_object_new_string(""); + } + json_object_object_add(jresp, "Title", jstring); + } + + if (BD_AVRCP_ARTIST & filter) + { + if (BDdevice->avrcp_artist) + { + jstring = json_object_new_string(BDdevice->avrcp_artist); + } + else + { + jstring = json_object_new_string(""); + } + json_object_object_add(jresp, "Artist", jstring); + } + + if (BD_AVRCP_STATUS & filter) + { + if (BDdevice->avrcp_status) + { + jstring = json_object_new_string(BDdevice->avrcp_status); + } + else + { + jstring = json_object_new_string(""); + } + json_object_object_add(jresp, "Status", jstring); + } + + if (BD_AVRCP_DURATION & filter) + { + json_object_object_add(jresp, "Duration", + json_object_new_int(BDdevice->avrcp_duration)); + } + + if (BD_AVRCP_POSITION & filter) + { + json_object_object_add(jresp, "Position", + json_object_new_int(BDdevice->avrcp_position)); + } + + return jresp; +} + /* create device json object*/ static json_object *new_json_object_from_device(struct btd_device *BDdevice, unsigned int filter) { @@ -186,6 +245,12 @@ static json_object *new_json_object_from_device(struct btd_device *BDdevice, uns jstring = (TRUE == BDdevice->avconnected) ? json_object_new_string("True"):json_object_new_string("False"); json_object_object_add(jresp, "AVPConnected", jstring); + + if (BDdevice->avconnected) + { + jstring = new_json_object_parse_avrcp(BDdevice, filter); + json_object_object_add(jresp, "Metadata", jstring); + } } if (BD_HFPCONNECTED & filter) @@ -638,7 +703,7 @@ 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; + 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; int ret; json_object *jresp = new_json_object_from_device(BDdevice, filter); |