[ACR-1178] Add new api for enable/disable replaygain 59/172159/9
authorGilbok Lee <gilbok.lee@samsung.com>
Mon, 12 Mar 2018 08:28:40 +0000 (17:28 +0900)
committerGilbok Lee <gilbok.lee@samsung.com>
Mon, 2 Apr 2018 09:01:55 +0000 (18:01 +0900)
Change-Id: I0222fdcc56fba4a424c9ea028c7460af0a93509f

include/player.h
src/player.c
test/player_test.c

index 3cca9b0ce4adc73797061cd7bf44a97310967a5a..248c73d829a829ee286cd486287cc5c79df2d90c 100644 (file)
@@ -1266,7 +1266,7 @@ int player_set_display_mode(player_h player, player_display_mode_e mode);
 int player_get_display_mode(player_h player, player_display_mode_e *mode);
 
 /**
- * @brief Sets the ROI(Region Of Interest) area of display.
+ * @brief Sets the ROI (Region Of Interest) area of display.
  * @since_tizen 3.0
  * @remarks If no display is set, no operation is performed and
  *          the ROI area is valid only in #PLAYER_DISPLAY_MODE_DST_ROI display mode.
@@ -2325,6 +2325,42 @@ int player_set_audio_only(player_h player, bool audio_only);
  */
 int player_is_audio_only(player_h player, bool *audio_only);
 
+/**
+ * @brief Sets the player's replaygain status.
+ * @details If the replaygain status is @c true, replaygain is applied (if contents has a replaygain tag).
+ *          If it is @c false, the replaygain isn't affected by tag and properties.
+ * @since_tizen 5.0
+ * @param[in]   player The handle to the media player
+ * @param[in]   enabled The new replaygain status: (@c true = enable, @c false = disable)
+ * @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_STATE     Invalid player state
+ * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation
+ * @pre The player state must be one of #PLAYER_STATE_IDLE, #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED.
+ * @see player_is_replaygain_enabled()
+ */
+int player_set_replaygain_enabled(player_h player, bool enabled);
+
+/**
+ * @brief Gets the player's replaygain status.
+ * @since_tizen 5.0
+ * @param[in]   player    The handle to the media player
+ * @param[out]  enabled   Pointer to store current replaygain status:
+ *                        (@c true = enabled replaygain,
+                          @c false = disabled replaygain)
+ * @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_STATE     Invalid player state
+ * @retval #PLAYER_ERROR_INVALID_OPERATION Invalid operation
+ * @pre The player state must be one of #PLAYER_STATE_IDLE, #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED.
+ * @see player_set_replaygain_enable()
+ */
+int player_is_replaygain_enabled(player_h player, bool *enabled);
+
 /**
  * @}
  */
index 016ca0c473d352b779c404da6be2ceb0760f78a2..debb1f2826068fca8347e8f43ac549e2a68180e3 100644 (file)
@@ -4707,3 +4707,42 @@ int player_360_get_field_of_view(player_h player, int *horizontal_degrees, int *
        LOGD("LEAVE 0x%X", ret);
        return ret;
 }
