[0.3.81] add considering of audio codec_type 24/166624/2
authorEunhae Choi <eunhae1.choi@samsung.com>
Thu, 11 Jan 2018 07:27:33 +0000 (16:27 +0900)
committerEunhae Choi <eunhae1.choi@samsung.com>
Thu, 11 Jan 2018 09:53:29 +0000 (18:53 +0900)
Change-Id: I4cffe77fbfce8bf8eb1ff6c9ef29d046528467a9

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

index 87273b8..70ed9ed 100644 (file)
@@ -39,14 +39,23 @@ 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
  */
@@ -738,6 +747,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 78b39d7..ba2cd2b 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
index 0775770..60ec957 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 27ff13b..c446146 100644 (file)
@@ -173,6 +173,7 @@ enum {
        CURRENT_STATUS_VIDEO360_SET_FOV1,
        CURRENT_STATUS_VIDEO360_SET_ZOOM,
        CURRENT_STATUS_VIDEO_CODEC_TYPE,
+       CURRENT_STATUS_AUDIO_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)
@@ -2227,7 +2240,7 @@ void _interpret_main_menu(char *cmd)
                } else if (strncmp(cmd, "C1", 2) == 0) {
                        g_menu_state = CURRENT_STATUS_VIDEO_CODEC_TYPE;
                } else if (strncmp(cmd, "C2", 2) == 0) {
-                       get_video_codec_type();
+                       get_codec_type();
                } else {
                        g_print("unknown menu \n");
                }
@@ -2413,6 +2426,8 @@ static void displaymenu()
                g_print("*** input zoom factor.(1.0~10.0, where 1.0 - no zoom, actual image) \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_AUDIO_CODEC_TYPE) {
+               g_print("*** set audio codec type (1: HW, 2: SW) \n");
        } else {
                g_print("*** unknown status.\n");
                quit_program();
@@ -2716,11 +2731,19 @@ static void interpret(char *cmd)
        case CURRENT_STATUS_VIDEO_CODEC_TYPE:
                {
                        int value = atoi(cmd);
-                       set_video_codec_type(value);
+                       codec_type.v_codec_type = value;
+                       g_menu_state = CURRENT_STATUS_AUDIO_CODEC_TYPE;
+
+               }
+               break;
+       case CURRENT_STATUS_AUDIO_CODEC_TYPE:
+               {
+                       int value = atoi(cmd);
+                       codec_type.a_codec_type = value;
+                       set_codec_type();
                        reset_menu_state();
                }
                break;
-
        }
 
        g_timeout_add(100, timeout_menu_display, 0);