2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 #define USE_EVENT_HANDLER
19 #include <player_internal.h>
20 #include <sound_manager.h>
24 #include <appcore-efl.h>
25 #include <Elementary.h>
33 #ifdef USE_EVENT_HANDLER
34 #include <mm_navevent_handler.h>
40 #define PACKAGE "player_test"
45 #define LOG_TAG "PLAYER_TEST"
47 #define MAX_STRING_LEN 2048
48 #define PLAYER_TEST_DUMP_PATH_PREFIX "/home/owner/dump_pcm_"
49 #define DEFAULT_HTTP_TIMEOUT -1
51 #include <system_info.h>
54 TIZEN_PROFILE_UNKNOWN = 0,
55 TIZEN_PROFILE_MOBILE = 0x1,
56 TIZEN_PROFILE_WEARABLE = 0x2,
57 TIZEN_PROFILE_TV = 0x4,
58 TIZEN_PROFILE_IVI = 0x8,
59 TIZEN_PROFILE_COMMON = 0x10,
67 #ifdef USE_EVENT_HANDLER
68 static void event_handler_cb(enum libinput_event_type ev_t, int x, int y, void *data, float e[3]);
69 static void event_handler_set_dov_fov();
70 static void event_handler_set_window_parameters();
71 mm_navevent_handler_h event_handler;
72 mm_navevent_handler_size_s image_size;
75 static tizen_profile_e _get_tizen_profile()
78 static tizen_profile_e profile = TIZEN_PROFILE_UNKNOWN;
80 if (__builtin_expect(profile != TIZEN_PROFILE_UNKNOWN, 1))
83 system_info_get_platform_string("http://tizen.org/feature/profile", &profileName);
84 switch (*profileName) {
87 profile = TIZEN_PROFILE_MOBILE;
91 profile = TIZEN_PROFILE_WEARABLE;
95 profile = TIZEN_PROFILE_TV;
99 profile = TIZEN_PROFILE_IVI;
101 default: // common or unknown ==> ALL ARE COMMON.
102 profile = TIZEN_PROFILE_COMMON;
108 #define TIZEN_TV ((_get_tizen_profile()) == TIZEN_PROFILE_TV)
110 static gboolean g_memory_playback = FALSE;
111 static char g_uri[MAX_STRING_LEN];
112 static char g_subtitle_uri[MAX_STRING_LEN];
113 static FILE *g_pcm_fd;
115 static gboolean is_es_push_mode = FALSE;
116 static pthread_t g_feed_video_thread_id = 0;
117 static bool g_thread_end = FALSE;
118 static media_packet_h g_audio_pkt = NULL;
119 static media_format_h g_audio_fmt = NULL;
121 static media_packet_h g_video_pkt = NULL;
122 static media_format_h g_video_fmt = NULL;
124 static int _save(unsigned char *src, int length);
126 #define DUMP_OUTBUF 1
128 FILE *fp_out1 = NULL;
129 FILE *fp_out2 = NULL;
130 GList *audio_dump_list = NULL;
134 CURRENT_STATUS_MAINMENU,
135 CURRENT_STATUS_HANDLE_NUM,
136 CURRENT_STATUS_FILENAME,
137 CURRENT_STATUS_VOLUME,
138 CURRENT_STATUS_SOUND_STREAM_INFO,
140 CURRENT_STATUS_POSITION_TIME,
141 CURRENT_STATUS_LOOPING,
142 CURRENT_STATUS_DISPLAY_SURFACE_CHANGE,
143 CURRENT_STATUS_EXPORT_VIDEO_FRAME,
144 CURRENT_STATUS_DISPLAY_MODE,
145 CURRENT_STATUS_DISPLAY_DST_ROI_AREA,
146 CURRENT_STATUS_DISPLAY_ROTATION,
147 CURRENT_STATUS_DISPLAY_VISIBLE,
148 CURRENT_STATUS_SUBTITLE_FILENAME,
149 CURRENT_STATUS_AUDIO_EQUALIZER,
150 CURRENT_STATUS_PLAYBACK_RATE,
151 CURRENT_STATUS_STREAMING_PLAYBACK_RATE,
152 CURRENT_STATUS_SET_TRACK_TYPE,
153 CURRENT_STATUS_SET_TRACK_INDEX,
154 CURRENT_STATUS_NEXT_URI,
155 CURRENT_STATUS_GAPLESS,
156 CURRENT_STATUS_GET_TRACK_INFO,
157 CURRENT_STATUS_POSITION_ACCURATE,
158 CURRENT_STATUS_SET_MAX_BANDWIDTH_VARIANT,
159 CURRENT_STATUS_SET_MAX_WIDTH_VARIANT,
160 CURRENT_STATUS_SET_MAX_HEIGHT_VARIANT,
161 CURRENT_STATUS_SET_AUDIO_ONLY,
162 CURRENT_STATUS_SET_PRE_BUFFERING_SIZE,
163 CURRENT_STATUS_SET_RE_BUFFERING_SIZE,
164 CURRENT_STATUS_VIDEO360_SET_ENABLE,
165 CURRENT_STATUS_VIDEO360_SET_DOV,
166 CURRENT_STATUS_VIDEO360_SET_DOV1,
167 CURRENT_STATUS_VIDEO360_SET_FOV,
168 CURRENT_STATUS_VIDEO360_SET_FOV1,
169 CURRENT_STATUS_VIDEO360_SET_ZOOM,
170 CURRENT_STATUS_VIDEO360_SET_ZOOM_WITH_FOV,
171 CURRENT_STATUS_VIDEO360_SET_ZOOM_WITH_FOV1,
172 CURRENT_STATUS_VIDEO360_SET_ZOOM_WITH_FOV2,
173 CURRENT_STATUS_AUDIO_CODEC_TYPE,
174 CURRENT_STATUS_VIDEO_CODEC_TYPE,
175 CURRENT_STATUS_REPLAYGAIN_ENABLE,
176 CURRENT_STATUS_AUDIO_OFFLOAD,
177 CURRENT_STATUS_PITCH_CONTROL,
178 CURRENT_STATUS_PITCH_VALUE,
179 CURRENT_STATUS_EXPORT_PCM_OPTION,
180 CURRENT_STATUS_EXPORT_PCM_CH,
181 CURRENT_STATUS_EXPORT_PCM_RATE,
182 CURRENT_STATUS_EXPORT_PCM_MIME,
185 #define MAX_HANDLE 20
187 /* for video display */
188 static Evas_Object *g_win_id;
189 #ifdef _ACTIVATE_EOM_
190 static Evas_Object *g_external_win_id;
192 static Evas_Object *selected_win_id;
193 static Evas_Object *g_eo[MAX_HANDLE] = { 0, };
195 static int g_current_surface_type = -1;
199 Evas_Object *layout_main; /* layout widget based on EDJ */
200 /* add more variables here */
201 #ifdef _ACTIVATE_EOM_
207 static player_h g_player[MAX_HANDLE] = { 0, };
209 int g_handle_num = 1;
210 int g_menu_state = CURRENT_STATUS_MAINMENU;
211 gboolean quit_pushing;
212 sound_stream_info_h g_stream_info_h = NULL;
214 static void win_del(void *data, Evas_Object *obj, void *event)
219 static Evas_Object *create_win(const char *name)
221 Evas_Object *eo = NULL;
225 g_print("[%s][%d] name=%s\n", __func__, __LINE__, name);
227 eo = elm_win_add(NULL, name, ELM_WIN_BASIC);
229 elm_win_title_set(eo, name);
230 elm_win_borderless_set(eo, EINA_TRUE);
231 evas_object_smart_callback_add(eo, "delete,request", win_del, NULL);
232 elm_win_screen_size_get(eo, NULL, NULL, &w, &h);
233 g_print("window size :%d,%d", w, h);
234 evas_object_resize(eo, w, h);
235 elm_win_autodel_set(eo, EINA_TRUE);
236 elm_win_alpha_set(eo, EINA_TRUE);
241 static Evas_Object *create_image_object(Evas_Object *eo_parent)
246 Evas *evas = evas_object_evas_get(eo_parent);
247 Evas_Object *eo = NULL;
249 eo = evas_object_image_add(evas);
254 void create_render_rect_and_bg(Evas_Object *win)
260 Evas_Object *bg, *rect;
262 bg = elm_bg_add(win);
263 elm_win_resize_object_add(win, bg);
264 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
265 evas_object_show(bg);
267 rect = evas_object_rectangle_add(evas_object_evas_get(win));
272 evas_object_color_set(rect, 0, 0, 0, 0);
273 evas_object_render_op_set(rect, EVAS_RENDER_COPY);
275 elm_win_resize_object_add(win, rect);
276 evas_object_size_hint_weight_set(rect, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
277 evas_object_show(rect);
278 evas_object_show(win);
281 #ifdef _ACTIVATE_EOM_
282 int eom_get_output_id(const char *output_name)
284 eom_output_id *output_ids = NULL;
285 eom_output_id output_id = 0;
286 eom_output_type_e output_type = EOM_OUTPUT_TYPE_UNKNOWN;
291 output_ids = eom_get_eom_output_ids(&id_cnt);
293 g_print("[eom] no external outuputs supported\n");
297 /* find output ids interested */
298 for (i = 0; i < id_cnt; i++) {
299 eom_get_output_type(output_ids[i], &output_type);
300 if (!strncmp(output_name, "HDMI", 4)) {
301 if (output_type == EOM_OUTPUT_TYPE_HDMIA || output_type == EOM_OUTPUT_TYPE_HDMIB) {
302 output_id = output_ids[i];
305 } else if (!strncmp(output_name, "Virtual", 4)) {
306 if (output_type == EOM_OUTPUT_TYPE_VIRTUAL) {
307 output_id = output_ids[i];
319 static void eom_notify_cb_output_add(eom_output_id output_id, void *user_data)
321 appdata *info = (appdata *)user_data;
323 if (info->hdmi_output_id != output_id) {
324 g_print("[eom] OUTPUT ADDED. SKIP. my output ID is %d\n", info->hdmi_output_id);
327 g_print("[eom] output(%d) connected\n", output_id);
328 /* it is for external window */
329 if (!g_external_win_id) {
330 g_external_win_id = elm_win_add(NULL, "External", ELM_WIN_BASIC);
331 if (eom_set_output_window(info->hdmi_output_id, g_external_win_id) == EOM_ERROR_NONE) {
332 create_render_rect_and_bg(g_external_win_id);
333 g_print("[eom] create external window\n");
335 evas_object_del(g_external_win_id);
336 g_external_win_id = NULL;
337 g_print("[eom] create external window fail\n");
342 static void eom_notify_cb_output_remove(eom_output_id output_id, void *user_data)
344 appdata *info = (appdata *)user_data;
345 player_state_e state;
347 if (info->hdmi_output_id != output_id) {
348 g_print("[eom] OUTPUT REMOVED. SKIP. my output ID is %d\n", info->hdmi_output_id);
351 g_print("[eom] output(%d) disconnected\n", output_id);
353 if (selected_win_id == g_external_win_id && g_player[0]) {
354 player_get_state(g_player[0], &state);
355 if (state >= PLAYER_STATE_READY) {
357 g_win_id = create_win(PACKAGE);
358 if (g_win_id == NULL)
360 g_print("create win_id %p\n", g_win_id);
361 create_render_rect_and_bg(g_win_id);
362 elm_win_activate(g_win_id);
363 evas_object_show(g_win_id);
365 player_set_display(g_player[0], PLAYER_DISPLAY_TYPE_OVERLAY, GET_DISPLAY(g_win_id));
369 /* it is for external window */
370 if (g_external_win_id) {
371 evas_object_del(g_external_win_id);
372 g_external_win_id = NULL;
374 selected_win_id = g_win_id;
377 static void eom_notify_cb_mode_changed(eom_output_id output_id, void *user_data)
379 appdata *info = (appdata *)user_data;
380 eom_output_mode_e mode = EOM_OUTPUT_MODE_NONE;
382 if (info->hdmi_output_id != output_id) {
383 g_print("[eom] MODE CHANGED. SKIP. my output ID is %d\n", info->hdmi_output_id);
387 eom_get_output_mode(output_id, &mode);
388 g_print("[eom] output(%d) mode changed(%d)\n", output_id, mode);
391 static void eom_notify_cb_attribute_changed(eom_output_id output_id, void *user_data)
393 appdata *info = (appdata *)user_data;
395 eom_output_attribute_e attribute = EOM_OUTPUT_ATTRIBUTE_NONE;
396 eom_output_attribute_state_e state = EOM_OUTPUT_ATTRIBUTE_STATE_NONE;
398 if (info->hdmi_output_id != output_id) {
399 g_print("[eom] ATTR CHANGED. SKIP. my output ID is %d\n", info->hdmi_output_id);
403 eom_get_output_attribute(output_id, &attribute);
404 eom_get_output_attribute_state(output_id, &state);
406 g_print("[eom] output(%d) attribute changed(%d, %d)\n", output_id, attribute, state);
407 if (state == EOM_OUTPUT_ATTRIBUTE_STATE_ACTIVE) {
408 g_print("[eom] active\n");
409 if (!g_external_win_id) {
410 g_external_win_id = elm_win_add(NULL, "External", ELM_WIN_BASIC);
411 if (eom_set_output_window(info->hdmi_output_id, g_external_win_id) == EOM_ERROR_NONE) {
412 create_render_rect_and_bg(g_external_win_id);
413 g_print("[eom] create external window\n");
415 evas_object_del(g_external_win_id);
416 g_external_win_id = NULL;
417 g_print("[eom] create external window fail\n");
420 selected_win_id = g_external_win_id;
421 /* play video on external window */
423 player_set_display(g_player[0], PLAYER_DISPLAY_TYPE_OVERLAY, GET_DISPLAY(selected_win_id));
424 } else if (state == EOM_OUTPUT_ATTRIBUTE_STATE_INACTIVE) {
425 g_print("[eom] inactive\n");
427 g_win_id = create_win(PACKAGE);
428 if (g_win_id == NULL)
430 g_print("create win_id %p\n", g_win_id);
431 create_render_rect_and_bg(g_win_id);
432 elm_win_activate(g_win_id);
433 evas_object_show(g_win_id);
435 selected_win_id = g_win_id;
437 player_set_display(g_player[0], PLAYER_DISPLAY_TYPE_OVERLAY, GET_DISPLAY(selected_win_id));
439 if (g_external_win_id) {
440 evas_object_del(g_external_win_id);
441 g_external_win_id = NULL;
443 } else if (state == EOM_OUTPUT_ATTRIBUTE_STATE_LOST) {
444 g_print("[eom] lost\n");
446 g_win_id = create_win(PACKAGE);
447 if (g_win_id == NULL)
449 g_print("create win_id %p\n", g_win_id);
450 create_render_rect_and_bg(g_win_id);
451 elm_win_activate(g_win_id);
452 evas_object_show(g_win_id);
454 selected_win_id = g_win_id;
457 player_set_display(g_player[0], PLAYER_DISPLAY_TYPE_OVERLAY, GET_DISPLAY(selected_win_id));
459 if (g_external_win_id) {
460 evas_object_del(g_external_win_id);
461 g_external_win_id = NULL;
464 eom_unset_output_added_cb(eom_notify_cb_output_add);
465 eom_unset_output_removed_cb(eom_notify_cb_output_remove);
466 eom_unset_mode_changed_cb(eom_notify_cb_mode_changed);
467 eom_unset_attribute_changed_cb(eom_notify_cb_attribute_changed);
473 static int app_create(void *data)
476 Evas_Object *win = NULL;
477 #ifdef _ACTIVATE_EOM_
478 eom_output_mode_e output_mode = EOM_OUTPUT_MODE_NONE;
482 elm_config_accel_preference_set("opengl");
485 win = create_win(PACKAGE);
490 selected_win_id = g_win_id;
491 create_render_rect_and_bg(ad->win);
492 /* Create evas image object for EVAS surface */
493 g_eo[0] = create_image_object(ad->win);
494 evas_object_image_size_set(g_eo[0], 500, 500);
495 evas_object_image_fill_set(g_eo[0], 0, 0, 500, 500);
496 evas_object_resize(g_eo[0], 500, 500);
498 elm_win_activate(win);
499 evas_object_show(win);
500 #ifdef _ACTIVATE_EOM_
501 /* check external device */
503 ad->hdmi_output_id = eom_get_output_id("HDMI");
504 if (ad->hdmi_output_id == 0) {
505 g_print("[eom] error : HDMI output id is NULL.\n");
509 g_print("eom_set_output_attribute EOM_OUTPUT_ATTRIBUTE_NORMAL(id:%d)\n", ad->hdmi_output_id);
510 if (eom_set_output_attribute(ad->hdmi_output_id, EOM_OUTPUT_ATTRIBUTE_NORMAL) != EOM_ERROR_NONE) {
511 g_print("attribute set fail. cannot use external output\n");
515 eom_get_output_mode(ad->hdmi_output_id, &output_mode);
516 if (output_mode != EOM_OUTPUT_MODE_NONE) {
517 g_external_win_id = elm_win_add(NULL, "External", ELM_WIN_BASIC);
518 if (eom_set_output_window(ad->hdmi_output_id, g_external_win_id) == EOM_ERROR_NONE) {
519 create_render_rect_and_bg(g_external_win_id);
520 g_print("[eom] create external window\n");
522 evas_object_del(g_external_win_id);
523 g_external_win_id = NULL;
524 g_print("[eom] create external window fail\n");
526 selected_win_id = g_external_win_id;
529 /* set callback for detecting external device */
530 eom_set_output_added_cb(eom_notify_cb_output_add, ad);
531 eom_set_output_removed_cb(eom_notify_cb_output_remove, ad);
532 eom_set_mode_changed_cb(eom_notify_cb_mode_changed, ad);
533 eom_set_attribute_changed_cb(eom_notify_cb_attribute_changed, ad);
536 #ifdef USE_EVENT_HANDLER
537 if (mm_navevent_handler_create(&event_handler,
538 MM_NAVEVENT_HANDLER_DEVICE_TYPE_TOUCH) != MM_NAVEVENT_HANDLER_ERROR_NONE) {
539 g_print ("Error during handler creation\n");
543 if (mm_navevent_handler_set_cb(event_handler, event_handler_cb, NULL) !=
544 MM_NAVEVENT_HANDLER_ERROR_NONE) {
545 g_print ("Error during callback set\n");
553 static int app_terminate(void *data)
558 #ifdef USE_EVENT_HANDLER
559 mm_navevent_handler_destroy(event_handler);
562 for (i = 0; i < MAX_HANDLE; i++) {
564 evas_object_del(g_eo[i]);
569 evas_object_del(g_win_id);
572 #ifdef _ACTIVATE_EOM_
573 if (g_external_win_id) {
574 evas_object_del(g_external_win_id);
575 g_external_win_id = NULL;
579 selected_win_id = NULL;
580 #ifdef _ACTIVATE_EOM_
581 eom_unset_output_added_cb(eom_notify_cb_output_add);
582 eom_unset_output_removed_cb(eom_notify_cb_output_remove);
583 eom_unset_mode_changed_cb(eom_notify_cb_mode_changed);
584 eom_unset_attribute_changed_cb(eom_notify_cb_attribute_changed);
591 struct appcore_ops ops = {
592 .create = app_create,
593 .terminate = app_terminate,
596 static void prepared_cb(void *user_data)
598 g_print("[Player_Test] prepared_cb!!!!\n");
601 static void _audio_frame_decoded_cb_ex(player_audio_raw_data_s *audio_raw_frame, void *user_data)
603 player_audio_raw_data_s *audio_raw = audio_raw_frame;
608 g_print("[Player_Test] decoded_cb_ex! channel: %d channel_mask: %llu\n", audio_raw->channel, audio_raw->channel_mask);
611 if (audio_raw->channel_mask == 1 && fp_out1)
612 fwrite((guint8 *)audio_raw->data, 1, audio_raw->size, fp_out1);
613 else if (audio_raw->channel_mask == 2 && fp_out2)
614 fwrite((guint8 *)audio_raw->data, 1, audio_raw->size, fp_out2);
618 static void buffering_cb(int percent, void *user_data)
620 g_print("[Player_Test] buffering_cb!!!! percent : %d\n", percent);
623 static void seek_completed_cb(void *user_data)
625 g_print("[Player_Test] seek_completed_cb!!! \n");
628 static void completed_cb(void *user_data)
630 g_print("[Player_Test] completed_cb!!!!\n");
633 static void error_cb(int code, void *user_data)
635 g_print("[Player_Test] error_cb!!!! code : %d\n", code);
638 static void interrupted_cb(player_interrupted_code_e code, void *user_data)
640 g_print("[Player_Test] interrupted_cb!!!! code : %d\n", code);
643 static void video_changed_cb(int width, int height, int fps, int bit_rate, void *user_data)
645 g_print("[Player_Test] video_changed_cb!!!! %d x %d, %d, %d \n", width, height, fps, bit_rate);
647 #ifdef USE_EVENT_HANDLER
648 image_size.width = width;
649 image_size.height = height;
650 event_handler_set_window_parameters();
655 static void audio_frame_decoded_cb(unsigned char *data, unsigned int size, void *user_data)
659 if (data && g_pcm_fd)
660 fwrite(data, 1, size, g_pcm_fd);
661 player_get_play_position(g_player[0], &pos);
662 g_print("[Player_Test] audio_frame_decoded_cb [size: %d] --- current pos : %d!!!!\n", size, pos);
666 static void subtitle_updated_cb(unsigned long duration, char *text, void *user_data)
668 g_print("[Player_Test] subtitle_updated_cb!!!! [%ld] %s\n", duration, text);
671 static void video_captured_cb(unsigned char *data, int width, int height, unsigned int size, void *user_data)
673 g_print("[Player_Test] video_captured_cb!!!! width: %d, height : %d, size : %d \n", width, height, size);
677 static int _save(unsigned char *src, int length)
679 /* unlink(CAPTUERD_IMAGE_SAVE_PATH); */
681 char filename[256] = { 0, };
682 static int WRITE_COUNT = 0;
683 /* gchar *filename = CAPTUERD_IMAGE_SAVE_PATH; */
684 snprintf(filename, 256, "/tmp/IMAGE_client%d", WRITE_COUNT);
686 fp = fopen(filename, "w+");
688 g_print("file open error!!\n");
691 g_print("open success\n");
692 if (fwrite(src, 1, length, fp) < 1) {
693 g_print("file write error!!\n");
697 g_print("write success(%s)\n", filename);
704 static void reset_display()
708 /* delete evas window, if it is */
709 for (i = 0; i < MAX_HANDLE; i++) {
711 evas_object_del(g_eo[i]);
717 static void input_filename(char *filename)
719 int len = strlen(filename);
722 if (len < 0 || len > MAX_STRING_LEN - 1)
725 for (i = 0; i < g_handle_num; i++) {
726 if (g_player[i] != NULL) {
727 player_unprepare(g_player[i]);
728 player_destroy(g_player[i]);
732 if (player_create(&g_player[i]) != PLAYER_ERROR_NONE)
733 g_print("player create is failed\n");
736 strncpy(g_uri, filename, len+1);
740 /* ned(APPSRC_TEST) */
745 GError *error = NULL;
746 guint8 *g_media_mem = NULL;
750 file = g_mapped_file_new(ext, FALSE, &error);
751 file_size = g_mapped_file_get_length(file);
752 g_media_mem = (guint8 *)g_mapped_file_get_contents(file);
754 g_sprintf(uri, "mem://ext=%s,size=%d", ext ? ext : "", file_size);
755 g_print("[uri] = %s\n", uri);
757 mm_player_set_attribute(g_player[0], &g_err_name, "profile_uri", uri, strlen(uri), "profile_user_param", g_media_mem, file_size NULL);
759 /* player_set_uri(g_player[0], filename); */
764 player_state_e state;
765 for (i = 0; i < g_handle_num; i++) {
766 ret = player_get_state(g_player[i], &state);
767 g_print("player_get_state returned [%d]\n", ret);
768 g_print("1. After player_create() - Current State : %d \n", state);
772 /* use this API instead of player_set_uri */
773 static void player_set_memory_buffer_test()
777 guint8 *g_media_mem = NULL;
779 file = g_mapped_file_new(g_uri, FALSE, NULL);
780 file_size = g_mapped_file_get_length(file);
781 g_media_mem = (guint8 *)g_mapped_file_get_contents(file);
783 int ret = player_set_memory_buffer(g_player[0], (void *)g_media_mem, file_size);
784 g_print("player_set_memory_buffer ret : %d\n", ret);
787 int video_packet_count = 0;
789 static void buffer_need_video_data_cb(unsigned int size, void *user_data)
791 int real_read_len = 0;
794 static guint64 pts = 0L;
797 guint8 *buff_ptr = NULL;
800 memset(fname, 0, 128);
801 memset(fptsname, 0, 128);
803 video_packet_count++;
805 if (video_packet_count > 1000) {
808 /* player_submit_packet(g_player[0], NULL, 0, 0, 1); */
809 player_push_media_stream(g_player[0], NULL);
813 /* snprintf(fname, 128, "/opt/storage/usb/test/packet/packet_%d.dat", video_packet_count); */
814 /* snprintf(fptsname, 128, "/opt/storage/usb/test/packet/gstpts_%d.dat", video_packet_count); */
815 snprintf(fname, 128, "/home/developer/test/packet/packet_%d.dat", video_packet_count);
816 snprintf(fptsname, 128, "/home/developer/test/packet/gstpts_%d.dat", video_packet_count);
818 fp = fopen(fptsname, "rb");
821 pts_len = fread(&pts, 1, sizeof(guint64), fp);
822 if (pts_len != sizeof(guint64))
823 g_print("Warning, pts value can be wrong.\n");
828 fp = fopen(fname, "rb");
830 buff_ptr = (guint8 *)g_malloc0(1048576);
832 g_print("no free space\n");
837 real_read_len = fread(buff_ptr, 1, size, fp);
841 g_print("video need data - data size : %d, pts : %" G_GUINT64_FORMAT "\n", real_read_len, pts);
843 player_submit_packet(g_player[0], buff_ptr, real_read_len, (pts / 1000000), 1);
845 /* create media packet */
847 media_packet_destroy(g_video_pkt);
851 if (media_packet_create_alloc(g_video_fmt, NULL, NULL, &g_video_pkt) != MEDIA_PACKET_ERROR_NONE) {
852 g_print("media_packet_create_alloc failed\n");
856 g_print("packet = %p, src = %p\n", g_video_pkt, src);
858 if (media_packet_get_buffer_data_ptr(g_video_pkt, &src) != MEDIA_PACKET_ERROR_NONE)
861 if (media_packet_set_pts(g_video_pkt, (uint64_t)pts) != MEDIA_PACKET_ERROR_NONE)
864 if (media_packet_set_buffer_size(g_video_pkt, (uint64_t)real_read_len) != MEDIA_PACKET_ERROR_NONE)
867 memcpy(src, buff_ptr, real_read_len);
870 player_push_media_stream(g_player[0], g_video_pkt);
877 int audio_packet_count = 0;
878 static void buffer_need_audio_data_cb(unsigned int size, void *user_data)
880 int real_read_len = 0;
883 guint8 *buff_ptr = NULL;
886 memset(fname, 0, 128);
887 audio_packet_count++;
889 if (audio_packet_count > 1000) {
891 /* player_submit_packet(g_player[0], NULL, 0, 0, 0); */
892 player_push_media_stream(g_player[0], NULL);
896 /* snprintf(fname, 128, "/opt/storage/usb/test/audio_packet/packet_%d.dat", audio_packet_count); */
897 snprintf(fname, 128, "/home/developer/test/audio_packet/packet_%d.dat", audio_packet_count);
899 static guint64 audio_pts = 0;
900 guint64 audio_dur = 21333333;
902 fp = fopen(fname, "rb");
904 buff_ptr = (guint8 *)g_malloc0(1048576);
906 g_print("no free space\n");
911 real_read_len = fread(buff_ptr, 1, size, fp);
915 g_print("\t audio need data - data size : %d, pts : %" G_GUINT64_FORMAT "\n", real_read_len, audio_pts);
918 player_submit_packet(g_player[0], buff_ptr, real_read_len, (audio_pts / 1000000), 0);
920 /* create media packet */
922 media_packet_destroy(g_audio_pkt);
926 if (media_packet_create_alloc(g_audio_fmt, NULL, NULL, &g_audio_pkt) != MEDIA_PACKET_ERROR_NONE) {
927 g_print("media_packet_create_alloc failed\n");
931 g_print("packet = %p, src = %p\n", g_audio_pkt, src);
933 if (media_packet_get_buffer_data_ptr(g_audio_pkt, &src) != MEDIA_PACKET_ERROR_NONE)
936 if (media_packet_set_pts(g_audio_pkt, (uint64_t)audio_pts) != MEDIA_PACKET_ERROR_NONE)
939 if (media_packet_set_buffer_size(g_audio_pkt, (uint64_t)real_read_len) != MEDIA_PACKET_ERROR_NONE)
942 memcpy(src, buff_ptr, real_read_len);
945 player_push_media_stream(g_player[0], g_audio_pkt);
948 audio_pts += audio_dur;
954 static void set_content_info(bool is_push_mode)
956 /* testcode for es buff src case, please input url as es_buff://123 or es_buff://push_mode */
957 /* unsigned char codec_data[45] = {0x0,0x0,0x1,0xb0,0x1,0x0,0x0,0x1,0xb5,0x89,0x13,0x0,0x0,0x1,0x0,0x0,0x0,0x1,0x20,0x0,0xc4,0x8d,0x88,0x5d,0xad,0x14,0x4,0x22,0x14,0x43,0x0,0x0,0x1,0xb2,0x4c,0x61,0x76,0x63,0x35,0x31,0x2e,0x34,0x30,0x2e,0x34}; */
959 /* create media format */
960 media_format_create(&g_audio_fmt);
961 media_format_create(&g_video_fmt);
964 /* configure media format for video and set to player */
965 media_format_set_video_mime(g_video_fmt, MEDIA_FORMAT_MPEG4_SP);
966 media_format_set_video_width(g_video_fmt, 640);
967 media_format_set_video_height(g_video_fmt, 272);
968 /* player_set_media_stream_info(g_player[0], PLAYER_STREAM_TYPE_VIDEO, g_video_fmt); */
970 /* Audio--aac--StarWars.mp4 */
971 media_format_set_audio_mime(g_audio_fmt, MEDIA_FORMAT_AAC);
972 media_format_set_audio_channel(g_audio_fmt, 2);
973 media_format_set_audio_samplerate(g_audio_fmt, 48000);
974 /* player_set_media_stream_info(g_player[0], PLAYER_STREAM_TYPE_AUDIO, g_audio_fmt); */
976 /* video_info->mime = g_strdup("video/mpeg"); *//* CODEC_ID_MPEG4VIDEO */
977 video_info->width = 640;
978 video_info->height = 272;
979 video_info->version = 4;
980 video_info->framerate_den = 100;
981 video_info->framerate_num = 2997;
983 video_info->extradata_size = 45;
984 video_info->codec_extradata = codec_data;
985 player_set_video_stream_info(g_player[0], video_info);
987 /* audio--aac--StarWars.mp4 */
988 /* audio_info->mime = g_strdup("audio/mpeg"); */
989 /* audio_info->version = 2; */
990 /* audio_info->user_info = 0; *//* raw */
995 player_set_buffer_need_video_data_cb(g_player[0], buffer_need_video_data_cb, (void *)g_player[0]);
996 player_set_buffer_need_audio_data_cb(g_player[0], buffer_need_audio_data_cb, (void *)g_player[0]);
1001 static void feed_video_data_thread_func(void *data)
1003 while (!g_thread_end) {
1004 buffer_need_video_data_cb(1048576, NULL);
1005 buffer_need_audio_data_cb(1048576, NULL);
1009 static void _player_prepare(bool async)
1012 int slen = strlen(g_subtitle_uri);
1014 if (slen > 0 && slen < MAX_STRING_LEN) {
1015 g_print("0. set subtile path() (size : %d) - %s \n", slen, g_subtitle_uri);
1016 player_set_subtitle_path(g_player[0], g_subtitle_uri);
1017 player_set_subtitle_updated_cb(g_player[0], subtitle_updated_cb, (void *)g_player[0]);
1019 if (g_current_surface_type == -1) {
1020 g_print("You must set display surface type before setting prepare.\n");
1024 if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
1025 player_set_buffering_cb(g_player[0], buffering_cb, (void *)g_player[0]);
1026 player_set_completed_cb(g_player[0], completed_cb, (void *)g_player[0]);
1027 player_set_interrupted_cb(g_player[0], interrupted_cb, (void *)g_player[0]);
1028 player_set_error_cb(g_player[0], error_cb, (void *)g_player[0]);
1029 player_set_video_stream_changed_cb(g_player[0], video_changed_cb, (void *)g_player[0]);
1030 if (g_memory_playback)
1031 player_set_memory_buffer_test();
1033 player_set_uri(g_player[0], g_uri);
1036 for (i = 0; i < g_handle_num; i++) {
1037 player_set_buffering_cb(g_player[i], buffering_cb, (void *)g_player[i]);
1038 player_set_completed_cb(g_player[i], completed_cb, (void *)g_player[i]);
1039 player_set_interrupted_cb(g_player[i], interrupted_cb, (void *)g_player[i]);
1040 player_set_error_cb(g_player[i], error_cb, (void *)g_player[i]);
1041 player_set_video_stream_changed_cb(g_player[0], video_changed_cb, (void *)g_player[0]);
1042 if (g_memory_playback)
1043 player_set_memory_buffer_test();
1045 player_set_uri(g_player[i], g_uri);
1049 if (strstr(g_uri, "es_buff://")) {
1050 is_es_push_mode = FALSE;
1051 video_packet_count = 0;
1052 audio_packet_count = 0;
1054 if (strstr(g_uri, "es_buff://push_mode")) {
1055 set_content_info(TRUE);
1057 is_es_push_mode = TRUE;
1060 set_content_info(FALSE);
1065 if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
1067 ret = player_prepare_async(g_player[0], prepared_cb, (void *)g_player[0]);
1069 ret = player_prepare(g_player[0]);
1072 for (i = 0; i < g_handle_num; i++) {
1074 ret = player_prepare_async(g_player[i], prepared_cb, (void *)g_player[i]);
1076 ret = player_prepare(g_player[i]);
1080 if (ret != PLAYER_ERROR_NONE)
1081 g_print("prepare is failed (errno = %d) \n", ret);
1083 player_state_e state;
1084 if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
1085 ret = player_get_state(g_player[0], &state);
1086 g_print("After player_prepare() - Current State : %d \n", state);
1089 for (i = 0; i < g_handle_num; i++) {
1090 ret = player_get_state(g_player[i], &state);
1091 g_print("After player_prepare() - Current State : %d \n", state);
1095 if (is_es_push_mode)
1096 pthread_create(&g_feed_video_thread_id, NULL, (void *)feed_video_data_thread_func, NULL);
1098 #ifdef USE_EVENT_HANDLER
1099 event_handler_set_dov_fov();
1103 static void _player_unprepare()
1107 if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
1108 ret = player_unprepare(g_player[0]);
1109 if (ret != PLAYER_ERROR_NONE)
1110 g_print("unprepare is failed (errno = %d) \n", ret);
1112 ret = player_unset_subtitle_updated_cb(g_player[0]);
1113 g_print("player_unset_subtitle_updated_cb ret %d\n", ret);
1115 ret = player_unset_buffering_cb(g_player[0]);
1116 g_print("player_unset_buffering_cb ret %d\n", ret);
1118 ret = player_unset_completed_cb(g_player[0]);
1119 g_print("player_unset_completed_cb ret %d\n", ret);
1121 ret = player_unset_interrupted_cb(g_player[0]);
1122 g_print("player_unset_interrupted_cb ret %d\n", ret);
1124 ret = player_unset_error_cb(g_player[0]);
1125 g_print("player_unset_error_cb ret %d\n", ret);
1127 for (i = 0; i < g_handle_num; i++) {
1128 if (g_player[i] != NULL) {
1129 ret = player_unprepare(g_player[i]);
1130 if (ret != PLAYER_ERROR_NONE)
1131 g_print("unprepare is failed (errno = %d) \n", ret);
1133 ret = player_unset_subtitle_updated_cb(g_player[i]);
1134 g_print("player_unset_subtitle_updated_cb [%d] ret %d\n", i, ret);
1136 ret = player_unset_buffering_cb(g_player[i]);
1137 g_print("player_unset_buffering_cb [%d] ret %d\n", i, ret);
1139 ret = player_unset_completed_cb(g_player[i]);
1140 g_print("player_unset_completed_cb [%d] ret %d\n", i, ret);
1142 ret = player_unset_interrupted_cb(g_player[i]);
1143 g_print("player_unset_interrupted_cb [%d] ret %d\n", i, ret);
1145 ret = player_unset_error_cb(g_player[i]);
1146 g_print("player_unset_error_cb [%d] ret %d\n", i, ret);
1151 memset(g_subtitle_uri, 0, sizeof(g_subtitle_uri));
1152 player_state_e state;
1153 if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
1154 ret = player_get_state(g_player[0], &state);
1155 g_print(" After player_unprepare() - Current State : %d \n", state);
1157 for (i = 0; i < g_handle_num; i++) {
1158 ret = player_get_state(g_player[i], &state);
1159 g_print(" After player_unprepare() - Current State : %d \n", state);
1164 static void _player_destroy()
1168 if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
1169 player_destroy(g_player[0]);
1172 for (i = 0; i < g_handle_num; i++) {
1173 if (g_player[i] != NULL) {
1174 player_unprepare(g_player[i]);
1175 player_destroy(g_player[i]);
1181 if (g_stream_info_h) {
1182 sound_manager_destroy_stream_information(g_stream_info_h);
1183 g_stream_info_h = NULL;
1187 media_packet_destroy(g_video_pkt);
1190 media_packet_destroy(g_audio_pkt);
1194 audio_pcm_dump_t *a_data = NULL;
1196 list = audio_dump_list;
1198 a_data = (audio_pcm_dump_t *)list->data;
1199 list = g_list_next(list);
1200 if (a_data && a_data->fp_out)
1201 fclose(a_data->fp_out);
1204 g_list_free(audio_dump_list);
1205 audio_dump_list = NULL;
1215 static void _player_play()
1219 if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
1220 #ifdef _ACTIVATE_EOM_
1221 /* for checking external display.... */
1222 player_set_display(g_player[0], g_current_surface_type, GET_DISPLAY(selected_win_id));
1224 bRet = player_start(g_player[0]);
1225 g_print("player_start returned [%d]", bRet);
1227 for (i = 0; i < g_handle_num; i++) {
1228 bRet = player_start(g_player[i]);
1229 g_print("player_start returned [%d]", bRet);
1234 static void _player_stop()
1238 if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
1239 bRet = player_stop(g_player[0]);
1240 g_print("player_stop returned [%d]", bRet);
1242 for (i = 0; i < g_handle_num; i++) {
1243 bRet = player_stop(g_player[i]);
1244 g_print("player_stop returned [%d]", bRet);
1248 g_thread_end = TRUE;
1249 if (g_feed_video_thread_id) {
1250 pthread_join(g_feed_video_thread_id, NULL);
1251 g_feed_video_thread_id = 0;
1256 static void _player_resume()
1260 if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
1261 #ifdef _ACTIVATE_EOM_
1262 /* for checking external display.... */
1263 player_set_display(g_player[0], PLAYER_DISPLAY_TYPE_OVERLAY, GET_DISPLAY(selected_win_id));
1265 bRet = player_start(g_player[0]);
1266 g_print("player_start returned [%d]", bRet);
1268 for (i = 0; i < g_handle_num; i++) {
1269 bRet = player_start(g_player[i]);
1270 g_print("player_start returned [%d]", bRet);
1275 static void _player_pause()
1279 if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
1280 bRet = player_pause(g_player[0]);
1281 g_print("player_pause returned [%d]", bRet);
1283 for (i = 0; i < g_handle_num; i++) {
1284 bRet = player_pause(g_player[i]);
1285 g_print("player_pause returned [%d]", bRet);
1290 static void _player_state()
1292 player_state_e state;
1293 player_get_state(g_player[0], &state);
1294 g_print(" ==> [Player_Test] Current Player State : %d\n", state);
1297 static void _player_enable_tsurf_pool(void)
1299 bool enabled = FALSE;
1302 g_print("not support at TV profile");
1306 player_is_enabled_tsurf_pool(g_player[0], &enabled);
1308 g_print("tbm surface pool will be %s", (enabled) ? "disabled" : "enabled");
1309 player_enable_tsurf_pool(g_player[0], !enabled);
1312 static void set_next_uri(char *uri)
1315 g_print("not support at TV profile");
1319 if (player_set_next_uri(g_player[0], uri) != PLAYER_ERROR_NONE)
1320 g_print("fail to set next uri");
1323 static void get_next_uri()
1328 g_print("not support at TV profile");
1332 if (player_get_next_uri(g_player[0], &uri) != PLAYER_ERROR_NONE) {
1333 g_print("fail to get next uri");
1338 g_print("next_uri = %s", uri);
1343 static void set_volume(float volume)
1345 if (player_set_volume(g_player[0], volume, volume) != PLAYER_ERROR_NONE)
1346 g_print("failed to set volume\n");
1349 static void get_volume(float *left, float *right)
1351 player_get_volume(g_player[0], left, right);
1352 g_print(" ==> [Player_Test] volume - left : %f, right : %f\n", *left, *right);
1355 static void set_mute(bool mute)
1357 if (player_set_mute(g_player[0], mute) != PLAYER_ERROR_NONE)
1358 g_print("failed to set_mute\n");
1361 static void get_mute(bool *mute)
1363 player_is_muted(g_player[0], mute);
1364 g_print(" ==> [Player_Test] mute = %d\n", *mute);
1367 void focus_callback(sound_stream_info_h stream_info,
1368 sound_stream_focus_mask_e focus_mask,
1369 sound_stream_focus_state_e focus_state,
1370 sound_stream_focus_change_reason_e reason,
1372 const char *extra_info,
1375 g_print("FOCUS callback is called, reason(%d), extra_info(%s), userdata(%p)", reason, extra_info, user_data);
1379 static void set_sound_stream_info(int type)
1381 sound_device_list_h device_list = NULL;
1382 int ret = SOUND_MANAGER_ERROR_NONE;
1384 if (g_stream_info_h) {
1385 g_print("stream information is already set, please destory handle and try again\n");
1388 if (sound_manager_create_stream_information(type, focus_callback, g_player[0], &g_stream_info_h)) {
1389 g_print("failed to create stream_information()\n");
1392 /* In case of MEDIA_EXTERNAL_ONLY, we need to set external device manually */
1393 if (type == (int)SOUND_STREAM_TYPE_MEDIA_EXTERNAL_ONLY) {
1394 sound_device_h device = NULL;
1395 sound_device_type_e device_type;
1397 if ((ret = sound_manager_get_device_list(SOUND_DEVICE_ALL_MASK, &device_list))) {
1398 g_print("failed to sound_manager_get_device_list(), ret(0x%x)\n", ret);
1401 while (!(ret = sound_manager_get_next_device(device_list, &device))) {
1402 if ((ret = sound_manager_get_device_type(device, &device_type))) {
1403 g_print("failed to sound_manager_get_device_type(), ret(0x%x)\n", ret);
1406 if (device_type == SOUND_DEVICE_BLUETOOTH_MEDIA || device_type == SOUND_DEVICE_USB_AUDIO) {
1407 if ((ret = sound_manager_add_device_for_stream_routing(g_stream_info_h, device))) {
1408 g_print("failed to sound_manager_add_device_for_stream_routing(), ret(0x%x)\n", ret);
1411 if ((ret = sound_manager_apply_stream_routing(g_stream_info_h))) {
1412 g_print("failed to sound_manager_apply_stream_routing(), ret(0x%x)\n", ret);
1418 if (ret != SOUND_MANAGER_ERROR_NONE) {
1419 g_print("failed to sound_manager_get_next_device(), ret(0x%x)\n", ret);
1424 if (player_set_sound_stream_info(g_player[0], g_stream_info_h) != PLAYER_ERROR_NONE)
1425 g_print("failed to set sound stream information(%p)\n", g_stream_info_h);
1427 g_print("set stream information(%p) success", g_stream_info_h);
1431 sound_manager_free_device_list(device_list);
1435 void variant_cb(int bandwidth, int width, int height, void *user_data)
1437 g_print(" ==> [Player_Test][b]%d, [w]%d, [h]%d\n", bandwidth, width, height);
1440 static void get_variant_info()
1442 player_foreach_adaptive_variant(g_player[0], (player_adaptive_variant_cb)variant_cb, g_player[0]);
1445 static void get_variant_limit()
1447 int bandwidth, width, height;
1448 player_get_max_adaptive_variant_limit(g_player[0], &bandwidth, &width, &height);
1449 g_print(" ==> [Player_Test]get [b]%d, [w]%d, [h]%d\n", bandwidth, width, height);
1452 static void set_variant_limit(int bandwidth, int width, int height)
1454 g_print(" ==> [Player_Test]set [b]%d, [w]%d, [h]%d\n", bandwidth, width, height);
1455 player_set_max_adaptive_variant_limit(g_player[0], bandwidth, width, height);
1458 static void set_buffer_size(int prebuffer, int rebuffer)
1461 int buffer_ms = 0, rebuffer_ms = 0;
1463 ret = player_get_streaming_buffering_time(g_player[0], &buffer_ms, &rebuffer_ms);
1464 if (ret != PLAYER_ERROR_NONE)
1465 g_print("failed to get buffering time. 0x%X\n", ret);
1467 g_print("current buffer size %d ms / %d ms\n", buffer_ms, rebuffer_ms);
1469 g_print("new buffer size %d ms / %d ms\n", prebuffer, rebuffer);
1471 player_set_streaming_buffering_time(g_player[0], prebuffer, rebuffer);
1474 static void get_buffering_position()
1477 int start = 0, end = 0;
1478 ret = player_get_streaming_download_progress(g_player[0], &start, &end);
1479 g_print(" ==> [Player_Test] buffering pos ()%d return : %d ~ %d\n", ret, start, end);
1482 static void get_position()
1486 ret = player_get_play_position(g_player[0], &position);
1487 g_print(" ==> [Player_Test] player_get_play_position()%d return : %d\n", ret, position);
1490 static void set_position(int position, bool accurate)
1492 if (player_set_play_position(g_player[0], position, accurate, seek_completed_cb, g_player[0]) != PLAYER_ERROR_NONE)
1493 g_print("failed to set position\n");
1496 static void set_playback_rate(float rate, bool streaming)
1499 if (player_set_streaming_playback_rate(g_player[0], rate) != PLAYER_ERROR_NONE)
1500 g_print("failed to set streaming playback rate\n");
1502 if (player_set_playback_rate(g_player[0], rate) != PLAYER_ERROR_NONE)
1503 g_print("failed to set playback rate\n");
1507 static void get_duration()
1511 ret = player_get_duration(g_player[0], &duration);
1512 g_print(" ==> [Player_Test] player_get_duration() return : %d\n", ret);
1513 g_print(" ==> [Player_Test] Duration: [%d ] msec\n", duration);
1516 static void set_codec_type(int a_codec_type, int v_codec_type)
1520 ret = player_set_codec_type(g_player[0], PLAYER_STREAM_TYPE_AUDIO, a_codec_type);
1521 g_print(" ==> [Player_Test] audio codec type (%d) return: %d\n", a_codec_type, ret);
1523 ret = player_set_codec_type(g_player[0], PLAYER_STREAM_TYPE_VIDEO, v_codec_type);
1524 g_print(" ==> [Player_Test] video codec type (%d) return: %d\n", v_codec_type, ret);
1528 static void get_codec_type(void)
1531 player_codec_type_e atype = 0, vtype = 0;
1533 ret = player_get_codec_type(g_player[0], PLAYER_STREAM_TYPE_AUDIO, &atype);
1534 g_print(" ==> [Player_Test] Audio Codec type: [%d][ret 0x%X]\n", atype, ret);
1536 ret = player_get_codec_type(g_player[0], PLAYER_STREAM_TYPE_VIDEO, &vtype);
1537 g_print(" ==> [Player_Test] Video Codec type: [%d][ret 0x%X]\n", vtype, ret);
1540 static void audio_frame_decoded_cb_ex(bool sync)
1544 fp_out1 = fopen("/tmp/out1.pcm", "wb");
1545 fp_out2 = fopen("/tmp/out2.pcm", "wb");
1546 if (!fp_out1 || !fp_out2) {
1547 g_print("File open error\n");
1552 ret = player_set_pcm_extraction_mode(g_player[0], sync, _audio_frame_decoded_cb_ex, &ret);
1553 g_print(" ==> [Player_Test] player_set_audio_frame_decoded_cb_ex(sync:%d) ret:%d\n", sync, ret);
1555 ret = player_set_pcm_spec(g_player[0], "F32LE", 44100, 2);
1556 g_print("[Player_Test] set_pcm_spec return: %d\n", ret);
1559 static void get_stream_info()
1565 player_get_content_info(g_player[0], PLAYER_CONTENT_INFO_ALBUM, &value);
1566 g_print(" ==> [Player_Test] PLAYER_CONTENT_INFO_ALBUM: [%s ] \n", value);
1567 player_get_content_info(g_player[0], PLAYER_CONTENT_INFO_ARTIST, &value);
1568 g_print(" ==> [Player_Test] PLAYER_CONTENT_INFO_ARTIST: [%s ] \n", value);
1569 player_get_content_info(g_player[0], PLAYER_CONTENT_INFO_AUTHOR, &value);
1570 g_print(" ==> [Player_Test] PLAYER_CONTENT_INFO_AUTHOR: [%s ] \n", value);
1571 player_get_content_info(g_player[0], PLAYER_CONTENT_INFO_GENRE, &value);
1572 g_print(" ==> [Player_Test] PLAYER_CONTENT_INFO_GENRE: [%s ] \n", value);
1573 player_get_content_info(g_player[0], PLAYER_CONTENT_INFO_TITLE, &value);
1574 g_print(" ==> [Player_Test] PLAYER_CONTENT_INFO_TITLE: [%s ] \n", value);
1577 player_get_album_art(g_player[0], &album, &size);
1578 g_print(" ==> [Player_Test] Album art : [ data : %p, size : %d ]\n", (unsigned int *)album, size);
1580 if (value != NULL) {
1588 int fps, v_bit_rate;
1589 player_get_audio_stream_info(g_player[0], &sample_rate, &channel, &bit_rate);
1590 g_print(" ==> [Player_Test] Sample Rate: [%d ] , Channel: [%d ] , Bit Rate: [%d ] \n", sample_rate, channel, bit_rate);
1592 player_get_video_stream_info(g_player[0], &fps, &v_bit_rate);
1593 g_print(" ==> [Player_Test] fps: [%d ] , Bit Rate: [%d ] \n", fps, v_bit_rate);
1595 char *audio_codec = NULL;
1596 char *video_codec = NULL;
1597 player_get_codec_info(g_player[0], &audio_codec, &video_codec);
1598 if (audio_codec != NULL) {
1599 g_print(" ==> [Player_Test] Audio Codec: [%s ] \n", audio_codec);
1603 if (video_codec != NULL) {
1604 g_print(" ==> [Player_Test] Video Codec: [%s ] \n", video_codec);
1608 player_get_video_size(g_player[0], &w, &h);
1609 g_print(" ==> [Player_Test] Width: [%d ] , Height: [%d ] \n", w, h);
1612 static void set_gapless(bool gapless)
1615 g_print("not support at TV profile");
1619 if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
1620 if (player_set_gapless(g_player[0], gapless) != PLAYER_ERROR_NONE)
1621 g_print("failed set_gapless\n");
1624 for (i = 0; i < g_handle_num; i++) {
1625 if (player_set_gapless(g_player[i], gapless) != PLAYER_ERROR_NONE)
1626 g_print("failed to set_gapless\n");
1631 static void set_looping(bool looping)
1633 if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
1634 if (player_set_looping(g_player[0], looping) != PLAYER_ERROR_NONE)
1635 g_print("failed to set_looping\n");
1638 for (i = 0; i < g_handle_num; i++) {
1639 if (player_set_looping(g_player[i], looping) != PLAYER_ERROR_NONE)
1640 g_print("failed to set_looping\n");
1645 static void get_looping(bool *looping)
1647 player_is_looping(g_player[0], looping);
1648 g_print(" ==> [Player_Test] looping = %d\n", *looping);
1651 void _video_decoded_cb(media_packet_h packet, void *user_data)
1653 media_packet_destroy(packet);
1656 static void set_video_frame_decoded_cb(void)
1658 player_set_media_packet_video_frame_decoded_cb(g_player[0], _video_decoded_cb, g_player[0]);
1661 void _audio_decoded_cb(media_packet_h packet, void *user_data)
1663 int mime, channel, rate;
1664 uint64_t channel_mask;
1669 g_print("invalid packet param");
1673 media_packet_get_format(packet, &g_audio_fmt);
1674 media_format_get_audio_info(g_audio_fmt, (media_format_mimetype_e *)&mime, &channel, &rate, NULL, NULL);
1675 media_format_get_audio_channel_mask(g_audio_fmt, &channel_mask);
1676 media_packet_get_buffer_data_ptr(packet, &pkt_data);
1677 media_packet_get_buffer_size(packet, &size);
1679 g_print("[ received ] channel: %d size: %"G_GUINT64_FORMAT", mask %"G_GUINT64_FORMAT"\n", channel, size, channel_mask);
1683 audio_pcm_dump_t *a_data = NULL;
1684 FILE *fp_dump = NULL;
1687 list = audio_dump_list;
1689 a_data = (audio_pcm_dump_t *)list->data;
1690 list = g_list_next(list);
1692 if (a_data && a_data->mask == channel_mask) {
1693 fp_dump = a_data->fp_out;
1700 a_data = g_try_malloc(sizeof(audio_pcm_dump_t));
1701 if (a_data == NULL) {
1702 g_print("failed to malloc");
1706 snprintf(file_path, 32, "/tmp/out%"G_GUINT64_FORMAT".pcm", channel_mask);
1708 a_data->mask = channel_mask;
1709 a_data->fp_out = fopen(file_path, "wb");
1710 if (!a_data->fp_out) {
1712 g_print("[ERROR] failed to open file\n");
1716 audio_dump_list = g_list_append(audio_dump_list, a_data);
1717 fp_dump = a_data->fp_out;
1720 fwrite((guint8 *)pkt_data, 1, size, fp_dump);
1724 media_packet_destroy(packet);
1727 static media_format_mimetype_e __convert_audio_pcm_str_to_media_format_mime(char *audio_pcm_str)
1729 int len = strlen("S16LE");
1730 if (!audio_pcm_str) {
1731 g_print("audio pcm str is NULL\n");
1732 return MEDIA_FORMAT_MAX;
1735 if (!strncasecmp(audio_pcm_str, "S16LE", len))
1736 return MEDIA_FORMAT_PCM_S16LE;
1737 else if (!strncasecmp(audio_pcm_str, "S24LE", len))
1738 return MEDIA_FORMAT_PCM_S24LE;
1739 else if (!strncasecmp(audio_pcm_str, "S32LE", len))
1740 return MEDIA_FORMAT_PCM_S32LE;
1741 else if (!strncasecmp(audio_pcm_str, "S16BE", len))
1742 return MEDIA_FORMAT_PCM_S16BE;
1743 else if (!strncasecmp(audio_pcm_str, "S24BE", len))
1744 return MEDIA_FORMAT_PCM_S24BE;
1745 else if (!strncasecmp(audio_pcm_str, "S32BE", len))
1746 return MEDIA_FORMAT_PCM_S32BE;
1747 else if (!strncasecmp(audio_pcm_str, "F32LE", len))
1748 return MEDIA_FORMAT_PCM_F32LE;
1749 else if (!strncasecmp(audio_pcm_str, "F32BE", len))
1750 return MEDIA_FORMAT_PCM_F32BE;
1751 else if (!strncasecmp(audio_pcm_str, "U16LE", len))
1752 return MEDIA_FORMAT_PCM_U16LE;
1753 else if (!strncasecmp(audio_pcm_str, "U24LE", len))
1754 return MEDIA_FORMAT_PCM_U24LE;
1755 else if (!strncasecmp(audio_pcm_str, "U32LE", len))
1756 return MEDIA_FORMAT_PCM_U32LE;
1757 else if (!strncasecmp(audio_pcm_str, "U16BE", len))
1758 return MEDIA_FORMAT_PCM_U16BE;
1759 else if (!strncasecmp(audio_pcm_str, "U24BE", len))
1760 return MEDIA_FORMAT_PCM_U24BE;
1761 else if (!strncasecmp(audio_pcm_str, "U32BE", len))
1762 return MEDIA_FORMAT_PCM_U32BE;
1764 g_print("Not supported audio pcm format str : %s\n", audio_pcm_str);
1765 return MEDIA_FORMAT_MAX;
1769 static void set_audio_frame_decoded_cb(player_audio_extract_option_e opt, char* mime, int ch, int rate)
1771 media_format_mimetype_e type = __convert_audio_pcm_str_to_media_format_mime(mime);
1773 if (type == MEDIA_FORMAT_MAX) {
1774 g_print("failed to convert the mime : %s\n", mime);
1778 media_format_create(&g_audio_fmt);
1779 media_format_set_audio_mime(g_audio_fmt, type);
1780 media_format_set_audio_channel(g_audio_fmt, ch);
1781 media_format_set_audio_samplerate(g_audio_fmt, rate);
1783 g_print("==========> [Player_Test] option = 0x%X, %s(%d), %d, %d\n", opt, mime, type, ch, rate);
1784 player_set_media_packet_audio_frame_decoded_cb(g_player[0], g_audio_fmt, opt, _audio_decoded_cb, g_player[0]);
1786 media_format_unref(g_audio_fmt);
1790 static void change_surface(int option)
1792 player_display_type_e surface_type = 0;
1793 int ret = PLAYER_ERROR_NONE;
1794 #ifdef _ACTIVATE_EOM_
1796 eom_output_mode_e output_mode;
1801 surface_type = PLAYER_DISPLAY_TYPE_OVERLAY;
1802 g_print("change surface type to X\n");
1804 #ifdef TIZEN_FEATURE_EVAS_RENDERER
1807 surface_type = PLAYER_DISPLAY_TYPE_EVAS;
1808 g_print("change surface type to EVAS\n");
1812 g_print("change surface type to NONE\n");
1813 surface_type = g_current_surface_type = PLAYER_DISPLAY_TYPE_NONE;
1814 player_set_display(g_player[0], PLAYER_DISPLAY_TYPE_NONE, NULL);
1817 g_print("invalid surface type\n");
1821 player_state_e player_state = PLAYER_STATE_NONE;
1822 ret = player_get_state(g_player[0], &player_state);
1824 g_print("failed to player_get_state(), ret(0x%x)\n", ret);
1828 if (surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
1829 #ifdef _ACTIVATE_EOM_
1830 hdmi_output_id = eom_get_output_id("HDMI");
1831 if (hdmi_output_id == 0)
1832 g_print("[eom] error : HDMI output id is NULL.\n");
1834 eom_get_output_mode(hdmi_output_id, &output_mode);
1835 if (output_mode == EOM_OUTPUT_MODE_NONE) {
1838 g_win_id = create_win(PACKAGE);
1839 if (g_win_id == NULL)
1841 g_print("create win_id %p\n", g_win_id);
1842 create_render_rect_and_bg(g_win_id);
1843 elm_win_activate(g_win_id);
1844 evas_object_show(g_win_id);
1845 g_win_id = selected_win_id;
1847 #ifdef _ACTIVATE_EOM_
1852 ret = player_set_display(g_player[0], surface_type, GET_DISPLAY(selected_win_id));
1855 g_win_id = create_win(PACKAGE);
1856 if (g_win_id == NULL)
1858 g_print("create win_id %p\n", g_win_id);
1859 create_render_rect_and_bg(g_win_id);
1860 elm_win_activate(g_win_id);
1861 evas_object_show(g_win_id);
1863 if (surface_type == PLAYER_DISPLAY_TYPE_EVAS) {
1864 /* surface type is PLAYER_DISPLAY_TYPE_NONE */
1866 for (i = 0; i < g_handle_num; i++) {
1867 /* Create evas image object for EVAS surface */
1869 g_eo[i] = create_image_object(g_win_id);
1870 g_print("create eo[%d] %p\n", i, g_eo[i]);
1871 evas_object_image_size_set(g_eo[i], 500, 500);
1872 evas_object_image_fill_set(g_eo[i], 0, 0, 500, 500);
1873 evas_object_resize(g_eo[i], 500, 500);
1874 evas_object_move(g_eo[i], i * 20, i * 20);
1876 ret = player_set_display(g_player[i], surface_type, g_eo[i]);
1880 g_print("surface type is PLAYER_DISPLAY_TYPE_NONE\n");
1884 g_print("failed to set display, surface_type(%d)\n", surface_type);
1887 g_current_surface_type = surface_type;
1891 static void set_display_mode(int mode)
1893 if (player_set_display_mode(g_player[0], mode) != PLAYER_ERROR_NONE)
1894 g_print("failed to player_set_display_mode\n");
1897 static void get_display_mode()
1899 player_display_mode_e mode;
1900 player_get_display_mode(g_player[0], &mode);
1901 g_print(" ==> [Player_Test] Display mode: [%d ] \n", mode);
1904 static void set_display_roi_area(int x, int y, int width, int height)
1906 player_set_display_roi_area(g_player[0], x, y, width, height);
1907 g_print(" ==> [Player_Test] Display roi area: [x(%d) y(%d) width(%d) height(%d)] \n", x, y, width, height);
1910 static void set_display_rotation(int rotation)
1912 if (player_set_display_rotation(g_player[0], rotation) != PLAYER_ERROR_NONE)
1913 g_print("failed to set_display_rotation\n");
1914 #ifdef USE_EVENT_HANDLER
1915 event_handler_set_window_parameters();
1919 static void get_display_rotation()
1921 player_display_rotation_e rotation = 0;
1922 player_get_display_rotation(g_player[0], &rotation);
1923 g_print(" ==> [Player_Test] Video Overlay Display rotation: [%d ] \n", rotation);
1926 static void set_display_visible(bool visible)
1928 if (player_set_display_visible(g_player[0], visible) != PLAYER_ERROR_NONE)
1929 g_print("failed to player_set_x11_display_visible\n");
1932 static void get_display_visible(bool *visible)
1934 player_is_display_visible(g_player[0], visible);
1935 g_print(" ==> [Player_Test] Video Overlay Display Visible = %d\n", *visible);
1938 static void input_subtitle_filename(char *subtitle_filename)
1940 int len = strlen(subtitle_filename);
1942 if (len < 1 || len > MAX_STRING_LEN)
1945 strncpy(g_subtitle_uri, subtitle_filename, len);
1946 g_print("subtitle uri is set to %s\n", g_subtitle_uri);
1947 player_set_subtitle_path(g_player[0], g_subtitle_uri);
1948 player_set_subtitle_updated_cb(g_player[0], subtitle_updated_cb, (void *)g_player[0]);
1951 static void set_track(int type, int index)
1953 char *lang_code = NULL;
1955 if (player_select_track(g_player[0], type, index) != PLAYER_ERROR_NONE)
1956 g_print("player_select_track failed\n");
1958 if (player_get_track_language_code(g_player[0], type, index, &lang_code) == PLAYER_ERROR_NONE) {
1959 g_print("selected track lang code %s\n", lang_code);
1964 static void get_track_info(int index)
1966 int count = 0, cur_index = 0;
1968 char *lang_code = NULL;
1970 if (index != PLAYER_STREAM_TYPE_AUDIO &&
1971 index != PLAYER_STREAM_TYPE_TEXT) {
1972 g_print("invalid stream type %d", index);
1976 ret = player_get_track_count(g_player[0], index, &count);
1977 if (ret != PLAYER_ERROR_NONE) {
1978 g_print("player_get_track_count fail!!!!\n");
1981 player_get_current_track(g_player[0], index, &cur_index);
1982 g_print("total track: %d, curr track: %d\n", count, cur_index);
1984 for (idx = 0; idx < count; idx++) {
1985 player_get_track_language_code(g_player[0], index, idx, &lang_code);
1986 g_print("track info = [%d] %s\n", idx, lang_code);
1989 g_print("no track\n");
1993 static void capture_video()
1995 if (player_capture_video(g_player[0], video_captured_cb, NULL) != PLAYER_ERROR_NONE)
1996 g_print("failed to player_capture_video\n");
1999 static void set_audio_only(int val)
2001 int ret = PLAYER_ERROR_NONE;
2002 bool audio_only = false;
2003 ret = player_is_audio_only(g_player[0], &audio_only);
2004 if (ret != PLAYER_ERROR_NONE)
2005 g_print("failed to get current setting. 0x%X\n", ret);
2007 g_print("current audio only mode : %s\n", (audio_only) ? "enabled" : "disabled");
2008 g_print("new audio only mode : %s\n", (val != 0) ? "enabled" : "disabled");
2011 ret = player_set_audio_only(g_player[0], true);
2013 ret = player_set_audio_only(g_player[0], false);
2014 g_print("finished 0x%X\n", ret);
2017 static void decoding_audio()
2021 char *suffix, *dump_path;
2022 GDateTime *time = g_date_time_new_now_local();
2024 suffix = g_date_time_format(time, "%Y%m%d_%H%M%S.pcm");
2025 dump_path = g_strjoin(NULL, PLAYER_TEST_DUMP_PATH_PREFIX, suffix, NULL);
2026 g_pcm_fd = fopen(dump_path, "w+");
2029 g_date_time_unref(time);
2031 g_print("Can not create debug dump file");
2033 ret = player_set_audio_frame_decoded_cb(g_player[0], 0, 0, audio_frame_decoded_cb, (void *)g_player[0]);
2034 if (ret != PLAYER_ERROR_NONE)
2035 g_print("player_set_audio_frame_decoded_cb is failed (errno = %d) \n", ret);
2039 static void set_audio_eq(int value)
2041 bool available = FALSE;
2042 int index, min = 0, max = 0;
2045 if (player_audio_effect_equalizer_is_available(g_player[0], &available) != PLAYER_ERROR_NONE)
2046 g_print("failed to player_audio_effect_equalizer_is_available\n");
2049 if ((player_audio_effect_get_equalizer_bands_count(g_player[0], &index) != PLAYER_ERROR_NONE) ||
2050 (player_audio_effect_get_equalizer_level_range(g_player[0], &min, &max) != PLAYER_ERROR_NONE) ||
2051 (player_audio_effect_set_equalizer_band_level(g_player[0], index / 2, max) != PLAYER_ERROR_NONE))
2052 g_print("failed to player_audio_effect_set_equalizer_band_level index %d, level %d\n", index / 2, max);
2055 if (player_audio_effect_equalizer_clear(g_player[0]) != PLAYER_ERROR_NONE)
2056 g_print("failed to player_audio_effect_equalizer_clear\n");
2061 static void get_audio_eq()
2063 int index, min, max, value;
2064 player_audio_effect_get_equalizer_bands_count(g_player[0], &index);
2065 g_print(" ==> [Player_Test] eq bands count: [%d] \n", index);
2066 player_audio_effect_get_equalizer_level_range(g_player[0], &min, &max);
2067 g_print(" ==> [Player_Test] eq bands range: [%d~%d] \n", min, max);
2068 player_audio_effect_get_equalizer_band_level(g_player[0], index / 2, &value);
2069 g_print(" ==> [Player_Test] eq bands level: [%d] \n", value);
2070 player_audio_effect_get_equalizer_band_frequency(g_player[0], 0, &value);
2071 g_print(" ==> [Player_Test] eq bands frequency: [%d] \n", value);
2072 player_audio_effect_get_equalizer_band_frequency_range(g_player[0], 0, &value);
2073 g_print(" ==> [Player_Test] eq bands frequency range: [%d] \n", value);
2076 static void video360_is_spherical(void)
2080 if (player_360_is_content_spherical(g_player[0], &spherical) != PLAYER_ERROR_NONE)
2081 g_print("failed to get content spherical info\n");
2083 g_print(" ==> [Player_Test] Video 360 content = %s\n", spherical ? "spherical" : "---");
2087 static void video360_set_enable(bool enable)
2089 bool enabled = false;
2091 #ifdef USE_EVENT_HANDLER
2092 event_handler_set_dov_fov();
2095 if (player_360_set_enabled(g_player[0], enable) != PLAYER_ERROR_NONE)
2096 g_print("failed to %s video 360 mode\n", enable ? "enable" : "disable");
2098 if (player_360_is_enabled(g_player[0], &enabled) != PLAYER_ERROR_NONE)
2099 g_print("failed to get video 360 mode status\n");
2101 g_print(" ==> [Player_Test] Video 360 mode = %s\n", enabled ? "enabled" : "disabled");
2104 static void video360_get_fov()
2108 if (player_360_get_field_of_view(g_player[0], &hfov, &vfov) != PLAYER_ERROR_NONE)
2109 g_print("failed to get video 360 field of view\n");
2111 g_print(" ==> [Player_Test] Video 360 FOV = %dx%d deg.\n", hfov, vfov);
2114 static void video360_set_fov(int hfov, int vfov)
2116 #ifdef USE_EVENT_HANDLER
2117 mm_navevent_handler_size_s fov;
2121 mm_navevent_handler_set_fov_size(event_handler, fov);
2123 if (player_360_set_field_of_view(g_player[0], hfov, vfov) != PLAYER_ERROR_NONE)
2124 g_print("failed to set video 360 field of view\n");
2129 static void video360_get_dov()
2133 if (player_360_get_direction_of_view(g_player[0], &yaw, &pitch) != PLAYER_ERROR_NONE)
2134 g_print("failed to get video 360 direction of view\n");
2136 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));
2139 static void video360_set_dov(int yaw_deg, int pitch_deg)
2143 angles[0] = M_PI * yaw_deg / 180.0f;
2144 angles[1] = M_PI * pitch_deg / 180.0f;
2147 #ifdef USE_EVENT_HANDLER
2148 mm_navevent_handler_set_angles(event_handler, angles);
2151 if (player_360_set_direction_of_view(g_player[0], angles[0], angles[1]) != PLAYER_ERROR_NONE)
2152 g_print("failed to set video 360 direction of view\n");
2157 static void video360_get_zoom()
2161 if (player_360_get_zoom(g_player[0], &zoom) != PLAYER_ERROR_NONE)
2162 g_print("failed to get video 360 zoom\n");
2164 g_print(" ==> [Player_Test] Video 360 zoom = %f\n", zoom);
2167 static void video360_set_zoom(float zoom)
2169 if (player_360_set_zoom(g_player[0], zoom) != PLAYER_ERROR_NONE)
2170 g_print("failed to set video 360 zoom\n");
2172 video360_get_zoom();
2175 static void video360_set_zoom_with_fov(float zoom, int hfov, int vfov)
2177 #ifdef USE_EVENT_HANDLER
2178 mm_navevent_handler_size_s fov;
2182 mm_navevent_handler_set_fov_size(event_handler, fov);
2184 if (player_360_set_zoom_with_field_of_view(g_player[0], zoom, hfov, vfov) != PLAYER_ERROR_NONE)
2185 g_print("failed to set video 360 zoom with field of view\n");
2188 video360_get_zoom();
2191 static void set_replaygain_enabled(bool enabled)
2193 if (player_set_replaygain_enabled(g_player[0], enabled) != PLAYER_ERROR_NONE)
2194 g_print("failed to set_replaygain_enabled\n");
2197 static void is_replaygain_enabled(bool *enable)
2199 player_is_replaygain_enabled(g_player[0], enable);
2200 g_print(" ==> [Player_Test] replaygain = %d\n", *enable);
2203 static void _supported_media_format_cb(media_format_mimetype_e format, void *user_data)
2205 g_print("- supported format mimetype 0x%X\n", format);
2208 static void set_audio_offload_enabled(bool enabled)
2210 bool is_enabled = false;
2212 player_audio_offload_is_enabled(g_player[0], &is_enabled);
2213 g_print("[Player_Test] offload setting %d -> %d\n", is_enabled, enabled);
2215 player_audio_offload_foreach_supported_format(g_player[0], _supported_media_format_cb, (void *)g_player[0]);
2217 if (player_audio_offload_set_enabled(g_player[0], enabled) != PLAYER_ERROR_NONE)
2218 g_print("failed to set audio offload\n");
2221 static void pitch_set_enabled(bool enabled)
2223 bool is_enabled = false;
2224 player_audio_pitch_is_enabled(g_player[0], &is_enabled);
2226 g_print("pitch enabled %d -> %d \n", is_enabled, enabled);
2227 if (player_audio_pitch_set_enabled(g_player[0], enabled) != PLAYER_ERROR_NONE)
2228 g_print("failed to pitch_set_enabled\n");
2231 static void pitch_set_value(float level)
2234 player_audio_pitch_get_value(g_player[0], &curr);
2236 g_print("pitch level %1.3f -> %1.3f \n", curr, level);
2237 if (player_audio_pitch_set_value(g_player[0], level) != PLAYER_ERROR_NONE)
2238 g_print("failed to set pitch value\n");
2241 #ifdef USE_EVENT_HANDLER
2242 static void event_handler_cb(enum libinput_event_type ev_t, int x, int y, void *data, float e[3])
2244 if (ev_t == LIBINPUT_EVENT_TOUCH_MOTION)
2245 if (player_360_set_direction_of_view(g_player[0], e[0], e[1]) != PLAYER_ERROR_NONE)
2246 g_print("Event handler callback: failed to set direction of view\n");
2249 static void event_handler_set_dov_fov()
2252 mm_navevent_handler_size_s fov;
2254 if (player_360_get_direction_of_view(g_player[0], &angles[0], &angles[1]) != PLAYER_ERROR_NONE) {
2255 g_print("Failed to get video360 direction of view\n");
2258 if (player_360_get_field_of_view(g_player[0], &fov.width, &fov.height) != PLAYER_ERROR_NONE) {
2259 g_print("Failed to get video360 field of view\n");
2262 mm_navevent_handler_set_angles(event_handler, angles);
2263 mm_navevent_handler_set_fov_size(event_handler, fov);
2266 static void event_handler_set_window_parameters()
2268 player_display_rotation_e window_orientation;
2269 mm_navevent_handler_size_s window_size;
2272 player_get_display_rotation(g_player[0], &window_orientation);
2273 elm_win_screen_size_get(selected_win_id, NULL, NULL, &window_size.width, &window_size.height);
2275 image_ratio = (float)image_size.width / (float)image_size.height;
2277 if (window_orientation == PLAYER_DISPLAY_ROTATION_NONE ||
2278 window_orientation == PLAYER_DISPLAY_ROTATION_180) {
2279 window_size.height = (int)((float)window_size.width / image_ratio);
2281 window_size.height = window_size.width;
2282 window_size.width = (int)((float)window_size.width * image_ratio);
2285 mm_navevent_handler_set_window_parameters(event_handler,
2286 (mm_navevent_handler_orientation_e)window_orientation, window_size);
2296 if (g_player[0] != NULL || g_player[1] != NULL) {
2297 _player_unprepare();
2304 media_format_unref(g_audio_fmt);
2307 media_format_unref(g_video_fmt);
2310 void play_with_ini(char *file_path)
2312 input_filename(file_path);
2316 void _interpret_main_menu(char *cmd)
2318 int len = strlen(cmd);
2320 if (strncmp(cmd, "a", 1) == 0) {
2321 g_menu_state = CURRENT_STATUS_FILENAME;
2322 } else if (strncmp(cmd, "b", 1) == 0) {
2324 } else if (strncmp(cmd, "c", 1) == 0) {
2326 } else if (strncmp(cmd, "d", 1) == 0) {
2328 } else if (strncmp(cmd, "e", 1) == 0) {
2330 } else if (strncmp(cmd, "S", 1) == 0) {
2332 } else if (strncmp(cmd, "f", 1) == 0) {
2333 g_menu_state = CURRENT_STATUS_VOLUME;
2334 } else if (strncmp(cmd, "g", 1) == 0) {
2337 get_volume(&left, &right);
2338 } else if (strncmp(cmd, "k", 1) == 0) {
2339 g_menu_state = CURRENT_STATUS_SOUND_STREAM_INFO;
2340 } else if (strncmp(cmd, "h", 1) == 0) {
2341 g_menu_state = CURRENT_STATUS_MUTE;
2342 } else if (strncmp(cmd, "i", 1) == 0) {
2345 } else if (strncmp(cmd, "j", 1) == 0) {
2346 g_menu_state = CURRENT_STATUS_POSITION_TIME;
2347 } else if (strncmp(cmd, "l", 1) == 0) {
2349 } else if (strncmp(cmd, "m", 1) == 0) {
2351 } else if (strncmp(cmd, "n", 1) == 0) {
2353 } else if (strncmp(cmd, "o", 1) == 0) {
2354 g_menu_state = CURRENT_STATUS_LOOPING;
2355 } else if (strncmp(cmd, "p", 1) == 0) {
2357 get_looping(&looping);
2358 } else if (strncmp(cmd, "r", 1) == 0) {
2359 g_menu_state = CURRENT_STATUS_DISPLAY_MODE;
2360 } else if (strncmp(cmd, "s", 1) == 0) {
2362 } else if (strncmp(cmd, "t", 1) == 0) {
2363 g_menu_state = CURRENT_STATUS_DISPLAY_ROTATION;
2364 } else if (strncmp(cmd, "u", 1) == 0) {
2365 get_display_rotation();
2366 } else if (strncmp(cmd, "v", 1) == 0) {
2367 g_menu_state = CURRENT_STATUS_DISPLAY_VISIBLE;
2368 } else if (strncmp(cmd, "w", 1) == 0) {
2370 get_display_visible(&visible);
2371 } else if (strncmp(cmd, "A", 1) == 0) {
2372 g_menu_state = CURRENT_STATUS_SUBTITLE_FILENAME;
2373 } else if (strncmp(cmd, "C", 1) == 0) {
2375 } else if (strncmp(cmd, "D", 1) == 0) {
2377 } else if (strncmp(cmd, "q", 1) == 0) {
2378 quit_pushing = TRUE;
2380 } else if (strncmp(cmd, "E", 1) == 0) {
2381 g_menu_state = CURRENT_STATUS_AUDIO_EQUALIZER;
2382 } else if (strncmp(cmd, "H", 1) == 0) {
2385 g_print("unknown menu \n");
2387 } else if (len == 2) {
2388 if (strncmp(cmd, "pr", 2) == 0) {
2390 if (g_current_surface_type == -1) {
2391 g_print("You must set display surface type before setting prepare. please 'pr' after setting display surface type.\n");
2392 g_menu_state = CURRENT_STATUS_DISPLAY_SURFACE_CHANGE;
2394 _player_prepare(FALSE);
2395 } else if (strncmp(cmd, "pa", 2) == 0) {
2397 if (g_current_surface_type == -1) {
2398 g_print("You must set display surface type before setting prepare. please 'pr' after setting display surface type.\n");
2399 g_menu_state = CURRENT_STATUS_DISPLAY_SURFACE_CHANGE;
2401 _player_prepare(TRUE);
2403 } else if (strncmp(cmd, "un", 2) == 0) {
2404 _player_unprepare();
2405 } else if (strncmp(cmd, "dt", 2) == 0) {
2407 } else if (strncmp(cmd, "mp", 2) == 0) {
2408 g_memory_playback = (g_memory_playback ? FALSE : TRUE);
2409 g_print("memory playback = %d\n", g_memory_playback);
2410 } else if (strncmp(cmd, "ds", 2) == 0) {
2411 g_menu_state = CURRENT_STATUS_DISPLAY_SURFACE_CHANGE;
2412 } else if (strncmp(cmd, "dr", 2) == 0) {
2413 g_menu_state = CURRENT_STATUS_DISPLAY_DST_ROI_AREA;
2414 } else if (strncmp(cmd, "nb", 2) == 0) {
2415 g_menu_state = CURRENT_STATUS_HANDLE_NUM;
2416 } else if (strncmp(cmd, "tr", 2) == 0) {
2417 g_menu_state = CURRENT_STATUS_PLAYBACK_RATE;
2418 } else if (strncmp(cmd, "X3", 2) == 0) {
2419 audio_frame_decoded_cb_ex(TRUE);
2420 } else if (strncmp(cmd, "X4", 2) == 0) {
2421 audio_frame_decoded_cb_ex(FALSE);
2422 } else if (strncmp(cmd, "X5", 2) == 0) {
2423 g_menu_state = CURRENT_STATUS_EXPORT_PCM_OPTION;
2424 } else if (strncmp(cmd, "ep", 2) == 0) {
2425 _player_enable_tsurf_pool();
2426 } else if (strncmp(cmd, "su", 2) == 0) {
2427 g_menu_state = CURRENT_STATUS_NEXT_URI;
2428 } else if (strncmp(cmd, "gu", 2) == 0) {
2430 } else if (strncmp(cmd, "sg", 2) == 0) {
2431 g_menu_state = CURRENT_STATUS_GAPLESS;
2432 } else if (strncmp(cmd, "tg", 2) == 0) {
2433 g_menu_state = CURRENT_STATUS_GET_TRACK_INFO;
2434 } else if (strncmp(cmd, "ts", 2) == 0) {
2435 g_menu_state = CURRENT_STATUS_SET_TRACK_TYPE;
2436 } else if (strncmp(cmd, "vi", 2) == 0) {
2438 } else if (strncmp(cmd, "vs", 2) == 0) {
2439 g_menu_state = CURRENT_STATUS_SET_MAX_BANDWIDTH_VARIANT;
2440 } else if (strncmp(cmd, "vg", 2) == 0) {
2441 get_variant_limit();
2442 } else if (strncmp(cmd, "ao", 2) == 0) {
2443 g_menu_state = CURRENT_STATUS_SET_AUDIO_ONLY;
2444 } else if (strncmp(cmd, "bf", 2) == 0) {
2445 g_menu_state = CURRENT_STATUS_SET_PRE_BUFFERING_SIZE;
2446 } else if (strncmp(cmd, "C1", 2) == 0) {
2447 g_menu_state = CURRENT_STATUS_AUDIO_CODEC_TYPE;
2448 } else if (strncmp(cmd, "C2", 2) == 0) {
2450 } else if (!strncmp(cmd, "si", 2)) {
2451 video360_is_spherical();
2452 } else if (!strncmp(cmd, "se", 2)) {
2453 g_menu_state = CURRENT_STATUS_VIDEO360_SET_ENABLE;
2454 } else if (!strncmp(cmd, "sd", 2)) {
2455 g_menu_state = CURRENT_STATUS_VIDEO360_SET_DOV;
2456 } else if (!strncmp(cmd, "sf", 2)) {
2457 g_menu_state = CURRENT_STATUS_VIDEO360_SET_FOV;
2458 } else if (!strncmp(cmd, "sz", 2)) {
2459 g_menu_state = CURRENT_STATUS_VIDEO360_SET_ZOOM;
2460 } else if (strncmp(cmd, "lb", 2) == 0) {
2461 get_buffering_position();
2462 } else if (strncmp(cmd, "ol", 2) == 0) {
2463 g_menu_state = CURRENT_STATUS_AUDIO_OFFLOAD;
2464 } else if (strncmp(cmd, "pc", 2) == 0) {
2465 g_menu_state = CURRENT_STATUS_PITCH_CONTROL;
2466 } else if (strncmp(cmd, "pv", 2) == 0) {
2467 g_menu_state = CURRENT_STATUS_PITCH_VALUE;
2469 g_print("unknown menu \n");
2471 } else if (len == 3) {
2472 if (strncmp(cmd, "trs", 3) == 0) {
2473 g_menu_state = CURRENT_STATUS_STREAMING_PLAYBACK_RATE;
2474 } else if (strncmp(cmd, "rgs", 3) == 0) {
2475 g_menu_state = CURRENT_STATUS_REPLAYGAIN_ENABLE;
2476 } else if (strncmp(cmd, "rgg", 3) == 0) {
2478 is_replaygain_enabled(&enable);
2479 } else if (!strncmp(cmd, "szz", 3)) {
2480 g_menu_state = CURRENT_STATUS_VIDEO360_SET_ZOOM_WITH_FOV;
2482 g_print("unknown menu \n");
2485 g_print("unknown menu \n");
2489 void display_sub_basic()
2492 g_print("=========================================================================================\n");
2493 g_print(" Player Test (press q to quit) \n");
2494 g_print("-----------------------------------------------------------------------------------------\n");
2495 g_print("[playback] a. Create\t");
2496 g_print("pr. Prepare \t");
2497 g_print("pa. Prepare async \t");
2498 g_print("b. Play \t");
2499 g_print("c. Stop \t");
2500 g_print("d. Resume\t");
2501 g_print("e. Pause \t");
2502 g_print("un. Unprepare \t");
2503 g_print("dt. Destroy \n");
2504 g_print("[State] S. Player State \n");
2505 g_print("[ volume ] f. Set Volume\t");
2506 g_print("g. Get Volume\t");
2507 g_print("z. Set Sound type\t");
2508 g_print("k. Set Sound Stream Info.\n");
2509 g_print("[ mute ] h. Set Mute\t");
2510 g_print("i. Get Mute\n");
2511 g_print("[audio eq] E. Set Audio EQ\t");
2512 g_print("H. Get Audio EQ\n");
2513 g_print("[position] j. Set Position \t");
2514 g_print("l. Get Position\t");
2515 g_print("lb. Get buffering position\n");
2516 g_print("[trick] tr. set playback rate\n");
2517 g_print("[duration] m. Get Duration\n");
2518 g_print("[Stream Info] n. Get stream info (Video Size, codec, audio stream info, and tag info)\n");
2519 g_print("[Looping] o. Set Looping\t");
2520 g_print("p. Get Looping\n");
2521 g_print("[display] v. Set display visible\t");
2522 g_print("w. Get display visible\n");
2523 g_print("[display] ds. Change display surface type\n");
2524 g_print("[display] dr. set display roi area\n");
2525 g_print("[overlay display] r. Set display mode\t");
2526 g_print("s. Get display mode\n");
2527 g_print("[overlay display] t. Set display Rotation\n");
2528 g_print("[Variant] vi. Get Streaming Variant Info\t");
2529 g_print("vs. Set max limit of variant\t");
2530 g_print("vg. Get max limit of variant\n");
2531 g_print("[audio only] ao. set audio only\n");
2532 g_print("[subtitle] A. Set(or change) subtitle path\n");
2533 g_print("[Track] tg. Get Track info\n");
2534 g_print("[Track] ts. Set track\n");
2535 g_print("[Video Capture] C. Capture \n");
2536 g_print("[Video Codec] C1. Set codec type (1:HW, 2:SW)\t");
2537 g_print("C2. Get codec type\n");
2538 g_print("[next uri] su. set next uri. \t");
2539 g_print("gu. get next uri. \t");
2540 g_print("sg. set gapless. \n");
2541 g_print("[audio_frame_decoded_cb_ex] X3. set audio_cb with sync\t");
2542 g_print("X4. set audio_cb with async\t");
2543 g_print("X5. set audio decoded cb with option\n");
2544 g_print("[video_frame_decoded_cb] ep. enable tbm surface pool\n");
2545 g_print("[buffering] bf. set new buffering size\n");
2546 g_print("[Video 360] si. check spherical info\t");
2547 g_print("se. Set Enable\n");
2548 g_print("[Video 360] sd. Set Direction Of View\t");
2549 g_print("sf. Set Field Of View\n");
2550 g_print("[Video 360] sz. Set Zoom\t\t");
2551 g_print("szz. Set Zoom with FOV\n");
2552 g_print("[Replaygain] rgs. Set Replaygain\t\t");
2553 g_print("rgg. Get replaygain\n");
2554 g_print("[Offload] ol. Set audio offload\n");
2555 g_print("[pitch] pc. enable pitch control\t");
2556 g_print("pv. Set pitch value\n");
2557 g_print("[etc] sp. Set Progressive Download\t");
2558 g_print("gp. Get Progressive Download status\t");
2559 g_print("mp. memory playback\n");
2561 g_print("=========================================================================================\n");
2564 static void displaymenu()
2566 if (g_menu_state == CURRENT_STATUS_MAINMENU) {
2567 display_sub_basic();
2568 } else if (g_menu_state == CURRENT_STATUS_HANDLE_NUM) {
2569 g_print("*** input number of handles.(recommended only for EVAS surface)\n");
2570 } else if (g_menu_state == CURRENT_STATUS_FILENAME) {
2571 g_print("*** input mediapath.\n");
2572 } else if (g_menu_state == CURRENT_STATUS_VOLUME) {
2573 g_print("*** input volume value.(0~1.0)\n");
2574 } else if (g_menu_state == CURRENT_STATUS_SOUND_STREAM_INFO) {
2575 g_print("*** input sound stream type.(0:MEDIA 1:SYSTEM 2:ALARM 3:NOTIFICATION 4:EMERGENCY 5:VOICE_INFORMATION 9:MEDIA_EXT_ONLY)\n");
2576 } else if (g_menu_state == CURRENT_STATUS_MUTE) {
2577 g_print("*** input mute value.(0: Not Mute, 1: Mute) \n");
2578 } else if (g_menu_state == CURRENT_STATUS_POSITION_TIME) {
2579 g_print("*** input position value(msec)\n");
2580 } else if (g_menu_state == CURRENT_STATUS_POSITION_ACCURATE) {
2581 g_print("*** input accurate value(0/1)\n");
2582 } else if (g_menu_state == CURRENT_STATUS_LOOPING) {
2583 g_print("*** input looping value.(0: Not Looping, 1: Looping) \n");
2584 } else if (g_menu_state == CURRENT_STATUS_DISPLAY_SURFACE_CHANGE) {
2585 g_print("*** input display surface type.(0: Wayland surface, 1: EVAS surface, 2: No use surface (e.g: audio playback)) \n");
2586 } else if (g_menu_state == CURRENT_STATUS_EXPORT_VIDEO_FRAME) {
2587 g_print("*** set video_decoded_cb (0: none, 1: set cb) \n");
2588 } else if (g_menu_state == CURRENT_STATUS_DISPLAY_MODE) {
2589 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");
2590 } else if (g_menu_state == CURRENT_STATUS_DISPLAY_DST_ROI_AREA) {
2591 g_print("*** input display roi value sequentially.(x, y, w, h)\n");
2592 } else if (g_menu_state == CURRENT_STATUS_DISPLAY_ROTATION) {
2593 g_print("*** input display rotation value.(0: NONE, 1: 90, 2: 180, 3: 270, 4:F LIP_HORZ, 5: FLIP_VERT ) \n");
2594 } else if (g_menu_state == CURRENT_STATUS_DISPLAY_VISIBLE) {
2595 g_print("*** input display visible value.(0: HIDE, 1: SHOW) \n");
2596 } else if (g_menu_state == CURRENT_STATUS_SUBTITLE_FILENAME) {
2597 g_print(" *** input subtitle file path.\n");
2598 } else if (g_menu_state == CURRENT_STATUS_AUDIO_EQUALIZER) {
2599 g_print(" *** input audio eq value.(0: UNSET, 1: SET) \n");
2600 } else if (g_menu_state == CURRENT_STATUS_PLAYBACK_RATE || g_menu_state == CURRENT_STATUS_STREAMING_PLAYBACK_RATE) {
2601 g_print(" *** input playback rate.(-5.0 ~ 5.0)\n");
2602 } else if (g_menu_state == CURRENT_STATUS_SET_TRACK_TYPE) {
2603 g_print(" *** input track type.(1:audio, 3:text)\n");
2604 } else if (g_menu_state == CURRENT_STATUS_SET_TRACK_INDEX) {
2605 g_print(" *** input track index\n");
2606 } else if (g_menu_state == CURRENT_STATUS_NEXT_URI) {
2607 g_print("*** input next uri.\n");
2608 } else if (g_menu_state == CURRENT_STATUS_GAPLESS) {
2609 g_print("*** input gapless value.(0:disable, 1: enable) \n");
2610 } else if (g_menu_state == CURRENT_STATUS_GET_TRACK_INFO) {
2611 g_print("*** input track type.(1:audio, 3:text) \n");
2612 } else if (g_menu_state == CURRENT_STATUS_SET_MAX_BANDWIDTH_VARIANT) {
2613 g_print("*** set max bandwidth (default: -1) \n");
2614 } else if (g_menu_state == CURRENT_STATUS_SET_MAX_WIDTH_VARIANT) {
2615 g_print("*** set max width (default: -1) \n");
2616 } else if (g_menu_state == CURRENT_STATUS_SET_MAX_HEIGHT_VARIANT) {
2617 g_print("*** set max height (default: -1) \n");
2618 } else if (g_menu_state == CURRENT_STATUS_SET_AUDIO_ONLY) {
2619 g_print("*** set audio only mode (0:disable, 1:enable) \n");
2620 } else if (g_menu_state == CURRENT_STATUS_SET_PRE_BUFFERING_SIZE) {
2621 g_print("*** set pre buffering size (ms) \n");
2622 } else if (g_menu_state == CURRENT_STATUS_SET_RE_BUFFERING_SIZE) {
2623 g_print("*** set re buffering size (ms) \n");
2624 } else if (g_menu_state == CURRENT_STATUS_VIDEO360_SET_ENABLE) {
2625 g_print("*** input video 360 status (0: disabled (full panorama), 1: enabled)\n");
2626 } else if (g_menu_state == CURRENT_STATUS_VIDEO360_SET_DOV) {
2627 g_print("*** input direction of view yaw angle (+/- 180 deg.)\n");
2628 } else if (g_menu_state == CURRENT_STATUS_VIDEO360_SET_DOV1) {
2629 g_print("*** input direction of view pitch angle (+/- 90 deg.)\n");
2630 } else if (g_menu_state == CURRENT_STATUS_VIDEO360_SET_FOV) {
2631 g_print("*** input horizontal field of view angle (1~360 deg.)\n");
2632 } else if (g_menu_state == CURRENT_STATUS_VIDEO360_SET_FOV1) {
2633 g_print("*** input vertical field of view angle (1~180 deg.)\n");
2634 } else if (g_menu_state == CURRENT_STATUS_VIDEO360_SET_ZOOM) {
2635 g_print("*** input zoom factor.(1.0~10.0, where 1.0 - no zoom, actual image) \n");
2636 } else if (g_menu_state == CURRENT_STATUS_VIDEO360_SET_ZOOM_WITH_FOV) {
2637 g_print("*** input zoom factor.(1.0~10.0, where 1.0 - no zoom, actual image) \n");
2638 } else if (g_menu_state == CURRENT_STATUS_VIDEO360_SET_ZOOM_WITH_FOV1) {
2639 g_print("*** input horizontal field of view angle (1~360 deg.)\n");
2640 } else if (g_menu_state == CURRENT_STATUS_VIDEO360_SET_ZOOM_WITH_FOV2) {
2641 g_print("*** input vertical field of view angle (1~180 deg.)\n");
2642 } else if (g_menu_state == CURRENT_STATUS_AUDIO_CODEC_TYPE) {
2643 g_print("*** set audio codec type (1: HW, 2: SW) \n");
2644 } else if (g_menu_state == CURRENT_STATUS_VIDEO_CODEC_TYPE) {
2645 g_print("*** set video codec type (1: HW, 2: SW) \n");
2646 } else if (g_menu_state == CURRENT_STATUS_REPLAYGAIN_ENABLE) {
2647 g_print("*** input replaygain value.(0:disable, 1: enable) \n");
2648 } else if (g_menu_state == CURRENT_STATUS_AUDIO_OFFLOAD) {
2649 g_print("*** input audio offload value.(0:disable, 1: enable) \n");
2650 } else if (g_menu_state == CURRENT_STATUS_PITCH_CONTROL) {
2651 g_print("*** input pitch control value.(0:disable, 1: enable) \n");
2652 } else if (g_menu_state == CURRENT_STATUS_PITCH_VALUE) {
2653 g_print("*** input pitch value.(0.5 ~ 2) \n");
2654 } else if (g_menu_state == CURRENT_STATUS_EXPORT_PCM_OPTION) {
2655 g_print("*** set option (0~3) \n");
2656 } else if (g_menu_state == CURRENT_STATUS_EXPORT_PCM_CH) {
2657 g_print("*** set pcm channel (e.g. 2)\n");
2658 } else if (g_menu_state == CURRENT_STATUS_EXPORT_PCM_RATE) {
2659 g_print("*** set pcm samplerate (e.g. 44100)\n");
2660 } else if (g_menu_state == CURRENT_STATUS_EXPORT_PCM_MIME) {
2661 g_print("*** set pcm mime (e.g. S16LE) \n");
2663 g_print("*** unknown status.\n");
2669 gboolean timeout_menu_display(void *data)
2675 gboolean timeout_quit_program(void *data)
2681 void reset_menu_state(void)
2683 g_menu_state = CURRENT_STATUS_MAINMENU;
2686 static void interpret(char *cmd)
2688 static int value1 = 0, value2 = 0, value3 = 0;
2689 static float fval = 0.0;
2691 switch (g_menu_state) {
2692 case CURRENT_STATUS_MAINMENU:
2694 _interpret_main_menu(cmd);
2697 case CURRENT_STATUS_HANDLE_NUM:
2700 if (0 >= value1 || value1 > MAX_HANDLE)
2701 g_print("not supported this number for handles(%d)\n", value1);
2703 g_handle_num = value1;
2708 case CURRENT_STATUS_FILENAME:
2710 input_filename(cmd);
2714 case CURRENT_STATUS_VOLUME:
2721 case CURRENT_STATUS_SOUND_STREAM_INFO:
2724 set_sound_stream_info(value1);
2728 case CURRENT_STATUS_MUTE:
2735 case CURRENT_STATUS_POSITION_TIME:
2738 g_menu_state = CURRENT_STATUS_POSITION_ACCURATE;
2741 case CURRENT_STATUS_POSITION_ACCURATE:
2743 set_position(value1, ((atoi(cmd) != 0) ? (true) : (false)));
2747 case CURRENT_STATUS_LOOPING:
2750 set_looping(value1);
2754 case CURRENT_STATUS_GAPLESS:
2757 set_gapless(value1);
2761 case CURRENT_STATUS_DISPLAY_SURFACE_CHANGE:
2764 change_surface(value1);
2765 if (value1 == 2) { /* null display type */
2766 g_menu_state = CURRENT_STATUS_EXPORT_VIDEO_FRAME;
2772 case CURRENT_STATUS_EXPORT_VIDEO_FRAME:
2776 set_video_frame_decoded_cb();
2779 case CURRENT_STATUS_DISPLAY_MODE:
2782 set_display_mode(value1);
2786 case CURRENT_STATUS_DISPLAY_DST_ROI_AREA:
2811 set_display_roi_area(x, y, w, h);
2820 case CURRENT_STATUS_DISPLAY_ROTATION:
2823 set_display_rotation(value1);
2827 case CURRENT_STATUS_DISPLAY_VISIBLE:
2830 set_display_visible(value1);
2834 case CURRENT_STATUS_SUBTITLE_FILENAME:
2836 input_subtitle_filename(cmd);
2840 case CURRENT_STATUS_AUDIO_EQUALIZER:
2843 set_audio_eq(value1);
2847 case CURRENT_STATUS_PLAYBACK_RATE:
2850 set_playback_rate(fval, FALSE);
2854 case CURRENT_STATUS_STREAMING_PLAYBACK_RATE:
2857 set_playback_rate(fval, TRUE);
2861 case CURRENT_STATUS_SET_TRACK_TYPE:
2864 get_track_info(value1);
2866 g_menu_state = CURRENT_STATUS_SET_TRACK_INDEX;
2869 case CURRENT_STATUS_SET_TRACK_INDEX:
2872 set_track(value1, value2);
2876 case CURRENT_STATUS_NEXT_URI:
2882 case CURRENT_STATUS_GET_TRACK_INFO:
2885 get_track_info(value1);
2889 case CURRENT_STATUS_SET_MAX_BANDWIDTH_VARIANT:
2892 g_menu_state = CURRENT_STATUS_SET_MAX_WIDTH_VARIANT;
2895 case CURRENT_STATUS_SET_MAX_WIDTH_VARIANT:
2898 g_menu_state = CURRENT_STATUS_SET_MAX_HEIGHT_VARIANT;
2901 case CURRENT_STATUS_SET_MAX_HEIGHT_VARIANT:
2904 set_variant_limit(value1, value2, value3);
2908 case CURRENT_STATUS_SET_AUDIO_ONLY:
2911 set_audio_only(value1);
2915 case CURRENT_STATUS_SET_PRE_BUFFERING_SIZE:
2918 g_menu_state = CURRENT_STATUS_SET_RE_BUFFERING_SIZE;
2921 case CURRENT_STATUS_SET_RE_BUFFERING_SIZE:
2924 set_buffer_size(value1, value2);
2928 case CURRENT_STATUS_VIDEO360_SET_ENABLE:
2931 video360_set_enable(value1);
2935 case CURRENT_STATUS_VIDEO360_SET_DOV:
2938 g_menu_state = CURRENT_STATUS_VIDEO360_SET_DOV1;
2941 case CURRENT_STATUS_VIDEO360_SET_DOV1:
2944 video360_set_dov(value1, value2);
2948 case CURRENT_STATUS_VIDEO360_SET_FOV:
2951 g_menu_state = CURRENT_STATUS_VIDEO360_SET_FOV1;
2954 case CURRENT_STATUS_VIDEO360_SET_FOV1:
2957 video360_set_fov(value1, value2);
2961 case CURRENT_STATUS_VIDEO360_SET_ZOOM:
2964 video360_set_zoom(fval);
2968 case CURRENT_STATUS_VIDEO360_SET_ZOOM_WITH_FOV:
2971 g_menu_state = CURRENT_STATUS_VIDEO360_SET_ZOOM_WITH_FOV1;
2974 case CURRENT_STATUS_VIDEO360_SET_ZOOM_WITH_FOV1:
2977 g_menu_state = CURRENT_STATUS_VIDEO360_SET_ZOOM_WITH_FOV2;
2980 case CURRENT_STATUS_VIDEO360_SET_ZOOM_WITH_FOV2:
2983 video360_set_zoom_with_fov(fval, value1, value2);
2987 case CURRENT_STATUS_AUDIO_CODEC_TYPE:
2990 g_menu_state = CURRENT_STATUS_VIDEO_CODEC_TYPE;
2993 case CURRENT_STATUS_VIDEO_CODEC_TYPE:
2996 set_codec_type(value1, value2);
3000 case CURRENT_STATUS_REPLAYGAIN_ENABLE:
3003 set_replaygain_enabled(value1);
3007 case CURRENT_STATUS_AUDIO_OFFLOAD:
3010 set_audio_offload_enabled(value1);
3014 case CURRENT_STATUS_PITCH_CONTROL:
3017 pitch_set_enabled(value1);
3021 case CURRENT_STATUS_PITCH_VALUE:
3024 pitch_set_value(fval);
3028 case CURRENT_STATUS_EXPORT_PCM_OPTION:
3031 g_menu_state = CURRENT_STATUS_EXPORT_PCM_CH;
3034 case CURRENT_STATUS_EXPORT_PCM_CH:
3037 g_menu_state = CURRENT_STATUS_EXPORT_PCM_RATE;
3040 case CURRENT_STATUS_EXPORT_PCM_RATE:
3043 g_menu_state = CURRENT_STATUS_EXPORT_PCM_MIME;
3046 case CURRENT_STATUS_EXPORT_PCM_MIME:
3048 set_audio_frame_decoded_cb((player_audio_extract_option_e)value1, cmd, value2, value3);
3054 g_timeout_add(100, timeout_menu_display, 0);
3057 gboolean input(GIOChannel *channel)
3059 gchar buf[MAX_STRING_LEN];
3061 GError *error = NULL;
3063 g_io_channel_read_chars(channel, buf, MAX_STRING_LEN, &read, &error);
3071 int main(int argc, char *argv[])
3073 GIOChannel *stdin_channel;
3074 stdin_channel = g_io_channel_unix_new(0);
3075 g_io_channel_set_flags(stdin_channel, G_IO_FLAG_NONBLOCK, NULL);
3076 g_io_add_watch(stdin_channel, G_IO_IN, (GIOFunc)input, NULL);
3079 memset(&ad, 0x0, sizeof(appdata));
3082 return appcore_efl_main(PACKAGE, &argc, &argv, &ops);