[0.3.79] Add internal api to select video codec type 92/164392/2
authorEunhae Choi <eunhae1.choi@samsung.com>
Tue, 19 Dec 2017 04:15:48 +0000 (13:15 +0900)
committerEunhae Choi <eunhae1.choi@samsung.com>
Tue, 19 Dec 2017 04:18:20 +0000 (13:18 +0900)
- can fix the video codec type among the sw, hw and default.
- in case of 'PLAYER_VIDEO_CODEC_TYPE_DEFAULT',
  the higher priority video codec will be selected as before.

Change-Id: I7efd32057112552dba905e8b767e5c96c7e73a6c

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

index 7413638..fd30f02 100644 (file)
@@ -30,13 +30,23 @@ extern "C" {
  * @addtogroup CAPI_MEDIA_PLAYER_MODULE
  * @{
  */
-
 typedef enum {
        ELM_WAYLAND_WIN = 1,
        ECORE_WAYLAND_WIN
 } wl_window_type;
 
 /**
+ * @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
  */
@@ -673,6 +683,40 @@ int player_360_set_field_of_view(player_h player, int horizontal_degrees, int ve
 int player_360_get_field_of_view(player_h player, int *horizontal_degrees, int *vertical_degrees);
 
 /**
+ * @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 player_get_video_codec_type()
+ */
+int 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 player_set_video_codec_type()
+ */
+int player_get_video_codec_type(player_h player, player_video_codec_type_e *ptype);
+
+/**
  * @}
  */
 
@@ -681,4 +725,3 @@ int player_360_get_field_of_view(player_h player, int *horizontal_degrees, int *
 #endif
 
 #endif /*__TIZEN_MEDIA_PLAYER_INTERNAL_H__*/
-
index 9423d7d..8f43c5b 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-player
 Summary:    A Media Player API
-Version:    0.3.78
+Version:    0.3.79
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index 45591b4..0775770 100644 (file)
@@ -381,3 +381,45 @@ int player_enable_media_packet_video_frame_decoded_cb(player_h player, bool enab
        g_free(ret_buf);
        return ret;
 }
+
+int player_set_video_codec_type(player_h player, player_video_codec_type_e 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;
+       char *ret_buf = NULL;
+
+       LOGD("ENTER %d", type);
+
+       player_msg_send1(api, pc, ret_buf, ret, INT, type);
+
+       g_free(ret_buf);
+       LOGD("LEAVE");
+       return ret;
+}
+
+int player_get_video_codec_type(player_h player, player_video_codec_type_e *ptype)
+{
+       PLAYER_INSTANCE_CHECK(player);
+       PLAYER_NULL_ARG_CHECK(ptype);
+
+       int ret = PLAYER_ERROR_NONE;
+       muse_player_api_e api = MUSE_PLAYER_API_GET_VIDEO_CODEC_TYPE;
+       player_cli_s *pc = (player_cli_s *) player;
+       char *ret_buf = NULL;
+       int type = 0;
+
+       LOGD("ENTER");
+
+       player_msg_send(api, pc, ret_buf, ret);
+       if (ret == PLAYER_ERROR_NONE) {
+               player_msg_get(type, ret_buf);
+               *ptype = type;
+       }
+
+       g_free(ret_buf);
+       LOGD("LEAVE");
+       return ret;
+}
index 531a17a..fc1c6e9 100644 (file)
@@ -152,6 +152,7 @@ enum {
        CURRENT_STATUS_SET_AUDIO_ONLY,
        CURRENT_STATUS_SET_PRE_BUFFERING_SIZE,
        CURRENT_STATUS_SET_RE_BUFFERING_SIZE,
+       CURRENT_STATUS_VIDEO_CODEC_TYPE,
 };
 
 typedef struct {
@@ -1466,6 +1467,24 @@ static void get_duration()
        g_print("                                                            ==> [Player_Test] Duration: [%d ] msec\n", duration);
 }
 
+static void set_video_codec_type(int type)
+{
+       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);
+}
+
+static void get_video_codec_type()
+{
+       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);
+}
+
 static void audio_frame_decoded_cb_ex(bool sync)
 {
        int ret;
@@ -2020,6 +2039,10 @@ void _interpret_main_menu(char *cmd)
                        g_menu_state = CURRENT_STATUS_SET_AUDIO_ONLY;
                } 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;
+               } else if (strncmp(cmd, "C2", 2) == 0) {
+                       get_video_codec_type();
                } else {
                        g_print("unknown menu \n");
                }
@@ -2077,6 +2100,8 @@ void display_sub_basic()
        g_print("[subtitle] A. Set(or change) subtitle path\n");
        g_print("[subtitle] ss. Select(or change) subtitle track\n");
        g_print("[Video Capture] C. Capture \n");
+       g_print("[Video Codec] C1. Set vcodec type (1:HW, 2:SW)\t");
+       g_print("C2. Get vcodec type\n");
        g_print("[next uri] su. set next uri. \t");
        g_print("gu. get next uri. \t");
        g_print("sg. set gapless. \n");
@@ -2161,6 +2186,8 @@ 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 {
                g_print("*** unknown status.\n");
                quit_program();
@@ -2419,6 +2446,13 @@ 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;
 
        }