[0.3.81] add considering of audio codec_type 14/167514/1 accepted/tizen/4.0/unified/20180123.105145 submit/tizen_4.0/20180118.070828
authorEunhae Choi <eunhae1.choi@samsung.com>
Thu, 11 Jan 2018 07:27:33 +0000 (16:27 +0900)
committerEunhae Choi <eunhae1.choi@samsung.com>
Thu, 18 Jan 2018 05:19:58 +0000 (14:19 +0900)
Change-Id: I4759e7a4e3a28792f5da4bb77b31306cb01594ad
(cherry picked from commit e0ff37b7dc109fdc72842ea82692f28ccb3bad99)

include/player.h
include/player_internal.h
packaging/capi-media-player.spec
src/player_internal.c
test/player_test.c

index 2b897c6d9414a137912b060c4ec0cf1513f8cd89..216cbd61f97b68166af7d825e30a9e53a4a555ae 100644 (file)
@@ -604,7 +604,7 @@ int player_set_memory_buffer(player_h player, const void * data, int size);
  * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter
  * @see #player_state_e
  */
-int  player_get_state(player_h player, player_state_e *state);
+int player_get_state(player_h player, player_state_e *state);
 
 /**
  * @brief Sets the player's volume.
index 87273b87cc21abe296342ba124f276a3a5562037..70ed9ed28cbaa60b2b66d18e72a04786e1b4a76d 100644 (file)
@@ -39,13 +39,22 @@ typedef enum {
  * @brief Enumeration for video codec type.
  * @since_tizen 4.0
  */
