add new api for audio_only 38/141738/5
authorEunhae Choi <eunhae1.choi@samsung.com>
Tue, 1 Aug 2017 08:58:32 +0000 (17:58 +0900)
committerEunhae Choi <eunhae1.choi@samsung.com>
Tue, 1 Aug 2017 09:42:05 +0000 (18:42 +0900)
Change-Id: I71c817a614644a3b98e9be5892a25901426bfdcc

src/player.c
test/player_test.c

index fae750f..aa6f8a2 100644 (file)
@@ -4245,7 +4245,7 @@ int player_get_max_adaptive_variant_limit(player_h player, int *pbandwidth, int
 {
        int ret = PLAYER_ERROR_NONE;
        PLAYER_INSTANCE_CHECK(player);
-       PLAYER_NULL_ARG_CHECK(pbandwidth && pwidth && pheight);
+       PLAYER_NULL_ARG_CHECK(pbandwidth || pwidth || pheight);
 
        player_cli_s *pc = (player_cli_s *) player;
        muse_player_api_e api = MUSE_PLAYER_API_GET_MAX_ADAPTIVE_VARIANT_LIMIT;
@@ -4260,9 +4260,9 @@ int player_get_max_adaptive_variant_limit(player_h player, int *pbandwidth, int
 
                player_msg_get3(ret_buf, bandwidth, INT, width, INT, height, INT, ret_val);
                if (ret_val) {
-                       *pbandwidth = bandwidth;
-                       *pwidth = width;
-                       *pheight = height;
+                       if (pbandwidth) *pbandwidth = bandwidth;
+                       if (pwidth) *pwidth = width;
+                       if (pheight) *pheight = height;
                } else {
                        ret = PLAYER_ERROR_INVALID_OPERATION;
                }
@@ -4272,3 +4272,44 @@ int player_get_max_adaptive_variant_limit(player_h player, int *pbandwidth, int
        LOGD("LEAVE 0x%X", ret);
        return ret;
 }
+
+int player_set_audio_only(player_h player, bool audio_only)
+{
+       int ret = PLAYER_ERROR_NONE;
+       PLAYER_INSTANCE_CHECK(player);
+       player_cli_s *pc = (player_cli_s *) player;
+       muse_player_api_e api = MUSE_PLAYER_API_SET_AUDIO_ONLY;
+       char *ret_buf = NULL;
+
+       LOGD("ENTER audio_only: %d", audio_only);
+
+       player_msg_send1(api, pc, ret_buf, ret, INT, audio_only);
+       g_free(ret_buf);
+
+       LOGD("LEAVE 0x%X", ret);
+       return ret;
+
+}
+
+int player_is_audio_only(player_h player, bool *paudio_only)
+{
+       PLAYER_INSTANCE_CHECK(player);
+       PLAYER_NULL_ARG_CHECK(paudio_only);
+       int ret = PLAYER_ERROR_NONE;
+       muse_player_api_e api = MUSE_PLAYER_API_IS_AUDIO_ONLY;
+       player_cli_s *pc = (player_cli_s *) player;
+       char *ret_buf = NULL;
+       int audio_only = 0;
+
+       LOGD("ENTER");
+
+       player_msg_send(api, pc, ret_buf, ret);
+       if (ret == PLAYER_ERROR_NONE) {
+               player_msg_get(audio_only, ret_buf);
+               *paudio_only = (bool)audio_only;
+       }
+       g_free(ret_buf);
+
+       LOGD("LEAVE 0x%X", ret);
+       return ret;
+}
index 3c6f451..cdfdc52 100644 (file)
@@ -142,6 +142,7 @@ enum {
        CURRENT_STATUS_SET_MAX_BANDWIDTH_VARIANT,
        CURRENT_STATUS_SET_MAX_WIDTH_VARIANT,
        CURRENT_STATUS_SET_MAX_HEIGHT_VARIANT,
+       CURRENT_STATUS_SET_AUDIO_ONLY,
 };
 
 typedef struct {
@@ -1754,6 +1755,24 @@ static void capture_video()
                g_print("failed to player_capture_video\n");
 }
 
+static void set_audio_only(int val)
+{
+       int ret = PLAYER_ERROR_NONE;
+       bool audio_only = false;
+       ret = player_is_audio_only(g_player[0], &audio_only);
+       if (ret != PLAYER_ERROR_NONE)
+               g_print("failed to get current setting. 0x%X\n", ret);
+       else
+               g_print("current audio only mode : %s\n", (audio_only) ? "enabled" : "disabled");
+       g_print("new audio only mode : %s\n", (val != 0) ? "enabled" : "disabled");
+
+       if (val != 0)
+               ret = player_set_audio_only(g_player[0], true);
+       else
+               ret = player_set_audio_only(g_player[0], false);
+       g_print("finished 0x%X\n", ret);
+}
+
 static void decoding_audio()
 {
 #if 0
@@ -1971,6 +1990,8 @@ void _interpret_main_menu(char *cmd)
                        g_menu_state = CURRENT_STATUS_SET_MAX_BANDWIDTH_VARIANT;
                } else if (strncmp(cmd, "vg", 2) == 0) {
                        get_variant_limit();
+               } else if (strncmp(cmd, "ao", 2) == 0) {
+                       g_menu_state = CURRENT_STATUS_SET_AUDIO_ONLY;
                } else {
                        g_print("unknown menu \n");
                }
@@ -2024,6 +2045,7 @@ void display_sub_basic()
        g_print("[Variant] vi. Get Streaming Variant Info\t");
        g_print("vs. Set max limit of variant\t");
        g_print("vg. Get max limit of variant\n");
+       g_print("[audio only] ao. set audio only\n");
        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");
@@ -2104,6 +2126,8 @@ static void displaymenu()
                g_print("*** set max width (default: -1) \n");
        } else if (g_menu_state == CURRENT_STATUS_SET_MAX_HEIGHT_VARIANT) {
                g_print("*** set max height (default: -1) \n");
+       } else if (g_menu_state == CURRENT_STATUS_SET_AUDIO_ONLY) {
+               g_print("*** set audio only mode (0:disable, 1:enable) \n");
        } else {
                g_print("*** unknown status.\n");
                quit_program();
@@ -2340,6 +2364,13 @@ static void interpret(char *cmd)
                        reset_menu_state();
                }
                break;
+       case CURRENT_STATUS_SET_AUDIO_ONLY:
+               {
+                       int value = atoi(cmd);
+                       set_audio_only(value);
+                       reset_menu_state();
+               }
+               break;
        }
 
        g_timeout_add(100, timeout_menu_display, 0);