[0.2.68] support video codec selection by api 91/164391/3 accepted/tizen/4.0/unified/20171226.073637 submit/tizen_4.0/20171222.073822
authorEunhae Choi <eunhae1.choi@samsung.com>
Tue, 19 Dec 2017 04:12:10 +0000 (13:12 +0900)
committerEunhae Choi <eunhae1.choi@samsung.com>
Tue, 19 Dec 2017 04:17:26 +0000 (13:17 +0900)
- can fix the video codec type among the sw, hw and default.
- in case of 'default', the higher priority video codec will be selected as before.

Change-Id: I731c41d766b937e7eb34c372aa36b3408331f0e9

legacy/include/legacy_player_internal.h
legacy/src/legacy_player.c
legacy/src/legacy_player_internal.c
muse/api.list
muse/src/muse_player.c
packaging/mmsvc-player.spec

index 734ddc4..9c79133 100644 (file)
@@ -32,6 +32,17 @@ extern "C" {
  */
 
 /**
+ * @brief Enumeration for video codec type.
+ * @since_tizen 4.0
+ */
+typedef enum
+{
+       PLAYER_VIDEO_CODEC_TYPE_DEFAULT = 0,  /**< This is an optional flag for using codec which has higher priority */
+       PLAYER_VIDEO_CODEC_TYPE_HW,           /**< This is an optional flag for using the h/w codec */
+       PLAYER_VIDEO_CODEC_TYPE_SW,           /**< This is an optional flag for using the s/w codec */
+} player_video_codec_type_e;
+
+/**
  * @brief This file contains the media player API for custom features.
  * @since_tizen 2.4
  */
@@ -271,9 +282,42 @@ int legacy_player_is_gapless(player_h player, bool *gapless);
 int legacy_player_enable_media_packet_video_frame_decoded_cb(player_h player, bool enable);
 
 /**
- * @}
+ * @brief Set video codec type as h/w codec or s/w codec.
+ * @since_tizen 4.0
+ * @details The default video codec type of the player is #PLAYER_VIDEO_CODEC_TYPE_DEFAULT.
+ *          Usually the H/W codec has higher priority than S/W codec if it exist.
+ * @param[in] player The handle to the media player
+ * @param[in] type   The video codec type
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #PLAYER_ERROR_NONE Successful
+ * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state
+ * @pre The player state must be #PLAYER_STATE_IDLE by player_create() or player_unprepare().
+ * @see legacy_player_get_video_codec_type()
+ */
+int legacy_player_set_video_codec_type(player_h player, player_video_codec_type_e type);
+
+/**
+ * @brief Get video codec type.
+ * @since_tizen 4.0
+ * @param[in]  player The handle to the media player
+ * @param[out] ptype  The video codec type
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #PLAYER_ERROR_NONE Successful
+ * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation
+ * @retval #PLAYER_ERROR_INVALID_STATE Invalid player state
+ * @pre The player state must be one of these: #PLAYER_STATE_IDLE, #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED.
+ * @see legacy_player_set_video_codec_type()
  */
+int legacy_player_get_video_codec_type(player_h player, player_video_codec_type_e *type);
 
+/**
+ * @}
+ */
 
 #ifdef __cplusplus
 }
