[0.3.41] remove file:// prefix before checking internal path 42/107242/1 accepted/tizen_3.0.m2_mobile accepted/tizen_3.0.m2_tv accepted/tizen_3.0.m2_wearable tizen_3.0.m2 accepted/tizen/3.0.m2/mobile/20170104.121558 accepted/tizen/3.0.m2/tv/20170104.122335 accepted/tizen/3.0.m2/wearable/20170104.122717 accepted/tizen/3.0/common/20161228.071728 accepted/tizen/3.0/ivi/20161228.022527 accepted/tizen/3.0/mobile/20161228.022429 accepted/tizen/3.0/tv/20161228.022447 accepted/tizen/3.0/wearable/20161228.022504 submit/tizen_3.0.m2/20170104.093749 submit/tizen_3.0/20161227.144016
authorEunhae Choi <eunhae1.choi@samsung.com>
Tue, 27 Dec 2016 08:22:29 +0000 (17:22 +0900)
committerEunhae Choi <eunhae1.choi@samsung.com>
Tue, 27 Dec 2016 08:22:29 +0000 (17:22 +0900)
Change-Id: I7b57664465a379693f2649fc034187a845a60916

include/player_private.h
packaging/capi-media-player.spec
src/player.c
src/player_internal.c

index ea053f1947ebe6a15bc4c9737ee097dd769d9d1c..590c84516c2432e96f3927f9178a7a41efb0a795 100644 (file)
@@ -182,7 +182,8 @@ typedef struct _player_cli_s {
 
 int client_get_api_timeout(player_cli_s * pc, muse_player_api_e api);
 int client_wait_for_cb_return(muse_player_api_e api, callback_cb_info_s * cb_info, char **ret_buf, int time_out);
-int _player_convert_display_type (player_display_type_e type, player_private_display_type_e *out_type);
+int _player_convert_display_type(player_display_type_e type, player_private_display_type_e *out_type);
+int _player_get_origin_internal_path(const char* uri, char* origin);
 
 #ifdef __cplusplus
 }
index e6421befbfd34c3421149ba9cc6a293f8a3154a0..1a5aa2999aecd0db01c18641613c4cdbdb4763bd 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-player
 Summary:    A Media Player API
-Version:    0.3.40
+Version:    0.3.41
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index f13b2f06c507b92dde8900a7448ab11a3576def5..be7a808b1b74881462b4d0e1ab8ef59fab1e9829 100644 (file)
@@ -1884,6 +1884,42 @@ int player_unprepare(player_h player)
        return ret;
 }
 
