[ACR-1378] Add condition to face related function 07/201907/5
authorMinje Ahn <minje.ahn@samsung.com>
Thu, 21 Mar 2019 01:07:54 +0000 (10:07 +0900)
committerMinje ahn <minje.ahn@samsung.com>
Wed, 3 Apr 2019 04:48:18 +0000 (04:48 +0000)
Change-Id: I07c7cf8838e1081075586667398edf87559aef31
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
include/media_face.h
include/media_info.h
include/media_info_private.h
include_product/media_face.h
include_product/media_info.h
include_product/media_info_private.h
src/media_face.c
src/media_info.c

index 4c879fe..b546923 100755 (executable)
@@ -169,7 +169,8 @@ int media_face_get_tag(media_face_h face, char **tag);
  *
  * @since_tizen 3.0
  *
- * @remarks The @a face should be released using media_face_destroy().
+ * @remarks The @a face should be released using media_face_destroy(). \n
+ *          Since 5.5, this function supports only image type.
  *
  * @param[in] media_id The media ID
  * @param[out] face The media face handle
index af622b5..2664f2a 100755 (executable)
@@ -1108,8 +1108,9 @@ int media_info_generate_thumbnail(media_info_h media);
  *                   %http://tizen.org/privilege/externalstorage
  *
  * @remarks If you want to destroy the media handle before callback invoked, you must cancel the face detection request by using media_info_cancel_face_detection(). \n
- *          If face detection fails, the face_count argument in media_face_detection_completed_cb() will be set to 0.
- *          Media items in external storage are not supported, with the exception of MMC items.
+ *          If face detection fails, the face_count argument in media_face_detection_completed_cb() will be set to 0. \n
+ *          Media items in external storage are not supported, with the exception of MMC items. \n
+ *          Since 5.5, if the format is unsupported, this function returns an error and callback will not be invoked.
  *
  * @param[in] media The handle to the media info
  * @param[in] callback The callback function to be invoked when detection is completed
index a928a0e..81babf8 100755 (executable)
@@ -573,6 +573,7 @@ typedef struct _media_content_cb_data {
 #define INSERT_FACE_TO_FACE                            "INSERT INTO "DB_TABLE_FACE" (media_uuid, face_rect_x , face_rect_y, face_rect_w, face_rect_h, orientation, media_face_tag) VALUES ('%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, media_face_tag=%Q WHERE media_face_id=%d"
 #define SELECT_MEDIA_COUNT_FROM_MEDIA_BY_ID            "SELECT COUNT(*) FROM "DB_VIEW_MEDIA" WHERE media_uuid='%q' AND validity=1"
+#define SELECT_IMAGE_COUNT_FROM_MEDIA_BY_ID            "SELECT COUNT(*) FROM "DB_VIEW_MEDIA" WHERE media_uuid='%q' AND media_type=0 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 media_face_id, fa.media_uuid, face_rect_x, face_rect_y, face_rect_w, face_rect_h, fa.orientation, media_face_tag FROM "FACE_MEDIA_JOIN
index 4c879fe..b546923 100755 (executable)
@@ -169,7 +169,8 @@ int media_face_get_tag(media_face_h face, char **tag);
  *
  * @since_tizen 3.0
  *
- * @remarks The @a face should be released using media_face_destroy().
+ * @remarks The @a face should be released using media_face_destroy(). \n
+ *          Since 5.5, this function supports only image type.
  *
  * @param[in] media_id The media ID
  * @param[out] face The media face handle
index af622b5..2664f2a 100755 (executable)
@@ -1108,8 +1108,9 @@ int media_info_generate_thumbnail(media_info_h media);
  *                   %http://tizen.org/privilege/externalstorage
  *
  * @remarks If you want to destroy the media handle before callback invoked, you must cancel the face detection request by using media_info_cancel_face_detection(). \n
- *          If face detection fails, the face_count argument in media_face_detection_completed_cb() will be set to 0.
- *          Media items in external storage are not supported, with the exception of MMC items.
+ *          If face detection fails, the face_count argument in media_face_detection_completed_cb() will be set to 0. \n
+ *          Media items in external storage are not supported, with the exception of MMC items. \n
+ *          Since 5.5, if the format is unsupported, this function returns an error and callback will not be invoked.
  *
  * @param[in] media The handle to the media info
  * @param[in] callback The callback function to be invoked when detection is completed
index d74d9b9..453be80 100755 (executable)
@@ -750,6 +750,7 @@ typedef struct _media_content_scan_cb_data_v2 {
 #define INSERT_FACE_TO_FACE                            "INSERT INTO "DB_TABLE_FACE" (media_uuid, face_rect_x , face_rect_y, face_rect_w, face_rect_h, orientation, media_face_tag) VALUES ('%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, media_face_tag=%Q WHERE media_face_id=%d"
 #define SELECT_MEDIA_COUNT_FROM_MEDIA_BY_ID            "SELECT COUNT(*) FROM "DB_VIEW_MEDIA" WHERE media_uuid='%q' AND validity=1"
+#define SELECT_IMAGE_COUNT_FROM_MEDIA_BY_ID            "SELECT COUNT(*) FROM "DB_VIEW_MEDIA" WHERE media_uuid='%q' AND media_type=0 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 media_face_id, fa.media_uuid, face_rect_x, face_rect_y, face_rect_w, face_rect_h, fa.orientation, media_face_tag FROM "FACE_MEDIA_JOIN
index cff1beb..979a92c 100755 (executable)
@@ -28,7 +28,8 @@ static int __media_face_check_media_id(const char *media_id)
 
        media_content_retvm_if(!STRING_VALID(media_id), MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "invalid media_id");
 
-       query_str = sqlite3_mprintf(SELECT_MEDIA_COUNT_FROM_MEDIA_BY_ID, media_id);
+       /* Get image count */
+       query_str = sqlite3_mprintf(SELECT_IMAGE_COUNT_FROM_MEDIA_BY_ID, media_id);
        ret = _content_query_prepare(&stmt, query_str, NULL, NULL);
        SQLITE3_SAFE_FREE(query_str);
        media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
@@ -186,7 +187,7 @@ int media_face_create(const char *media_id, media_face_h *face)
        media_content_retvm_if(face == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Invalid handle");
 
        ret = __media_face_check_media_id(media_id);
-       media_content_retvm_if(ret != MEDIA_CONTENT_ERROR_NONE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Not exist media_id");
+       media_content_retvm_if(ret != MEDIA_CONTENT_ERROR_NONE, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "media_id does not exist or is not an image");
 
        media_face_s* _face = calloc(1, sizeof(media_face_s));
        media_content_retvm_if(_face == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "Out of memory");
index a911855..894f077 100755 (executable)
@@ -2050,6 +2050,11 @@ int media_info_start_face_detection(media_info_h media, media_face_detection_com
        }
 
        if (_media != NULL && STRING_VALID(_media->media_id) && STRING_VALID(_media->file_path)) {
+               if (g_strcmp0(_media->mime_type, "image/jpeg") != 0 && g_strcmp0(_media->mime_type, "image/png") != 0 && g_strcmp0(_media->mime_type, "image/bmp") != 0) {
+                       media_content_error("Unsupported mime type");
+                       return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+               }
+
                memset(repl_path, 0, sizeof(repl_path));
                ret = _media_content_replace_path(_media->file_path, repl_path);
                media_content_retvm_if(!STRING_VALID(repl_path), MEDIA_CONTENT_ERROR_INVALID_OPERATION, "path replacement failed");