Callback(API return) timeout is divided accoring to the API 52/48852/2 accepted/tizen/mobile/20151001.224716 accepted/tizen/tv/20151001.224730 accepted/tizen/wearable/20151001.224744 submit/tizen/20151001.072241
authorHyongtaek Lim <hyongtaek.lim@samsung.com>
Wed, 30 Sep 2015 23:21:05 +0000 (08:21 +0900)
committerHyongtaek Lim <hyongtaek.lim@samsung.com>
Thu, 1 Oct 2015 06:14:26 +0000 (23:14 -0700)
Signed-off-by: Hyongtaek Lim <hyongtaek.lim@samsung.com>
Change-Id: I705e93e07f567b794003277d01efef8a0d9768ef

client/src/player2.c
include/player2_private.h
include/player_msg_private.h
packaging/capi-media-player.spec
src/player_msg_dispatcher.c

index ca9002a..c5ec458 100644 (file)
@@ -1046,6 +1046,29 @@ static void callback_destroy(callback_cb_info_s * cb_info)
        g_free(cb_info);
 }
 
+int _get_api_timeout(player_cli_s *pc, muse_player_api_e api)
+{
+       int timeout = 0;
+
+       switch(api) {
+       case MUSE_PLAYER_API_PREPARE:
+       case MUSE_PLAYER_API_PREPARE_ASYNC:
+       case MUSE_PLAYER_API_UNPREPARE:
+       case MUSE_PLAYER_API_START:
+       case MUSE_PLAYER_API_STOP:
+       case MUSE_PLAYER_API_PAUSE:
+               timeout += SERVER_TIMEOUT(pc);
+       default:
+               /* check prepare async is done */
+               if(pc && CALLBACK_INFO(pc) &&
+                               CALLBACK_INFO(pc)->user_cb[_PLAYER_EVENT_TYPE_PREPARE])
+                       timeout += SERVER_TIMEOUT(pc);
+               break;
+       }
+       timeout += CALLBACK_TIME_OUT;
+       return timeout;
+}
+
 int wait_for_cb_return(muse_player_api_e api, callback_cb_info_s *cb_info,
                char **ret_buf, int time_out)
 {
@@ -1145,6 +1168,8 @@ int player_create(player_h * player)
                        ret = PLAYER_ERROR_INVALID_OPERATION;
                        goto ErrorExit;
                }
