[v0.3.33] consider the lang code len 99/97399/1
authorEunhae Choi <eunhae1.choi@samsung.com>
Mon, 14 Nov 2016 05:42:13 +0000 (14:42 +0900)
committerEunhae Choi <eunhae1.choi@samsung.com>
Mon, 14 Nov 2016 05:42:13 +0000 (14:42 +0900)
Change-Id: Ib52fda460d60716367cd3b4f2c586185549dc79d

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

index ba22a3d..a728101 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-player
 Summary:    A Media Player API
-Version:    0.3.32
+Version:    0.3.33
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index 26a2a49..549d4a7 100644 (file)
@@ -3917,16 +3917,19 @@ int player_get_track_language_code(player_h player, player_stream_type_e type, i
        muse_player_api_e api = MUSE_PLAYER_API_GET_TRACK_LANGUAGE_CODE;
        char *ret_buf = NULL;
        char code[MUSE_MSG_MAX_LENGTH] = { 0, };
-       const int code_len = 2;
+       int code_len = 0;
 
        LOGD("ENTER");
 
        player_msg_send2(api, pc, ret_buf, ret, INT, type, INT, index);
        if (ret == PLAYER_ERROR_NONE) {
-               if (player_msg_get_string(code, ret_buf))
+               bool recv_ret = TRUE;
+               player_msg_get1_string(ret_buf, code_len, INT, code, recv_ret);
+               if (recv_ret)
                        *pcode = strndup(code, code_len);
+               else
+                       ret = PLAYER_ERROR_INVALID_OPERATION;
        }
-
        g_free(ret_buf);
        return ret;
 }
index ba0d33f..010cf38 100644 (file)
@@ -85,6 +85,7 @@ enum {
        CURRENT_STATUS_SWITCH_SUBTITLE,
        CURRENT_STATUS_NEXT_URI,
        CURRENT_STATUS_GAPLESS,
+       CURRENT_STATUS_GET_TRACK_INFO,
 };
 
 #define MAX_HANDLE 20
@@ -1618,6 +1619,35 @@ static void switch_subtitle(int index)
        }
 }
 
+static void get_track_info(int index)
+{
+       int count = 0, cur_index = 0;
+       int ret = 0;
+       char *lang_code = NULL;
+
+       if (index != PLAYER_STREAM_TYPE_AUDIO &&
+               index != PLAYER_STREAM_TYPE_TEXT) {
+               g_print("invalid stream type %d", index);
+               return;
+       }
+
+       ret = player_get_track_count(g_player[0], index, &count);
+       if (ret != PLAYER_ERROR_NONE)
+               g_print("player_get_track_count fail!!!!\n");
+       else if (count) {
+               int idx = 0;
+               player_get_current_track(g_player[0], index, &cur_index);
+               g_print("total track: %d, curr track: %d\n", count, cur_index);
+
+               for (idx = 0; idx < count; idx++) {
+                       player_get_track_language_code(g_player[0], index, idx, &lang_code);
+                       g_print("track info = [%d] %s\n", idx, lang_code);
+               }
+       } else {
+               g_print("no track\n");
+       }
+}
+
 static void capture_video()
 {
        if (player_capture_video(g_player[0], video_captured_cb, NULL) != PLAYER_ERROR_NONE)
@@ -1828,6 +1858,8 @@ void _interpret_main_menu(char *cmd)
                        get_next_uri();
                } else if (strncmp(cmd, "sg", 2) == 0) {
                        g_menu_state = CURRENT_STATUS_GAPLESS;
+               } else if (strncmp(cmd, "tl", 2) == 0) {
+                       g_menu_state = CURRENT_STATUS_GET_TRACK_INFO;
                } else {
                        g_print("unknown menu \n");
                }
@@ -1948,6 +1980,8 @@ static void displaymenu()
                g_print("*** input next uri.\n");
        } else if (g_menu_state == CURRENT_STATUS_GAPLESS) {
                g_print("*** input gapless value.(0:disable, 1: enable) \n");
+       } else if (g_menu_state == CURRENT_STATUS_GET_TRACK_INFO) {
+               g_print("*** input stream type.(1:audio, 3:text) \n");
        } else {
                g_print("*** unknown status.\n");
                quit_program();
@@ -2149,6 +2183,13 @@ static void interpret(char *cmd)
                        reset_menu_state();
                }
                break;
+       case CURRENT_STATUS_GET_TRACK_INFO:
+               {
+                       int index = atoi(cmd);
+                       get_track_info(index);
+                       reset_menu_state();
+               }
+               break;
        }
 
        g_timeout_add(100, timeout_menu_display, 0);