From 6c1719bec34a62309426b25dced79dd2be840910 Mon Sep 17 00:00:00 2001 From: Matt Ranostay Date: Thu, 15 Nov 2018 02:58:25 -0800 Subject: binding: mediaplayer: update local media metadata to match avrcp To allow the mediaplayer application to not care if an media is local or a2dp stream the reported metadata events should be the same. Bug-AGL: SPEC-1630 Change-Id: I0fb00aa94d8b44e4babced0c87f3eeb6c3dd15e5 Signed-off-by: Matt Ranostay --- binding/afm-mediaplayer-binding.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/binding/afm-mediaplayer-binding.c b/binding/afm-mediaplayer-binding.c index d6f1a69..d8efe37 100644 --- a/binding/afm-mediaplayer-binding.c +++ b/binding/afm-mediaplayer-binding.c @@ -547,16 +547,17 @@ static json_object *populate_json_metadata_image(json_object *jresp) static json_object *populate_json_metadata(void) { struct playlist_item *track; - json_object *jresp; + json_object *jresp, *metadata; if (current_track == NULL || current_track->data == NULL) return NULL; track = current_track->data; - jresp = populate_json(track); + metadata = populate_json(track); + jresp = json_object_new_object(); if (data.duration != GST_CLOCK_TIME_NONE) - json_object_object_add(jresp, "duration", + json_object_object_add(metadata, "duration", json_object_new_int64(data.duration / GST_MSECOND)); if (data.position != GST_CLOCK_TIME_NONE) @@ -566,7 +567,8 @@ static json_object *populate_json_metadata(void) json_object_object_add(jresp, "volume", json_object_new_int64(data.volume)); - jresp = populate_json_metadata_image(jresp); + metadata = populate_json_metadata_image(metadata); + json_object_object_add(jresp, "track", metadata); return jresp; } @@ -680,7 +682,7 @@ static gboolean handle_message(GstBus *bus, GstMessage *msg, CustomData *data) static gboolean position_event(CustomData *data) { struct playlist_item *track; - json_object *jresp = NULL; + json_object *jresp = NULL, *metadata; pthread_mutex_lock(&mutex); @@ -703,7 +705,8 @@ static gboolean position_event(CustomData *data) } track = current_track->data; - jresp = populate_json(track); + metadata = populate_json(track); + jresp = json_object_new_object(); if (!GST_CLOCK_TIME_IS_VALID(data->duration)) gst_element_query_duration(data->playbin, @@ -712,7 +715,7 @@ static gboolean position_event(CustomData *data) gst_element_query_position(data->playbin, GST_FORMAT_TIME, &data->position); - json_object_object_add(jresp, "duration", + json_object_object_add(metadata, "duration", json_object_new_int64(data->duration / GST_MSECOND)); json_object_object_add(jresp, "position", json_object_new_int64(data->position / GST_MSECOND)); @@ -720,10 +723,12 @@ static gboolean position_event(CustomData *data) json_object_new_string("playing")); if (metadata_track != current_track) { - jresp = populate_json_metadata_image(jresp); + metadata = populate_json_metadata_image(metadata); metadata_track = current_track; } + json_object_object_add(jresp, "track", metadata); + pthread_mutex_unlock(&mutex); afb_event_push(metadata_event, jresp); -- cgit 1.2.3-korg