[0.2.119] get supported media stream input format info 67/210067/3 accepted/tizen/unified/20190722.074811 submit/tizen/20190719.073411
authorEunhye Choi <eunhae1.choi@samsung.com>
Mon, 15 Jul 2019 11:35:31 +0000 (20:35 +0900)
committerEunhye Choi <eunhae1.choi@samsung.com>
Thu, 18 Jul 2019 06:55:10 +0000 (15:55 +0900)
- get supported input format from player attribute
- check the input format when set media stream info
- reordering some functions
- add not supported format error

Change-Id: Ie8b60bfa83512850284bb2bb8dd6ced1b158b40c

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

index 4833310..81fb702 100644 (file)
@@ -83,6 +83,7 @@ typedef enum {
        PLAYER_ERROR_NOT_SUPPORTED_AUDIO_CODEC = PLAYER_ERROR_CLASS | 0x0e,        /**< Not supported audio codec but video can be played (Since 4.0) */
        PLAYER_ERROR_NOT_SUPPORTED_VIDEO_CODEC = PLAYER_ERROR_CLASS | 0x0f,        /**< Not supported video codec but audio can be played (Since 4.0) */
        PLAYER_ERROR_NOT_SUPPORTED_SUBTITLE = PLAYER_ERROR_CLASS | 0x10,           /**< Not supported subtitle format (Since 4.0) */
+       PLAYER_ERROR_NOT_SUPPORTED_FORMAT = PLAYER_ERROR_CLASS | 0x11,             /**< Not supported format (Since 5.5) */
 } player_error_e;
 
 /**
@@ -702,6 +703,20 @@ int legacy_player_set_media_packet_audio_frame_decoded_cb(legacy_player_h player
 int legacy_player_push_media_stream(legacy_player_h player, media_packet_h packet);
 
 /**
+ * @brief Retrieves all supported media format for playback of external media stream.
+ * @since_tizen 5.5
+ * @param[in]  player       The handle to the media player
+ * @param[out] format_info  The supported media format info
+ * @param[out] len          The length of format_info
+ * @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
+ */
+int legacy_player_get_media_stream_supported_format(legacy_player_h player, int **format_info, int *len);
+
+/**
  * @brief  Sets contents information for media stream
  * @since_tizen 2.4
  * @remarks AV format should be set before pushing elementary stream with legacy_player_push_media_stream().
@@ -1614,7 +1629,7 @@ int legacy_player_set_replaygain_enabled(legacy_player_h player, bool enabled);
 int legacy_player_is_replaygain_enabled(legacy_player_h player, bool *enabled);
 
 /* audio offload */
-int legacy_player_audio_offload_get_supported_format(legacy_player_h player, int *len, int **format_info);
+int legacy_player_audio_offload_get_supported_format(legacy_player_h player, int **format_info, int *len);
 int legacy_player_audio_offload_set_enabled(legacy_player_h player, bool enabled);
 int legacy_player_audio_offload_is_enabled(legacy_player_h player, bool *enabled);
 int legacy_player_audio_offload_is_activated(legacy_player_h player, bool *activated);
