summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Ranostay <matt.ranostay@konsulko.com>2017-12-07 17:57:38 -0800
committerMatt Ranostay <matt.ranostay@konsulko.com>2017-12-09 20:57:46 -0800
commit91126397febe969a6ee94f9baff6337568ee7c65 (patch)
tree78b5204b8695afc1bf6bf87791db47e2add1e1bf
parent34aeacdb140533e04e2d6d9512bc25c342135dc7 (diff)
binding: mediascanner: add video scan from lightmediascanner
Add to the playlist the video media found from the lightmediascanner database. Bug-AGL: SPEC-1169 Change-Id: I9ebf2e21805fe0e59a853dd081eacf02af501c96 Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
-rw-r--r--binding/media-api.c5
-rw-r--r--binding/media-manager.c15
-rw-r--r--binding/media-manager.h17
3 files changed, 30 insertions, 7 deletions
diff --git a/binding/media-api.c b/binding/media-api.c
index ae22fb1..892f67d 100644
--- a/binding/media-api.c
+++ b/binding/media-api.c
@@ -126,11 +126,12 @@ static json_object *new_json_object_from_device(GList *list)
static void media_results_get (struct afb_req request)
{
- GList *list;
+ GList *list = NULL;
json_object *jresp = NULL;
ListLock();
- list = media_lightmediascanner_scan(list, NULL);
+ list = media_lightmediascanner_scan(list, NULL, LMS_AUDIO_SCAN);
+ list = media_lightmediascanner_scan(list, NULL, LMS_VIDEO_SCAN);
if (list == NULL) {
afb_req_fail(request, "failed", "media scan error");
ListUnlock();
diff --git a/binding/media-manager.c b/binding/media-manager.c
index e0c8ae7..46c7d1d 100644
--- a/binding/media-manager.c
+++ b/binding/media-manager.c
@@ -84,7 +84,7 @@ void DebugTraceSendMsg(int level, gchar* message)
}
-GList* media_lightmediascanner_scan(GList *list, gchar *uri)
+GList* media_lightmediascanner_scan(GList *list, gchar *uri, int scan_type)
{
sqlite3 *conn;
sqlite3_stmt *res;
@@ -101,7 +101,15 @@ GList* media_lightmediascanner_scan(GList *list, gchar *uri)
return NULL;
}
- query = g_strdup_printf(SQL_QUERY, uri ? uri : "");
+ switch (scan_type) {
+ case LMS_VIDEO_SCAN:
+ query = g_strdup_printf(VIDEO_SQL_QUERY, uri ? uri : "");
+ break;
+ case LMS_AUDIO_SCAN:
+ default:
+ query = g_strdup_printf(AUDIO_SQL_QUERY, uri ? uri : "");
+ }
+
if (!query) {
LOGE("Cannot allocate memory for query\n");
return NULL;
@@ -183,7 +191,8 @@ on_interface_proxy_properties_changed (GDBusProxy *proxy,
ListLock();
- list = media_lightmediascanner_scan(list, MediaPlayerManage.uri_filter);
+ list = media_lightmediascanner_scan(list, MediaPlayerManage.uri_filter, LMS_AUDIO_SCAN);
+ list = media_lightmediascanner_scan(list, MediaPlayerManage.uri_filter, LMS_VIDEO_SCAN);
g_free(MediaPlayerManage.uri_filter);
MediaPlayerManage.uri_filter = NULL;
diff --git a/binding/media-manager.h b/binding/media-manager.h
index 2e5c0d3..37621b0 100644
--- a/binding/media-manager.h
+++ b/binding/media-manager.h
@@ -74,7 +74,8 @@ void DebugTraceSendMsg(int level, gchar* message);
#define FREEDESKTOP_PROPERTIES "org.freedesktop.DBus.Properties"
//sqlite
-#define SQL_QUERY "SELECT files.path, audios.title, audio_artists.name, " \
+#define AUDIO_SQL_QUERY \
+ "SELECT files.path, audios.title, audio_artists.name, " \
"audio_albums.name, audio_genres.name, audios.length " \
"FROM files LEFT JOIN audios " \
"LEFT JOIN audio_artists " \
@@ -88,6 +89,13 @@ void DebugTraceSendMsg(int level, gchar* message);
"ORDER BY " \
"audios.artist_id, audios.album_id, audios.trackno"
+#define VIDEO_SQL_QUERY \
+ "SELECT files.path, videos.title, videos.artist, \"\", \"\", " \
+ "videos.length FROM files LEFT JOIN videos " \
+ "WHERE files.path LIKE '%s/%%' " \
+ "ORDER BY " \
+ "videos.title"
+
typedef struct {
GList *list;
gchar *uri_filter;
@@ -108,7 +116,7 @@ int MediaPlayerManagerInit(void);
void ListLock();
void ListUnlock();
-GList* media_lightmediascanner_scan(GList *list, gchar *uri);
+GList* media_lightmediascanner_scan(GList *list, gchar *uri, int scan_type);
struct Media_Item {
gchar *path;
@@ -121,4 +129,9 @@ struct Media_Item {
} metadata;
};
+enum {
+ LMS_AUDIO_SCAN,
+ LMS_VIDEO_SCAN,
+};
+
#endif