Add New APIs for filtering bookmark and face 48/133548/1
authorHaejeong Kim <backto.kim@samsung.com>
Tue, 13 Jun 2017 00:53:07 +0000 (09:53 +0900)
committerHaejeong Kim <backto.kim@samsung.com>
Tue, 13 Jun 2017 00:53:07 +0000 (09:53 +0900)
Change-Id: I775ffe5859bbd194675f8d00066f814ae3a0a23e

include/media_info_private.h
src/media_bookmark.c
src/media_db.c
src/media_face.c

index e801a3b..cf99666 100755 (executable)
@@ -166,6 +166,7 @@ typedef enum {
        MEDIA_GROUP_TAG_BY_MEDIA_ID,
        MEDIA_GROUP_BOOKMARK_BY_MEDIA_ID,
        MEDIA_GROUP_STORAGE,
+       MEDIA_GROUP_FACE,
        MEDIA_GROUP_FACE_BY_MEDIA_ID,
 } group_list_e;
 
@@ -619,6 +620,7 @@ typedef struct _media_content_cb_data {
 /* Bookmark */
 #define INSERT_BOOKMARK_TO_BOOKMARK                    "INSERT INTO "DB_TABLE_BOOKMARK" (media_uuid, marked_time, thumbnail_path, name) VALUES ('%q', '%d', %Q, %Q)"
 #define SELECT_BOOKMARK_COUNT_BY_MEDIA_ID              "SELECT COUNT(*) FROM "BOOKMARK_MEDIA_JOIN" AND b.media_uuid='%s'"
+#define SELECT_BOOKMARK_LIST                                           "SELECT b.bookmark_id, b.media_uuid, b.marked_time, b.thumbnail_path, b.name FROM "BOOKMARK_MEDIA_JOIN
 #define SELECT_BOOKMARK_LIST_BY_MEDIA_ID                       "SELECT b.bookmark_id, b.media_uuid, b.marked_time, b.thumbnail_path, b.name FROM "BOOKMARK_MEDIA_JOIN" AND b.media_uuid='%s'"
 #define SELECT_BOOKMARK_ID_FROM_BOOKMARK               "SELECT bookmark_id FROM "DB_TABLE_BOOKMARK" WHERE media_uuid='%s' AND marked_time=%d"
 
@@ -657,7 +659,9 @@ typedef struct _media_content_cb_data {
 #define INSERT_FACE_TO_FACE                            "INSERT INTO "DB_TABLE_FACE" (face_uuid, media_uuid, face_rect_x , face_rect_y, face_rect_w, face_rect_h, orientation, face_tag) VALUES ('%q', '%q', %d, %d, %d, %d, %d, %Q);"
 #define UPDATE_FACE_TO_FACE                    "UPDATE "DB_TABLE_FACE" SET face_rect_x=%d, face_rect_y=%d, face_rect_w=%d, face_rect_h=%d, orientation=%d, face_tag=%Q WHERE face_uuid='%q'"
 #define SELECT_MEDIA_COUNT_FROM_MEDIA_BY_ID            "SELECT COUNT(*) FROM "DB_TABLE_MEDIA_VIEW" WHERE media_uuid='%q' AND validity=1"
+#define SELECT_FACE_COUNT                                      "SELECT COUNT(*) FROM "FACE_MEDIA_JOIN
 #define SELECT_FACE_COUNT_BY_MEDIA_ID          "SELECT COUNT(*) FROM "FACE_MEDIA_JOIN" AND fa.media_uuid='%s'"
+#define SELECT_FACE_LIST                                               "SELECT fa.face_uuid, fa.media_uuid, fa.face_rect_x, fa.face_rect_y, fa.face_rect_w, fa.face_rect_h, fa.orientation, fa.face_tag FROM "FACE_MEDIA_JOIN
 #define SELECT_FACE_LIST_BY_MEDIA_ID           "SELECT fa.face_uuid, fa.media_uuid, fa.face_rect_x, fa.face_rect_y, fa.face_rect_w, fa.face_rect_h, fa.orientation, fa.face_tag FROM "FACE_MEDIA_JOIN" AND fa.media_uuid='%s'"
 #define SELECT_FACE_PATH_FROM_MEDIA            "SELECT path FROM "DB_TABLE_MEDIA_VIEW" media_uuid='%s'"
 
index 2edeb29..2c72e80 100755 (executable)
@@ -93,6 +93,17 @@ int media_bookmark_get_bookmark_count_from_db(filter_h filter, int *bookmark_cou
        return ret;
 }
 
+int media_bookmark_foreach_bookmark_from_db(filter_h filter, media_bookmark_cb callback, void *user_data)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       media_content_retvm_if(callback == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid paramter");
+
+       ret = _media_db_get_bookmark(NULL, filter, callback, user_data);
+
+       return ret;
+}
+
 int media_bookmark_destroy(media_bookmark_h bookmark)
 {
        int ret = MEDIA_CONTENT_ERROR_NONE;
index 657aeb6..7b689a8 100755 (executable)
@@ -254,6 +254,7 @@ int _media_db_get_group_count(filter_h filter, group_list_e group_type, int *gro
        case MEDIA_GROUP_NONE:
        case MEDIA_GROUP_TAG_BY_MEDIA_ID:
        case MEDIA_GROUP_BOOKMARK_BY_MEDIA_ID:
+       case MEDIA_GROUP_FACE_BY_MEDIA_ID:
                {
                        media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
                        return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
@@ -308,6 +309,14 @@ int _media_db_get_group_count(filter_h filter, group_list_e group_type, int *gro
                        return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
                }
                break;
+       case MEDIA_GROUP_FACE:
+               attr = _content_get_alias_attirbute_handle();
+
+               if ((_filter != NULL) && STRING_VALID(_filter->storage_id))
+                       snprintf(select_query, sizeof(select_query), SELECT_FACE_COUNT, _filter->storage_id);
+               else
+                       snprintf(select_query, sizeof(select_query), SELECT_FACE_COUNT, DB_TABLE_MEDIA_VIEW);
+               break;
 #ifdef _USE_TV_PROFILE
        case MEDIA_GROUP_PVR:
        case MEDIA_GROUP_UHD:
@@ -820,14 +829,21 @@ int _media_db_get_bookmark(const char *media_id, filter_h filter, media_bookmark
        attribute_h attr = NULL;
        filter_s *_filter = (filter_s*)filter;
 
-       attr = _content_get_attirbute_handle();
+       attr = _content_get_alias_attirbute_handle();
 
        memset(select_query, 0x00, sizeof(select_query));
 
-       if ((_filter != NULL) && STRING_VALID(_filter->storage_id))
-               snprintf(select_query, sizeof(select_query), SELECT_BOOKMARK_LIST_BY_MEDIA_ID, _filter->storage_id, media_id);
-       else
-               snprintf(select_query, sizeof(select_query), SELECT_BOOKMARK_LIST_BY_MEDIA_ID, DB_TABLE_MEDIA_VIEW, media_id);
+       if (STRING_VALID(media_id)) {   //get bookmark by media_id
+               if ((_filter != NULL) && STRING_VALID(_filter->storage_id))
+                       snprintf(select_query, sizeof(select_query), SELECT_BOOKMARK_LIST_BY_MEDIA_ID, _filter->storage_id, media_id);
+               else
+                       snprintf(select_query, sizeof(select_query), SELECT_BOOKMARK_LIST_BY_MEDIA_ID, DB_TABLE_MEDIA_VIEW, media_id);
+       } else {
+               if ((_filter != NULL) && STRING_VALID(_filter->storage_id))
+                       snprintf(select_query, sizeof(select_query), SELECT_BOOKMARK_LIST, _filter->storage_id);
+               else
+                       snprintf(select_query, sizeof(select_query), SELECT_BOOKMARK_LIST, DB_TABLE_MEDIA_VIEW);
+       }
 
        ret = __media_db_make_query(filter, attr, select_query, sizeof(select_query), &condition_query, &option_query);
        media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
@@ -876,14 +892,21 @@ int _media_db_get_face(const char *media_id, filter_h filter, media_face_cb call
        attribute_h attr = NULL;
        filter_s *_filter = (filter_s*)filter;
 
-       attr = _content_get_attirbute_handle();
+       attr = _content_get_alias_attirbute_handle();
 
        memset(select_query, 0x00, sizeof(select_query));
 
-       if ((_filter != NULL) && STRING_VALID(_filter->storage_id))
-               snprintf(select_query, sizeof(select_query), SELECT_FACE_LIST_BY_MEDIA_ID, _filter->storage_id, media_id);
-       else
-               snprintf(select_query, sizeof(select_query), SELECT_FACE_LIST_BY_MEDIA_ID, DB_TABLE_MEDIA_VIEW, media_id);
+       if (STRING_VALID(media_id)) {   //get face by media_id
+               if ((_filter != NULL) && STRING_VALID(_filter->storage_id))
+                       snprintf(select_query, sizeof(select_query), SELECT_FACE_LIST_BY_MEDIA_ID, _filter->storage_id, media_id);
+               else
+                       snprintf(select_query, sizeof(select_query), SELECT_FACE_LIST_BY_MEDIA_ID, DB_TABLE_MEDIA_VIEW, media_id);
+       } else {
+               if ((_filter != NULL) && STRING_VALID(_filter->storage_id))
+                       snprintf(select_query, sizeof(select_query), SELECT_FACE_LIST, _filter->storage_id);
+               else
+                       snprintf(select_query, sizeof(select_query), SELECT_FACE_LIST, DB_TABLE_MEDIA_VIEW);
+       }
 
        ret = __media_db_make_query(filter, attr, select_query, sizeof(select_query), &condition_query, &option_query);
        media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
index d9ac937..30483ce 100755 (executable)
@@ -301,3 +301,28 @@ int media_face_delete_from_db(const char *face_id)
 
        return ret;
 }
+
+int media_face_get_face_count_from_db(filter_h filter, int *face_count)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       if (face_count == NULL) {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = _media_db_get_group_count(filter, MEDIA_GROUP_FACE, face_count);
+
+       return ret;
+}
+
+int media_face_foreach_face_from_db(filter_h filter, media_face_cb callback, void *user_data)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       media_content_retvm_if(callback == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid paramter");
+
+       ret = _media_db_get_face(NULL, filter, callback, user_data);
+
+       return ret;
+}