+/* 1. covert '/opt/usr/media/xxx' file path to '/opt/usr/home/owner/media/xxx'
+ * 2. remove 'file://' prefix */
+int _player_get_origin_internal_path(const char* uri, char* origin)
+{
+       gchar *file_path = NULL;
+       GError *err = NULL;
+
+       if (strstr(uri, "file://")) {
+               file_path = g_filename_from_uri(uri, NULL, &err);
+
+               if (!file_path || (err != NULL)) {
+                 LOGE("Invalid URI '%s', err: %s", uri,
+                               (err != NULL) ? err->message : "unknown error");
+
+                 if (err) g_error_free(err);
+                 if (file_path) g_free(file_path);
+
+                 return PLAYER_ERROR_INVALID_PARAMETER;
+               }
+               LOGD("get file path from uri");
+       }
+
+       if (storage_get_origin_internal_path((file_path) ? (file_path) : (uri), MAX_URL_LEN, origin) < 0) {
+               /* cannot convert path. use the original one. */
+               strncpy(origin, (file_path) ? (file_path) : (uri), MAX_URL_LEN-1);
+       } else {
+               /* need to use converted path. */
+               LOGD("Converted path : %s -> %s", uri, origin);
+       }
+
+       if (file_path)
+               g_free(file_path);
+
+       return PLAYER_ERROR_NONE;
+}
+
 int player_set_uri(player_h player, const char *uri)
 {
        PLAYER_INSTANCE_CHECK(player);
@@ -1896,13 +1932,8 @@ int player_set_uri(player_h player, const char *uri)
 
        LOGD("ENTER");
 
-       if (storage_get_origin_internal_path(uri, MAX_URL_LEN, path) < 0) {
-               /* cannot convert path. use the original one. */
-               strncpy(path, uri, MAX_URL_LEN-1);
-       } else {
-               /* need to use converted path. */
-               LOGD("Converted path : %s -> %s", uri, path);
-       }
+       if (_player_get_origin_internal_path(uri, path) != PLAYER_ERROR_NONE)
+               return PLAYER_ERROR_INVALID_PARAMETER;
 
        player_msg_send1(api, pc, ret_buf, ret, STRING, path);
        pc->push_media_stream = FALSE;
@@ -3220,14 +3251,8 @@ int player_set_subtitle_path(player_h player, const char *path)
 
        LOGD("ENTER");
 
-       if (storage_get_origin_internal_path(path, MAX_URL_LEN, subtitle_path) < 0) {
-               /* cannot convert path. use the original one. */
-               if (path != NULL)
-                       strncpy(subtitle_path, path, MAX_URL_LEN-1);
-       } else {
-               /* need to use converted path. */
-               LOGD("Converted path : %s -> %s", path, subtitle_path);
-       }
+       if (_player_get_origin_internal_path(path, subtitle_path) != PLAYER_ERROR_NONE)
+               return PLAYER_ERROR_INVALID_PARAMETER;
 
        player_msg_send1(api, pc, ret_buf, ret, STRING, subtitle_path);
        g_free(ret_buf);
@@ -3265,13 +3290,8 @@ int player_set_progressive_download_path(player_h player, const char *path)
        if (!_player_check_network_availability())
                return PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE;
 
-       if (storage_get_origin_internal_path(path, MAX_URL_LEN, dw_path) < 0) {
-               /* cannot convert path. use the original one. */
-               strncpy(dw_path, path, MAX_URL_LEN-1);
-       } else {
-               /* need to use converted path. */
-               LOGD("Converted path : %s -> %s", path, dw_path);
-       }
+       if (_player_get_origin_internal_path(path, dw_path) != PLAYER_ERROR_NONE)
+               return PLAYER_ERROR_INVALID_PARAMETER;
 
        player_msg_send1(api, pc, ret_buf, ret, STRING, dw_path);
        g_free(ret_buf);
index ab84ac1fbc49758ad4ada808cb1d90acef7ba5dd..0b25da9dac07bcef4f7a86979f562882766a9e8d 100644 (file)
@@ -204,9 +204,8 @@ int player_set_ecore_wl_display(player_h player, player_display_type_e type, Eco
 
        LOGD("ENTER");
        ret = _player_convert_display_type(type, &conv_type);
-       if (ret != PLAYER_ERROR_NONE) {
+       if (ret != PLAYER_ERROR_NONE)
                return ret;
-       }
 
        if (conv_type != PLAYER_PRIVATE_DISPLAY_TYPE_OVERLAY) {
                LOGE("Display type(%d) is not overlay", conv_type);
@@ -274,13 +273,8 @@ int player_set_next_uri(player_h player, const char *uri)
 
        LOGD("ENTER");
 
-       if (storage_get_origin_internal_path(uri, MAX_URL_LEN, path) < 0) {
-               /* cannot convert path. use the original one. */
-               strncpy(path, uri, MAX_URL_LEN-1);
-       } else {
-               /* need to use converted path. */
-               LOGD("Converted path : %s -> %s", uri, path);
-       }
+       if (_player_get_origin_internal_path(uri, path) != PLAYER_ERROR_NONE)
+               return PLAYER_ERROR_INVALID_PARAMETER;
 
        player_msg_send1(api, pc, ret_buf, ret, STRING, path);