[v0.3.31] add network feature check of streaming related APIs 47/94847/2
authorEunhae Choi <eunhae1.choi@samsung.com>
Tue, 1 Nov 2016 12:23:00 +0000 (21:23 +0900)
committerEunhae Choi <eunhae1.choi@samsung.com>
Tue, 1 Nov 2016 12:23:03 +0000 (21:23 +0900)
Change-Id: Ifbe1a9bf3976145eb8a5be394bf2cb354f7eacfa
Signed-off-by: Eunhae Choi <eunhae1.choi@samsung.com>
CMakeLists.txt
packaging/capi-media-player.spec
src/player.c

index f14d13f..d300510 100644 (file)
@@ -17,9 +17,9 @@ SET(INC_COM_DIR include)
 
 INCLUDE_DIRECTORIES(${INC_DIR}, ${INC_COM_DIR})
 IF (TIZEN_FEATURE_EVAS_RENDERER)
-SET(dependents "dlog glib-2.0 libtbm capi-media-tool capi-media-sound-manager capi-base-common mused mm-common tizen-extension-client evas ecore elementary mm-evas-renderer storage")
+SET(dependents "dlog glib-2.0 libtbm capi-media-tool capi-media-sound-manager capi-base-common mused mm-common tizen-extension-client evas ecore elementary mm-evas-renderer storage capi-system-info")
 ELSE (TIZEN_FEATURE_EVAS_RENDERER)
-SET(dependents "dlog glib-2.0 libtbm capi-media-tool capi-media-sound-manager capi-base-common mused mm-common tizen-extension-client evas ecore elementary storage")
+SET(dependents "dlog glib-2.0 libtbm capi-media-tool capi-media-sound-manager capi-base-common mused mm-common tizen-extension-client evas ecore elementary storage capi-system-info")
 ENDIF (TIZEN_FEATURE_EVAS_RENDERER)
 SET(pc_dependents "libtbm capi-media-tool capi-base-common capi-media-sound-manager ecore-wayland")
 
index 7dafcd3..a3aac07 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-player
 Summary:    A Media Player API
-Version:    0.3.30
+Version:    0.3.31
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
@@ -25,6 +25,7 @@ BuildRequires:  pkgconfig(json-c)
 BuildRequires:  pkgconfig(libtbm)
 BuildRequires:  pkgconfig(eom)
 BuildRequires:  pkgconfig(storage)
+BuildRequires:  pkgconfig(capi-system-info)
 %if "%{?profile}" != "tv" && "%{?profile}" != "wearable"
 BuildRequires:  pkgconfig(mm-evas-renderer)
 %endif
index b0e04fc..2c0e330 100644 (file)
@@ -37,6 +37,7 @@
 #include <sound_manager.h>
 #include <sound_manager_internal.h>
 #include <storage-internal.h>
+#include <system_info.h>
 #include "player_internal.h"
 #include "player_private.h"
 #include "player_display.h"
@@ -270,6 +271,44 @@ static int __player_convert_error_code(int code, char *func_name)
        return ret;
 }
 
+static bool _player_check_network_availability(void)
+{
+#define _FEATURE_NAME_WIFI             "http://tizen.org/feature/network.wifi"
+#define _FEATURE_NAME_TELEPHONY        "http://tizen.org/feature/network.telephony"
+#define _FEATURE_NAME_ETHERNET "http://tizen.org/feature/network.ethernet"
+       bool enabled = FALSE;
+       bool supported = FALSE;
+
+       if (SYSTEM_INFO_ERROR_NONE == system_info_get_platform_bool(_FEATURE_NAME_WIFI, &enabled)) {
+               LOGI("wifi status = %d", enabled);
+               if (enabled)
+                       supported = TRUE;
+       } else {
+               LOGE("SYSTEM_INFO_ERROR");
+       }
+
+       if (SYSTEM_INFO_ERROR_NONE == system_info_get_platform_bool(_FEATURE_NAME_TELEPHONY, &enabled)) {
+               LOGI("telephony status = %d", enabled);
+               if (enabled)
+                       supported = TRUE;
+       } else {
+               LOGE("SYSTEM_INFO_ERROR");
+       }
+
+       if (SYSTEM_INFO_ERROR_NONE == system_info_get_platform_bool(_FEATURE_NAME_ETHERNET, &enabled)) {
+               LOGI("ethernet status = %d", enabled);
+               if (enabled)
+                       supported = TRUE;
+       } else {
+               LOGE("SYSTEM_INFO_ERROR");
+       }
+
+       if (!supported)
+               return FALSE;
+
+       return TRUE;
+}
+
 static void *_get_mem(player_cli_s * player, int size)
 {
        player_data_s *mem = g_new(player_data_s, sizeof(player_data_s));
@@ -383,6 +422,11 @@ static int __set_callback(muse_player_event_e type, player_h player, void *callb
        muse_player_api_e api = MUSE_PLAYER_API_SET_CALLBACK;
        int set = 1;
 
+       if (MUSE_PLAYER_EVENT_TYPE_BUFFERING == type) {
+               if (!_player_check_network_availability())
+                       return PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE;
+       }
+
        LOGI("Event type : %d ", type);
        player_msg_set_callback(api, pc, ret, type, set);
 
@@ -2159,7 +2203,7 @@ int player_set_play_position(player_h player, int millisecond, bool accurate, pl
                g_mutex_lock(&pc->cb_info->seek_cb_mutex);
                if (pc->push_media_stream == TRUE)
                        pc->cb_info->block_seek_cb = TRUE;
-               LOGI("Event type : %d, pos : %d ", MUSE_PLAYER_EVENT_TYPE_SEEK, millisecond);
+               LOGI("Event type : %d, pos : %d, accurate : %d", MUSE_PLAYER_EVENT_TYPE_SEEK, millisecond, accurate);
                pc->cb_info->user_cb[MUSE_PLAYER_EVENT_TYPE_SEEK] = callback;
                pc->cb_info->user_data[MUSE_PLAYER_EVENT_TYPE_SEEK] = user_data;
                g_mutex_unlock(&pc->cb_info->seek_cb_mutex);
@@ -3152,6 +3196,9 @@ int player_set_progressive_download_path(player_h player, const char *path)
 
        LOGD("ENTER");
 
+       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);
@@ -3348,6 +3395,9 @@ int player_set_progressive_download_message_cb(player_h player, player_pd_messag
 
        LOGD("ENTER");
 
+       if (!_player_check_network_availability())
+               return PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE;
+
        player_msg_send2(api, pc, ret_buf, ret, INT, type, INT, set);
 
        if (ret == PLAYER_ERROR_NONE) {