[0.3.58] get framerate info from media format when set media stream info 58/128558/3 accepted/tizen/unified/20170511.173259 submit/tizen/20170511.065823 tizen_4.0.m1_release
authorEunhae Choi <eunhae1.choi@samsung.com>
Wed, 10 May 2017 10:21:50 +0000 (19:21 +0900)
committereunhae choi <eunhae1.choi@samsung.com>
Wed, 10 May 2017 11:10:51 +0000 (11:10 +0000)
Change-Id: Ifff9746cf0011d0b584a0e37661db71e4024b20d

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

index d11ba07..ad2396b 100644 (file)
@@ -294,6 +294,49 @@ extern "C" {
  * @param[in] player The handle of capi media player.
  * @param[out] retbuf The buffer of return message. Must be char pointer.Must free after use.
  * @param[out] ret The return value from server.
+ * @param[in] type The enum of parameter type. Muse be one of thease(INT, INT64, POINTER, DOUBLE, STRING, ARRAY)
+ * @param[in] param# the name of param is key, must be local variable. never be pointer.
+ */
+#define player_msg_send7(api, player, retbuf, ret, type1, param1, type2, param2, type3, param3, type4, param4, type5, param5, type6, param6, type7, param7) \
+       do {    \
+               char *__sndMsg__; \
+               int __len__; \
+               int __fd__; \
+               int __timeout__ = client_get_api_timeout(player, api); \
+               type1 __value1__ = (type1)param1; \
+               type2 __value2__ = (type2)param2; \
+               type3 __value3__ = (type3)param3; \
+               type4 __value4__ = (type4)param4; \
+               type5 __value5__ = (type5)param5; \
+               type6 __value6__ = (type6)param6; \
+               type7 __value7__ = (type7)param7; \
+               if (CALLBACK_INFO(player)) __fd__ = MSG_FD(player); \
+               else {ret = PLAYER_ERROR_INVALID_STATE; break; } \
+               __sndMsg__ = muse_core_msg_json_factory_new(api, \
+                               MUSE_TYPE_##type1, #param1, __value1__, \
+                               MUSE_TYPE_##type2, #param2, __value2__, \
+                               MUSE_TYPE_##type3, #param3, __value3__, \
+                               MUSE_TYPE_##type4, #param4, __value4__, \
+                               MUSE_TYPE_##type5, #param5, __value5__, \
+                               MUSE_TYPE_##type6, #param6, __value6__, \
+                               MUSE_TYPE_##type7, #param7, __value7__, \
+                               0); \
+               __len__ = muse_core_ipc_send_msg(__fd__, __sndMsg__); \
+               if (__len__ <= 0) { \
+                       LOGE("sending message failed"); \
+                       ret = PLAYER_ERROR_INVALID_OPERATION; \
+               } else \
+                       ret = client_wait_for_cb_return(api, CALLBACK_INFO(player), &retbuf, __timeout__); \
+               muse_core_msg_json_factory_free(__sndMsg__); \
+       } while (0)
+
+/**
+ * @brief Create and send message. Wait for server result.
+ * @remarks Does NOT guarantee thread safe.
+ * @param[in] api The enum of module API.
+ * @param[in] player The handle of capi media player.
+ * @param[out] retbuf The buffer of return message. Must be char pointer.Must free after use.
+ * @param[out] ret The return value from server.
  * @param[in] param the name of param is key, must be local array/pointer variable.
  * @param[in] length The size of array.
  * @param[in] datum_size The size of a array's datum.
index 00b5af5..a3dae70 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-player
 Summary:    A Media Player API
-Version:    0.3.57
+Version:    0.3.58
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index c059cda..72b2b5e 100644 (file)
@@ -2757,6 +2757,11 @@ int player_set_display(player_h player, player_display_type_e type, player_displ
                        }
 #ifdef TIZEN_FEATURE_EVAS_RENDERER
                        else if (conv_type == PLAYER_PRIVATE_DISPLAY_TYPE_EVAS && !strcmp(object_type, "image")) {
+                               if (!CALLBACK_INFO(pc)) {
+                                       LOGE("there is no cb info in player handle");
+                                       return PLAYER_ERROR_INVALID_OPERATION;
+                               }
+
                                /* evas object surface */
                                LOGI("evas surface type");
                                wl_win.type = conv_type;
@@ -2766,12 +2771,12 @@ int player_set_display(player_h player, player_display_type_e type, player_displ
 
                                if (EVAS_HANDLE(pc)) {
                                        LOGW("evas client already exists");
-                                       if (CALLBACK_INFO(pc))
-                                               player_unset_media_packet_video_frame_decoded_cb(player);
+                                       player_unset_media_packet_video_frame_decoded_cb(player);
+
                                        if (mm_evas_renderer_destroy(&EVAS_HANDLE(pc)) != MM_ERROR_NONE)
                                                LOGW("fail to unset evas client");
                                        __player_unset_retrieve_buffer_cb(player);
-                                       g_free(pc->cb_info->evas_info);
+
                                        /* need to set display information again to new handle */
                                        EVAS_INFO(pc)->update_needed = TRUE;
                                }
@@ -2815,8 +2820,9 @@ int player_set_display(player_h player, player_display_type_e type, player_displ
 #endif
                        else
                                return PLAYER_ERROR_INVALID_PARAMETER;
-               } else
+               } else {
                        return PLAYER_ERROR_INVALID_PARAMETER;
+               }
        } else {        /* PLAYER_DISPLAY_TYPE_NONE */
                LOGI("Wayland surface type is NONE");
                wl_win.type = conv_type;
@@ -4114,22 +4120,31 @@ int player_set_media_stream_info(player_h player, player_stream_type_e type, med
        muse_player_api_e api = MUSE_PLAYER_API_SET_MEDIA_STREAM_INFO;
        char *ret_buf = NULL;
        media_format_mimetype_e mimetype;
-       int width;
-       int height;
-       int avg_bps;
-       int max_bps;
-       int channel;
-       int samplerate;
-       int bit;
+       int width = 0;
+       int height = 0;
+       int avg_bps = 0;
+       int max_bps = 0;
+       int channel = 0;
+       int samplerate = 0;
+       int bit = 0;
+       int frame_rate = 0;
 
        LOGD("ENTER");
 
        media_format_ref(format);
        if (type == PLAYER_STREAM_TYPE_VIDEO) {
-               media_format_get_video_info(format, &mimetype, &width, &height, &avg_bps, &max_bps);
-               player_msg_send6(api, pc, ret_buf, ret, INT, type, INT, mimetype, INT, width, INT, height, INT, avg_bps, INT, max_bps);
+               if (media_format_get_video_info(format, &mimetype, &width, &height, &avg_bps, &max_bps) != MEDIA_FORMAT_ERROR_NONE ||
+                       media_format_get_video_frame_rate(format, &frame_rate) != MEDIA_FORMAT_ERROR_NONE) {
+                       LOGE("failed to get video info from format.");
+                       return PLAYER_ERROR_INVALID_PARAMETER;
+               }
+
+               player_msg_send7(api, pc, ret_buf, ret, INT, type, INT, mimetype, INT, width, INT, height, INT, avg_bps, INT, max_bps, INT, frame_rate);
        } else if (type == PLAYER_STREAM_TYPE_AUDIO) {
-               media_format_get_audio_info(format, &mimetype, &channel, &samplerate, &bit, &avg_bps);
+               if (media_format_get_audio_info(format, &mimetype, &channel, &samplerate, &bit, &avg_bps) != MEDIA_FORMAT_ERROR_NONE) {
+                       LOGE("failed to get audio info from format.");
+                       return PLAYER_ERROR_INVALID_PARAMETER;
+               }
                player_msg_send6(api, pc, ret_buf, ret, INT, type, INT, mimetype, INT, channel, INT, samplerate, INT, avg_bps, INT, bit);
        }
        media_format_unref(format);