summaryrefslogtreecommitdiffstats
path: root/binding/media-manager.c
diff options
context:
space:
mode:
authorMatt Ranostay <matt.ranostay@konsulko.com>2017-10-01 16:38:49 -0700
committerMatt Ranostay <matt.ranostay@konsulko.com>2017-10-05 20:13:15 -0700
commit47593c4e5a71a95fb5ee9824e7bef8bf31d4f41f (patch)
tree6e3f3954b8aa8ed2ac9b3fe1c3973b4bd2ba9c4f /binding/media-manager.c
parentaa7bfb7a49ef4e2b9e7334330650c9550eb3892a (diff)
binding: mediascanner: add media metadata to JSON output
Add metadata of the tracks artist, title, album and genre to the JSON output for media results. Bug-AGL: SPEC-924 Change-Id: I240481b3b36909cb2de6ff7ba5c0a168d7973dc2 Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
Diffstat (limited to 'binding/media-manager.c')
-rw-r--r--binding/media-manager.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/binding/media-manager.c b/binding/media-manager.c
index 342df47..d451b3d 100644
--- a/binding/media-manager.c
+++ b/binding/media-manager.c
@@ -98,7 +98,9 @@ GList* media_local_scan(GList *list)
while ((tmp = (gchar *) g_dir_read_name(dir)) != NULL)
{
- list = g_list_append(list, g_strdup_printf("file://%s/%s", path, tmp));
+ struct Media_Item *item = g_malloc0(sizeof(*item));
+ item->path = g_strdup_printf("file://%s", path);
+ list = g_list_append(list, item);
}
g_free(path);
@@ -132,18 +134,37 @@ GList* media_lightmediascanner_scan(void)
while (sqlite3_step(res) == SQLITE_ROW) {
struct stat buf;
+ struct Media_Item *item;
const char *path = (const char *) sqlite3_column_text(res, 0);
ret = stat(path, &buf);
if (ret)
continue;
- list = g_list_append(list, g_strdup_printf("file://%s", path));
+ item = g_malloc0(sizeof(*item));
+ item->path = g_strdup_printf("file://%s", path);
+ item->metadata.title = g_strdup((gchar *) sqlite3_column_text(res, 1));
+ item->metadata.artist = g_strdup((gchar *) sqlite3_column_text(res, 2));
+ item->metadata.album = g_strdup((gchar *) sqlite3_column_text(res, 3));
+ item->metadata.genre = g_strdup((gchar *) sqlite3_column_text(res, 4));
+ item->metadata.duration = sqlite3_column_int(res, 5) * 1000;
+ list = g_list_append(list, item);
}
return list;
}
+static void free_media_item(void *data)
+{
+ struct Media_Item *item = data;
+
+ g_free(item->metadata.title);
+ g_free(item->metadata.artist);
+ g_free(item->metadata.album);
+ g_free(item->metadata.genre);
+ g_free(item->path);
+ g_free(item);
+}
static void
on_interface_proxy_properties_changed (GDBusProxy *proxy,
@@ -183,7 +204,7 @@ on_interface_proxy_properties_changed (GDBusProxy *proxy,
if (list != NULL && g_RegisterCallback.binding_device_added)
g_RegisterCallback.binding_device_added(list);
- g_list_free_full(list, g_free);
+ g_list_free_full(list, free_media_item);
ListUnlock();
}