+               mm_player_get_state_timeout(INT_HANDLE(pc), &SERVER_TIMEOUT(pc), TRUE);
+               SERVER_TIMEOUT(pc) += CALLBACK_TIME_OUT;
                if(player_msg_get_string(stream_path, ret_buf)) {
                        LOGD("shmsrc stream path : %s", stream_path);
                        if(mm_player_set_shm_stream_path(INT_HANDLE(pc), stream_path)
@@ -1208,6 +1233,7 @@ int player_prepare_async(player_h player, player_prepared_cb callback,
        muse_player_api_e api = MUSE_PLAYER_API_PREPARE_ASYNC;
        player_cli_s *pc = (player_cli_s *) player;
        char *ret_buf = NULL;
+       int is_streaming = 0;
 
        LOGD("ENTER");
 
@@ -1221,6 +1247,13 @@ int player_prepare_async(player_h player, player_prepared_cb callback,
        }
        player_msg_send(api, pc, ret_buf, ret);
 
+       if(ret == PLAYER_ERROR_NONE) {
+               player_msg_get(is_streaming, ret_buf);
+               IS_STREAMING_CONTENT(pc) = is_streaming;
+               mm_player_get_state_timeout(INT_HANDLE(pc), &SERVER_TIMEOUT(pc),
+                               is_streaming);
+       }
+
        g_free(ret_buf);
        return ret;
 }
@@ -1233,6 +1266,7 @@ int player_prepare(player_h player)
        player_cli_s *pc = (player_cli_s *) player;
        char *ret_buf = NULL;
        char caps[MUSE_MSG_MAX_LENGTH] = {0};
+       int is_streaming = 0;
 
        LOGD("ENTER");
 
@@ -1243,6 +1277,10 @@ int player_prepare(player_h player)
                        NULL);
 
        if(ret == PLAYER_ERROR_NONE) {
+               player_msg_get(is_streaming, ret_buf);
+               IS_STREAMING_CONTENT(pc) = is_streaming;
+               mm_player_get_state_timeout(INT_HANDLE(pc), &SERVER_TIMEOUT(pc),
+                               is_streaming);
                player_msg_get_string(caps, ret_buf);
                if(strlen(caps) > 0 &&
                                mm_player_mused_realize(INT_HANDLE(pc), caps) != MM_ERROR_NONE)
index c9cd867..674dc4f 100644 (file)
@@ -244,6 +244,8 @@ typedef struct _callback_cb_info {
 
 typedef struct {
        intptr_t bo;
+       gboolean is_streaming;
+       gint timeout;
 }server_info_s;
 
 typedef struct _player_cli_s{
@@ -266,10 +268,16 @@ typedef struct _player_cli_s{
 
 /* server tbm bo */
 #define SERVER_TBM_BO(h)       ((h)->server.bo)
+/* content type is streaming */
+#define IS_STREAMING_CONTENT(h)                ((h)->server.is_streaming)
+/* server state change timeout */
+#define SERVER_TIMEOUT(h)              ((h)->server.timeout)
 
+int _get_api_timeout(player_cli_s *pc, muse_player_api_e api);
 int wait_for_cb_return(muse_player_api_e api, callback_cb_info_s *cb_info,
                char **ret_buf, int time_out);
 int player_sound_register(player_h player, int pid);
+int player_is_streaming(player_h player, bool *is_streaming);
 
 /**
  * @brief Called when the video sink bin is crated.
index 48b71bc..661c2cd 100644 (file)
@@ -26,7 +26,7 @@ extern "C" {
 #include <tbm_bufmgr.h>
 #include <player2_private.h>
 
-#define CALLBACK_TIME_OUT 35
+#define CALLBACK_TIME_OUT 5
 
 typedef int32_t INT;
 typedef int64_t INT64;
@@ -118,6 +118,7 @@ typedef struct {
                char *__sndMsg__; \
                int __len__; \
                int __fd__; \
+               int __timeout__ = _get_api_timeout(player, api); \
                if(CALLBACK_INFO(player)) __fd__ = MSG_FD(player); \
                else {ret = PLAYER_ERROR_INVALID_STATE;break;} \
                __sndMsg__ = muse_core_msg_json_factory_new(api, \
@@ -127,7 +128,7 @@ typedef struct {
                        LOGE("sending message failed"); \
                        ret = PLAYER_ERROR_INVALID_OPERATION; \
                } else \
-                       ret = wait_for_cb_return(api, CALLBACK_INFO(player), &retbuf, CALLBACK_TIME_OUT); \
+                       ret = wait_for_cb_return(api, CALLBACK_INFO(player), &retbuf, __timeout__); \
                muse_core_msg_json_factory_free(__sndMsg__); \
        }while(0)
 
@@ -146,6 +147,7 @@ typedef struct {
                char *__sndMsg__; \
                int __len__; \
                int __fd__; \
+               int __timeout__ = _get_api_timeout(player, api); \
                type __value__ = (type)param; \
                if(CALLBACK_INFO(player)) __fd__ = MSG_FD(player); \
                else {ret = PLAYER_ERROR_INVALID_STATE;break;} \
@@ -157,7 +159,7 @@ typedef struct {
                        LOGE("sending message failed"); \
                        ret = PLAYER_ERROR_INVALID_OPERATION; \
                } else \
-                       ret = wait_for_cb_return(api, CALLBACK_INFO(player), &retbuf, CALLBACK_TIME_OUT); \
+                       ret = wait_for_cb_return(api, CALLBACK_INFO(player), &retbuf, __timeout__); \
                muse_core_msg_json_factory_free(__sndMsg__); \
        }while(0)
 
@@ -176,6 +178,7 @@ typedef struct {
                char *__sndMsg__; \
                int __len__; \
                int __fd__; \
+               int __timeout__ = _get_api_timeout(player, api); \
                type1 __value1__ = (type1)param1; \
                type2 __value2__ = (type2)param2; \
                if(CALLBACK_INFO(player)) __fd__ = MSG_FD(player); \
@@ -189,7 +192,7 @@ typedef struct {
                        LOGE("sending message failed"); \
                        ret = PLAYER_ERROR_INVALID_OPERATION; \
                } else \
-                       ret = wait_for_cb_return(api, CALLBACK_INFO(player), &retbuf, CALLBACK_TIME_OUT); \
+                       ret = wait_for_cb_return(api, CALLBACK_INFO(player), &retbuf, __timeout__); \
                muse_core_msg_json_factory_free(__sndMsg__); \
        }while(0)
 
@@ -208,6 +211,7 @@ typedef struct {
                char *__sndMsg__; \
                int __len__; \
                int __fd__; \
+               int __timeout__ = _get_api_timeout(player, api); \
                type1 __value1__ = (type1)param1; \
                type2 __value2__ = (type2)param2; \
                type3 __value3__ = (type3)param3; \
@@ -223,7 +227,7 @@ typedef struct {
                        LOGE("sending message failed"); \
                        ret = PLAYER_ERROR_INVALID_OPERATION; \
                } else \
-                       ret = wait_for_cb_return(api, CALLBACK_INFO(player), &retbuf, CALLBACK_TIME_OUT); \
+                       ret = wait_for_cb_return(api, CALLBACK_INFO(player), &retbuf, __timeout__); \
                muse_core_msg_json_factory_free(__sndMsg__); \
        }while(0)
 
@@ -242,6 +246,7 @@ typedef struct {
                char *__sndMsg__; \
                int __len__; \
                int __fd__; \
+               int __timeout__ = _get_api_timeout(player, api); \
                type1 __value1__ = (type1)param1; \
                type2 __value2__ = (type2)param2; \
                type3 __value3__ = (type3)param3; \
@@ -263,7 +268,7 @@ typedef struct {
                        LOGE("sending message failed"); \
                        ret = PLAYER_ERROR_INVALID_OPERATION; \
                } else \
-                       ret = wait_for_cb_return(api, CALLBACK_INFO(player), &retbuf, CALLBACK_TIME_OUT); \
+                       ret = wait_for_cb_return(api, CALLBACK_INFO(player), &retbuf, __timeout__); \
                muse_core_msg_json_factory_free(__sndMsg__); \
        }while(0)
 
@@ -283,6 +288,7 @@ typedef struct {
                char *__sndMsg__; \
                int __len__; \
                int __fd__; \
+               int __timeout__ = _get_api_timeout(player, api); \
                int *__value__ = (int *)param; \
                if(CALLBACK_INFO(player)) __fd__ = MSG_FD(player); \
                else {ret = PLAYER_ERROR_INVALID_STATE;break;} \
@@ -298,7 +304,7 @@ typedef struct {
                        LOGE("sending message failed"); \
                        ret = PLAYER_ERROR_INVALID_OPERATION; \
                } else \
-                       ret = wait_for_cb_return(api, CALLBACK_INFO(player), &retbuf, CALLBACK_TIME_OUT); \
+                       ret = wait_for_cb_return(api, CALLBACK_INFO(player), &retbuf, __timeout__); \
                muse_core_msg_json_factory_free(__sndMsg__); \
        }while(0)
 
@@ -318,6 +324,7 @@ typedef struct {
                char *__sndMsg__; \
                int __len__; \
                int __fd__; \
+               int __timeout__ = _get_api_timeout(player, api); \
                int *__value1__ = (int *)param1; \
                int *__value2__ = (int *)param2; \
                if(CALLBACK_INFO(player)) __fd__ = MSG_FD(player); \
@@ -339,7 +346,7 @@ typedef struct {
                        LOGE("sending message failed"); \
                        ret = PLAYER_ERROR_INVALID_OPERATION; \
                } else \
-                       ret = wait_for_cb_return(api, CALLBACK_INFO(player), &retbuf, CALLBACK_TIME_OUT); \
+                       ret = wait_for_cb_return(api, CALLBACK_INFO(player), &retbuf, __timeout__); \
                muse_core_msg_json_factory_free(__sndMsg__); \
        }while(0)
 
index fa8fe20..adfb3d6 100644 (file)
@@ -3,7 +3,7 @@
 
 Name:       capi-media-player
 Summary:    A Media Daemon player library in Tizen Native API
-Version:    0.3.1
+Version:    0.3.2
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index 27c4bbc..787ef0d 100644 (file)
@@ -688,6 +688,7 @@ static int player_disp_prepare(muse_module_h module)
        muse_player_api_e api = MUSE_PLAYER_API_PREPARE;
        player_h player;
        char *caps = NULL;
+       bool is_streaming = FALSE;
 
        handle = muse_core_ipc_get_handle(module);
 
@@ -695,12 +696,15 @@ static int player_disp_prepare(muse_module_h module)
 
        ret = player_prepare(player);
        if(ret == PLAYER_ERROR_NONE) {
+               player_is_streaming(player, &is_streaming);
                ret = player_get_raw_video_caps(player, &caps);
                if(ret == PLAYER_ERROR_NONE && caps) {
-                       player_msg_return1(api, ret, module, STRING, caps);
+                       player_msg_return2(api, ret, module, STRING, caps, INT, is_streaming);
                        g_free(caps);
-                       return ret;
-               }
+               } else
+                       player_msg_return1(api, ret, module, INT, is_streaming);
+
+               return ret;
        }
 
        player_msg_return(api, ret, module);
@@ -715,6 +719,7 @@ static int player_disp_prepare_async(muse_module_h module)
        muse_player_api_e api = MUSE_PLAYER_API_PREPARE_ASYNC;
        player_h player;
        prepare_data_t *prepare_data;
+       bool is_streaming = FALSE;
 
        handle = muse_core_ipc_get_handle(module);
 
@@ -725,6 +730,11 @@ static int player_disp_prepare_async(muse_module_h module)
        prepare_data->module = module;
 
        ret = player_prepare_async(player, _prepare_async_cb, prepare_data);
+       if(ret == PLAYER_ERROR_NONE) {
+               player_is_streaming(player, &is_streaming);
+               player_msg_return1(api, ret, module, INT, is_streaming);
+               return ret;
+       }
 
        player_msg_return(api, ret, module);