index 23cffe5..ba7911f 100644 (file)
@@ -45,12 +45,6 @@ extern "C" {
 #define PLAYER_NULL_ARG_CHECK(arg)      \
        PLAYER_CHECK_CONDITION((arg), PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER")
 
-#define PLAYER_RANGE_ARG_CHECK(arg, min, max)      \
-       do {    \
-               PLAYER_CHECK_CONDITION(arg <= max, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");   \
-               PLAYER_CHECK_CONDITION(arg >= min, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");   \
-       } while (0)
-
 #ifdef TIZEN_TTRACE
 #include <ttrace.h>
 #define PLAYER_TRACE_BEGIN(NAME) traceBegin(TTRACE_TAG_VIDEO, NAME)
index 35dec4b..2fb56b3 100644 (file)
@@ -2018,6 +2018,7 @@ int legacy_player_set_media_packet_audio_frame_decoded_cb(legacy_player_h player
 
        return PLAYER_ERROR_NONE;
 }
+
 int legacy_player_push_media_stream(legacy_player_h player, media_packet_h packet)
 {
        legacy_player_t *handle = (legacy_player_t *)player;
@@ -2033,15 +2034,90 @@ int legacy_player_push_media_stream(legacy_player_h player, media_packet_h packe
        return PLAYER_ERROR_NONE;
 }
 
-int legacy_player_set_media_stream_info(legacy_player_h player, player_stream_type_e type, media_format_h format)
+int legacy_player_get_media_stream_supported_format(legacy_player_h player, int **format_info, int *len)
 {
+       int ret = MM_ERROR_NONE;
        legacy_player_t *handle = (legacy_player_t *)player;
+       mmplayer_attrs_info_t info;
+
+       PLAYER_INSTANCE_CHECK(player);
+       PLAYER_NULL_ARG_CHECK(format_info);
+
+       ret = mm_player_get_attribute_info(handle->mm_handle, MM_PLAYER_MEDIA_STREAM_INPUT_FORMAT, &info);
+       if (ret != MM_ERROR_NONE) {
+               LOGE("failed to get attr info 0x%x", ret);
+               return _lplayer_convert_error_code(ret, (char *)__FUNCTION__);
+       }
+
+       LOGD("num of supported format : %d", info.int_array.count);
+       *len = info.int_array.count;
+       *format_info = info.int_array.array;
+
+       return PLAYER_ERROR_NONE;
+}
+
+static int __lplayer_check_supported_format(media_format_h format, mmplayer_attrs_info_t info)
+{
+       int i = 0;
+       media_format_type_e format_type = MEDIA_FORMAT_NONE;
+       media_format_mimetype_e mimetype = MEDIA_FORMAT_MAX;
+
+       media_format_get_type(format, &format_type);
+
+       if (format_type == MEDIA_FORMAT_AUDIO) {
+               if (media_format_get_audio_info(format, &mimetype,
+                               NULL, NULL, NULL, NULL) != MEDIA_FORMAT_ERROR_NONE) {
+                       LOGE("failed to get audio mimetype");
+                       return PLAYER_ERROR_INVALID_OPERATION;
+               }
+               LOGD("Audio format 0x%X", mimetype);
+       } else if (format_type == MEDIA_FORMAT_VIDEO) {
+               if (media_format_get_video_info(format, &mimetype,
+                               NULL, NULL, NULL, NULL) != MEDIA_FORMAT_ERROR_NONE) {
+                       LOGE("failed to get video mimetype");
+                       return PLAYER_ERROR_INVALID_OPERATION;
+               }
+               LOGD("Video format 0x%X", mimetype);
+       } else {
+               LOGE("not supported format type 0x%X", format_type);
+               return PLAYER_ERROR_NOT_SUPPORTED_FORMAT;
+       }
+
+       for (i = 0 ; i < info.int_array.count ; i++) {
+               if (info.int_array.array[i] == mimetype) {
+                       LOGD("supported format 0x%X", mimetype);
+                       return PLAYER_ERROR_NONE;
+               }
+       }
+
+       LOGE("not supported format mimetype 0x%X", mimetype);
+       return PLAYER_ERROR_NOT_SUPPORTED_FORMAT;
+}
+
+int legacy_player_set_media_stream_info(legacy_player_h player, player_stream_type_e type, media_format_h format)
+{
        int ret = MM_ERROR_NONE;
+       legacy_player_t *handle = (legacy_player_t *)player;
+       mmplayer_attrs_info_t info;
+
        PLAYER_INSTANCE_CHECK(player);
        PLAYER_STATE_CHECK(handle, PLAYER_STATE_IDLE);
 
        handle->is_media_stream = true;
 
+       /* check supported input format */
+       ret = mm_player_get_attribute_info(handle->mm_handle, MM_PLAYER_MEDIA_STREAM_INPUT_FORMAT, &info);
+       if (ret != MM_ERROR_NONE) {
+               LOGE("failed to get attr info 0x%x", ret);
+               return _lplayer_convert_error_code(ret, (char *)__FUNCTION__);
+       }
+
+       ret = __lplayer_check_supported_format(format, info);
+       if (ret != PLAYER_ERROR_NONE) {
+               LOGE("failed check supported format 0x%x", ret);
+               return ret;
+       }
+
        if (type == PLAYER_STREAM_TYPE_VIDEO)
                ret = mm_player_set_video_info(handle->mm_handle, format);
        else if (type == PLAYER_STREAM_TYPE_AUDIO)
@@ -2768,7 +2844,7 @@ int legacy_player_is_replaygain_enabled(legacy_player_h player, bool *enabled)
        return PLAYER_ERROR_NONE;
 }
 
-int legacy_player_audio_offload_get_supported_format(legacy_player_h player, int *len, int **format_info)
+int legacy_player_audio_offload_get_supported_format(legacy_player_h player, int **format_info, int *len)
 {
        int ret = MM_ERROR_NONE;
        legacy_player_t *handle = (legacy_player_t *)player;
@@ -2777,7 +2853,7 @@ int legacy_player_audio_offload_get_supported_format(legacy_player_h player, int
        PLAYER_INSTANCE_CHECK(player);
        PLAYER_NULL_ARG_CHECK(format_info);
 
-       ret = mm_player_get_attribute_info(handle->mm_handle, "audio_offload_format", &info);
+       ret = mm_player_get_attribute_info(handle->mm_handle, MM_PLAYER_AUDIO_OFFLOAD_FORMAT, &info);
        if (ret != MM_ERROR_NONE) {
                LOGE("failed to get attr info 0x%x", ret);
                return _lplayer_convert_error_code(ret, (char *)__FUNCTION__);
index d7e5a26..130d251 100644 (file)
@@ -9,6 +9,7 @@ stop
 pause
 set_memory_buffer
 deinit_memory_buffer
+set_callback
 get_state
 set_volume
 get_volume
@@ -55,13 +56,13 @@ get_streaming_download_progress
 set_subtitle_path
 set_subtitle_position_offset
 push_media_stream
+get_media_stream_supported_format
 set_media_stream_info
-set_callback
-return_video_data
 set_media_stream_buffer_max_size
 get_media_stream_buffer_max_size
 set_media_stream_buffer_min_threshold
 get_media_stream_buffer_min_threshold
+return_video_data
 get_track_count
 get_current_track
 select_track
@@ -106,4 +107,4 @@ pitch_set_enabled
 pitch_is_enabled
 pitch_set_value
 pitch_get_value
-set_media_packet_audio_frame_decoded_cb
\ No newline at end of file
+set_media_packet_audio_frame_decoded_cb
index 0682d1c..b09089f 100644 (file)
@@ -1456,6 +1456,43 @@ int player_disp_deinit_memory_buffer(muse_module_h module)       /* MUSE_PLAYER_API_DE
        return PLAYER_ERROR_NONE;
 }
 
+int player_disp_set_callback(muse_module_h module)
+{
+       int ret = PLAYER_ERROR_NONE;
+       muse_player_handle_t *muse_player = NULL;
+       muse_player_event_e type;
+       int set = 0;
+       bool ret_val = true;
+
+       ret_val = __mplayer_disp_get_param_value(muse_server_module_get_msg(module),
+                                                               MUSE_TYPE_INT, "type", (void *)&type,
+                                                               MUSE_TYPE_INT, "set", (void *)&set,
+                                                               INVALID_MUSE_TYPE_VALUE);
+
+       if (!ret_val) {
+               LOGE("failed to get param value");
+               ret = PLAYER_ERROR_INVALID_OPERATION;
+               goto EXIT;
+       }
+
+       if (type >= MUSE_PLAYER_EVENT_TYPE_NUM) {
+               LOGE("invalid type value %d", type);
+               ret = PLAYER_ERROR_INVALID_PARAMETER;
+               goto EXIT;
+       }
+
+       muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
+       ret = __mplayer_set_callback_func(muse_player, type, set, module);
+       if (ret != PLAYER_ERROR_NONE) {
+               LOGE("failed to set callback type %d", type);
+               /* goto EXIT; */
+       }
+
+EXIT:
+       PLAYER_RETURN_MSG(MUSE_PLAYER_API_SET_CALLBACK, ret, module);
+       return ret;
+}
+
 int player_disp_get_state(muse_module_h module)
 {
        int ret = PLAYER_ERROR_NONE;
@@ -2439,6 +2476,28 @@ push_media_stream_exit1:
        return ret;
 }
 
+int player_disp_get_media_stream_supported_format(muse_module_h module)
+{
+       int ret = PLAYER_ERROR_NONE;
+       muse_player_api_e api = MUSE_PLAYER_API_GET_MEDIA_STREAM_SUPPORTED_FORMAT;
+       muse_player_handle_t *muse_player = NULL;
+       int len = 0;
+       int *format_info = NULL;
+
+       muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
+
+       ret = legacy_player_get_media_stream_supported_format(muse_player->player_handle, &format_info, &len);
+
+       if (ret != PLAYER_ERROR_NONE || len <= 0 || !format_info)
+               PLAYER_RETURN_MSG(api, ret, module);
+       else
+               PLAYER_RETURN_MSG(api, ret, module,
+                               MUSE_TYPE_INT, "len", len,
+                               MUSE_TYPE_ARRAY, "format_info", len, format_info);
+
+       return ret;
+}
+
 int player_disp_set_media_stream_info(muse_module_h module)
 {
        int ret = PLAYER_ERROR_NONE;
@@ -2506,70 +2565,6 @@ set_media_stream_info_exit:
        return ret;
 }
 
-
-int player_disp_set_callback(muse_module_h module)
-{
-       int ret = PLAYER_ERROR_NONE;
-       muse_player_handle_t *muse_player = NULL;
-       muse_player_event_e type;
-       int set = 0;
-       bool ret_val = true;
-
-       ret_val = __mplayer_disp_get_param_value(muse_server_module_get_msg(module),
-                                                               MUSE_TYPE_INT, "type", (void *)&type,
-                                                               MUSE_TYPE_INT, "set", (void *)&set,
-                                                               INVALID_MUSE_TYPE_VALUE);
-
-       if (!ret_val) {
-               LOGE("failed to get param value");
-               ret = PLAYER_ERROR_INVALID_OPERATION;
-               goto EXIT;
-       }
-
-       if (type >= MUSE_PLAYER_EVENT_TYPE_NUM) {
-               LOGE("invalid type value %d", type);
-               ret = PLAYER_ERROR_INVALID_PARAMETER;
-               goto EXIT;
-       }
-
-       muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
-       ret = __mplayer_set_callback_func(muse_player, type, set, module);
-       if (ret != PLAYER_ERROR_NONE) {
-               LOGE("failed to set callback type %d", type);
-               /* goto EXIT; */
-       }
-
-EXIT:
-       PLAYER_RETURN_MSG(MUSE_PLAYER_API_SET_CALLBACK, ret, module);
-       return ret;
-}
-
-int player_disp_return_video_data(muse_module_h module) /* MUSE_PLAYER_API_RETURN_VIDEO_DATA */
-{
-       mmplayer_video_decoded_data_info_t *v_data = NULL;
-       muse_player_handle_t *muse_player = NULL;
-       bool find_data = false;
-
-       player_msg_get_type(v_data, muse_server_module_get_msg(module), POINTER);
-
-       muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
-       if (muse_player && muse_player->video_data_list) {
-               g_mutex_lock(&muse_player->list_lock);
-               if (g_list_find(muse_player->video_data_list, v_data)) {
-                       muse_player->video_data_list = g_list_remove(muse_player->video_data_list, v_data);
-                       find_data = true;
-               } else {
-                       LOGW("the v_data(%p) is not in the exported list.", v_data);
-               }
-               g_mutex_unlock(&muse_player->list_lock);
-
-               if (find_data)
-                       __mplayer_remove_video_stream_data(module, v_data);
-       }
-
-       return PLAYER_ERROR_NONE;
-}
-
 int player_disp_set_media_stream_buffer_max_size(muse_module_h module)
 {
        int ret = PLAYER_ERROR_NONE;
@@ -2678,6 +2673,31 @@ int player_disp_set_media_stream_dynamic_resolution(muse_module_h module)
        return ret;
 }
 
+int player_disp_return_video_data(muse_module_h module) /* MUSE_PLAYER_API_RETURN_VIDEO_DATA */
+{
+       mmplayer_video_decoded_data_info_t *v_data = NULL;
+       muse_player_handle_t *muse_player = NULL;
+       bool find_data = false;
+
+       player_msg_get_type(v_data, muse_server_module_get_msg(module), POINTER);
+
+       muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
+       if (muse_player && muse_player->video_data_list) {
+               g_mutex_lock(&muse_player->list_lock);
+               if (g_list_find(muse_player->video_data_list, v_data)) {
+                       muse_player->video_data_list = g_list_remove(muse_player->video_data_list, v_data);
+                       find_data = true;
+               } else {
+                       LOGW("the v_data(%p) is not in the exported list.", v_data);
+               }
+               g_mutex_unlock(&muse_player->list_lock);
+
+               if (find_data)
+                       __mplayer_remove_video_stream_data(module, v_data);
+       }
+
+       return PLAYER_ERROR_NONE;
+}
 
 int player_disp_get_track_count(muse_module_h module)
 {
@@ -3388,7 +3408,7 @@ int player_disp_audio_offload_get_supported_format(muse_module_h module)
 
        muse_player = (muse_player_handle_t *)muse_server_ipc_get_handle(module);
 
-       ret = legacy_player_audio_offload_get_supported_format(muse_player->player_handle, &len, &format_info);
+       ret = legacy_player_audio_offload_get_supported_format(muse_player->player_handle, &format_info, &len);
 
        if (ret != PLAYER_ERROR_NONE || len <= 0 || !format_info)
                PLAYER_RETURN_MSG(api, ret, module);
index fbe0b7c..43b8c94 100644 (file)
@@ -1,6 +1,6 @@
 Name:       mmsvc-player
 Summary:    A Media Player module for muse server
-Version:    0.2.118
+Version:    0.2.119
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0