[0.3.123] remove deprecated internal api
[platform/core/api/player.git] / test / player_test.c
index 1e7d55f..27302c3 100644 (file)
@@ -13,6 +13,8 @@
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
+#define USE_EVENT_HANDLER
+
 #include <player.h>
 #include <player_internal.h>
 #include <sound_manager.h>
 #include <appcore-efl.h>
 #include <Elementary.h>
 #include <Ecore.h>
-#include <Ecore_Wayland.h>
+#include <stdio.h>
+#include <string.h>
 #ifdef _ACTIVATE_EOM_
 #include <eom.h>
 #endif
 
+#ifdef USE_EVENT_HANDLER
+#include <mm_navevent_handler.h>
+#endif
+
 #ifdef PACKAGE
 #undef PACKAGE
 #endif
 #define LOG_TAG "PLAYER_TEST"
 
 #define MAX_STRING_LEN 2048
-#define MMTS_SAMPLELIST_INI_DEFAULT_PATH "/opt/etc/mmts_filelist.ini"
-#define PLAYER_TEST_DUMP_PATH_PREFIX   "/home/owner/content/dump_pcm_"
-#define INI_SAMPLE_LIST_MAX 9
+#define PLAYER_TEST_DUMP_PATH_PREFIX   "/home/owner/dump_pcm_"
 #define DEFAULT_HTTP_TIMEOUT -1
 
+#include <system_info.h>
+#include <stdlib.h>
+typedef enum {
+       TIZEN_PROFILE_UNKNOWN = 0,
+       TIZEN_PROFILE_MOBILE = 0x1,
+       TIZEN_PROFILE_WEARABLE = 0x2,
+       TIZEN_PROFILE_TV = 0x4,
+       TIZEN_PROFILE_IVI = 0x8,
+       TIZEN_PROFILE_COMMON = 0x10,
+} tizen_profile_e;
+
+typedef struct {
+       uint64_t mask;
+       FILE *fp_out;
+} audio_pcm_dump_t;
+
+#ifdef USE_EVENT_HANDLER
+static void event_handler_cb(enum libinput_event_type ev_t, int x, int y, void *data, float e[3]);
+static void event_handler_set_dov_fov();
+static void event_handler_set_window_parameters();
+mm_navevent_handler_h event_handler;
+mm_navevent_handler_size_s image_size;
+#endif
+
+static tizen_profile_e _get_tizen_profile()
+{
+       char *profileName;
+       static tizen_profile_e profile = TIZEN_PROFILE_UNKNOWN;
+
+       if (__builtin_expect(profile != TIZEN_PROFILE_UNKNOWN, 1))
+               return profile;
+
+       system_info_get_platform_string("http://tizen.org/feature/profile", &profileName);
+       switch (*profileName) {
+       case 'm':
+       case 'M':
+               profile = TIZEN_PROFILE_MOBILE;
+               break;
+       case 'w':
+       case 'W':
+               profile = TIZEN_PROFILE_WEARABLE;
+               break;
+       case 't':
+       case 'T':
+               profile = TIZEN_PROFILE_TV;
+               break;
+       case 'i':
+       case 'I':
+               profile = TIZEN_PROFILE_IVI;
+               break;
+       default: // common or unknown ==> ALL ARE COMMON.
+               profile = TIZEN_PROFILE_COMMON;
+       }
+       free(profileName);
+
+       return profile;
+}
+#define TIZEN_TV  ((_get_tizen_profile()) == TIZEN_PROFILE_TV)
+
 static gboolean g_memory_playback = FALSE;
 static char g_uri[MAX_STRING_LEN];
 static char g_subtitle_uri[MAX_STRING_LEN];
@@ -63,6 +127,7 @@ static int _save(unsigned char *src, int length);
 #if DUMP_OUTBUF
 FILE *fp_out1 = NULL;
 FILE *fp_out2 = NULL;