-typedef enum
-{
+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 Enumeration for codec type.
+ * @since_tizen 4.0
+ */
+typedef enum {
+       PLAYER_CODEC_TYPE_DEFAULT = 0,  /**< This is an optional flag for using codec which has higher priority */
+       PLAYER_CODEC_TYPE_HW,           /**< This is an optional flag for using the h/w codec */
+       PLAYER_CODEC_TYPE_SW,           /**< This is an optional flag for using the s/w codec */
+} player_codec_type_e;
+
 /**
  * @brief This file contains the media player API for custom features.
  * @since_tizen 2.4
@@ -737,6 +746,43 @@ int player_set_video_codec_type(player_h player, player_video_codec_type_e type)
  */
 int player_get_video_codec_type(player_h player, player_video_codec_type_e *ptype);
 
+/**
+ * @brief Set audio/video codec type as h/w codec or s/w codec.
+ * @since_tizen 4.0
+ * @details The default codec type of the player is #PLAYER_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] stream_type  The stream type and it have to be #PLAYER_STREAM_TYPE_AUDIO or #PLAYER_STREAM_TYPE_VIDEO.
+ * @param[in] codec_type   The 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 player_get_codec_type()
+ */
+int player_set_codec_type(player_h player, player_stream_type_e stream_type, player_codec_type_e codec_type);
+
+/**
+ * @brief Get video codec type.
+ * @since_tizen 4.0
+ * @param[in]  player The handle to the media player
+ * @param[in]  stream_type  The stream type and it have to be #PLAYER_STREAM_TYPE_AUDIO or #PLAYER_STREAM_TYPE_VIDEO.
+ * @param[out] pcodec_type   The 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 player_set_codec_type()
+ */
+int player_get_codec_type(player_h player, player_stream_type_e stream_type, player_codec_type_e *pcodec_type);
+
+
 /**
  * @}
  */
index e0a002eb386531e6b095e49cdabe50a33bb47f92..ba2cd2b6d7d3d365c2005970cebf00220be8cf63 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-player
 Summary:    A Media Player API
-Version:    0.3.80
+Version:    0.3.81
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
@@ -45,12 +45,12 @@ Requires: %{name} = %{version}-%{release}
 %devel_desc
 
 %package display
-Summary:  A display interface library for Media Player libray
+Summary:  A display interface library for Media Player library
 Group:    Display/Multimedia
 Requires: %{name} = %{version}-%{release}
 
 %description display
-A display interface library for Media Player libray
+A display interface library for Media Player library
 
 %package utils
 Summary: A test app for Media Player API
index 077577055541021c5a8b89bf2112aabd618db4c5..60ec95742e4a8ed1cf7e9a2fd46fd3d2abf4ae59 100644 (file)
@@ -382,41 +382,87 @@ int player_enable_media_packet_video_frame_decoded_cb(player_h player, bool enab
        return ret;
 }
 
-int player_set_video_codec_type(player_h player, player_video_codec_type_e type)
+int player_set_video_codec_type(player_h player, player_video_codec_type_e codec_type)
 {
        PLAYER_INSTANCE_CHECK(player);
 
        int ret = PLAYER_ERROR_NONE;
-       muse_player_api_e api = MUSE_PLAYER_API_SET_VIDEO_CODEC_TYPE;
-       player_cli_s *pc = (player_cli_s *)player;
+       muse_player_api_e api = MUSE_PLAYER_API_SET_CODEC_TYPE;
+       player_cli_s *pc = (player_cli_s *) player;
        char *ret_buf = NULL;
+       int stream_type = PLAYER_STREAM_TYPE_VIDEO;
 
-       LOGD("ENTER %d", type);
+       LOGD("ENTER %d", codec_type);
 
-       player_msg_send1(api, pc, ret_buf, ret, INT, type);
+       player_msg_send2(api, pc, ret_buf, ret, INT, stream_type, INT, codec_type);
 
        g_free(ret_buf);
        LOGD("LEAVE");
        return ret;
 }
 
-int player_get_video_codec_type(player_h player, player_video_codec_type_e *ptype)
+int player_get_video_codec_type(player_h player, player_video_codec_type_e *pcodec_type)
 {
        PLAYER_INSTANCE_CHECK(player);
-       PLAYER_NULL_ARG_CHECK(ptype);
+       PLAYER_NULL_ARG_CHECK(pcodec_type);
 
        int ret = PLAYER_ERROR_NONE;
-       muse_player_api_e api = MUSE_PLAYER_API_GET_VIDEO_CODEC_TYPE;
+       muse_player_api_e api = MUSE_PLAYER_API_GET_CODEC_TYPE;
        player_cli_s *pc = (player_cli_s *) player;
        char *ret_buf = NULL;
-       int type = 0;
+       int stream_type = PLAYER_STREAM_TYPE_VIDEO;
+       int codec_type = 0;
 
        LOGD("ENTER");
 
-       player_msg_send(api, pc, ret_buf, ret);
+       player_msg_send1(api, pc, ret_buf, ret, INT, stream_type);
+       if (ret == PLAYER_ERROR_NONE) {
+               player_msg_get(codec_type, ret_buf);
+               *pcodec_type = codec_type;
+       }
+
+       g_free(ret_buf);
+       LOGD("LEAVE");
+       return ret;
+}
+
+int player_set_codec_type(player_h player, player_stream_type_e stream_type, player_codec_type_e codec_type)
+{
+       PLAYER_INSTANCE_CHECK(player);
+       PLAYER_CHECK_CONDITION(stream_type == PLAYER_STREAM_TYPE_AUDIO || stream_type == PLAYER_STREAM_TYPE_VIDEO, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");
+
+       int ret = PLAYER_ERROR_NONE;
+       muse_player_api_e api = MUSE_PLAYER_API_SET_CODEC_TYPE;
+       player_cli_s *pc = (player_cli_s *) player;
+       char *ret_buf = NULL;
+
+       LOGD("ENTER stream: %d, codec: %d", stream_type, codec_type);
+
+       player_msg_send2(api, pc, ret_buf, ret, INT, stream_type, INT, codec_type);
+
+       g_free(ret_buf);
+       LOGD("LEAVE");
+       return ret;
+}
+
+int player_get_codec_type(player_h player, player_stream_type_e stream_type, player_codec_type_e *pcodec_type)
+{
+       PLAYER_INSTANCE_CHECK(player);
+       PLAYER_NULL_ARG_CHECK(pcodec_type);
+       PLAYER_CHECK_CONDITION(stream_type == PLAYER_STREAM_TYPE_AUDIO || stream_type == PLAYER_STREAM_TYPE_VIDEO, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER");
+
+       int ret = PLAYER_ERROR_NONE;
+       muse_player_api_e api = MUSE_PLAYER_API_GET_CODEC_TYPE;
+       player_cli_s *pc = (player_cli_s *) player;
+       char *ret_buf = NULL;
+       int codec_type = 0;
+
+       LOGD("ENTER stream_type: %d", stream_type);
+
+       player_msg_send1(api, pc, ret_buf, ret, INT, stream_type);
        if (ret == PLAYER_ERROR_NONE) {
-               player_msg_get(type, ret_buf);
-               *ptype = type;
+               player_msg_get(codec_type, ret_buf);
+               *pcodec_type = codec_type;
        }
 
        g_free(ret_buf);
index b0dca60faf027d8e1ef73875c53ffc0d813f4c64..10e9aae3d0275e4f4389ea51b1e99a6dda732d38 100644 (file)
@@ -166,13 +166,14 @@ enum {
        CURRENT_STATUS_SET_AUDIO_ONLY,
        CURRENT_STATUS_SET_PRE_BUFFERING_SIZE,
        CURRENT_STATUS_SET_RE_BUFFERING_SIZE,
-       CURRENT_STATUS_VIDEO_CODEC_TYPE,
        CURRENT_STATUS_VIDEO360_SET_ENABLE,
        CURRENT_STATUS_VIDEO360_SET_DOV,
        CURRENT_STATUS_VIDEO360_SET_DOV1,
        CURRENT_STATUS_VIDEO360_SET_FOV,
        CURRENT_STATUS_VIDEO360_SET_FOV1,
        CURRENT_STATUS_VIDEO360_SET_ZOOM,
+       CURRENT_STATUS_AUDIO_CODEC_TYPE,
+       CURRENT_STATUS_VIDEO_CODEC_TYPE,
 };
 
 typedef struct {
@@ -180,6 +181,11 @@ typedef struct {
        bool accurate;
 } player_seek_pos_t;
 
+typedef struct {
+       int a_codec_type;
+       int v_codec_type;
+} player_codec_type_t;
+
 #define MAX_HANDLE 20
 
 /* for video display */
@@ -206,6 +212,7 @@ typedef struct {
 static appdata ad;
 static player_h g_player[MAX_HANDLE] = { 0, };
 static player_seek_pos_t seek_info = {0};
+static player_codec_type_t codec_type = {0};
 int g_handle_num = 1;
 int g_menu_state = CURRENT_STATUS_MAINMENU;
 gboolean quit_pushing;
@@ -1516,22 +1523,28 @@ static void get_duration()
        g_print("                                                            ==> [Player_Test] Duration: [%d ] msec\n", duration);
 }
 
-static void set_video_codec_type(int type)
+static void set_codec_type(void)
 {
        int ret;
-       if (type < PLAYER_VIDEO_CODEC_TYPE_DEFAULT || type > PLAYER_VIDEO_CODEC_TYPE_SW)
-               type = PLAYER_VIDEO_CODEC_TYPE_DEFAULT;
-       ret = player_set_video_codec_type(g_player[0], type);
-       g_print("                                                            ==> [Player_Test] player_set_video_codec_type(%d) return: %d\n", type, ret);
+
+       ret = player_set_codec_type(g_player[0], PLAYER_STREAM_TYPE_AUDIO, codec_type.a_codec_type);
+       g_print("                                                            ==> [Player_Test] audio codec type (%d) return: %d\n", codec_type.a_codec_type, ret);
+
+       ret = player_set_codec_type(g_player[0], PLAYER_STREAM_TYPE_VIDEO, codec_type.v_codec_type);
+       g_print("                                                            ==> [Player_Test] video codec type (%d) return: %d\n", codec_type.v_codec_type, ret);
+
 }
 
-static void get_video_codec_type()
+static void get_codec_type(void)
 {
-       player_video_codec_type_e type = 0;
        int ret;
-       ret = player_get_video_codec_type(g_player[0], &type);
-       g_print("                                                            ==> [Player_Test] player_get_video_codec_type() return : %d\n", ret);
-       g_print("                                                            ==> [Player_Test] Codec type: [%d]\n", type);
+       player_codec_type_e atype = 0, vtype = 0;
+
+       ret = player_get_codec_type(g_player[0], PLAYER_STREAM_TYPE_AUDIO, &atype);
+       g_print("                                                            ==> [Player_Test] Audio Codec type: [%d][ret 0x%X]\n", atype, ret);
+
+       ret = player_get_codec_type(g_player[0], PLAYER_STREAM_TYPE_VIDEO, &vtype);
+       g_print("                                                            ==> [Player_Test] Video Codec type: [%d][ret 0x%X]\n", vtype, ret);
 }
 
 static void audio_frame_decoded_cb_ex(bool sync)
@@ -2225,9 +2238,9 @@ void _interpret_main_menu(char *cmd)
                } else if (strncmp(cmd, "bf", 2) == 0) {
                        g_menu_state = CURRENT_STATUS_SET_PRE_BUFFERING_SIZE;
                } else if (strncmp(cmd, "C1", 2) == 0) {
-                       g_menu_state = CURRENT_STATUS_VIDEO_CODEC_TYPE;
+                       g_menu_state = CURRENT_STATUS_AUDIO_CODEC_TYPE;
                } else if (strncmp(cmd, "C2", 2) == 0) {
-                       get_video_codec_type();
+                       get_codec_type();
                } else {
                        g_print("unknown menu \n");
                }
@@ -2399,8 +2412,6 @@ static void displaymenu()
                g_print("*** set pre buffering size (ms) \n");
        } else if (g_menu_state == CURRENT_STATUS_SET_RE_BUFFERING_SIZE) {
                g_print("*** set re buffering size (ms) \n");
-       } else if (g_menu_state == CURRENT_STATUS_VIDEO_CODEC_TYPE) {
-               g_print("*** set video codec type (1: HW, 2: SW) \n");
        } else if (g_menu_state == CURRENT_STATUS_VIDEO360_SET_ENABLE) {
                g_print("*** input video 360 status (0: disabled (full panorama), 1: enabled)\n");
        } else if (g_menu_state == CURRENT_STATUS_VIDEO360_SET_DOV) {
@@ -2413,6 +2424,10 @@ static void displaymenu()
                g_print("*** input vertical field of view angle (1~180 deg.)\n");
        } else if (g_menu_state == CURRENT_STATUS_VIDEO360_SET_ZOOM) {
                g_print("*** input zoom factor.(1.0~10.0, where 1.0 - no zoom, actual image) \n");
+       } else if (g_menu_state == CURRENT_STATUS_AUDIO_CODEC_TYPE) {
+               g_print("*** set audio codec type (1: HW, 2: SW) \n");
+       } else if (g_menu_state == CURRENT_STATUS_VIDEO_CODEC_TYPE) {
+               g_print("*** set video codec type (1: HW, 2: SW) \n");
        } else {
                g_print("*** unknown status.\n");
                quit_program();
@@ -2673,13 +2688,6 @@ static void interpret(char *cmd)
                        reset_menu_state();
                }
                break;
-       case CURRENT_STATUS_VIDEO_CODEC_TYPE:
-               {
-                       int value = atoi(cmd);
-                       set_video_codec_type(value);
-                       reset_menu_state();
-               }
-               break;
        case CURRENT_STATUS_VIDEO360_SET_ENABLE:
                {
                        int enable = atoi(cmd);
@@ -2720,7 +2728,21 @@ static void interpret(char *cmd)
                        reset_menu_state();
                }
                break;
-
+       case CURRENT_STATUS_AUDIO_CODEC_TYPE:
+               {
+                       int value = atoi(cmd);
+                       codec_type.a_codec_type = value;
+                       g_menu_state = CURRENT_STATUS_VIDEO_CODEC_TYPE;
+               }
+               break;
+       case CURRENT_STATUS_VIDEO_CODEC_TYPE:
+               {
+                       int value = atoi(cmd);
+                       codec_type.v_codec_type = value;
+                       set_codec_type();
+                       reset_menu_state();
+               }
+               break;
        }
 
        g_timeout_add(100, timeout_menu_display, 0);