summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEunhae Choi <eunhae1.choi@samsung.com>2017-03-29 16:39:30 +0900
committerEunhae Choi <eunhae1.choi@samsung.com>2017-03-29 16:40:04 +0900
commite54ad145e13d324e15c4a9e1544d26917dad2857 (patch)
tree5d2aceb15875dfffd7e6bcd0551ebfc6c2e5ed2a
parent7d5703174a0008be4b9e6b57761ea275aac55e7c (diff)
parenta939fd93a89c19d7ad8be05671926dc353066d6b (diff)
downloadlibmm-player-accepted/tizen_tv.tar.gz
libmm-player-accepted/tizen_tv.tar.bz2
libmm-player-accepted/tizen_tv.zip
Change-Id: Ic11b26c766a65efa8ccacf84d0f575fb525d829e
-rw-r--r--configure.ac8
-rw-r--r--packaging/libmm-player.spec4
-rw-r--r--src/Makefile.am4
-rw-r--r--src/include/mm_player.h5
-rw-r--r--src/include/mm_player_priv.h17
-rw-r--r--src/include/mm_player_utils.h2
-rw-r--r--src/mm_player.c15
-rw-r--r--src/mm_player_common_priv.c32
-rw-r--r--src/mm_player_pd.c6
-rw-r--r--src/mm_player_priv.c106
-rw-r--r--src/mm_player_sound_focus.c27
-rw-r--r--src/mm_player_utils.c47
12 files changed, 233 insertions, 40 deletions
diff --git a/configure.ac b/configure.ac
index 7e65006..a9d2d04 100644
--- a/configure.ac
+++ b/configure.ac
@@ -84,6 +84,14 @@ PKG_CHECK_MODULES(GST_APP, gstreamer-app-1.0 >= 1.2.0)
AC_SUBST(GST_APP_CFLAGS)
AC_SUBST(GST_APP_LIBS)
+PKG_CHECK_MODULES(STORAGE, storage)
+AC_SUBST(STORAGE_CFLAGS)
+AC_SUBST(STORAGE_LIBS)
+
+PKG_CHECK_MODULES(TZPLATFORM_CONFIG, libtzplatform-config)
+AC_SUBST(TZPLATFORM_CONFIG_CFLAGS)
+AC_SUBST(TZPLATFORM_CONFIG_LIBS)
+
PKG_CHECK_MODULES(APPFWK, appcore-efl)
AC_SUBST(APPFWK_CFLAGS)
AC_SUBST(APPFWK_LIBS)
diff --git a/packaging/libmm-player.spec b/packaging/libmm-player.spec
index 9d9a116..dde0c45 100644
--- a/packaging/libmm-player.spec
+++ b/packaging/libmm-player.spec
@@ -1,6 +1,6 @@
Name: libmm-player
Summary: Multimedia Framework Player Library
-Version: 0.6.34
+Version: 0.6.39
Release: 0
Group: Multimedia/Libraries
License: Apache-2.0
@@ -27,6 +27,8 @@ BuildRequires: pkgconfig(capi-media-tool)
BuildRequires: pkgconfig(murphy-resource)
BuildRequires: pkgconfig(murphy-glib)
BuildRequires: pkgconfig(capi-system-info)
+BuildRequires: pkgconfig(storage)
+BuildRequires: pkgconfig(libtzplatform-config)
%description
Multimedia Framework Player Library files.
diff --git a/src/Makefile.am b/src/Makefile.am
index 861ebc3..84e3c1f 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -38,6 +38,8 @@ libmmfplayer_la_CFLAGS = -I$(srcdir)/include \
$(DLOG_CFLAGS) \
$(ECORE_CFLAGS) \
$(SYSTEMINFO_CFLAGS) \
+ $(STORAGE_CFLAGS) \
+ $(TZPLATFORM_CONFIG_CFLAGS) \
-Werror -Wno-deprecated -Wno-deprecated-declarations -Wno-cpp
noinst_HEADERS = include/mm_player_utils.h \
@@ -69,6 +71,8 @@ libmmfplayer_la_LIBADD = $(GST_LIBS) \
$(UTILX_LIBS) \
$(ECORE_LIBS) \
$(SYSTEMINFO_LIBS)
+ $(STORAGE_LIBS) \
+ $(TZPLATFORM_CONFIG_LIBS)
if IS_SDK
diff --git a/src/include/mm_player.h b/src/include/mm_player.h
index a35b5ef..787b42d 100644
--- a/src/include/mm_player.h
+++ b/src/include/mm_player.h
@@ -2338,6 +2338,11 @@ int mm_player_set_file_buffering_path(MMHandleType player, const char *file_path
int mm_player_set_sound_stream_info(MMHandleType player, char *stream_type, int stream_index);
/**
+ * This function is to manage the playback according to the external storage state
+ */
+int mm_player_manage_external_storage_state(MMHandleType player, int state);
+
+/**
@}
*/
diff --git a/src/include/mm_player_priv.h b/src/include/mm_player_priv.h
index 284a151..e4996b9 100644
--- a/src/include/mm_player_priv.h
+++ b/src/include/mm_player_priv.h
@@ -37,6 +37,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <tbm_bufmgr.h>
+#include <storage.h>
#include "mm_player.h"
#include "mm_player_internal.h"
#include "mm_player_audioeffect.h"
@@ -327,6 +328,12 @@ enum StreamingSrcError {
MMPLAYER_STREAMING_ERROR_OPTION_NOT_SUPPORTED,
};
+typedef enum {
+ MMPLAYER_PATH_VOD = 0,
+ MMPLAYER_PATH_TEXT,
+ MMPLAYER_PATH_MAX
+} MMPlayerPathType;
+
/*---------------------------------------------------------------------------
| GLOBAL DATA TYPE DEFINITIONS: |
---------------------------------------------------------------------------*/
@@ -367,6 +374,12 @@ typedef struct {
} MMPlayerParseProfile;
typedef struct {
+ storage_type_e type;
+ storage_state_e state;
+ int id;
+} MMPlayerStorageInfo;
+
+typedef struct {
bool is_pending;
MMPlayerPosFormatType format;
unsigned long pos;
@@ -568,6 +581,7 @@ typedef struct {
/* content profile */
MMPlayerParseProfile profile;
+ MMPlayerStorageInfo storage_info[MMPLAYER_PATH_MAX];
/* streaming service type */
MMStreamingType streaming_type;
@@ -845,6 +859,7 @@ void _mm_player_media_packet_video_stream_internal_buffer_unref(void *buffer);
int _mmplayer_set_pcm_spec(MMHandleType hplayer, int samplerate, int channel);
int _mmplayer_get_timeout(MMHandleType hplayer, int *timeout);
int _mmplayer_get_num_of_video_out_buffers(MMHandleType hplayer, int *num, int *extra_num);
+int _mmplayer_manage_external_storage_state(MMHandleType hplayer, int state);
int __mmplayer_gst_set_state(mm_player_t* player, GstElement * pipeline, GstState state, gboolean async, gint timeout);
int __mmplayer_set_state(mm_player_t* player, int state);
int __mmplayer_check_state(mm_player_t* player, enum PlayerCommandState command);
@@ -867,7 +882,7 @@ gboolean __mmplayer_check_useful_message(mm_player_t *player, GstMessage * messa
gboolean __mmplayer_handle_gst_error(mm_player_t* player, GstMessage * message, GError* error);
gint __gst_handle_core_error(mm_player_t* player, int code);
gint __gst_handle_library_error(mm_player_t* player, int code);
-gint __gst_handle_resource_error(mm_player_t* player, int code);
+gint __gst_handle_resource_error(mm_player_t* player, int code, GstMessage * message);
gint __gst_handle_stream_error(mm_player_t* player, GError* error, GstMessage * message);
int _mmplayer_sound_register_with_pid(MMHandleType hplayer, int pid);
int _mmplayer_get_client_pid(MMHandleType hplayer, int* pid);
diff --git a/src/include/mm_player_utils.h b/src/include/mm_player_utils.h
index 099986f..9176954 100644
--- a/src/include/mm_player_utils.h
+++ b/src/include/mm_player_utils.h
@@ -30,6 +30,7 @@
#include <mm_types.h>
#include <mm_error.h>
#include <mm_message.h>
+#include "mm_player_priv.h"
#ifdef __cplusplus
extern "C" {
@@ -293,6 +294,7 @@ char** util_get_cookie_list(const char *cookies);
bool util_check_valid_url(const char *proxy);
const char* util_get_charset(const char *file_path);
int util_get_pixtype(unsigned int fourcc);
+bool util_get_storage_info(const char *path, MMPlayerStorageInfo *storage_info);
#ifdef __cplusplus
}
diff --git a/src/mm_player.c b/src/mm_player.c
index 0ef1b83..dcac88c 100644
--- a/src/mm_player.c
+++ b/src/mm_player.c
@@ -1323,3 +1323,18 @@ int mm_player_set_sound_stream_info(MMHandleType player, char *stream_type, int
return result;
}
+
+int mm_player_manage_external_storage_state(MMHandleType player, int state)
+{
+ int result = MM_ERROR_NONE;
+
+ MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
+
+ MMPLAYER_CMD_LOCK( player );
+
+ result = _mmplayer_manage_external_storage_state(player, state);
+
+ MMPLAYER_CMD_UNLOCK( player );
+
+ return result;
+}
diff --git a/src/mm_player_common_priv.c b/src/mm_player_common_priv.c
index 0619d85..a871bff 100644
--- a/src/mm_player_common_priv.c
+++ b/src/mm_player_common_priv.c
@@ -584,7 +584,7 @@ __mmplayer_handle_gst_error(mm_player_t* player, GstMessage * message, GError* e
} else if (error->domain == GST_LIBRARY_ERROR) {
msg_param.code = __gst_handle_library_error(player, error->code);
} else if (error->domain == GST_RESOURCE_ERROR) {
- msg_param.code = __gst_handle_resource_error(player, error->code);
+ msg_param.code = __gst_handle_resource_error(player, error->code, message);
} else if (error->domain == GST_STREAM_ERROR) {
msg_param.code = __gst_handle_stream_error(player, error, message);
} else {
@@ -607,6 +607,17 @@ __mmplayer_handle_gst_error(mm_player_t* player, GstMessage * message, GError* e
if (msg_param.code == MM_ERROR_NONE)
return TRUE;
+ /* skip error to avoid duplicated posting */
+ if ((player->storage_info[MMPLAYER_PATH_VOD].state <= STORAGE_STATE_REMOVED) ||
+ (player->storage_info[MMPLAYER_PATH_TEXT].state <= STORAGE_STATE_REMOVED)) {
+
+ /* The error will be handled by mused.
+ * @ref _mmplayer_manage_external_storage_state() */
+
+ LOGW("storage is removed, skip error post");
+ return TRUE;
+ }
+
/* post error to application */
if (!player->msg_posted) {
MMPLAYER_POST_MSG(player, MM_MESSAGE_ERROR, &msg_param);
@@ -682,7 +693,7 @@ __gst_handle_library_error(mm_player_t* player, int code)
}
gint
-__gst_handle_resource_error(mm_player_t* player, int code)
+__gst_handle_resource_error(mm_player_t* player, int code, GstMessage * message)
{
gint trans_err = MM_ERROR_NONE;
@@ -706,7 +717,22 @@ __gst_handle_resource_error(mm_player_t* player, int code)
|| MMPLAYER_IS_RTSP_STREAMING(player)) {
trans_err = MM_ERROR_PLAYER_STREAMING_FAIL;
break;
- }
+ } else if (message != NULL && message->src != NULL) {
+ storage_state_e storage_state = STORAGE_STATE_UNMOUNTABLE;
+ MMPlayerPathType path_type = MMPLAYER_PATH_MAX;
+
+ if (message->src == (GstObject *)player->pipeline->mainbin[MMPLAYER_M_SRC].gst)
+ path_type = MMPLAYER_PATH_VOD;
+ else if (message->src == (GstObject *)player->pipeline->mainbin[MMPLAYER_M_SUBSRC].gst)
+ path_type = MMPLAYER_PATH_TEXT;
+
+ if (path_type != MMPLAYER_PATH_MAX && player->storage_info[path_type].type == STORAGE_TYPE_EXTERNAL) {
+ /* check storage state */
+ storage_get_state(player->storage_info[path_type].id, &storage_state);
+ player->storage_info[path_type].state = storage_state;
+ LOGW("path %d, storage state %d", path_type, storage_state);
+ }
+ } /* fall through */
case GST_RESOURCE_ERROR_WRITE:
case GST_RESOURCE_ERROR_FAILED:
case GST_RESOURCE_ERROR_SEEK:
diff --git a/src/mm_player_pd.c b/src/mm_player_pd.c
index 4a8851c..62c6ffe 100644
--- a/src/mm_player_pd.c
+++ b/src/mm_player_pd.c
@@ -25,6 +25,8 @@
#include "mm_player_utils.h"
#include "mm_player_priv.h"
+#define PD_STATE_CHANGE_TIMEOUT (30 * GST_SECOND)
+
/*---------------------------------------------------------------------------------------
| LOCAL FUNCTION PROTOTYPES: |
---------------------------------------------------------------------------------------*/
@@ -388,7 +390,7 @@ gboolean _mmplayer_start_pd_downloader(MMHandleType handle)
LOGD("set_state :: sret = %d\n", sret);
- sret = gst_element_get_state(pd->downloader_pipeline, &cur_state, &pending_state, GST_CLOCK_TIME_NONE);
+ sret = gst_element_get_state(pd->downloader_pipeline, &cur_state, &pending_state, PD_STATE_CHANGE_TIMEOUT);
if (GST_STATE_CHANGE_FAILURE == sret) {
LOGE("PD download pipeline failed to do get_state...");
return FALSE;
@@ -415,7 +417,7 @@ gboolean _mmplayer_unrealize_pd_downloader(MMHandleType handle)
MMPLAYER_RETURN_VAL_IF_FAIL(pd && pd->downloader_pipeline, FALSE);
gst_element_set_state(pd->downloader_pipeline, GST_STATE_NULL);
- gst_element_get_state(pd->downloader_pipeline, NULL, NULL, GST_CLOCK_TIME_NONE);
+ gst_element_get_state(pd->downloader_pipeline, NULL, NULL, PD_STATE_CHANGE_TIMEOUT);
gst_object_unref(G_OBJECT(pd->downloader_pipeline));
pd->downloader_pipeline = NULL;
diff --git a/src/mm_player_priv.c b/src/mm_player_priv.c
index f876e1a..6b481ba 100644
--- a/src/mm_player_priv.c
+++ b/src/mm_player_priv.c
@@ -275,6 +275,7 @@ static gboolean __gst_seek_subtitle_data(GstElement * appsrc, guint64 position,
static void __mmplayer_gst_caps_notify_cb(GstPad * pad, GParamSpec * unused, gpointer data);
static void __mmplayer_audio_stream_clear_buffer(mm_player_t* player, gboolean send_all);
static void __mmplayer_audio_stream_send_data(mm_player_t* player, mm_player_audio_stream_buff_t *a_buffer);
+static void __mmplayer_initialize_storage_info(mm_player_t* player, MMPlayerPathType path_type);
/*===========================================================================================
| |
@@ -1807,7 +1808,7 @@ if (gst_tag_list_get_uint(tag_list, gsttag, &v_uint)) {\
mm_attrs_set_int_by_name(attribute, "content_audio_bitrate", v_uint); \
if (player->updated_bitrate_count < MM_PLAYER_STREAM_COUNT_MAX) {\
player->bitrate[player->updated_bitrate_count] = v_uint;\
- player->total_bitrate += player->bitrate[player->updated_maximum_bitrate_count]; \
+ player->total_bitrate += player->bitrate[player->updated_bitrate_count]; \
player->updated_bitrate_count++; \
mm_attrs_set_int_by_name(attribute, playertag, player->total_bitrate);\
SECURE_LOGD("update bitrate %d[bps] of stream #%d.\n", v_uint, player->updated_bitrate_count);\
@@ -2611,7 +2612,7 @@ __mmplayer_gst_decode_pad_added(GstElement *elem, GstPad *pad, gpointer data)
}
gchar *caps_str = gst_caps_to_string(caps);
- if (strstr(caps_str, "ST12") || strstr(caps_str, "SN12"))
+ if (caps_str && (strstr(caps_str, "ST12") || strstr(caps_str, "SN12")))
player->set_mode.video_zc = TRUE;
MMPLAYER_FREEIF(caps_str);
@@ -3516,7 +3517,7 @@ __mmplayer_gst_decode_callback(GstElement *elem, GstPad *pad, gpointer data) //
goto ERROR;
}
} else if (strstr(name, "video")) {
- if (strstr(caps_str, "ST12") || strstr(caps_str, "SN12"))
+ if (caps_str && (strstr(caps_str, "ST12") || strstr(caps_str, "SN12")))
player->set_mode.video_zc = TRUE;
if (player->pipeline->videobin == NULL) {
@@ -4541,7 +4542,6 @@ void __mmplayer_gst_set_audiosink_property(mm_player_t* player, MMHandleType att
gint stream_id = 0;
gchar stream_props[MAX_PROPS_LEN] = {0,};
GstStructure *props = NULL;
- gint stream_focus_status = 0;
/* set volume table
* It should be set after player creation through attribute.
@@ -4554,14 +4554,15 @@ void __mmplayer_gst_set_audiosink_property(mm_player_t* player, MMHandleType att
if (!stream_type) {
LOGE("stream_type is null.\n");
} else {
- if (_mmplayer_is_using_internal_sound_focus(&player->sound_focus))
- stream_focus_status = 1;
-
- snprintf(stream_props, sizeof(stream_props)-1, "props,media.role=%s, media.parent_id=%d, media.focus_status=%d",
- stream_type, stream_id, stream_focus_status);
+ if (player->sound_focus.focus_id)
+ snprintf(stream_props, sizeof(stream_props)-1, "props,media.role=%s, media.parent_id=%d, media.focus_id=%d",
+ stream_type, stream_id, player->sound_focus.focus_id);
+ else
+ snprintf(stream_props, sizeof(stream_props)-1, "props,media.role=%s, media.parent_id=%d",
+ stream_type, stream_id);
props = gst_structure_from_string(stream_props, NULL);
g_object_set(player->pipeline->audiobin[MMPLAYER_A_SINK].gst, "stream-properties", props, NULL);
- LOGI("stream_id[%d], stream_type[%s], stream_focus[%d], result[%s].\n", stream_id, stream_type, stream_focus_status, stream_props);
+ LOGI("stream_type[%s], stream_id[%d], focus_id[%d], result[%s].\n", stream_type, stream_id, player->sound_focus.focus_id, stream_props);
}
mm_attrs_get_int_by_name(attrs, "sound_latency_mode", &latency_mode);
@@ -5823,6 +5824,9 @@ __mmplayer_gst_create_subtitle_src(mm_player_t* player)
gst_object_unref(pad);
pad = NULL;
+ if (!util_get_storage_info(subtitle_uri, &player->storage_info[MMPLAYER_PATH_TEXT]))
+ LOGE("failed to get storage info of subtitle path");
+
/* create dot. for debugging */
MMPLAYER_GENERATE_DOT_IF_ENABLED(player, "pipeline-with-subtitle");
MMPLAYER_FLEAVE();
@@ -6254,6 +6258,7 @@ __mmplayer_gst_create_pipeline(mm_player_t* player) // @
player->last_multiwin_status = FALSE;
_mmplayer_track_initialize(player);
+ __mmplayer_initialize_storage_info(player, MMPLAYER_PATH_MAX);
/* create source element */
switch (player->profile.uri_type) {
@@ -6390,6 +6395,8 @@ __mmplayer_gst_create_pipeline(mm_player_t* player) // @
g_object_get(element, "location", &location, NULL);
LOGD("PD_LOCATION [%s].\n", location);
+ if (!util_get_storage_info(location, &player->storage_info[MMPLAYER_PATH_VOD]))
+ LOGE("failed to get storage info");
if (location)
g_free(location);
}
@@ -6410,7 +6417,8 @@ __mmplayer_gst_create_pipeline(mm_player_t* player) // @
}
g_object_set(G_OBJECT(element), "location", (player->profile.uri)+7, NULL); /* uri+7 -> remove "file:// */
- //g_object_set(G_OBJECT(element), "use-mmap", TRUE, NULL);
+ if (!util_get_storage_info(player->profile.uri, &player->storage_info[MMPLAYER_PATH_VOD]))
+ LOGE("failed to get storage info");
}
break;
@@ -7364,7 +7372,7 @@ int __gst_pause(mm_player_t* player, gboolean async) // @
if (error->domain == GST_STREAM_ERROR)
ret = __gst_handle_stream_error(player, error, msg);
else if (error->domain == GST_RESOURCE_ERROR)
- ret = __gst_handle_resource_error(player, error->code);
+ ret = __gst_handle_resource_error(player, error->code, NULL);
else if (error->domain == GST_LIBRARY_ERROR)
ret = __gst_handle_library_error(player, error->code);
else if (error->domain == GST_CORE_ERROR)
@@ -8383,7 +8391,6 @@ __mmplayer_sound_focus_callback(int id, mm_sound_focus_type_e focus_type, mm_sou
}
} else if (focus_state == FOCUS_IS_ACQUIRED) {
LOGW("FOCUS_IS_ACQUIRED: Got msg from asm to resume");
- player->sound_focus.acquired = TRUE;
player->sound_focus.antishock = TRUE;
player->sound_focus.by_asm_cb = FALSE;
@@ -8401,6 +8408,8 @@ DONE:
player->sound_focus.cb_pending = FALSE;
EXIT:
+ if (mm_sound_update_focus_status(id, 0))
+ LOGE("failed to update focus status\n");
MMPLAYER_CMD_UNLOCK(player);
LOGW("dispatched");
return;
@@ -9433,7 +9442,7 @@ _mmplayer_set_runtime_buffering_mode(MMHandleType hplayer, MMPlayerBufferingMode
return MM_ERROR_NONE;
}
-int
+static int
__mmplayer_start_streaming_ext(mm_player_t *player)
{
gint ret = MM_ERROR_NONE;
@@ -10296,7 +10305,6 @@ __mmplayer_try_to_plug_decodebin(mm_player_t* player, GstPad *srcpad, const GstC
GstElement* queue2 = NULL;
GstPad* sinkpad = NULL;
GstPad* qsrcpad = NULL;
- gchar *caps_str = NULL;
gint64 dur_bytes = 0L;
guint max_buffer_size_bytes = 0;
@@ -10446,8 +10454,6 @@ __mmplayer_try_to_plug_decodebin(mm_player_t* player, GstPad *srcpad, const GstC
ERROR:
- MMPLAYER_FREEIF(caps_str);
-
if (sinkpad)
gst_object_unref(GST_OBJECT(sinkpad));
@@ -11153,6 +11159,7 @@ __mmplayer_initialize_next_play(mm_player_t *player)
player->total_maximum_bitrate = 0;
_mmplayer_track_initialize(player);
+ __mmplayer_initialize_storage_info(player, MMPLAYER_PATH_MAX);
for (i = 0; i < MM_PLAYER_STREAM_COUNT_MAX; i++) {
player->bitrate[i] = 0;
@@ -11253,6 +11260,8 @@ __mmplayer_activate_next_source(mm_player_t *player, GstState target)
}
g_object_set(G_OBJECT(element), "location", (player->profile.uri)+7, NULL); /* uri+7 -> remove "file:// */
+ if (!util_get_storage_info(player->profile.uri, &player->storage_info[MMPLAYER_PATH_VOD]))
+ LOGE("failed to get storage info");
break;
}
case MM_PLAYER_URI_TYPE_URL_HTTP:
@@ -12326,6 +12335,7 @@ __mmplayer_release_misc_post(mm_player_t* player)
/* clear the video stream bo list */
__mmplayer_video_stream_destroy_bo_list(player);
+ __mmplayer_initialize_storage_info(player, MMPLAYER_PATH_MAX);
player->uri_info.uri_idx = 0;
MMPLAYER_FLEAVE();
@@ -14256,8 +14266,13 @@ __mmplayer_change_external_subtitle_language(mm_player_t* player, const char* fi
goto EXIT;
}
+ __mmplayer_initialize_storage_info(player, MMPLAYER_PATH_TEXT);
+
g_object_set(G_OBJECT(mainbin[MMPLAYER_M_SUBSRC].gst), "location", filepath, NULL);
+ if (!util_get_storage_info(filepath, &player->storage_info[MMPLAYER_PATH_TEXT]))
+ LOGE("failed to get storage info of subtitle path");
+
charset = util_get_charset(filepath);
if (charset) {
LOGD("detected charset is %s\n", charset);
@@ -15118,3 +15133,60 @@ int _mmplayer_get_num_of_video_out_buffers(MMHandleType hplayer, int *num, int *
return MM_ERROR_NONE;
}
+static void
+__mmplayer_initialize_storage_info(mm_player_t* player, MMPlayerPathType path_type)
+{
+ int i = 0;
+ MMPLAYER_FENTER();
+ MMPLAYER_RETURN_IF_FAIL(player);
+
+ for (i=0; i<MMPLAYER_PATH_MAX; i++) {
+
+ if (path_type == MMPLAYER_PATH_MAX || path_type == i) {
+ player->storage_info[i].type = STORAGE_TYPE_INTERNAL;
+ player->storage_info[i].state = STORAGE_STATE_MOUNTED;
+ player->storage_info[i].id = -1;
+
+ if (path_type != MMPLAYER_PATH_MAX)
+ break;
+ }
+ }
+
+ MMPLAYER_FLEAVE();
+}
+
+int _mmplayer_manage_external_storage_state(MMHandleType hplayer, int state)
+{
+ int ret = MM_ERROR_NONE;
+ mm_player_t* player = (mm_player_t*) hplayer;
+ MMMessageParamType msg_param = {0, };
+
+ MMPLAYER_FENTER();
+ MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
+
+ LOGD("storage state : %d", state);
+
+ if (state != STORAGE_STATE_UNMOUNTABLE && state != STORAGE_STATE_REMOVED)
+ return MM_ERROR_NONE;
+
+ if ((player->storage_info[MMPLAYER_PATH_VOD].type == STORAGE_TYPE_EXTERNAL) ||
+ (player->storage_info[MMPLAYER_PATH_TEXT].type == STORAGE_TYPE_EXTERNAL)) {
+ LOGW("external storage is removed.");
+
+ if (player->msg_posted == FALSE) {
+ memset(&msg_param, 0, sizeof(MMMessageParamType));
+ msg_param.code = MM_ERROR_PLAYER_INVALID_URI;
+ MMPLAYER_POST_MSG(player, MM_MESSAGE_ERROR, &msg_param);
+ player->msg_posted = TRUE;
+ }
+
+ /* unrealize the player */
+ ret = _mmplayer_unrealize(hplayer);
+ if (ret != MM_ERROR_NONE)
+ LOGE("failed to unrealize");
+ }
+
+ MMPLAYER_FLEAVE();
+ return ret;
+}
+
diff --git a/src/mm_player_sound_focus.c b/src/mm_player_sound_focus.c
index a36fb13..5088a76 100644
--- a/src/mm_player_sound_focus.c
+++ b/src/mm_player_sound_focus.c
@@ -121,7 +121,6 @@ int
_mmplayer_sound_acquire_focus(MMPlayerSoundFocus* sound_focus)
{
int ret = MM_ERROR_NONE;
- const gchar *stream_type = NULL;
MMPLAYER_FENTER();
MMPLAYER_CHECK_SOUND_FOCUS_INSTANCE(sound_focus);
@@ -131,18 +130,19 @@ _mmplayer_sound_acquire_focus(MMPlayerSoundFocus* sound_focus)
return MM_ERROR_NONE;
}
- stream_type = __mmplayer_sound_get_stream_type(sound_focus->session_type);
-
- if ((!strstr(stream_type, "media")) ||
- (sound_focus->session_flags & MM_SESSION_OPTION_PAUSE_OTHERS)) {
+ if (_mmplayer_is_using_internal_sound_focus(sound_focus)) {
- ret = mm_sound_acquire_focus(sound_focus->focus_id, FOCUS_FOR_BOTH, NULL);
+ ret = mm_sound_acquire_focus(sound_focus->focus_id, FOCUS_FOR_BOTH, "mm-player acquire focus");
if (ret != MM_ERROR_NONE) {
LOGE("failed to acquire sound focus\n");
return ret;
}
sound_focus->acquired = TRUE;
+
+ ret = mm_sound_update_focus_status(sound_focus->focus_id, 1);
+ if (ret != MM_ERROR_NONE)
+ LOGE("failed to update focus status\n");
}
MMPLAYER_FLEAVE();
@@ -153,7 +153,6 @@ int
_mmplayer_sound_release_focus(MMPlayerSoundFocus* sound_focus)
{
int ret = MM_ERROR_NONE;
- const gchar *stream_type = NULL;
MMPLAYER_FENTER();
MMPLAYER_CHECK_SOUND_FOCUS_INSTANCE(sound_focus);
@@ -163,17 +162,18 @@ _mmplayer_sound_release_focus(MMPlayerSoundFocus* sound_focus)
return MM_ERROR_NONE;
}
- stream_type = __mmplayer_sound_get_stream_type(sound_focus->session_type);
-
- if ((!strstr(stream_type, "media")) ||
- (sound_focus->session_flags & MM_SESSION_OPTION_PAUSE_OTHERS)) {
- ret = mm_sound_release_focus(sound_focus->focus_id, FOCUS_FOR_BOTH, NULL);
+ if (_mmplayer_is_using_internal_sound_focus(sound_focus)) {
+ ret = mm_sound_release_focus(sound_focus->focus_id, FOCUS_FOR_BOTH, "mm-player release focus");
if (ret != MM_ERROR_NONE) {
LOGE("failed to release sound focus\n");
return ret;
}
sound_focus->acquired = FALSE;
+
+ ret = mm_sound_update_focus_status(sound_focus->focus_id, 0);
+ if (ret != MM_ERROR_NONE)
+ LOGE("failed to update focus status\n");
}
MMPLAYER_FLEAVE();
@@ -354,9 +354,6 @@ bool _mmplayer_is_using_internal_sound_focus(MMPlayerSoundFocus* sound_focus)
return false;
if ((sound_focus->session_type == MM_SESSION_TYPE_MEDIA && sound_focus->session_flags & MM_SESSION_OPTION_PAUSE_OTHERS) ||
- (sound_focus->session_type == MM_SESSION_TYPE_CALL) ||
- (sound_focus->session_type == MM_SESSION_TYPE_VIDEOCALL) ||
- (sound_focus->session_type == MM_SESSION_TYPE_VOIP) ||
(sound_focus->session_type == MM_SESSION_TYPE_NOTIFY) ||
(sound_focus->session_type == MM_SESSION_TYPE_ALARM) ||
(sound_focus->session_type == MM_SESSION_TYPE_EMERGENCY))
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;
+}