+GList *audio_dump_list = NULL;
 #endif
 
 enum {
@@ -70,21 +135,50 @@ enum {
        CURRENT_STATUS_HANDLE_NUM,
        CURRENT_STATUS_FILENAME,
        CURRENT_STATUS_VOLUME,
-       CURRENT_STATUS_SOUND_TYPE,
        CURRENT_STATUS_SOUND_STREAM_INFO,
        CURRENT_STATUS_MUTE,
        CURRENT_STATUS_POSITION_TIME,
        CURRENT_STATUS_LOOPING,
        CURRENT_STATUS_DISPLAY_SURFACE_CHANGE,
+       CURRENT_STATUS_EXPORT_VIDEO_FRAME,
        CURRENT_STATUS_DISPLAY_MODE,
+       CURRENT_STATUS_DISPLAY_DST_ROI_AREA,
        CURRENT_STATUS_DISPLAY_ROTATION,
        CURRENT_STATUS_DISPLAY_VISIBLE,
        CURRENT_STATUS_SUBTITLE_FILENAME,
        CURRENT_STATUS_AUDIO_EQUALIZER,
        CURRENT_STATUS_PLAYBACK_RATE,
        CURRENT_STATUS_STREAMING_PLAYBACK_RATE,
-       CURRENT_STATUS_SWITCH_SUBTITLE,
+       CURRENT_STATUS_SET_TRACK_TYPE,
+       CURRENT_STATUS_SET_TRACK_INDEX,
        CURRENT_STATUS_NEXT_URI,
+       CURRENT_STATUS_GAPLESS,
+       CURRENT_STATUS_GET_TRACK_INFO,
+       CURRENT_STATUS_POSITION_ACCURATE,
+       CURRENT_STATUS_SET_MAX_BANDWIDTH_VARIANT,
+       CURRENT_STATUS_SET_MAX_WIDTH_VARIANT,
+       CURRENT_STATUS_SET_MAX_HEIGHT_VARIANT,
+       CURRENT_STATUS_SET_AUDIO_ONLY,
+       CURRENT_STATUS_SET_PRE_BUFFERING_SIZE,
+       CURRENT_STATUS_SET_RE_BUFFERING_SIZE,
+       CURRENT_STATUS_VIDEO360_SET_ENABLE,
+       CURRENT_STATUS_VIDEO360_SET_DOV,
+       CURRENT_STATUS_VIDEO360_SET_DOV1,
+       CURRENT_STATUS_VIDEO360_SET_FOV,
+       CURRENT_STATUS_VIDEO360_SET_FOV1,
+       CURRENT_STATUS_VIDEO360_SET_ZOOM,
+       CURRENT_STATUS_VIDEO360_SET_ZOOM_WITH_FOV,
+       CURRENT_STATUS_VIDEO360_SET_ZOOM_WITH_FOV1,
+       CURRENT_STATUS_VIDEO360_SET_ZOOM_WITH_FOV2,
+       CURRENT_STATUS_VIDEO_CODEC_TYPE,
+       CURRENT_STATUS_REPLAYGAIN_ENABLE,
+       CURRENT_STATUS_AUDIO_OFFLOAD,
+       CURRENT_STATUS_PITCH_CONTROL,
+       CURRENT_STATUS_PITCH_VALUE,
+       CURRENT_STATUS_EXPORT_PCM_OPTION,
+       CURRENT_STATUS_EXPORT_PCM_CH,
+       CURRENT_STATUS_EXPORT_PCM_RATE,
+       CURRENT_STATUS_EXPORT_PCM_MIME,
 };
 
 #define MAX_HANDLE 20
@@ -97,7 +191,7 @@ static Evas_Object *g_external_win_id;
 static Evas_Object *selected_win_id;
 static Evas_Object *g_eo[MAX_HANDLE] = { 0, };
 
-static int g_current_surface_type = PLAYER_DISPLAY_TYPE_OVERLAY;
+static int g_current_surface_type = -1;
 
 typedef struct {
        Evas_Object *win;
@@ -113,11 +207,10 @@ static player_h g_player[MAX_HANDLE] = { 0, };
 
 int g_handle_num = 1;
 int g_menu_state = CURRENT_STATUS_MAINMENU;
-char g_file_list[9][256];
 gboolean quit_pushing;
 sound_stream_info_h g_stream_info_h = NULL;
 
-static void win_del(void *data, Evas_Object * obj, void *event)
+static void win_del(void *data, Evas_Object *obj, void *event)
 {
        elm_exit();
 }
@@ -144,7 +237,7 @@ static Evas_Object *create_win(const char *name)
        return eo;
 }
 
-static Evas_Object *create_image_object(Evas_Object * eo_parent)
+static Evas_Object *create_image_object(Evas_Object *eo_parent)
 {
        if (!eo_parent)
                return NULL;
@@ -157,7 +250,7 @@ static Evas_Object *create_image_object(Evas_Object * eo_parent)
        return eo;
 }
 
-void create_render_rect_and_bg(Evas_Object * win)
+void create_render_rect_and_bg(Evas_Object *win)
 {
        if (!win) {
                g_print("no win");
@@ -224,7 +317,7 @@ int eom_get_output_id(const char *output_name)
 
 static void eom_notify_cb_output_add(eom_output_id output_id, void *user_data)
 {
-       appdata *info = (appdata *) user_data;
+       appdata *info = (appdata *)user_data;
 
        if (info->hdmi_output_id != output_id) {
                g_print("[eom] OUTPUT ADDED. SKIP. my output ID is %d\n", info->hdmi_output_id);
@@ -247,7 +340,7 @@ static void eom_notify_cb_output_add(eom_output_id output_id, void *user_data)
 
 static void eom_notify_cb_output_remove(eom_output_id output_id, void *user_data)
 {
-       appdata *info = (appdata *) user_data;
+       appdata *info = (appdata *)user_data;
        player_state_e state;
 
        if (info->hdmi_output_id != output_id) {
@@ -282,7 +375,7 @@ static void eom_notify_cb_output_remove(eom_output_id output_id, void *user_data
 
 static void eom_notify_cb_mode_changed(eom_output_id output_id, void *user_data)
 {
-       appdata *info = (appdata *) user_data;
+       appdata *info = (appdata *)user_data;
        eom_output_mode_e mode = EOM_OUTPUT_MODE_NONE;
 
        if (info->hdmi_output_id != output_id) {
@@ -296,7 +389,7 @@ static void eom_notify_cb_mode_changed(eom_output_id output_id, void *user_data)
 
 static void eom_notify_cb_attribute_changed(eom_output_id output_id, void *user_data)
 {
-       appdata *info = (appdata *) user_data;
+       appdata *info = (appdata *)user_data;
 
        eom_output_attribute_e attribute = EOM_OUTPUT_ATTRIBUTE_NONE;
        eom_output_attribute_state_e state = EOM_OUTPUT_ATTRIBUTE_STATE_NONE;
@@ -383,6 +476,7 @@ static int app_create(void *data)
 #ifdef _ACTIVATE_EOM_
        eom_output_mode_e output_mode = EOM_OUTPUT_MODE_NONE;
 #endif
+
        /* use gl backend */
        elm_config_accel_preference_set("opengl");
 
@@ -437,6 +531,21 @@ static int app_create(void *data)
        eom_set_mode_changed_cb(eom_notify_cb_mode_changed, ad);
        eom_set_attribute_changed_cb(eom_notify_cb_attribute_changed, ad);
 #endif
+
+#ifdef USE_EVENT_HANDLER
+       if (mm_navevent_handler_create(&event_handler,
+                       MM_NAVEVENT_HANDLER_DEVICE_TYPE_TOUCH) != MM_NAVEVENT_HANDLER_ERROR_NONE) {
+               g_print ("Error during handler creation\n");
+               return -1;
+       }
+
+       if (mm_navevent_handler_set_cb(event_handler, event_handler_cb, NULL) !=
+                       MM_NAVEVENT_HANDLER_ERROR_NONE) {
+               g_print ("Error during callback set\n");
+               return -1;
+       }
+#endif
+
        return 0;
 }
 
@@ -445,6 +554,10 @@ static int app_terminate(void *data)
        appdata *ad = data;
        int i = 0;
 
+#ifdef USE_EVENT_HANDLER
+       mm_navevent_handler_destroy(event_handler);
+#endif
+
        for (i = 0; i < MAX_HANDLE; i++) {
                if (g_eo[i]) {
                        evas_object_del(g_eo[i]);
@@ -484,28 +597,6 @@ static void prepared_cb(void *user_data)
        g_print("[Player_Test] prepared_cb!!!!\n");
 }
 
-static void _audio_frame_decoded_cb_ex(player_audio_raw_data_s * audio_raw_frame, void *user_data)
-{
-       player_audio_raw_data_s *audio_raw = audio_raw_frame;
-
-       if (!audio_raw)
-               return;
-
-       g_print("[Player_Test] decoded_cb_ex! channel: %d channel_mask: %llu\n", audio_raw->channel, audio_raw->channel_mask);
-
-#if DUMP_OUTBUF
-       if (audio_raw->channel_mask == 1 && fp_out1)
-               fwrite((guint8 *) audio_raw->data, 1, audio_raw->size, fp_out1);
-       else if (audio_raw->channel_mask == 2 && fp_out2)
-               fwrite((guint8 *) audio_raw->data, 1, audio_raw->size, fp_out2);
-#endif
-}
-
-static void progress_down_cb(player_pd_message_type_e type, void *user_data)
-{
-       g_print("[Player_Test] progress_down_cb!!!! type : %d\n", type);
-}
-
 static void buffering_cb(int percent, void *user_data)
 {
        g_print("[Player_Test] buffering_cb!!!! percent : %d\n", percent);
@@ -531,6 +622,17 @@ static void interrupted_cb(player_interrupted_code_e code, void *user_data)
        g_print("[Player_Test] interrupted_cb!!!! code : %d\n", code);
 }
 
+static void video_changed_cb(int width, int height, int fps, int bit_rate, void *user_data)
+{
+       g_print("[Player_Test] video_changed_cb!!!! %d x %d, %d, %d \n", width, height, fps, bit_rate);
+
+#ifdef USE_EVENT_HANDLER
+       image_size.width = width;
+       image_size.height = height;
+       event_handler_set_window_parameters();
+#endif
+}
+
 #if 0
 static void audio_frame_decoded_cb(unsigned char *data, unsigned int size, void *user_data)
 {
@@ -580,7 +682,7 @@ static int _save(unsigned char *src, int length)
 
        return TRUE;
 }
-
+#ifdef NO_USE_CODE
 static void reset_display()
 {
        int i = 0;
@@ -593,7 +695,7 @@ static void reset_display()
                }
        }
 }
-
+#endif
 static void input_filename(char *filename)
 {
        int len = strlen(filename);
@@ -613,7 +715,7 @@ static void input_filename(char *filename)
                        g_print("player create is failed\n");
        }
 
-       strncpy(g_uri, filename, len);
+       strncpy(g_uri, filename, len+1);
        g_uri[len] = '\0';
 
 #if 0
@@ -629,7 +731,7 @@ static void input_filename(char *filename)
 
        file = g_mapped_file_new(ext, FALSE, &error);
        file_size = g_mapped_file_get_length(file);
-       g_media_mem = (guint8 *) g_mapped_file_get_contents(file);
+       g_media_mem = (guint8 *)g_mapped_file_get_contents(file);
 
        g_sprintf(uri, "mem://ext=%s,size=%d", ext ? ext : "", file_size);
        g_print("[uri] = %s\n", uri);
@@ -658,7 +760,7 @@ static void player_set_memory_buffer_test()
 
        file = g_mapped_file_new(g_uri, FALSE, NULL);
        file_size = g_mapped_file_get_length(file);
-       g_media_mem = (guint8 *) g_mapped_file_get_contents(file);
+       g_media_mem = (guint8 *)g_mapped_file_get_contents(file);
 
        int ret = player_set_memory_buffer(g_player[0], (void *)g_media_mem, file_size);
        g_print("player_set_memory_buffer ret : %d\n", ret);
@@ -707,7 +809,7 @@ static void buffer_need_video_data_cb(unsigned int size, void *user_data)
 
        fp = fopen(fname, "rb");
        if (fp) {
-               buff_ptr = (guint8 *) g_malloc0(1048576);
+               buff_ptr = (guint8 *)g_malloc0(1048576);
                if (!buff_ptr) {
                        g_print("no free space\n");
                        fclose(fp);
@@ -728,17 +830,20 @@ static void buffer_need_video_data_cb(unsigned int size, void *user_data)
                g_video_pkt = NULL;
        }
 
-       media_packet_create_alloc(g_video_fmt, NULL, NULL, &g_video_pkt);
+       if (media_packet_create_alloc(g_video_fmt, NULL, NULL, &g_video_pkt) != MEDIA_PACKET_ERROR_NONE) {
+               g_print("media_packet_create_alloc failed\n");
+               goto EXIT;
+       }
 
        g_print("packet = %p, src = %p\n", g_video_pkt, src);
 
        if (media_packet_get_buffer_data_ptr(g_video_pkt, &src) != MEDIA_PACKET_ERROR_NONE)
                goto EXIT;
 
-       if (media_packet_set_pts(g_video_pkt, (uint64_t) pts) != MEDIA_PACKET_ERROR_NONE)
+       if (media_packet_set_pts(g_video_pkt, (uint64_t)pts) != MEDIA_PACKET_ERROR_NONE)
                goto EXIT;
 
-       if (media_packet_set_buffer_size(g_video_pkt, (uint64_t) real_read_len) != MEDIA_PACKET_ERROR_NONE)
+       if (media_packet_set_buffer_size(g_video_pkt, (uint64_t)real_read_len) != MEDIA_PACKET_ERROR_NONE)
                goto EXIT;
 
        memcpy(src, buff_ptr, real_read_len);
@@ -747,11 +852,8 @@ static void buffer_need_video_data_cb(unsigned int size, void *user_data)
        player_push_media_stream(g_player[0], g_video_pkt);
 #endif
 
- EXIT:
-       if (buff_ptr) {
-               g_free(buff_ptr);
-               buff_ptr = NULL;
-       }
+EXIT:
+       g_free(buff_ptr);
 }
 
 int audio_packet_count = 0;
@@ -781,7 +883,7 @@ static void buffer_need_audio_data_cb(unsigned int size, void *user_data)
 
        fp = fopen(fname, "rb");
        if (fp) {
-               buff_ptr = (guint8 *) g_malloc0(1048576);
+               buff_ptr = (guint8 *)g_malloc0(1048576);
                if (!buff_ptr) {
                        g_print("no free space\n");
                        fclose(fp);
@@ -802,17 +904,21 @@ static void buffer_need_audio_data_cb(unsigned int size, void *user_data)
                media_packet_destroy(g_audio_pkt);
                g_audio_pkt = NULL;
        }
-       media_packet_create_alloc(g_audio_fmt, NULL, NULL, &g_audio_pkt);
+
+       if (media_packet_create_alloc(g_audio_fmt, NULL, NULL, &g_audio_pkt) != MEDIA_PACKET_ERROR_NONE) {
+               g_print("media_packet_create_alloc failed\n");
+               goto EXIT;
+       }
 
        g_print("packet = %p, src = %p\n", g_audio_pkt, src);
 
        if (media_packet_get_buffer_data_ptr(g_audio_pkt, &src) != MEDIA_PACKET_ERROR_NONE)
                goto EXIT;
 
-       if (media_packet_set_pts(g_audio_pkt, (uint64_t) audio_pts) != MEDIA_PACKET_ERROR_NONE)
+       if (media_packet_set_pts(g_audio_pkt, (uint64_t)audio_pts) != MEDIA_PACKET_ERROR_NONE)
                goto EXIT;
 
-       if (media_packet_set_buffer_size(g_audio_pkt, (uint64_t) real_read_len) != MEDIA_PACKET_ERROR_NONE)
+       if (media_packet_set_buffer_size(g_audio_pkt, (uint64_t)real_read_len) != MEDIA_PACKET_ERROR_NONE)
                goto EXIT;
 
        memcpy(src, buff_ptr, real_read_len);
@@ -822,11 +928,9 @@ static void buffer_need_audio_data_cb(unsigned int size, void *user_data)
 #endif
 
        audio_pts += audio_dur;
- EXIT:
-       if (buff_ptr) {
-               g_free(buff_ptr);
-               buff_ptr = NULL;
-       }
+
+EXIT:
+       g_free(buff_ptr);
 }
 
 static void set_content_info(bool is_push_mode)
@@ -894,12 +998,17 @@ static void _player_prepare(bool async)
                player_set_subtitle_path(g_player[0], g_subtitle_uri);
                player_set_subtitle_updated_cb(g_player[0], subtitle_updated_cb, (void *)g_player[0]);
        }
+       if (g_current_surface_type == -1) {
+               g_print("You must set display surface type before setting prepare.\n");
+               return;
+       }
+
        if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
-               player_set_display(g_player[0], g_current_surface_type, GET_DISPLAY(selected_win_id));
                player_set_buffering_cb(g_player[0], buffering_cb, (void *)g_player[0]);
                player_set_completed_cb(g_player[0], completed_cb, (void *)g_player[0]);
                player_set_interrupted_cb(g_player[0], interrupted_cb, (void *)g_player[0]);
                player_set_error_cb(g_player[0], error_cb, (void *)g_player[0]);
+               player_set_video_stream_changed_cb(g_player[0], video_changed_cb, (void *)g_player[0]);
                if (g_memory_playback)
                        player_set_memory_buffer_test();
                else
@@ -907,11 +1016,11 @@ static void _player_prepare(bool async)
        } else {
                int i = 0;
                for (i = 0; i < g_handle_num; i++) {
-                       player_set_display(g_player[i], g_current_surface_type, g_eo[i]);
                        player_set_buffering_cb(g_player[i], buffering_cb, (void *)g_player[i]);
                        player_set_completed_cb(g_player[i], completed_cb, (void *)g_player[i]);
                        player_set_interrupted_cb(g_player[i], interrupted_cb, (void *)g_player[i]);
                        player_set_error_cb(g_player[i], error_cb, (void *)g_player[i]);
+                       player_set_video_stream_changed_cb(g_player[0], video_changed_cb, (void *)g_player[0]);
                        if (g_memory_playback)
                                player_set_memory_buffer_test();
                        else
@@ -968,6 +1077,9 @@ static void _player_prepare(bool async)
        if (is_es_push_mode)
                pthread_create(&g_feed_video_thread_id, NULL, (void *)feed_video_data_thread_func, NULL);
 
+#ifdef USE_EVENT_HANDLER
+       event_handler_set_dov_fov();
+#endif
 }
 
 static void _player_unprepare()
@@ -1017,8 +1129,7 @@ static void _player_unprepare()
                        }
                }
        }
-       /* attention! surface(evas) -> unprepare -> surface(evas) : evas object will disappear. */
-       reset_display();
+
        memset(g_subtitle_uri, 0, sizeof(g_subtitle_uri));
        player_state_e state;
        if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
@@ -1037,11 +1148,8 @@ static void _player_destroy()
        int i = 0;
 
        if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
-               player_unprepare(g_player[0]);
-               for (i = 0; i < g_handle_num; i++) {
-                       player_destroy(g_player[i]);
-                       g_player[i] = 0;
-               }
+               player_destroy(g_player[0]);
+               g_player[0] = 0;
        } else {
                for (i = 0; i < g_handle_num; i++) {
                        if (g_player[i] != NULL) {
@@ -1064,6 +1172,20 @@ static void _player_destroy()
                media_packet_destroy(g_audio_pkt);
 
 #if DUMP_OUTBUF
+       GList *list = NULL;
+       audio_pcm_dump_t *a_data = NULL;
+
+       list = audio_dump_list;
+       while(list) {
+               a_data = (audio_pcm_dump_t *)list->data;
+               list = g_list_next(list);
+               if (a_data && a_data->fp_out)
+                               fclose(a_data->fp_out);
+               g_free(a_data);
+       }
+       g_list_free(audio_dump_list);
+       audio_dump_list = NULL;
+
        if (fp_out1)
                fclose(fp_out1);
        if (fp_out2)
@@ -1154,35 +1276,41 @@ static void _player_state()
        g_print("                                                            ==> [Player_Test] Current Player State : %d\n", state);
 }
 
-static void _player_set_progressive_download()
+static void _player_enable_tsurf_pool(void)
 {
-       player_set_progressive_download_path(g_player[0], "/home/owner/test.pd");
-       player_set_progressive_download_message_cb(g_player[0], progress_down_cb, (void *)g_player[0]);
-}
+       bool enabled = FALSE;
 
-static void _player_get_progressive_download_status()
-{
-       int bRet;
-       unsigned long curr, total;
-       bRet = player_get_progressive_download_status(g_player[0], &curr, &total);
-       g_print("player_get_progressive_download_status return[%d]           ==> [Player_Test] progressive download status : %lu/%lu\n", bRet, curr, total);
+       if (TIZEN_TV) {
+               g_print("not support at TV profile");
+               return;
+       }
+
+       player_is_enabled_tsurf_pool(g_player[0], &enabled);
+
+       g_print("tbm surface pool will be %s", (enabled) ? "disabled" : "enabled");
+       player_enable_tsurf_pool(g_player[0], !enabled);
 }
 
-static void set_next_uri(char * uri)
+static void set_next_uri(char *uri)
 {
-#ifndef TIZEN_TV
-       player_set_gapless(g_player[0], TRUE);
+       if (TIZEN_TV) {
+               g_print("not support at TV profile");
+               return;
+       }
+
        if (player_set_next_uri(g_player[0], uri) != PLAYER_ERROR_NONE)
                g_print("fail to set next uri");
-#else
-       g_print("not support at TV profile");
-#endif
 }
 
 static void get_next_uri()
 {
-#ifndef TIZEN_TV
        char *uri;
+
+       if (TIZEN_TV) {
+               g_print("not support at TV profile");
+               return;
+       }
+
        if (player_get_next_uri(g_player[0], &uri) != PLAYER_ERROR_NONE) {
                g_print("fail to get next uri");
                return;
@@ -1192,9 +1320,6 @@ static void get_next_uri()
                g_print("next_uri = %s", uri);
                free(uri);
        }
-#else
-       g_print("not support at TV profile");
-#endif
 }
 
 static void set_volume(float volume)
@@ -1215,21 +1340,19 @@ static void set_mute(bool mute)
                g_print("failed to set_mute\n");
 }
 
-static void get_mute(bool * mute)
+static void get_mute(bool *mute)
 {
        player_is_muted(g_player[0], mute);
        g_print("                                                            ==> [Player_Test] mute = %d\n", *mute);
 }
 
-static void set_sound_type(sound_type_e type)
-{
-       if (player_set_sound_type(g_player[0], type) != PLAYER_ERROR_NONE)
-               g_print("failed to set sound type(%d)\n", type);
-       else
-               g_print("set sound type(%d) success", type);
-}
-
-void focus_callback(sound_stream_info_h stream_info, sound_stream_focus_change_reason_e reason, const char *extra_info, void *user_data)
+void focus_callback(sound_stream_info_h stream_info,
+                                       sound_stream_focus_mask_e focus_mask,
+                                       sound_stream_focus_state_e focus_state,
+                                       sound_stream_focus_change_reason_e reason,
+                                       int sound_behavior,
+                                       const char *extra_info,
+                                       void *user_data)
 {
        g_print("FOCUS callback is called, reason(%d), extra_info(%s), userdata(%p)", reason, extra_info, user_data);
        return;
@@ -1253,16 +1376,16 @@ static void set_sound_stream_info(int type)
                sound_device_h device = NULL;
                sound_device_type_e device_type;
 
-               if ((ret = sound_manager_get_current_device_list(SOUND_DEVICE_ALL_MASK, &device_list))) {
-                       g_print("failed to sound_manager_get_current_device_list(), ret(0x%x)\n", ret);
-                       return;
+               if ((ret = sound_manager_get_device_list(SOUND_DEVICE_ALL_MASK, &device_list))) {
+                       g_print("failed to sound_manager_get_device_list(), ret(0x%x)\n", ret);
+                       goto END;
                }
                while (!(ret = sound_manager_get_next_device(device_list, &device))) {
                        if ((ret = sound_manager_get_device_type(device, &device_type))) {
                                g_print("failed to sound_manager_get_device_type(), ret(0x%x)\n", ret);
                                goto END;
                        }
-                       if (device_type == SOUND_DEVICE_BLUETOOTH || device_type == SOUND_DEVICE_USB_AUDIO) {
+                       if (device_type == SOUND_DEVICE_BLUETOOTH_MEDIA || device_type == SOUND_DEVICE_USB_AUDIO) {
                                if ((ret = sound_manager_add_device_for_stream_routing(g_stream_info_h, device))) {
                                        g_print("failed to sound_manager_add_device_for_stream_routing(), ret(0x%x)\n", ret);
                                        goto END;
@@ -1280,17 +1403,64 @@ static void set_sound_stream_info(int type)
                }
        }
 
-       if (player_set_audio_policy_info(g_player[0], g_stream_info_h) != PLAYER_ERROR_NONE)
+       if (player_set_sound_stream_info(g_player[0], g_stream_info_h) != PLAYER_ERROR_NONE)
                g_print("failed to set sound stream information(%p)\n", g_stream_info_h);
        else
                g_print("set stream information(%p) success", g_stream_info_h);
 
- END:
+END:
        if (device_list)
                sound_manager_free_device_list(device_list);
        return;
 }
 
+void variant_cb(int bandwidth, int width, int height, void *user_data)
+{
+       g_print("                                                            ==> [Player_Test][b]%d, [w]%d, [h]%d\n", bandwidth, width, height);
+}
+
+static void get_variant_info()
+{
+       player_foreach_adaptive_variant(g_player[0], (player_adaptive_variant_cb)variant_cb, g_player[0]);
+}
+
+static void get_variant_limit()
+{
+       int bandwidth, width, height;
+       player_get_max_adaptive_variant_limit(g_player[0], &bandwidth, &width, &height);
+       g_print("                                                            ==> [Player_Test]get [b]%d, [w]%d, [h]%d\n", bandwidth, width, height);
+}
+
+static void set_variant_limit(int bandwidth, int width, int height)
+{
+       g_print("                                                            ==> [Player_Test]set [b]%d, [w]%d, [h]%d\n", bandwidth, width, height);
+       player_set_max_adaptive_variant_limit(g_player[0], bandwidth, width, height);
+}
+
+static void set_buffer_size(int prebuffer, int rebuffer)
+{
+       int ret = 0;
+       int buffer_ms = 0, rebuffer_ms = 0;
+
+       ret = player_get_streaming_buffering_time(g_player[0], &buffer_ms, &rebuffer_ms);
+       if (ret != PLAYER_ERROR_NONE)
+               g_print("failed to get buffering time. 0x%X\n", ret);
+       else
+               g_print("current buffer size %d ms / %d ms\n", buffer_ms, rebuffer_ms);
+
+       g_print("new buffer size %d ms / %d ms\n", prebuffer, rebuffer);
+
+       player_set_streaming_buffering_time(g_player[0], prebuffer, rebuffer);
+}
+
+static void get_buffering_position()
+{
+       int ret;
+       int start = 0, end = 0;
+       ret = player_get_streaming_download_progress(g_player[0], &start, &end);
+       g_print("                                                            ==> [Player_Test] buffering pos ()%d return : %d ~ %d\n", ret, start, end);
+}
+
 static void get_position()
 {
        int position = 0;
@@ -1299,9 +1469,9 @@ static void get_position()
        g_print("                                                            ==> [Player_Test] player_get_play_position()%d return : %d\n", ret, position);
 }
 
-static void set_position(int position)
+static void set_position(int position, bool accurate)
 {
-       if (player_set_play_position(g_player[0], position, TRUE, seek_completed_cb, g_player[0]) != PLAYER_ERROR_NONE)
+       if (player_set_play_position(g_player[0], position, accurate, seek_completed_cb, g_player[0]) != PLAYER_ERROR_NONE)
                g_print("failed to set position\n");
 }
 
@@ -1325,23 +1495,22 @@ static void get_duration()
        g_print("                                                            ==> [Player_Test] Duration: [%d ] msec\n", duration);
 }
 
-static void audio_frame_decoded_cb_ex(bool sync)
+static void set_video_codec_type(int v_codec_type)
 {
        int ret;
-#if DUMP_OUTBUF
-       fp_out1 = fopen("/tmp/out1.pcm", "wb");
-       fp_out2 = fopen("/tmp/out2.pcm", "wb");
-       if (!fp_out1 || !fp_out2) {
-               g_print("File open error\n");
-               return;
-       }
-#endif
 
-       ret = player_set_pcm_extraction_mode(g_player[0], sync, _audio_frame_decoded_cb_ex, &ret);
-       g_print("                                                            ==> [Player_Test] player_set_audio_frame_decoded_cb_ex(sync:%d) ret:%d\n", sync, ret);
+       ret = player_set_video_codec_type_ex(g_player[0], v_codec_type);
+       g_print("                                                            ==> [Player_Test] video codec type (%d) return: %d\n", v_codec_type, ret);
+
+}
+
+static void get_codec_type(void)
+{
+       int ret;
+       player_video_codec_type_ex_e vtype = 0;
 
-       ret = player_set_pcm_spec(g_player[0], "F32LE", 44100, 2);
-       g_print("[Player_Test] set_pcm_spec return: %d\n", ret);
+       ret = player_get_video_codec_type_ex(g_player[0], &vtype);
+       g_print("                                                            ==> [Player_Test] Video Codec type: [%d][ret 0x%X]\n", vtype, ret);
 }
 
 static void get_stream_info()
@@ -1397,6 +1566,25 @@ static void get_stream_info()
        g_print("                                                            ==> [Player_Test] Width: [%d ] , Height: [%d ] \n", w, h);
 }
 
+static void set_gapless(bool gapless)
+{
+       if (TIZEN_TV) {
+               g_print("not support at TV profile");
+               return;
+       }
+
+       if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
+               if (player_set_gapless(g_player[0], gapless) != PLAYER_ERROR_NONE)
+                       g_print("failed set_gapless\n");
+       } else {
+               int i = 0;
+               for (i = 0; i < g_handle_num; i++) {
+                       if (player_set_gapless(g_player[i], gapless) != PLAYER_ERROR_NONE)
+                               g_print("failed to set_gapless\n");
+               }
+       }
+}
+
 static void set_looping(bool looping)
 {
        if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
@@ -1411,12 +1599,151 @@ static void set_looping(bool looping)
        }
 }
 
-static void get_looping(bool * looping)
+static void get_looping(bool *looping)
 {
        player_is_looping(g_player[0], looping);
        g_print("                                                            ==> [Player_Test] looping = %d\n", *looping);
 }
 
+void _video_decoded_cb(media_packet_h packet, void *user_data)
+{
+       media_packet_destroy(packet);
+}
+
+static void set_video_frame_decoded_cb(void)
+{
+       player_set_media_packet_video_frame_decoded_cb(g_player[0], _video_decoded_cb, g_player[0]);
+}
+
+void _audio_decoded_cb(media_packet_h packet, void *user_data)
+{
+       int mime, channel, rate;
+       uint64_t channel_mask;
+       uint64_t size;
+       void *pkt_data;
+
+       if (!packet) {
+               g_print("invalid packet param");
+               return;
+       }
+
+       media_packet_get_format(packet, &g_audio_fmt);
+       media_format_get_audio_info(g_audio_fmt, (media_format_mimetype_e *)&mime, &channel, &rate, NULL, NULL);
+       media_format_get_audio_channel_mask(g_audio_fmt, &channel_mask);
+       media_packet_get_buffer_data_ptr(packet, &pkt_data);
+       media_packet_get_buffer_size(packet, &size);
+
+       g_print("[ received ] channel: %d size: %"G_GUINT64_FORMAT", mask %"G_GUINT64_FORMAT"\n", channel, size, channel_mask);
+
+#if DUMP_OUTBUF
+       GList *list = NULL;
+       audio_pcm_dump_t *a_data = NULL;
+       FILE *fp_dump = NULL;
+       char file_path[32];
+
+       list = audio_dump_list;
+       while(list) {
+               a_data = (audio_pcm_dump_t *)list->data;
+               list = g_list_next(list);
+
+               if (a_data && a_data->mask == channel_mask) {
+                       fp_dump = a_data->fp_out;
+                       break;
+               }
+       }
+
+       a_data = NULL;
+       if (!fp_dump) {
+               a_data = g_try_malloc(sizeof(audio_pcm_dump_t));
+               if (a_data == NULL) {
+                       g_print("failed to malloc");
+                       goto EXIT;
+               }
+
+               snprintf(file_path, 32, "/tmp/out%"G_GUINT64_FORMAT".pcm", channel_mask);
+
+               a_data->mask = channel_mask;
+               a_data->fp_out = fopen(file_path, "wb");
+               if (!a_data->fp_out) {
+                       g_free(a_data);
+                       g_print("[ERROR] failed to open file\n");
+                       goto EXIT;
+               }
+
+               audio_dump_list = g_list_append(audio_dump_list, a_data);
+               fp_dump = a_data->fp_out;
+       }
+
+       fwrite((guint8 *)pkt_data, 1, size, fp_dump);
+#endif
+
+EXIT:
+       media_packet_destroy(packet);
+}
+
+static media_format_mimetype_e __convert_audio_pcm_str_to_media_format_mime(char *audio_pcm_str)
+{
+       int len = strlen("S16LE");
+       if (!audio_pcm_str) {
+               g_print("audio pcm str is NULL\n");
+               return MEDIA_FORMAT_MAX;
+       }
+
+       if (!strncasecmp(audio_pcm_str, "S16LE", len))
+               return MEDIA_FORMAT_PCM_S16LE;
+       else if (!strncasecmp(audio_pcm_str, "S24LE", len))
+               return MEDIA_FORMAT_PCM_S24LE;
+       else if (!strncasecmp(audio_pcm_str, "S32LE", len))
+               return MEDIA_FORMAT_PCM_S32LE;
+       else if (!strncasecmp(audio_pcm_str, "S16BE", len))
+               return MEDIA_FORMAT_PCM_S16BE;
+       else if (!strncasecmp(audio_pcm_str, "S24BE", len))
+               return MEDIA_FORMAT_PCM_S24BE;
+       else if (!strncasecmp(audio_pcm_str, "S32BE", len))
+               return MEDIA_FORMAT_PCM_S32BE;
+       else if (!strncasecmp(audio_pcm_str, "F32LE", len))
+               return MEDIA_FORMAT_PCM_F32LE;
+       else if (!strncasecmp(audio_pcm_str, "F32BE", len))
+               return MEDIA_FORMAT_PCM_F32BE;
+       else if (!strncasecmp(audio_pcm_str, "U16LE", len))
+               return MEDIA_FORMAT_PCM_U16LE;
+       else if (!strncasecmp(audio_pcm_str, "U24LE", len))
+               return MEDIA_FORMAT_PCM_U24LE;
+       else if (!strncasecmp(audio_pcm_str, "U32LE", len))
+               return MEDIA_FORMAT_PCM_U32LE;
+       else if (!strncasecmp(audio_pcm_str, "U16BE", len))
+               return MEDIA_FORMAT_PCM_U16BE;
+       else if (!strncasecmp(audio_pcm_str, "U24BE", len))
+               return MEDIA_FORMAT_PCM_U24BE;
+       else if (!strncasecmp(audio_pcm_str, "U32BE", len))
+               return MEDIA_FORMAT_PCM_U32BE;
+       else {
+               g_print("Not supported audio pcm format str : %s\n", audio_pcm_str);
+               return MEDIA_FORMAT_MAX;
+       }
+}
+
+static void set_audio_frame_decoded_cb(player_audio_extract_option_e opt, char* mime, int ch, int rate)
+{
+       media_format_mimetype_e type = __convert_audio_pcm_str_to_media_format_mime(mime);
+
+       if (type == MEDIA_FORMAT_MAX) {
+               g_print("failed to convert the mime : %s\n", mime);
+               return;
+       }
+
+       media_format_create(&g_audio_fmt);
+       media_format_set_audio_mime(g_audio_fmt, type);
+       media_format_set_audio_channel(g_audio_fmt, ch);
+       media_format_set_audio_samplerate(g_audio_fmt, rate);
+
+       g_print("==========> [Player_Test] option = 0x%X, %s(%d), %d, %d\n", opt, mime, type, ch, rate);
+       player_set_media_packet_audio_frame_decoded_cb(g_player[0], g_audio_fmt, opt, _audio_decoded_cb, g_player[0]);
+
+       media_format_unref(g_audio_fmt);
+       g_audio_fmt = NULL;
+}
+
 static void change_surface(int option)
 {
        player_display_type_e surface_type = 0;
@@ -1431,7 +1758,7 @@ static void change_surface(int option)
                surface_type = PLAYER_DISPLAY_TYPE_OVERLAY;
                g_print("change surface type to X\n");
                break;
-#ifdef EVAS_RENDERER_SUPPORT
+#ifdef TIZEN_FEATURE_EVAS_RENDERER
        case 1:
                /* EVAS surface */
                surface_type = PLAYER_DISPLAY_TYPE_EVAS;
@@ -1448,43 +1775,22 @@ static void change_surface(int option)
                return;
        }
 
-       if (surface_type == g_current_surface_type) {
-               g_print("same with the previous surface type(%d)\n", g_current_surface_type);
-               return;
-       } else {
-               player_state_e player_state = PLAYER_STATE_NONE;
-               ret = player_get_state(g_player[0], &player_state);
-               if (ret)
-                       g_print("failed to player_get_state(), ret(0x%x)\n", ret);
-
-               reset_display();
-
-               if (surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
-#ifdef _ACTIVATE_EOM_
-                       hdmi_output_id = eom_get_output_id("HDMI");
-                       if (hdmi_output_id == 0)
-                               g_print("[eom] error : HDMI output id is NULL.\n");
-
-                       eom_get_output_mode(hdmi_output_id, &output_mode);
-                       if (output_mode == EOM_OUTPUT_MODE_NONE) {
+       player_state_e player_state = PLAYER_STATE_NONE;
+       ret = player_get_state(g_player[0], &player_state);
+       if (ret)
+               g_print("failed to player_get_state(), ret(0x%x)\n", ret);
+#ifdef NO_USE_CODE
+       reset_display();
 #endif
-                               if (!g_win_id) {
-                                       g_win_id = create_win(PACKAGE);
-                                       if (g_win_id == NULL)
-                                               return;
-                                       g_print("create win_id %p\n", g_win_id);
-                                       create_render_rect_and_bg(g_win_id);
-                                       elm_win_activate(g_win_id);
-                                       evas_object_show(g_win_id);
-                                       g_win_id = selected_win_id;
-                               }
+       if (surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
 #ifdef _ACTIVATE_EOM_
-                       } else {
-                               /* for external */
-                       }
+               hdmi_output_id = eom_get_output_id("HDMI");
+               if (hdmi_output_id == 0)
+                       g_print("[eom] error : HDMI output id is NULL.\n");
+
+               eom_get_output_mode(hdmi_output_id, &output_mode);
+               if (output_mode == EOM_OUTPUT_MODE_NONE) {
 #endif
-                       ret = player_set_display(g_player[0], surface_type, GET_DISPLAY(selected_win_id));
-               } else {
                        if (!g_win_id) {
                                g_win_id = create_win(PACKAGE);
                                if (g_win_id == NULL)
@@ -1493,7 +1799,26 @@ static void change_surface(int option)
                                create_render_rect_and_bg(g_win_id);
                                elm_win_activate(g_win_id);
                                evas_object_show(g_win_id);
+                               g_win_id = selected_win_id;
                        }
+#ifdef _ACTIVATE_EOM_
+               } else {
+                       /* for external */
+               }
+#endif
+               ret = player_set_display(g_player[0], surface_type, GET_DISPLAY(selected_win_id));
+       } else {
+               if (!g_win_id) {
+                       g_win_id = create_win(PACKAGE);
+                       if (g_win_id == NULL)
+                               return;
+                       g_print("create win_id %p\n", g_win_id);
+                       create_render_rect_and_bg(g_win_id);
+                       elm_win_activate(g_win_id);
+                       evas_object_show(g_win_id);
+               }
+               if (surface_type == PLAYER_DISPLAY_TYPE_EVAS) {
+                       /* surface type is PLAYER_DISPLAY_TYPE_NONE */
                        int i = 0;
                        for (i = 0; i < g_handle_num; i++) {
                                /* Create evas image object for EVAS surface */
@@ -1508,13 +1833,15 @@ static void change_surface(int option)
                                ret = player_set_display(g_player[i], surface_type, g_eo[i]);
 
                        }
+               } else {
+                       g_print("surface type is PLAYER_DISPLAY_TYPE_NONE\n");
                }
-               if (ret) {
-                       g_print("failed to set display, surface_type(%d)\n", surface_type);
-                       return;
-               }
-               g_current_surface_type = surface_type;
        }
+       if (ret) {
+               g_print("failed to set display, surface_type(%d)\n", surface_type);
+               return;
+       }
+       g_current_surface_type = surface_type;
        return;
 }
 
@@ -1531,10 +1858,19 @@ static void get_display_mode()
        g_print("                                                            ==> [Player_Test] Display mode: [%d ] \n", mode);
 }
 
+static void set_display_roi_area(int x, int y, int width, int height)
+{
+       player_set_display_roi_area(g_player[0], x, y, width, height);
+       g_print("                                                            ==> [Player_Test] Display roi area: [x(%d) y(%d) width(%d) height(%d)] \n", x, y, width, height);
+}
+
 static void set_display_rotation(int rotation)
 {
        if (player_set_display_rotation(g_player[0], rotation) != PLAYER_ERROR_NONE)
                g_print("failed to set_display_rotation\n");
+#ifdef USE_EVENT_HANDLER
+       event_handler_set_window_parameters();
+#endif
 }
 
 static void get_display_rotation()
@@ -1550,7 +1886,7 @@ static void set_display_visible(bool visible)
                g_print("failed to player_set_x11_display_visible\n");
 }
 
-static void get_display_visible(bool * visible)
+static void get_display_visible(bool *visible)
 {
        player_is_display_visible(g_player[0], visible);
        g_print("                                                            ==> [Player_Test] Video Overlay Display Visible = %d\n", *visible);
@@ -1566,26 +1902,75 @@ static void input_subtitle_filename(char *subtitle_filename)
        strncpy(g_subtitle_uri, subtitle_filename, len);
        g_print("subtitle uri is set to %s\n", g_subtitle_uri);
        player_set_subtitle_path(g_player[0], g_subtitle_uri);
+       player_set_subtitle_updated_cb(g_player[0], subtitle_updated_cb, (void *)g_player[0]);
 }
 
-static void switch_subtitle(int index)
+static void set_track(int type, int index)
 {
        char *lang_code = NULL;
-       if (player_select_track(g_player[0], PLAYER_STREAM_TYPE_TEXT, index) != PLAYER_ERROR_NONE)
+
+       if (player_select_track(g_player[0], type, index) != PLAYER_ERROR_NONE)
                g_print("player_select_track failed\n");
 
-       if (player_get_track_language_code(g_player[0], PLAYER_STREAM_TYPE_TEXT, index, &lang_code) == PLAYER_ERROR_NONE) {
-               g_print("selected track code %s\n", lang_code);
+       if (player_get_track_language_code(g_player[0], type, index, &lang_code) == PLAYER_ERROR_NONE) {
+               g_print("selected track lang code %s\n", lang_code);
                free(lang_code);
        }
 }
 
+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)
                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
@@ -1611,7 +1996,7 @@ static void decoding_audio()
 static void set_audio_eq(int value)
 {
        bool available = FALSE;
-       int index, min, max;
+       int index, min = 0, max = 0;
 
        if (value) {
                if (player_audio_effect_equalizer_is_available(g_player[0], &available) != PLAYER_ERROR_NONE)
@@ -1623,9 +2008,7 @@ static void set_audio_eq(int value)
                                (player_audio_effect_set_equalizer_band_level(g_player[0], index / 2, max) != PLAYER_ERROR_NONE))
                                g_print("failed to player_audio_effect_set_equalizer_band_level index %d, level %d\n", index / 2, max);
                }
-       }
-
-       else {
+       } else {
                if (player_audio_effect_equalizer_clear(g_player[0]) != PLAYER_ERROR_NONE)
                        g_print("failed to player_audio_effect_equalizer_clear\n");
        }
@@ -1647,20 +2030,232 @@ static void get_audio_eq()
        g_print("                                                            ==> [Player_Test] eq bands frequency range: [%d] \n", value);
 }
 
+static void video360_is_spherical(void)
+{
+       bool spherical;
+
+       if (player_360_is_content_spherical(g_player[0], &spherical) != PLAYER_ERROR_NONE)
+               g_print("failed to get content spherical info\n");
+       else
+               g_print("                                                          ==> [Player_Test] Video 360 content = %s\n", spherical ? "spherical" : "---");
+
+}
+
+static void video360_set_enable(bool enable)
+{
+       bool enabled = false;
+
+#ifdef USE_EVENT_HANDLER
+       event_handler_set_dov_fov();
+#endif
+
+       if (player_360_set_enabled(g_player[0], enable) != PLAYER_ERROR_NONE)
+               g_print("failed to %s video 360 mode\n", enable ? "enable" : "disable");
+
+       if (player_360_is_enabled(g_player[0], &enabled) != PLAYER_ERROR_NONE)
+               g_print("failed to get video 360 mode status\n");
+       else
+               g_print("                                                          ==> [Player_Test] Video 360 mode = %s\n", enabled ? "enabled" : "disabled");
+}
+
+static void video360_get_fov()
+{
+       int hfov, vfov;
+
+       if (player_360_get_field_of_view(g_player[0], &hfov, &vfov) != PLAYER_ERROR_NONE)
+               g_print("failed to get video 360 field of view\n");
+       else
+               g_print("                                                          ==> [Player_Test] Video 360 FOV = %dx%d deg.\n", hfov, vfov);
+}
+
+static void video360_set_fov(int hfov, int vfov)
+{
+#ifdef USE_EVENT_HANDLER
+       mm_navevent_handler_size_s fov;
+
+       fov.width = hfov;
+       fov.height = vfov;
+       mm_navevent_handler_set_fov_size(event_handler, fov);
+#endif
+       if (player_360_set_field_of_view(g_player[0], hfov, vfov) != PLAYER_ERROR_NONE)
+               g_print("failed to set video 360 field of view\n");
+
+       video360_get_fov();
+}
+
+static void video360_get_dov()
+{
+       float yaw, pitch;
+
+       if (player_360_get_direction_of_view(g_player[0], &yaw, &pitch) != PLAYER_ERROR_NONE)
+               g_print("failed to get video 360 direction of view\n");
+       else
+               g_print("                                                          ==> [Player_Test] Video 360 DOV yaw = %d, pitch = %d deg.\n", (int)(yaw * 180.0f / M_PI), (int)(pitch * 180.0f / M_PI));
+}
+
+static void video360_set_dov(int yaw_deg, int pitch_deg)
+{
+       float angles[3];
+
+       angles[0] = M_PI * yaw_deg / 180.0f;
+       angles[1] = M_PI * pitch_deg / 180.0f;
+       angles[2] = 0;
+
+#ifdef USE_EVENT_HANDLER
+       mm_navevent_handler_set_angles(event_handler, angles);
+#endif
+
+       if (player_360_set_direction_of_view(g_player[0], angles[0], angles[1]) != PLAYER_ERROR_NONE)
+               g_print("failed to set video 360 direction of view\n");
+
+       video360_get_dov();
+}
+
+static void video360_get_zoom()
+{
+       float zoom;
+
+       if (player_360_get_zoom(g_player[0], &zoom) != PLAYER_ERROR_NONE)
+               g_print("failed to get video 360 zoom\n");
+       else
+               g_print("                                                          ==> [Player_Test] Video 360 zoom = %f\n", zoom);
+}
+
+static void video360_set_zoom(float zoom)
+{
+       if (player_360_set_zoom(g_player[0], zoom) != PLAYER_ERROR_NONE)
+               g_print("failed to set video 360 zoom\n");
+
+       video360_get_zoom();
+}
+
+static void video360_set_zoom_with_fov(float zoom, int hfov, int vfov)
+{
+#ifdef USE_EVENT_HANDLER
+       mm_navevent_handler_size_s fov;
+
+       fov.width = hfov;
+       fov.height = vfov;
+       mm_navevent_handler_set_fov_size(event_handler, fov);
+#endif
+       if (player_360_set_zoom_with_field_of_view(g_player[0], zoom, hfov, vfov) != PLAYER_ERROR_NONE)
+               g_print("failed to set video 360 zoom with field of view\n");
+
+       video360_get_fov();
+       video360_get_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);
+}
+
+static bool _supported_media_format_cb(media_format_mimetype_e format, void *user_data)
+{
+       g_print("- supported format mimetype 0x%X\n", format);
+       return true;
+}
+
+static void set_audio_offload_enabled(bool enabled)
+{
+       bool is_enabled = false;
+
+       player_audio_offload_is_enabled(g_player[0], &is_enabled);
+       g_print("[Player_Test] offload setting %d -> %d\n", is_enabled, enabled);
+
+       player_audio_offload_foreach_supported_format(g_player[0], _supported_media_format_cb, (void *)g_player[0]);
+
+       if (player_audio_offload_set_enabled(g_player[0], enabled) != PLAYER_ERROR_NONE)
+               g_print("failed to set audio offload\n");
+}
+
+static void pitch_set_enabled(bool enabled)
+{
+       bool is_enabled = false;
+       player_audio_pitch_is_enabled(g_player[0], &is_enabled);
+
+       g_print("pitch enabled %d -> %d \n", is_enabled, enabled);
+       if (player_audio_pitch_set_enabled(g_player[0], enabled) != PLAYER_ERROR_NONE)
+               g_print("failed to pitch_set_enabled\n");
+}
+
+static void pitch_set_value(float level)
+{
+       float curr = 0.0;
+       player_audio_pitch_get_value(g_player[0], &curr);
+
+       g_print("pitch level %1.3f -> %1.3f \n", curr, level);
+       if (player_audio_pitch_set_value(g_player[0], level) != PLAYER_ERROR_NONE)
+               g_print("failed to set pitch value\n");
+}
+
+#ifdef USE_EVENT_HANDLER
+static void event_handler_cb(enum libinput_event_type ev_t, int x, int y, void *data, float e[3])
+{
+       if (ev_t == LIBINPUT_EVENT_TOUCH_MOTION)
+               if (player_360_set_direction_of_view(g_player[0], e[0], e[1]) != PLAYER_ERROR_NONE)
+                       g_print("Event handler callback: failed to set direction of view\n");
+}
+
+static void event_handler_set_dov_fov()
+{
+       float angles[3];
+       mm_navevent_handler_size_s fov;
+
+       if (player_360_get_direction_of_view(g_player[0], &angles[0], &angles[1]) != PLAYER_ERROR_NONE) {
+               g_print("Failed to get video360 direction of view\n");
+               return;
+       }
+       if (player_360_get_field_of_view(g_player[0], &fov.width, &fov.height) != PLAYER_ERROR_NONE) {
+               g_print("Failed to get video360 field of view\n");
+               return;
+       }
+       mm_navevent_handler_set_angles(event_handler, angles);
+       mm_navevent_handler_set_fov_size(event_handler, fov);
+}
+
+static void event_handler_set_window_parameters()
+{
+       player_display_rotation_e window_orientation;
+       mm_navevent_handler_size_s window_size;
+       float image_ratio;
+
+       player_get_display_rotation(g_player[0], &window_orientation);
+       elm_win_screen_size_get(selected_win_id, NULL, NULL, &window_size.width, &window_size.height);
+
+       image_ratio = (float)image_size.width / (float)image_size.height;
+
+       if (window_orientation == PLAYER_DISPLAY_ROTATION_NONE ||
+                       window_orientation == PLAYER_DISPLAY_ROTATION_180) {
+               window_size.height = (int)((float)window_size.width / image_ratio);
+       } else {
+               window_size.height = window_size.width;
+               window_size.width = (int)((float)window_size.width * image_ratio);
+       }
+
+       mm_navevent_handler_set_window_parameters(event_handler,
+                       (mm_navevent_handler_orientation_e)window_orientation, window_size);
+}
+#endif
+
 void quit_program()
 {
-       int i = 0;
 
        if (g_pcm_fd)
                fclose(g_pcm_fd);
 
-       for (i = 0; i < g_handle_num; i++) {
-               if (g_player[i] != NULL) {
-                       player_unprepare(g_player[i]);
-                       player_destroy(g_player[i]);
-                       g_player[i] = 0;
-               }
+       if (g_player[0] != NULL || g_player[1] != NULL) {
+               _player_unprepare();
+               _player_destroy();
        }
+
        elm_exit();
 
        if (g_audio_fmt)
@@ -1682,24 +2277,6 @@ void _interpret_main_menu(char *cmd)
        if (len == 1) {
                if (strncmp(cmd, "a", 1) == 0) {
                        g_menu_state = CURRENT_STATUS_FILENAME;
-               } else if (strncmp(cmd, "1", 1) == 0) {
-                       play_with_ini(g_file_list[0]);
-               } else if (strncmp(cmd, "2", 1) == 0) {
-                       play_with_ini(g_file_list[1]);
-               } else if (strncmp(cmd, "3", 1) == 0) {
-                       play_with_ini(g_file_list[2]);
-               } else if (strncmp(cmd, "4", 1) == 0) {
-                       play_with_ini(g_file_list[3]);
-               } else if (strncmp(cmd, "5", 1) == 0) {
-                       play_with_ini(g_file_list[4]);
-               } else if (strncmp(cmd, "6", 1) == 0) {
-                       play_with_ini(g_file_list[5]);
-               } else if (strncmp(cmd, "7", 1) == 0) {
-                       play_with_ini(g_file_list[6]);
-               } else if (strncmp(cmd, "8", 1) == 0) {
-                       play_with_ini(g_file_list[7]);
-               } else if (strncmp(cmd, "9", 1) == 0) {
-                       play_with_ini(g_file_list[8]);
                } else if (strncmp(cmd, "b", 1) == 0) {
                        _player_play();
                } else if (strncmp(cmd, "c", 1) == 0) {
@@ -1716,8 +2293,6 @@ void _interpret_main_menu(char *cmd)
                        float left;
                        float right;
                        get_volume(&left, &right);
-               } else if (strncmp(cmd, "z", 1) == 0) {
-                       g_menu_state = CURRENT_STATUS_SOUND_TYPE;
                } else if (strncmp(cmd, "k", 1) == 0) {
                        g_menu_state = CURRENT_STATUS_SOUND_STREAM_INFO;
                } else if (strncmp(cmd, "h", 1) == 0) {
@@ -1770,62 +2345,107 @@ void _interpret_main_menu(char *cmd)
        } else if (len == 2) {
                if (strncmp(cmd, "pr", 2) == 0) {
                        /* sync */
-                       _player_prepare(FALSE);
+                       if (g_current_surface_type == -1) {
+                               g_print("You must set display surface type before setting prepare. please 'pr' after setting display surface type.\n");
+                               g_menu_state = CURRENT_STATUS_DISPLAY_SURFACE_CHANGE;
+                       } else
+                               _player_prepare(FALSE);
                } else if (strncmp(cmd, "pa", 2) == 0) {
                        /* async */
-                       _player_prepare(TRUE);
+                       if (g_current_surface_type == -1) {
+                               g_print("You must set display surface type before setting prepare. please 'pr' after setting display surface type.\n");
+                               g_menu_state = CURRENT_STATUS_DISPLAY_SURFACE_CHANGE;
+                       } else {
+                               _player_prepare(TRUE);
+                       }
                } else if (strncmp(cmd, "un", 2) == 0) {
                        _player_unprepare();
                } else if (strncmp(cmd, "dt", 2) == 0) {
                        _player_destroy();
-               } else if (strncmp(cmd, "sp", 2) == 0) {
-                       _player_set_progressive_download();
-               } else if (strncmp(cmd, "gp", 2) == 0) {
-                       _player_get_progressive_download_status();
                } else if (strncmp(cmd, "mp", 2) == 0) {
                        g_memory_playback = (g_memory_playback ? FALSE : TRUE);
                        g_print("memory playback = %d\n", g_memory_playback);
                } else if (strncmp(cmd, "ds", 2) == 0) {
                        g_menu_state = CURRENT_STATUS_DISPLAY_SURFACE_CHANGE;
+               } else if (strncmp(cmd, "dr", 2) == 0) {
+                       g_menu_state = CURRENT_STATUS_DISPLAY_DST_ROI_AREA;
                } else if (strncmp(cmd, "nb", 2) == 0) {
                        g_menu_state = CURRENT_STATUS_HANDLE_NUM;
                } else if (strncmp(cmd, "tr", 2) == 0) {
                        g_menu_state = CURRENT_STATUS_PLAYBACK_RATE;
-               } else if (strncmp(cmd, "ss", 2) == 0) {
-                       g_menu_state = CURRENT_STATUS_SWITCH_SUBTITLE;
-               } else if (strncmp(cmd, "X3", 2) == 0) {
-                       audio_frame_decoded_cb_ex(TRUE);
-               } else if (strncmp(cmd, "X4", 2) == 0) {
-                       audio_frame_decoded_cb_ex(FALSE);
+               } else if (strncmp(cmd, "X5", 2) == 0) {
+                       g_menu_state = CURRENT_STATUS_EXPORT_PCM_OPTION;
+               } else if (strncmp(cmd, "ep", 2) == 0) {
+                       _player_enable_tsurf_pool();
                } else if (strncmp(cmd, "su", 2) == 0) {
                        g_menu_state = CURRENT_STATUS_NEXT_URI;
                } else if (strncmp(cmd, "gu", 2) == 0) {
                        get_next_uri();
+               } else if (strncmp(cmd, "sg", 2) == 0) {
+                       g_menu_state = CURRENT_STATUS_GAPLESS;
+               } else if (strncmp(cmd, "tg", 2) == 0) {
+                       g_menu_state = CURRENT_STATUS_GET_TRACK_INFO;
+               } else if (strncmp(cmd, "ts", 2) == 0) {
+                       g_menu_state = CURRENT_STATUS_SET_TRACK_TYPE;
+               } else if (strncmp(cmd, "vi", 2) == 0) {
+                       get_variant_info();
+               } else if (strncmp(cmd, "vs", 2) == 0) {
+                       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 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_codec_type();
+               } else if (!strncmp(cmd, "si", 2)) {
+                       video360_is_spherical();
+               } else if (!strncmp(cmd, "se", 2)) {
+                       g_menu_state = CURRENT_STATUS_VIDEO360_SET_ENABLE;
+               } else if (!strncmp(cmd, "sd", 2)) {
+                       g_menu_state = CURRENT_STATUS_VIDEO360_SET_DOV;
+               } else if (!strncmp(cmd, "sf", 2)) {
+                       g_menu_state = CURRENT_STATUS_VIDEO360_SET_FOV;
+               } else if (!strncmp(cmd, "sz", 2)) {
+                       g_menu_state = CURRENT_STATUS_VIDEO360_SET_ZOOM;
+               } else if (strncmp(cmd, "lb", 2) == 0) {
+                       get_buffering_position();
+               } else if (strncmp(cmd, "ol", 2) == 0) {
+                       g_menu_state = CURRENT_STATUS_AUDIO_OFFLOAD;
+               } else if (strncmp(cmd, "pc", 2) == 0) {
+                       g_menu_state = CURRENT_STATUS_PITCH_CONTROL;
+               } else if (strncmp(cmd, "pv", 2) == 0) {
+                       g_menu_state = CURRENT_STATUS_PITCH_VALUE;
                } else {
                        g_print("unknown menu \n");
                }
-       } else {
-               if (strncmp(cmd, "trs", 3) == 0)
+       } else if (len == 3) {
+               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 if (!strncmp(cmd, "szz", 3)) {
+                       g_menu_state = CURRENT_STATUS_VIDEO360_SET_ZOOM_WITH_FOV;
+               } else {
                        g_print("unknown menu \n");
+               }
+       } else {
+               g_print("unknown menu \n");
        }
 }
 
 void display_sub_basic()
 {
-       int idx;
        g_print("\n");
        g_print("=========================================================================================\n");
        g_print("                          Player Test (press q to quit) \n");
        g_print("-----------------------------------------------------------------------------------------\n");
-       g_print("*. Sample List in [%s]      \t", MMTS_SAMPLELIST_INI_DEFAULT_PATH);
-       g_print("nb. num. of handles \n");
-       for (idx = 1; idx <= INI_SAMPLE_LIST_MAX; idx++) {
-               if (strlen(g_file_list[idx - 1]) > 0)
-                       g_print("%d. Play [%s]\n", idx, g_file_list[idx - 1]);
-       }
-       g_print("-----------------------------------------------------------------------------------------\n");
        g_print("[playback] a. Create\t");
        g_print("pr. Prepare  \t");
        g_print("pa. Prepare async \t");
@@ -1839,13 +2459,14 @@ void display_sub_basic()
        g_print("[ volume ] f. Set Volume\t");
        g_print("g. Get Volume\t");
        g_print("z. Set Sound type\t");
-       g_print("k. Set Sound Stream Info.\t");
+       g_print("k. Set Sound Stream Info.\n");
        g_print("[ mute ] h. Set Mute\t");
        g_print("i. Get Mute\n");
        g_print("[audio eq] E. Set Audio EQ\t");
        g_print("H. Get Audio EQ\n");
        g_print("[position] j. Set Position \t");
-       g_print("l. Get Position\n");
+       g_print("l. Get Position\t");
+       g_print("lb. Get buffering position\n");
        g_print("[trick] tr. set playback rate\n");
        g_print("[duration] m. Get Duration\n");
        g_print("[Stream Info] n. Get stream info (Video Size, codec, audio stream info, and tag info)\n");
@@ -1854,20 +2475,40 @@ void display_sub_basic()
        g_print("[display] v. Set display visible\t");
        g_print("w. Get display visible\n");
        g_print("[display] ds. Change display surface type\n");
+       g_print("[display] dr. set display roi area\n");
        g_print("[overlay display] r. Set display mode\t");
        g_print("s. Get display mode\n");
-       g_print("[overlay display] t. Set display Rotation\t");
-       g_print("[Track] tl. Get Track language info(single only)\n");
+       g_print("[overlay display] t. Set display Rotation\n");
+       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("[Track] tg. Get Track info\n");
+       g_print("[Track] ts. Set track\n");
        g_print("[Video Capture] C. Capture \n");
+       g_print("[Video Codec] C1. Set codec type (1:HW, 2:SW)\t");
+       g_print("C2. Get codec type\n");
        g_print("[next uri] su. set next uri. \t");
        g_print("gu. get next uri. \t");
+       g_print("sg. set gapless. \n");
+       g_print("[audio_frame_decoded_cb] X5. set audio decoded cb\n");
+       g_print("[video_frame_decoded_cb] ep. enable tbm surface pool\n");
+       g_print("[buffering] bf. set new buffering size\n");
+       g_print("[Video 360] si. check spherical info\t");
+       g_print("se. Set Enable\n");
+       g_print("[Video 360] sd. Set Direction Of View\t");
+       g_print("sf. Set Field Of View\n");
+       g_print("[Video 360] sz. Set Zoom\t\t");
+       g_print("szz. Set Zoom with FOV\n");
+       g_print("[Replaygain] rgs. Set Replaygain\t\t");
+       g_print("rgg. Get replaygain\n");
+       g_print("[Offload] ol. Set audio offload\n");
+       g_print("[pitch] pc. enable pitch control\t");
+       g_print("pv. Set pitch value\n");
        g_print("[etc] sp. Set Progressive Download\t");
-       g_print("gp. Get Progressive Download status\n");
+       g_print("gp. Get Progressive Download status\t");
        g_print("mp. memory playback\n");
-       g_print("[audio_frame_decoded_cb_ex] X3. set audio_cb with sync\t");
-       g_print("X4. set audio_cb with async \n");
        g_print("\n");
        g_print("=========================================================================================\n");
 }
@@ -1882,20 +2523,24 @@ static void displaymenu()
                g_print("*** input mediapath.\n");
        } else if (g_menu_state == CURRENT_STATUS_VOLUME) {
                g_print("*** input volume value.(0~1.0)\n");
-       } else if (g_menu_state == CURRENT_STATUS_SOUND_TYPE) {
-               g_print("*** input sound type.(0:SYSTEM 1:NOTIFICATION 2:ALARM 3:RINGTONE 4:MEDIA 5:CALL 6:VOIP 7:FIXED)\n");
        } else if (g_menu_state == CURRENT_STATUS_SOUND_STREAM_INFO) {
                g_print("*** input sound stream type.(0:MEDIA 1:SYSTEM 2:ALARM 3:NOTIFICATION 4:EMERGENCY 5:VOICE_INFORMATION 9:MEDIA_EXT_ONLY)\n");
        } else if (g_menu_state == CURRENT_STATUS_MUTE) {
                g_print("*** input mute value.(0: Not Mute, 1: Mute) \n");
        } else if (g_menu_state == CURRENT_STATUS_POSITION_TIME) {
                g_print("*** input position value(msec)\n");
+       } else if (g_menu_state == CURRENT_STATUS_POSITION_ACCURATE) {
+               g_print("*** input accurate value(0/1)\n");
        } else if (g_menu_state == CURRENT_STATUS_LOOPING) {
                g_print("*** input looping value.(0: Not Looping, 1: Looping) \n");
        } else if (g_menu_state == CURRENT_STATUS_DISPLAY_SURFACE_CHANGE) {
-               g_print("*** input display surface type.(0: X surface, 1: EVAS surface) \n");
+               g_print("*** input display surface type.(0: Wayland surface, 1: EVAS surface, 2: No use surface (e.g: audio playback)) \n");
+       } else if (g_menu_state == CURRENT_STATUS_EXPORT_VIDEO_FRAME) {
+               g_print("*** set video_decoded_cb (0: none, 1: set cb) \n");
        } else if (g_menu_state == CURRENT_STATUS_DISPLAY_MODE) {
-               g_print("*** input display mode value.(0: LETTER BOX, 1: ORIGIN SIZE, 2: FULL_SCREEN, 3: CROPPED_FULL, 4: ORIGIN_OR_LETTER) \n");
+               g_print("*** input display mode value.(0: LETTER BOX, 1: ORIGIN SIZE, 2: FULL_SCREEN, 3: CROPPED_FULL, 4: ORIGIN_OR_LETTER, 5:ROI) \n");
+       } else if (g_menu_state == CURRENT_STATUS_DISPLAY_DST_ROI_AREA) {
+               g_print("*** input display roi value sequentially.(x, y, w, h)\n");
        } else if (g_menu_state == CURRENT_STATUS_DISPLAY_ROTATION) {
                g_print("*** input display rotation value.(0: NONE, 1: 90, 2: 180, 3: 270, 4:F LIP_HORZ, 5: FLIP_VERT ) \n");
        } else if (g_menu_state == CURRENT_STATUS_DISPLAY_VISIBLE) {
@@ -1906,22 +2551,64 @@ static void displaymenu()
                g_print(" *** input audio eq value.(0: UNSET, 1: SET) \n");
        } else if (g_menu_state == CURRENT_STATUS_PLAYBACK_RATE || g_menu_state == CURRENT_STATUS_STREAMING_PLAYBACK_RATE) {
                g_print(" *** input playback rate.(-5.0 ~ 5.0)\n");
-       } else if (g_menu_state == CURRENT_STATUS_SWITCH_SUBTITLE) {
-               int count = 0, cur_index = 0;
-               int ret = 0;
-
-               ret = player_get_track_count(g_player[0], PLAYER_STREAM_TYPE_TEXT, &count);
-               if (ret != PLAYER_ERROR_NONE)
-                       g_print("player_get_track_count fail!!!!\n");
-               else if (count) {
-                       g_print("Total subtitle tracks = %d \n", count);
-                       player_get_current_track(g_player[0], PLAYER_STREAM_TYPE_TEXT, &cur_index);
-                       g_print("Current index = %d \n", cur_index);
-                       g_print(" *** input correct index 0 to %d\n:", (count - 1));
-               } else
-                       g_print("no track\n");
+       } else if (g_menu_state == CURRENT_STATUS_SET_TRACK_TYPE) {
+               g_print(" *** input track type.(1:audio, 3:text)\n");
+       } else if (g_menu_state == CURRENT_STATUS_SET_TRACK_INDEX) {
+               g_print(" *** input track index\n");
        } else if (g_menu_state == CURRENT_STATUS_NEXT_URI) {
                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 track type.(1:audio, 3:text) \n");
+       } else if (g_menu_state == CURRENT_STATUS_SET_MAX_BANDWIDTH_VARIANT) {
+               g_print("*** set max bandwidth (default: -1) \n");
+       } else if (g_menu_state == CURRENT_STATUS_SET_MAX_WIDTH_VARIANT) {
+               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 if (g_menu_state == CURRENT_STATUS_SET_PRE_BUFFERING_SIZE) {
+               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_VIDEO360_SET_ENABLE) {
+               g_print("*** input video 360 status (0: disabled (full panorama), 1: enabled)\n");
+       } else if (g_menu_state == CURRENT_STATUS_VIDEO360_SET_DOV) {
+               g_print("*** input direction of view yaw angle (+/- 180 deg.)\n");
+       } else if (g_menu_state == CURRENT_STATUS_VIDEO360_SET_DOV1) {
+               g_print("*** input direction of view pitch angle (+/- 90 deg.)\n");
+       } else if (g_menu_state == CURRENT_STATUS_VIDEO360_SET_FOV) {
+               g_print("*** input horizontal field of view angle (1~360 deg.)\n");
+       } else if (g_menu_state == CURRENT_STATUS_VIDEO360_SET_FOV1) {
+               g_print("*** input vertical field of view angle (1~180 deg.)\n");
+       } else if (g_menu_state == CURRENT_STATUS_VIDEO360_SET_ZOOM) {
+               g_print("*** input zoom factor.(1.0~10.0, where 1.0 - no zoom, actual image) \n");
+       } else if (g_menu_state == CURRENT_STATUS_VIDEO360_SET_ZOOM_WITH_FOV) {
+               g_print("*** input zoom factor.(1.0~10.0, where 1.0 - no zoom, actual image) \n");
+       } else if (g_menu_state == CURRENT_STATUS_VIDEO360_SET_ZOOM_WITH_FOV1) {
+               g_print("*** input horizontal field of view angle (1~360 deg.)\n");
+       } else if (g_menu_state == CURRENT_STATUS_VIDEO360_SET_ZOOM_WITH_FOV2) {
+               g_print("*** input vertical field of view angle (1~180 deg.)\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 if (g_menu_state == CURRENT_STATUS_AUDIO_OFFLOAD) {
+               g_print("*** input audio offload value.(0:disable, 1: enable) \n");
+       } else if (g_menu_state == CURRENT_STATUS_PITCH_CONTROL) {
+               g_print("*** input pitch control value.(0:disable, 1: enable) \n");
+       } else if (g_menu_state == CURRENT_STATUS_PITCH_VALUE) {
+               g_print("*** input pitch value.(0.5 ~ 2) \n");
+       } else if (g_menu_state == CURRENT_STATUS_EXPORT_PCM_OPTION) {
+               g_print("*** set option (0~3) \n");
+       } else if (g_menu_state == CURRENT_STATUS_EXPORT_PCM_CH) {
+               g_print("*** set pcm channel (e.g. 2)\n");
+       } else if (g_menu_state == CURRENT_STATUS_EXPORT_PCM_RATE) {
+               g_print("*** set pcm samplerate (e.g. 44100)\n");
+       } else if (g_menu_state == CURRENT_STATUS_EXPORT_PCM_MIME) {
+               g_print("*** set pcm mime (e.g. S16LE) \n");
        } else {
                g_print("*** unknown status.\n");
                quit_program();
@@ -1948,6 +2635,9 @@ void reset_menu_state(void)
 
 static void interpret(char *cmd)
 {
+       static int value1 = 0, value2 = 0, value3 = 0;
+       static float fval = 0.0;
+
        switch (g_menu_state) {
        case CURRENT_STATUS_MAINMENU:
                {
@@ -1956,11 +2646,11 @@ static void interpret(char *cmd)
                break;
        case CURRENT_STATUS_HANDLE_NUM:
                {
-                       int num_handle = atoi(cmd);
-                       if (0 >= num_handle || num_handle > MAX_HANDLE)
-                               g_print("not supported this number for handles(%d)\n", num_handle);
+                       value1 = atoi(cmd);
+                       if (0 >= value1 || value1 > MAX_HANDLE)
+                               g_print("not supported this number for handles(%d)\n", value1);
                        else
-                               g_handle_num = num_handle;
+                               g_handle_num = value1;
 
                        reset_menu_state();
                }
@@ -1973,71 +2663,121 @@ static void interpret(char *cmd)
                break;
        case CURRENT_STATUS_VOLUME:
                {
-                       float level = atof(cmd);
-                       set_volume(level);
-                       reset_menu_state();
-               }
-               break;
-       case CURRENT_STATUS_SOUND_TYPE:
-               {
-                       int type = atoi(cmd);
-                       set_sound_type(type);
+                       fval = atof(cmd);
+                       set_volume(fval);
                        reset_menu_state();
                }
                break;
        case CURRENT_STATUS_SOUND_STREAM_INFO:
                {
-                       int type = atoi(cmd);
-                       set_sound_stream_info(type);
+                       value1 = atoi(cmd);
+                       set_sound_stream_info(value1);
                        reset_menu_state();
                }
                break;
        case CURRENT_STATUS_MUTE:
                {
-                       int mute = atoi(cmd);
-                       set_mute(mute);
+                       value1 = atoi(cmd);
+                       set_mute(value1);
                        reset_menu_state();
                }
                break;
        case CURRENT_STATUS_POSITION_TIME:
                {
-                       long position = atol(cmd);
-                       set_position(position);
+                       value1 = atoi(cmd);
+                       g_menu_state = CURRENT_STATUS_POSITION_ACCURATE;
+               }
+               break;
+       case CURRENT_STATUS_POSITION_ACCURATE:
+               {
+                       set_position(value1, ((atoi(cmd) != 0) ? (true) : (false)));
                        reset_menu_state();
                }
                break;
        case CURRENT_STATUS_LOOPING:
                {
-                       int looping = atoi(cmd);
-                       set_looping(looping);
+                       value1 = atoi(cmd);
+                       set_looping(value1);
+                       reset_menu_state();
+               }
+               break;
+       case CURRENT_STATUS_GAPLESS:
+               {
+                       value1 = atoi(cmd);
+                       set_gapless(value1);
                        reset_menu_state();
                }
                break;
        case CURRENT_STATUS_DISPLAY_SURFACE_CHANGE:
                {
-                       int type = atoi(cmd);
-                       change_surface(type);
+                       value1 = atoi(cmd);
+                       change_surface(value1);
+                       if (value1 == 2) { /* null display type */
+                               g_menu_state = CURRENT_STATUS_EXPORT_VIDEO_FRAME;
+                               break;
+                       }
                        reset_menu_state();
                }
                break;
+       case CURRENT_STATUS_EXPORT_VIDEO_FRAME:
+               {
+                       value2 = atoi(cmd);
+                       if (value2 != 0)
+                               set_video_frame_decoded_cb();
+                       reset_menu_state();
+               } break;
        case CURRENT_STATUS_DISPLAY_MODE:
                {
-                       int mode = atoi(cmd);
-                       set_display_mode(mode);
+                       value1 = atoi(cmd);
+                       set_display_mode(value1);
                        reset_menu_state();
                }
                break;
+       case CURRENT_STATUS_DISPLAY_DST_ROI_AREA:
+               {
+                       value1 = atoi(cmd);
+                       static int x = 0;
+                       static int y = 0;
+                       static int w = 0;
+                       static int h = 0;
+                       static int cnt = 0;
+
+                       switch (cnt) {
+                       case 0:
+                               x = value1;
+                               cnt++;
+                               break;
+                       case 1:
+                               y = value1;
+                               cnt++;
+                               break;
+                       case 2:
+                               w = value1;
+                               cnt++;
+                               break;
+                       case 3:
+                               cnt = 0;
+                               h = value1;
+                               set_display_roi_area(x, y, w, h);
+                               x = y = w = h = 0;
+                               reset_menu_state();
+                               break;
+                       default:
+                               break;
+                       }
+               }
+               break;
        case CURRENT_STATUS_DISPLAY_ROTATION:
                {
-                       int rotation = atoi(cmd);
-                       set_display_rotation(rotation);
+                       value1 = atoi(cmd);
+                       set_display_rotation(value1);
                        reset_menu_state();
                }
                break;
        case CURRENT_STATUS_DISPLAY_VISIBLE:
                {
-                       int visible = atoi(cmd);
-                       set_display_visible(visible);
+                       value1 = atoi(cmd);
+                       set_display_visible(value1);
                        reset_menu_state();
                }
                break;
@@ -2049,29 +2789,37 @@ static void interpret(char *cmd)
                break;
        case CURRENT_STATUS_AUDIO_EQUALIZER:
                {
-                       int value = atoi(cmd);
-                       set_audio_eq(value);
+                       value1 = atoi(cmd);
+                       set_audio_eq(value1);
                        reset_menu_state();
                }
                break;
        case CURRENT_STATUS_PLAYBACK_RATE:
                {
-                       float rate = atof(cmd);
-                       set_playback_rate(rate, FALSE);
+                       fval = atof(cmd);
+                       set_playback_rate(fval, FALSE);
                        reset_menu_state();
                }
                break;
        case CURRENT_STATUS_STREAMING_PLAYBACK_RATE:
                {
-                       float rate = atof(cmd);
-                       set_playback_rate(rate, TRUE);
+                       fval = atof(cmd);
+                       set_playback_rate(fval, TRUE);
                        reset_menu_state();
                }
                break;
-       case CURRENT_STATUS_SWITCH_SUBTITLE:
+       case CURRENT_STATUS_SET_TRACK_TYPE:
                {
-                       int index = atoi(cmd);
-                       switch_subtitle(index);
+                       value1 = atoi(cmd);
+                       get_track_info(value1);
+
+                       g_menu_state = CURRENT_STATUS_SET_TRACK_INDEX;
+               }
+               break;
+       case CURRENT_STATUS_SET_TRACK_INDEX:
+               {
+                       value2 = atoi(cmd);
+                       set_track(value1, value2);
                        reset_menu_state();
                }
                break;
@@ -2081,12 +2829,176 @@ static void interpret(char *cmd)
                        reset_menu_state();
                }
                break;
+       case CURRENT_STATUS_GET_TRACK_INFO:
+               {
+                       value1 = atoi(cmd);
+                       get_track_info(value1);
+                       reset_menu_state();
+               }
+               break;
+       case CURRENT_STATUS_SET_MAX_BANDWIDTH_VARIANT:
+               {
+                       value1 = atoi(cmd);
+                       g_menu_state = CURRENT_STATUS_SET_MAX_WIDTH_VARIANT;
+               }
+               break;
+       case CURRENT_STATUS_SET_MAX_WIDTH_VARIANT:
+               {
+                       value2 = atoi(cmd);
+                       g_menu_state = CURRENT_STATUS_SET_MAX_HEIGHT_VARIANT;
+               }
+               break;
+       case CURRENT_STATUS_SET_MAX_HEIGHT_VARIANT:
+               {
+                       value3 = atoi(cmd);
+                       set_variant_limit(value1, value2, value3);
+                       reset_menu_state();
+               }
+               break;
+       case CURRENT_STATUS_SET_AUDIO_ONLY:
+               {
+                       value1 = atoi(cmd);
+                       set_audio_only(value1);
+                       reset_menu_state();
+               }
+               break;
+       case CURRENT_STATUS_SET_PRE_BUFFERING_SIZE:
+               {
+                       value1 = atoi(cmd);
+                       g_menu_state = CURRENT_STATUS_SET_RE_BUFFERING_SIZE;
+               }
+               break;
+       case CURRENT_STATUS_SET_RE_BUFFERING_SIZE:
+               {
+                       value2 = atoi(cmd);
+                       set_buffer_size(value1, value2);
+                       reset_menu_state();
+               }
+               break;
+       case CURRENT_STATUS_VIDEO360_SET_ENABLE:
+               {
+                       value1 = atoi(cmd);
+                       video360_set_enable(value1);
+                       reset_menu_state();
+               }
+               break;
+       case CURRENT_STATUS_VIDEO360_SET_DOV:
+               {
+                       value1 = atoi(cmd);
+                       g_menu_state = CURRENT_STATUS_VIDEO360_SET_DOV1;
+               }
+               break;
+       case CURRENT_STATUS_VIDEO360_SET_DOV1:
+               {
+                       value2 = atoi(cmd);
+                       video360_set_dov(value1, value2);
+                       reset_menu_state();
+               }
+               break;
+       case CURRENT_STATUS_VIDEO360_SET_FOV:
+               {
+                       value1 = atoi(cmd);
+                       g_menu_state = CURRENT_STATUS_VIDEO360_SET_FOV1;
+               }
+               break;
+       case CURRENT_STATUS_VIDEO360_SET_FOV1:
+               {
+                       value2 = atoi(cmd);
+                       video360_set_fov(value1, value2);
+                       reset_menu_state();
+               }
+               break;
+       case CURRENT_STATUS_VIDEO360_SET_ZOOM:
+               {
+                       fval = atof(cmd);
+                       video360_set_zoom(fval);
+                       reset_menu_state();
+               }
+               break;
+       case CURRENT_STATUS_VIDEO360_SET_ZOOM_WITH_FOV:
+               {
+                       fval = atof(cmd);
+                       g_menu_state = CURRENT_STATUS_VIDEO360_SET_ZOOM_WITH_FOV1;
+               }
+               break;
+       case CURRENT_STATUS_VIDEO360_SET_ZOOM_WITH_FOV1:
+               {
+                       value1 = atoi(cmd);
+                       g_menu_state = CURRENT_STATUS_VIDEO360_SET_ZOOM_WITH_FOV2;
+               }
+               break;
+       case CURRENT_STATUS_VIDEO360_SET_ZOOM_WITH_FOV2:
+               {
+                       value2 = atoi(cmd);
+                       video360_set_zoom_with_fov(fval, value1, value2);
+                       reset_menu_state();
+               }
+               break;
+       case CURRENT_STATUS_VIDEO_CODEC_TYPE:
+               {
+                       value1 = atoi(cmd);
+                       set_video_codec_type(value1);
+                       reset_menu_state();
+               }
+               break;
+       case CURRENT_STATUS_REPLAYGAIN_ENABLE:
+               {
+                       value1 = atoi(cmd);
+                       set_replaygain_enabled(value1);
+                       reset_menu_state();
+               }
+               break;
+       case CURRENT_STATUS_AUDIO_OFFLOAD:
+               {
+                       value1 = atoi(cmd);
+                       set_audio_offload_enabled(value1);
+                       reset_menu_state();
+               }
+               break;
+       case CURRENT_STATUS_PITCH_CONTROL:
+               {
+                       value1 = atoi(cmd);
+                       pitch_set_enabled(value1);
+                       reset_menu_state();
+               }
+               break;
+       case CURRENT_STATUS_PITCH_VALUE:
+               {
+                       fval = atof(cmd);
+                       pitch_set_value(fval);
+                       reset_menu_state();
+               }
+               break;
+       case CURRENT_STATUS_EXPORT_PCM_OPTION:
+               {
+                       value1 = atoi(cmd);
+                       g_menu_state = CURRENT_STATUS_EXPORT_PCM_CH;
+               }
+               break;
+       case CURRENT_STATUS_EXPORT_PCM_CH:
+               {
+                       value2 = atoi(cmd);
+                       g_menu_state = CURRENT_STATUS_EXPORT_PCM_RATE;
+               }
+               break;
+       case CURRENT_STATUS_EXPORT_PCM_RATE:
+               {
+                       value3 = atoi(cmd);
+                       g_menu_state = CURRENT_STATUS_EXPORT_PCM_MIME;
+               }
+               break;
+       case CURRENT_STATUS_EXPORT_PCM_MIME:
+               {
+                       set_audio_frame_decoded_cb((player_audio_extract_option_e)value1, cmd, value2, value3);
+                       reset_menu_state();
+               }
+               break;
        }
 
        g_timeout_add(100, timeout_menu_display, 0);
 }
 
-gboolean input(GIOChannel * channel)
+gboolean input(GIOChannel *channel)
 {
        gchar buf[MAX_STRING_LEN];
        gsize read;
@@ -2105,7 +3017,7 @@ int main(int argc, char *argv[])
        GIOChannel *stdin_channel;
        stdin_channel = g_io_channel_unix_new(0);
        g_io_channel_set_flags(stdin_channel, G_IO_FLAG_NONBLOCK, NULL);
-       g_io_add_watch(stdin_channel, G_IO_IN, (GIOFunc) input, NULL);
+       g_io_add_watch(stdin_channel, G_IO_IN, (GIOFunc)input, NULL);
 
        displaymenu();
        memset(&ad, 0x0, sizeof(appdata));