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);
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;
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);
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);
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);
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);