diff options
Diffstat (limited to 'binding')
-rw-r--r-- | binding/media-api.c | 5 | ||||
-rw-r--r-- | binding/media-manager.c | 15 | ||||
-rw-r--r-- | binding/media-manager.h | 17 |
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 |