Removed media contant deprecated API 71/196071/3 submit/tizen/20181224.162738
authorKartik Tidke <kr.tidke@samsung.com>
Fri, 21 Dec 2018 14:50:23 +0000 (20:20 +0530)
committerKartik Tidke <kr.tidke@samsung.com>
Fri, 21 Dec 2018 16:38:57 +0000 (22:08 +0530)
Change-Id: Ie455dd4ffdddb0460a1a09e77858cc89b787930e
Signed-off-by: Kartik Tidke <kr.tidke@samsung.com>
CMakeLists.txt
src/common/mp-util-media-service.c

index 90c93ab..5ace08a 100755 (executable)
@@ -87,6 +87,7 @@ pkg_check_modules(pkgs REQUIRED
        capi-content-mime-type
        capi-system-media-key
        shortcut
+       storage
        capi-system-sensor
        notification
        capi-system-runtime-info
index 92f10a0..f0fd270 100644 (file)
@@ -20,6 +20,7 @@
 
 #include <metadata_extractor.h>
 #include <image_util.h>
+#include <storage.h>
 
 #include "mp-util.h"
 #include "mp-video-log.h"
 
 #define CAMERA_FOLDER_PATH     "/opt/usr/media/Camera"
 
+typedef struct _storage_rec_t storage_rec_s;
+
+struct _storage_rec_t {
+       int storage_id;
+       char *file_url;
+};
+
 
 static Eina_List *VideoFolderList = NULL;
 static Eina_List *VideoItemList = NULL;
@@ -40,6 +48,31 @@ static int nNumberOfVideoItemByType = 0;
 static media_content_noti_h noti_handle = NULL;
 
 /**
+ * Called to get information once for each supported storage.
+ * @param storage_id : The unique storage ID
+ * @param type : The type of the storage
+ * @param state : The current state of the storage
+ * @param path : The absolute path to the root directory of the storage
+ * @param user_data : The user data passed from the foreach function
+ * @return
+ */
+static bool _storage_device_supported_cb(int storage_id, storage_type_e type,
+                               storage_state_e state, const char *path, void *user_data)
+{
+       storage_rec_s *storage_rec = (storage_rec_s *)user_data;
+
+       if (!(storage_rec && storage_rec->file_url && path)) {
+               return true;
+       }
+
+       if (strncmp(path, storage_rec->file_url, strlen(path)) == 0) {
+               storage_rec->storage_id = storage_id;
+               return false;
+       }
+       return true;
+}
+
+/**
 * Check if the give file is of 3gp format
 * @param szFileUri : file string
 * @return true/false
@@ -1930,6 +1963,8 @@ MpMediaStorageType mp_util_svc_get_folder_storage(const int
 {
 
        MpMediaStorageType storage_local = MP_MEDIA_TYPE_STORAGE_UNKNOWN;
+       char *folder_path;
+       int ret = -1;
 
        if (!VideoFolderList) {
                VideoLogError("Not exist video folder list handle.");
@@ -1942,16 +1977,35 @@ MpMediaStorageType mp_util_svc_get_folder_storage(const int
                return storage_local;
        }
 
-       media_content_storage_e storage_type = MEDIA_CONTENT_STORAGE_INTERNAL;
        media_folder_h pFolderItem =
                (media_folder_h) eina_list_nth(VideoFolderList, nVideoFolderIndex);
-       if (media_folder_get_storage_type(pFolderItem, &storage_type) !=
+
+       if (media_folder_get_path(pFolderItem, &folder_path) !=
                MEDIA_CONTENT_ERROR_NONE) {
-               VideoLogError("fail to get the folder storage type");
+               VideoLogError("Get folder path failed!");
+               return storage_local;
        }
-       if (storage_type == MEDIA_CONTENT_STORAGE_INTERNAL) {
+
+       storage_rec_s storage_rec;
+       storage_rec.storage_id = -1;
+       storage_rec.file_url = folder_path;
+       storage_type_e storage_type = 0;
+
+       ret = storage_foreach_device_supported(_storage_device_supported_cb, &storage_rec);
+       if (ret != STORAGE_ERROR_NONE || storage_rec.storage_id == -1) {
+               VideoLogError("Get storage id failed!");
+               return storage_local;
+       }
+
+       ret = storage_get_type(storage_rec.storage_id, &storage_type);
+       if (ret != STORAGE_ERROR_NONE) {
+               VideoLogError("Get storage type failed!");
+               return storage_local;
+       }
+
+       if (storage_type == STORAGE_TYPE_INTERNAL) {
                storage_local = MP_MEDIA_TYPE_STORAGE_INTERNAL;
-       } else if (storage_type == MEDIA_CONTENT_STORAGE_EXTERNAL) {
+       } else if (storage_type == STORAGE_TYPE_EXTERNAL) {
                storage_local = MP_MEDIA_TYPE_STORAGE_EXTERNAL;
        }