summaryrefslogtreecommitdiff
path: root/src/mm_player_utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mm_player_utils.c')
-rw-r--r--src/mm_player_utils.c47
1 files changed, 46 insertions, 1 deletions
diff --git a/src/mm_player_utils.c b/src/mm_player_utils.c
index 99fdab7..6e72720 100644
--- a/src/mm_player_utils.c
+++ b/src/mm_player_utils.c
@@ -30,9 +30,12 @@
#include <arpa/inet.h>
#include <unicode/ucsdet.h>
#include <dlog.h>
-
+#include <storage.h>
+#include <tzplatform_config.h>
#include "mm_player_utils.h"
+#define MEDIA_PATH_EXTERNAL tzplatform_getenv(TZ_SYS_STORAGE) /* external storage */
+
int util_exist_file_path(const char *file_path)
{
int fd = 0;
@@ -461,3 +464,45 @@ int util_get_pixtype(unsigned int fourcc)
return pixtype;
}
+
+static int _util_storage_supported_cb(int storage_id, storage_type_e type,
+ storage_state_e state, const char *path, void *user_data)
+{
+ MMPlayerStorageInfo *storage_info = (MMPlayerStorageInfo *)user_data;
+
+ MMPLAYER_RETURN_VAL_IF_FAIL(storage_info, FALSE);
+
+ if (type == storage_info->type && state >= STORAGE_STATE_MOUNTED) {
+ storage_info->id = storage_id;
+ storage_info->state = state;
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+bool util_get_storage_info(const char *path, MMPlayerStorageInfo *storage_info)
+{
+ int ret = 0;
+ const char *file_path = path;
+
+ MMPLAYER_RETURN_VAL_IF_FAIL(file_path && storage_info, false);
+
+ if (strncmp(file_path, "file://", strlen("file://")) == 0)
+ file_path = path+7; /* remove file prefix */
+
+ if (strncmp(file_path, MEDIA_PATH_EXTERNAL, strlen(MEDIA_PATH_EXTERNAL)) == 0)
+ storage_info->type = STORAGE_TYPE_EXTERNAL;
+ else
+ storage_info->type = STORAGE_TYPE_INTERNAL;
+
+ ret = storage_foreach_device_supported((storage_device_supported_cb)_util_storage_supported_cb, storage_info);
+ if (ret != STORAGE_ERROR_NONE) {
+ LOGE("storage_foreach_device_supported failed 0x%x", ret);
+ return false;
+ }
+
+ LOGD("storage info: type %d, id %d", storage_info->type, storage_info->id);
+
+ return true;
+}