+
+int player_set_replaygain_enabled(player_h player, bool enabled)
+{
+       PLAYER_INSTANCE_CHECK(player);
+       int ret = PLAYER_ERROR_NONE;
+       muse_player_api_e api = MUSE_PLAYER_API_SET_REPLAYGAIN_ENABLED;
+       player_cli_s *pc = (player_cli_s *) player;
+       char *ret_buf = NULL;
+       int val = (int)enabled;
+
+       LOGD("ENTER");
+
+       player_msg_send1(api, pc, ret_buf, ret, INT, val);
+       g_free(ret_buf);
+       return ret;
+}
+
+int player_is_replaygain_enabled(player_h player, bool *enabled)
+{
+       PLAYER_INSTANCE_CHECK(player);
+       PLAYER_NULL_ARG_CHECK(enabled);
+       int ret = PLAYER_ERROR_NONE;
+       muse_player_api_e api = MUSE_PLAYER_API_IS_REPLAYGAIN_ENABLED;
+       player_cli_s *pc = (player_cli_s *) player;
+       char *ret_buf = NULL;
+       int val = -1;
+
+       LOGD("ENTER");
+
+       player_msg_send(api, pc, ret_buf, ret);
+       if (ret == PLAYER_ERROR_NONE) {
+               player_msg_get(val, ret_buf);
+               *enabled = (bool) val;
+       }
+
+       g_free(ret_buf);
+       return ret;
+}
+
index 73f9a15994083a284b02064179cc08363ad17d1b..63000c957acc918cd3bdd7453a08d722c0e34479 100644 (file)
@@ -174,6 +174,7 @@ enum {
        CURRENT_STATUS_VIDEO360_SET_ZOOM,
        CURRENT_STATUS_AUDIO_CODEC_TYPE,
        CURRENT_STATUS_VIDEO_CODEC_TYPE,
+       CURRENT_STATUS_REPLAYGAIN_ENABLE,
 };
 
 typedef struct {
@@ -2046,6 +2047,18 @@ static void video360_get_zoom()
                g_print("                                                          ==> [Player_Test] Video 360 zoom = %f\n", zoom);
 }
 
+static void set_replaygain_enabled(bool enabled)
+{
+       if (player_set_replaygain_enabled(g_player[0], enabled) != PLAYER_ERROR_NONE)
+               g_print("failed to set_replaygain_enabled\n");
+}
+
+static void is_replaygain_enabled(bool *enable)
+{
+       player_is_replaygain_enabled(g_player[0], enable);
+       g_print("                                                            ==> [Player_Test] replaygain = %d\n", *enable);
+}
+
 #ifdef USE_EVENT_HANDLER
 static void event_handler_cb(enum libinput_event_type ev_t, int x, int y, void * data, float e[3])
 {
@@ -2263,10 +2276,16 @@ void _interpret_main_menu(char *cmd)
                        g_print("unknown menu \n");
                }
        } else if (len == 3) {
-               if (strncmp(cmd, "trs", 3) == 0)
+               if (strncmp(cmd, "trs", 3) == 0) {
                        g_menu_state = CURRENT_STATUS_STREAMING_PLAYBACK_RATE;
-               else
+               } else if (strncmp(cmd, "rgs", 3) == 0) {
+                       g_menu_state = CURRENT_STATUS_REPLAYGAIN_ENABLE;
+               } else if (strncmp(cmd, "rgg", 3) == 0) {
+                       bool enable;
+                       is_replaygain_enabled(&enable);
+               } else {
                        g_print("unknown menu \n");
+               }
        } else if (len == 4) {
                if (!strncmp(cmd, "v3sp", 4))
                        video360_is_spherical();
@@ -2356,6 +2375,8 @@ void display_sub_basic()
        g_print("v3gf. Get Field Of View\n");
        g_print("[Video 360] v3sz. Set Zoom\t\t");
        g_print("v3gz. Get Zoom\n");
+       g_print("[Replaygain] rgs. Set Replaygain\t\t");
+       g_print("rgg. Get replaygain\n");
        g_print("[etc] sp. Set Progressive Download\t");
        g_print("gp. Get Progressive Download status\t");
        g_print("mp. memory playback\n");
@@ -2449,6 +2470,8 @@ static void displaymenu()
                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 if (g_menu_state == CURRENT_STATUS_REPLAYGAIN_ENABLE) {
+               g_print("*** input replaygain value.(0:disable, 1: enable) \n");
        } else {
                g_print("*** unknown status.\n");
                quit_program();
@@ -2764,6 +2787,13 @@ static void interpret(char *cmd)
                        reset_menu_state();
                }
                break;
+       case CURRENT_STATUS_REPLAYGAIN_ENABLE:
+               {
+                       int value = atoi(cmd);
+                       set_replaygain_enabled(value);
+                       reset_menu_state();
+               }
+               break;
        }
 
        g_timeout_add(100, timeout_menu_display, 0);