index d8c98ca..588cc00 100644 (file)
@@ -664,13 +664,12 @@ static int __msg_callback(int message, void *param, void *user_data)
                if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_CAPTURE]) {
                        int w;
                        int h;
+                       MMPlayerVideoCapture *capture = (MMPlayerVideoCapture *)msg->data;
                        int ret = mm_player_get_attribute(handle->mm_handle, NULL, MM_PLAYER_VIDEO_WIDTH, &w, MM_PLAYER_VIDEO_HEIGHT, &h, (char *)NULL);
                        if (ret != MM_ERROR_NONE && handle->user_cb[MUSE_PLAYER_EVENT_TYPE_ERROR]) {
                                LOGE("[%s] PLAYER_ERROR_VIDEO_CAPTURE_FAILED (0x%08x) : Failed to get video size on video captured (0x%x)", __FUNCTION__, PLAYER_ERROR_VIDEO_CAPTURE_FAILED, ret);
                                err_code = PLAYER_ERROR_VIDEO_CAPTURE_FAILED;
                        } else {
-                               MMPlayerVideoCapture *capture = (MMPlayerVideoCapture *)msg->data;
-
                                switch (msg->captured_frame.orientation) {
                                case 0:
                                case 180:
@@ -694,12 +693,14 @@ static int __msg_callback(int message, void *param, void *user_data)
 
                                /* call application callback */
                                ((player_video_captured_cb)handle->user_cb[MUSE_PLAYER_EVENT_TYPE_CAPTURE])(capture->data, w, h, capture->size, handle->user_data[MUSE_PLAYER_EVENT_TYPE_CAPTURE]);
+                       }
 
-                               if (capture->data) {
-                                       g_free(capture->data);
-                                       capture->data = NULL;
-                               }
+                       /* capure->data have to be released to avoid mem leak even if _get_attribute got failed. */
+                       if (capture && capture->data) {
+                               g_free(capture->data);
+                               capture->data = NULL;
                        }
+
                        handle->user_cb[MUSE_PLAYER_EVENT_TYPE_CAPTURE] = NULL;
                        handle->user_data[MUSE_PLAYER_EVENT_TYPE_CAPTURE] = NULL;
                }
index 570b8a5..6b0faa4 100644 (file)
@@ -334,3 +334,31 @@ int legacy_player_enable_media_packet_video_frame_decoded_cb(player_h player, bo
        else
                return PLAYER_ERROR_NONE;
 }
+
+int legacy_player_set_video_codec_type(player_h player, player_video_codec_type_e type)
+{
+       PLAYER_INSTANCE_CHECK(player);
+       player_s * handle = (player_s *) player;
+       PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE);
+
+       LOGI("video codec type : %d", type);
+       int ret = mm_player_set_attribute(handle->mm_handle, NULL, MM_PLAYER_VIDEO_CODEC_TYPE, type, (char*)NULL);
+       if (ret != MM_ERROR_NONE)
+               return __player_convert_error_code(ret, (char*)__FUNCTION__);
+       else
+               return PLAYER_ERROR_NONE;
+}
+
+int legacy_player_get_video_codec_type(player_h player, player_video_codec_type_e *type)
+{
+       PLAYER_INSTANCE_CHECK(player);
+       PLAYER_NULL_ARG_CHECK(type);
+       player_s * handle = (player_s *) player;
+
+       int ret = mm_player_get_attribute(handle->mm_handle, NULL, MM_PLAYER_VIDEO_CODEC_TYPE, type, (char*)NULL);
+       if (ret != MM_ERROR_NONE)
+               return __player_convert_error_code(ret, (char*)__FUNCTION__);
+       else
+               return PLAYER_ERROR_NONE;
+}
+
index 8185913..440f027 100644 (file)
@@ -92,4 +92,6 @@ get_streaming_buffering_time
 360_set_zoom
 360_get_zoom
 360_set_field_of_view
-360_get_field_of_view
\ No newline at end of file
+360_get_field_of_view
+set_video_codec_type
+get_video_codec_type
\ No newline at end of file
index 72cf986..00adb7c 100644 (file)
@@ -3061,3 +3061,37 @@ int player_disp_360_get_field_of_view(muse_module_h module)
        player_msg_return2(api, ret, module, DOUBLE, h_val, DOUBLE, v_val);
        return ret;
 }
+
+int player_disp_set_video_codec_type(muse_module_h module)
+{
+       int ret = PLAYER_ERROR_NONE;
+       muse_player_handle_s *muse_player = NULL;
+       muse_player_api_e api = MUSE_PLAYER_API_SET_VIDEO_CODEC_TYPE;
+       int type = 0;
+
+       muse_player = (muse_player_handle_s *)muse_server_ipc_get_handle(module);
+       player_msg_get(type, muse_server_module_get_msg(module));
+
+       ret = legacy_player_set_video_codec_type(muse_player->player_handle, (player_video_codec_type_e)type);
+
+       player_msg_return(api, ret, module);
+
+       return ret;
+}
+
+int player_disp_get_video_codec_type(muse_module_h module)
+{
+       int ret = PLAYER_ERROR_NONE;
+       muse_player_handle_s *muse_player = NULL;
+       muse_player_api_e api = MUSE_PLAYER_API_GET_VIDEO_CODEC_TYPE;
+       player_video_codec_type_e type = 0;
+
+       muse_player = (muse_player_handle_s *)muse_server_ipc_get_handle(module);
+
+       ret = legacy_player_get_video_codec_type(muse_player->player_handle, &type);
+
+       player_msg_return1(api, ret, module, INT, type);
+
+       return ret;
+}
+
index cd5742b..41aa087 100644 (file)
@@ -1,6 +1,6 @@
 Name:       mmsvc-player
 Summary:    A Media Player module for muse server
-Version:    0.2.67
+Version:    0.2.68
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0