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>
27 #include <Ecore_Wayland.h>
34 #ifdef USE_EVENT_HANDLER
35 #include <mm_navevent_handler.h>
41 #define PACKAGE "player_test"
46 #define LOG_TAG "PLAYER_TEST"
48 #define MAX_STRING_LEN 2048
49 #define PLAYER_TEST_DUMP_PATH_PREFIX "/home/owner/dump_pcm_"
50 #define DEFAULT_HTTP_TIMEOUT -1
52 #include <system_info.h>
55 TIZEN_PROFILE_UNKNOWN = 0,
56 TIZEN_PROFILE_MOBILE = 0x1,
57 TIZEN_PROFILE_WEARABLE = 0x2,
58 TIZEN_PROFILE_TV = 0x4,
59 TIZEN_PROFILE_IVI = 0x8,
60 TIZEN_PROFILE_COMMON = 0x10,
63 #ifdef USE_EVENT_HANDLER
64 static void event_handler_cb(enum libinput_event_type ev_t, int x, int y, void * data, float e[3]);
65 static void event_handler_set_dov_fov();
66 static void event_handler_set_window_parameters();
67 mm_navevent_handler_h event_handler;
68 mm_navevent_handler_size_s image_size;
71 static tizen_profile_t _get_tizen_profile()
74 static tizen_profile_t profile = TIZEN_PROFILE_UNKNOWN;
76 if (__builtin_expect(profile != TIZEN_PROFILE_UNKNOWN, 1))
79 system_info_get_platform_string("http://tizen.org/feature/profile", &profileName);
80 switch (*profileName) {
83 profile = TIZEN_PROFILE_MOBILE;
87 profile = TIZEN_PROFILE_WEARABLE;
91 profile = TIZEN_PROFILE_TV;
95 profile = TIZEN_PROFILE_IVI;
97 default: // common or unknown ==> ALL ARE COMMON.
98 profile = TIZEN_PROFILE_COMMON;
104 #define TIZEN_TV ((_get_tizen_profile()) == TIZEN_PROFILE_TV)
106 static gboolean g_memory_playback = FALSE;
107 static char g_uri[MAX_STRING_LEN];
108 static char g_subtitle_uri[MAX_STRING_LEN];
109 static FILE *g_pcm_fd;
111 static gboolean is_es_push_mode = FALSE;
112 static pthread_t g_feed_video_thread_id = 0;
113 static bool g_thread_end = FALSE;
114 static media_packet_h g_audio_pkt = NULL;
115 static media_format_h g_audio_fmt = NULL;
117 static media_packet_h g_video_pkt = NULL;
118 static media_format_h g_video_fmt = NULL;
120 static int _save(unsigned char *src, int length);
122 #define DUMP_OUTBUF 1
124 FILE *fp_out1 = NULL;
125 FILE *fp_out2 = NULL;
129 CURRENT_STATUS_MAINMENU,
130 CURRENT_STATUS_HANDLE_NUM,
131 CURRENT_STATUS_FILENAME,
132 CURRENT_STATUS_VOLUME,
133 CURRENT_STATUS_SOUND_STREAM_INFO,
135 CURRENT_STATUS_POSITION_TIME,
136 CURRENT_STATUS_LOOPING,
137 CURRENT_STATUS_DISPLAY_SURFACE_CHANGE,
138 CURRENT_STATUS_EXPORT_VIDEO_FRAME,
139 CURRENT_STATUS_DISPLAY_MODE,
140 CURRENT_STATUS_DISPLAY_DST_ROI_AREA,
141 CURRENT_STATUS_DISPLAY_ROTATION,
142 CURRENT_STATUS_DISPLAY_VISIBLE,
143 CURRENT_STATUS_SUBTITLE_FILENAME,
144 CURRENT_STATUS_AUDIO_EQUALIZER,
145 CURRENT_STATUS_PLAYBACK_RATE,
146 CURRENT_STATUS_STREAMING_PLAYBACK_RATE,
147 CURRENT_STATUS_SET_TRACK_TYPE,
148 CURRENT_STATUS_SET_TRACK_INDEX,
149 CURRENT_STATUS_NEXT_URI,
150 CURRENT_STATUS_GAPLESS,
151 CURRENT_STATUS_GET_TRACK_INFO,
152 CURRENT_STATUS_POSITION_ACCURATE,
153 CURRENT_STATUS_SET_MAX_BANDWIDTH_VARIANT,
154 CURRENT_STATUS_SET_MAX_WIDTH_VARIANT,
155 CURRENT_STATUS_SET_MAX_HEIGHT_VARIANT,
156 CURRENT_STATUS_SET_AUDIO_ONLY,
157 CURRENT_STATUS_SET_PRE_BUFFERING_SIZE,
158 CURRENT_STATUS_SET_RE_BUFFERING_SIZE,
159 CURRENT_STATUS_VIDEO360_SET_ENABLE,
160 CURRENT_STATUS_VIDEO360_SET_DOV,
161 CURRENT_STATUS_VIDEO360_SET_DOV1,
162 CURRENT_STATUS_VIDEO360_SET_FOV,
163 CURRENT_STATUS_VIDEO360_SET_FOV1,
164 CURRENT_STATUS_VIDEO360_SET_ZOOM,
165 CURRENT_STATUS_VIDEO360_SET_ZOOM_WITH_FOV,
166 CURRENT_STATUS_VIDEO360_SET_ZOOM_WITH_FOV1,
167 CURRENT_STATUS_VIDEO360_SET_ZOOM_WITH_FOV2,
168 CURRENT_STATUS_AUDIO_CODEC_TYPE,
169 CURRENT_STATUS_VIDEO_CODEC_TYPE,
170 CURRENT_STATUS_REPLAYGAIN_ENABLE,
173 #define MAX_HANDLE 20
175 /* for video display */
176 static Evas_Object *g_win_id;
177 #ifdef _ACTIVATE_EOM_
178 static Evas_Object *g_external_win_id;
180 static Evas_Object *selected_win_id;
181 static Evas_Object *g_eo[MAX_HANDLE] = { 0, };
183 static int g_current_surface_type = -1;
187 Evas_Object *layout_main; /* layout widget based on EDJ */
188 /* add more variables here */
189 #ifdef _ACTIVATE_EOM_
195 static player_h g_player[MAX_HANDLE] = { 0, };
197 int g_handle_num = 1;
198 int g_menu_state = CURRENT_STATUS_MAINMENU;
199 gboolean quit_pushing;
200 sound_stream_info_h g_stream_info_h = NULL;
202 static void win_del(void *data, Evas_Object * obj, void *event)
207 static Evas_Object *create_win(const char *name)
209 Evas_Object *eo = NULL;
213 g_print("[%s][%d] name=%s\n", __func__, __LINE__, name);
215 eo = elm_win_add(NULL, name, ELM_WIN_BASIC);
217 elm_win_title_set(eo, name);
218 elm_win_borderless_set(eo, EINA_TRUE);
219 evas_object_smart_callback_add(eo, "delete,request", win_del, NULL);
220 elm_win_screen_size_get(eo, NULL, NULL, &w, &h);
221 g_print("window size :%d,%d", w, h);
222 evas_object_resize(eo, w, h);
223 elm_win_autodel_set(eo, EINA_TRUE);
224 elm_win_alpha_set(eo, EINA_TRUE);
229 static Evas_Object *create_image_object(Evas_Object * eo_parent)
234 Evas *evas = evas_object_evas_get(eo_parent);
235 Evas_Object *eo = NULL;
237 eo = evas_object_image_add(evas);
242 void create_render_rect_and_bg(Evas_Object * win)
248 Evas_Object *bg, *rect;
250 bg = elm_bg_add(win);
251 elm_win_resize_object_add(win, bg);
252 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
253 evas_object_show(bg);
255 rect = evas_object_rectangle_add(evas_object_evas_get(win));
260 evas_object_color_set(rect, 0, 0, 0, 0);
261 evas_object_render_op_set(rect, EVAS_RENDER_COPY);
263 elm_win_resize_object_add(win, rect);
264 evas_object_size_hint_weight_set(rect, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
265 evas_object_show(rect);
266 evas_object_show(win);
269 #ifdef _ACTIVATE_EOM_
270 int eom_get_output_id(const char *output_name)
272 eom_output_id *output_ids = NULL;
273 eom_output_id output_id = 0;
274 eom_output_type_e output_type = EOM_OUTPUT_TYPE_UNKNOWN;
279 output_ids = eom_get_eom_output_ids(&id_cnt);
281 g_print("[eom] no external outuputs supported\n");
285 /* find output ids interested */
286 for (i = 0; i < id_cnt; i++) {
287 eom_get_output_type(output_ids[i], &output_type);
288 if (!strncmp(output_name, "HDMI", 4)) {
289 if (output_type == EOM_OUTPUT_TYPE_HDMIA || output_type == EOM_OUTPUT_TYPE_HDMIB) {
290 output_id = output_ids[i];
293 } else if (!strncmp(output_name, "Virtual", 4)) {
294 if (output_type == EOM_OUTPUT_TYPE_VIRTUAL) {
295 output_id = output_ids[i];
307 static void eom_notify_cb_output_add(eom_output_id output_id, void *user_data)
309 appdata *info = (appdata *) user_data;
311 if (info->hdmi_output_id != output_id) {
312 g_print("[eom] OUTPUT ADDED. SKIP. my output ID is %d\n", info->hdmi_output_id);
315 g_print("[eom] output(%d) connected\n", output_id);
316 /* it is for external window */
317 if (!g_external_win_id) {
318 g_external_win_id = elm_win_add(NULL, "External", ELM_WIN_BASIC);
319 if (eom_set_output_window(info->hdmi_output_id, g_external_win_id) == EOM_ERROR_NONE) {
320 create_render_rect_and_bg(g_external_win_id);
321 g_print("[eom] create external window\n");
323 evas_object_del(g_external_win_id);
324 g_external_win_id = NULL;
325 g_print("[eom] create external window fail\n");
330 static void eom_notify_cb_output_remove(eom_output_id output_id, void *user_data)
332 appdata *info = (appdata *) user_data;
333 player_state_e state;
335 if (info->hdmi_output_id != output_id) {
336 g_print("[eom] OUTPUT REMOVED. SKIP. my output ID is %d\n", info->hdmi_output_id);
339 g_print("[eom] output(%d) disconnected\n", output_id);
341 if (selected_win_id == g_external_win_id && g_player[0]) {
342 player_get_state(g_player[0], &state);
343 if (state >= PLAYER_STATE_READY) {
345 g_win_id = create_win(PACKAGE);
346 if (g_win_id == NULL)
348 g_print("create win_id %p\n", g_win_id);
349 create_render_rect_and_bg(g_win_id);
350 elm_win_activate(g_win_id);
351 evas_object_show(g_win_id);
353 player_set_display(g_player[0], PLAYER_DISPLAY_TYPE_OVERLAY, GET_DISPLAY(g_win_id));
357 /* it is for external window */
358 if (g_external_win_id) {
359 evas_object_del(g_external_win_id);
360 g_external_win_id = NULL;
362 selected_win_id = g_win_id;
365 static void eom_notify_cb_mode_changed(eom_output_id output_id, void *user_data)
367 appdata *info = (appdata *) user_data;
368 eom_output_mode_e mode = EOM_OUTPUT_MODE_NONE;
370 if (info->hdmi_output_id != output_id) {
371 g_print("[eom] MODE CHANGED. SKIP. my output ID is %d\n", info->hdmi_output_id);
375 eom_get_output_mode(output_id, &mode);
376 g_print("[eom] output(%d) mode changed(%d)\n", output_id, mode);
379 static void eom_notify_cb_attribute_changed(eom_output_id output_id, void *user_data)
381 appdata *info = (appdata *) user_data;
383 eom_output_attribute_e attribute = EOM_OUTPUT_ATTRIBUTE_NONE;
384 eom_output_attribute_state_e state = EOM_OUTPUT_ATTRIBUTE_STATE_NONE;
386 if (info->hdmi_output_id != output_id) {
387 g_print("[eom] ATTR CHANGED. SKIP. my output ID is %d\n", info->hdmi_output_id);
391 eom_get_output_attribute(output_id, &attribute);
392 eom_get_output_attribute_state(output_id, &state);
394 g_print("[eom] output(%d) attribute changed(%d, %d)\n", output_id, attribute, state);
395 if (state == EOM_OUTPUT_ATTRIBUTE_STATE_ACTIVE) {
396 g_print("[eom] active\n");
397 if (!g_external_win_id) {
398 g_external_win_id = elm_win_add(NULL, "External", ELM_WIN_BASIC);
399 if (eom_set_output_window(info->hdmi_output_id, g_external_win_id) == EOM_ERROR_NONE) {
400 create_render_rect_and_bg(g_external_win_id);
401 g_print("[eom] create external window\n");
403 evas_object_del(g_external_win_id);
404 g_external_win_id = NULL;
405 g_print("[eom] create external window fail\n");
408 selected_win_id = g_external_win_id;
409 /* play video on external window */
411 player_set_display(g_player[0], PLAYER_DISPLAY_TYPE_OVERLAY, GET_DISPLAY(selected_win_id));
412 } else if (state == EOM_OUTPUT_ATTRIBUTE_STATE_INACTIVE) {
413 g_print("[eom] inactive\n");
415 g_win_id = create_win(PACKAGE);
416 if (g_win_id == NULL)
418 g_print("create win_id %p\n", g_win_id);
419 create_render_rect_and_bg(g_win_id);
420 elm_win_activate(g_win_id);
421 evas_object_show(g_win_id);
423 selected_win_id = g_win_id;
425 player_set_display(g_player[0], PLAYER_DISPLAY_TYPE_OVERLAY, GET_DISPLAY(selected_win_id));
427 if (g_external_win_id) {
428 evas_object_del(g_external_win_id);
429 g_external_win_id = NULL;
431 } else if (state == EOM_OUTPUT_ATTRIBUTE_STATE_LOST) {
432 g_print("[eom] lost\n");
434 g_win_id = create_win(PACKAGE);
435 if (g_win_id == NULL)
437 g_print("create win_id %p\n", g_win_id);
438 create_render_rect_and_bg(g_win_id);
439 elm_win_activate(g_win_id);
440 evas_object_show(g_win_id);
442 selected_win_id = g_win_id;
445 player_set_display(g_player[0], PLAYER_DISPLAY_TYPE_OVERLAY, GET_DISPLAY(selected_win_id));
447 if (g_external_win_id) {
448 evas_object_del(g_external_win_id);
449 g_external_win_id = NULL;
452 eom_unset_output_added_cb(eom_notify_cb_output_add);
453 eom_unset_output_removed_cb(eom_notify_cb_output_remove);
454 eom_unset_mode_changed_cb(eom_notify_cb_mode_changed);
455 eom_unset_attribute_changed_cb(eom_notify_cb_attribute_changed);
461 static int app_create(void *data)
464 Evas_Object *win = NULL;
465 #ifdef _ACTIVATE_EOM_
466 eom_output_mode_e output_mode = EOM_OUTPUT_MODE_NONE;
470 elm_config_accel_preference_set("opengl");
473 win = create_win(PACKAGE);
478 selected_win_id = g_win_id;
479 create_render_rect_and_bg(ad->win);
480 /* Create evas image object for EVAS surface */
481 g_eo[0] = create_image_object(ad->win);
482 evas_object_image_size_set(g_eo[0], 500, 500);
483 evas_object_image_fill_set(g_eo[0], 0, 0, 500, 500);
484 evas_object_resize(g_eo[0], 500, 500);
486 elm_win_activate(win);
487 evas_object_show(win);
488 #ifdef _ACTIVATE_EOM_
489 /* check external device */
491 ad->hdmi_output_id = eom_get_output_id("HDMI");
492 if (ad->hdmi_output_id == 0) {
493 g_print("[eom] error : HDMI output id is NULL.\n");
497 g_print("eom_set_output_attribute EOM_OUTPUT_ATTRIBUTE_NORMAL(id:%d)\n", ad->hdmi_output_id);
498 if (eom_set_output_attribute(ad->hdmi_output_id, EOM_OUTPUT_ATTRIBUTE_NORMAL) != EOM_ERROR_NONE) {
499 g_print("attribute set fail. cannot use external output\n");
503 eom_get_output_mode(ad->hdmi_output_id, &output_mode);
504 if (output_mode != EOM_OUTPUT_MODE_NONE) {
505 g_external_win_id = elm_win_add(NULL, "External", ELM_WIN_BASIC);
506 if (eom_set_output_window(ad->hdmi_output_id, g_external_win_id) == EOM_ERROR_NONE) {
507 create_render_rect_and_bg(g_external_win_id);
508 g_print("[eom] create external window\n");
510 evas_object_del(g_external_win_id);
511 g_external_win_id = NULL;
512 g_print("[eom] create external window fail\n");
514 selected_win_id = g_external_win_id;
517 /* set callback for detecting external device */
518 eom_set_output_added_cb(eom_notify_cb_output_add, ad);
519 eom_set_output_removed_cb(eom_notify_cb_output_remove, ad);
520 eom_set_mode_changed_cb(eom_notify_cb_mode_changed, ad);
521 eom_set_attribute_changed_cb(eom_notify_cb_attribute_changed, ad);
524 #ifdef USE_EVENT_HANDLER
525 if (mm_navevent_handler_create(&event_handler,
526 MM_NAVEVENT_HANDLER_DEVICE_TYPE_TOUCH) != MM_NAVEVENT_HANDLER_ERROR_NONE) {
527 g_print ("Error during handler creation\n");
531 if (mm_navevent_handler_set_cb(event_handler, event_handler_cb, NULL) !=
532 MM_NAVEVENT_HANDLER_ERROR_NONE) {
533 g_print ("Error during callback set\n");
541 static int app_terminate(void *data)
546 #ifdef USE_EVENT_HANDLER
547 mm_navevent_handler_destroy(event_handler);
550 for (i = 0; i < MAX_HANDLE; i++) {
552 evas_object_del(g_eo[i]);
557 evas_object_del(g_win_id);
560 #ifdef _ACTIVATE_EOM_
561 if (g_external_win_id) {
562 evas_object_del(g_external_win_id);
563 g_external_win_id = NULL;
567 selected_win_id = NULL;
568 #ifdef _ACTIVATE_EOM_
569 eom_unset_output_added_cb(eom_notify_cb_output_add);
570 eom_unset_output_removed_cb(eom_notify_cb_output_remove);
571 eom_unset_mode_changed_cb(eom_notify_cb_mode_changed);
572 eom_unset_attribute_changed_cb(eom_notify_cb_attribute_changed);
579 struct appcore_ops ops = {
580 .create = app_create,
581 .terminate = app_terminate,
584 static void prepared_cb(void *user_data)
586 g_print("[Player_Test] prepared_cb!!!!\n");
589 static void _audio_frame_decoded_cb_ex(player_audio_raw_data_s * audio_raw_frame, void *user_data)
591 player_audio_raw_data_s *audio_raw = audio_raw_frame;
596 g_print("[Player_Test] decoded_cb_ex! channel: %d channel_mask: %llu\n", audio_raw->channel, audio_raw->channel_mask);
599 if (audio_raw->channel_mask == 1 && fp_out1)
600 fwrite((guint8 *) audio_raw->data, 1, audio_raw->size, fp_out1);
601 else if (audio_raw->channel_mask == 2 && fp_out2)
602 fwrite((guint8 *) audio_raw->data, 1, audio_raw->size, fp_out2);
606 static void progress_down_cb(player_pd_message_type_e type, void *user_data)
608 g_print("[Player_Test] progress_down_cb!!!! type : %d\n", type);
611 static void buffering_cb(int percent, void *user_data)
613 g_print("[Player_Test] buffering_cb!!!! percent : %d\n", percent);
616 static void seek_completed_cb(void *user_data)
618 g_print("[Player_Test] seek_completed_cb!!! \n");
621 static void completed_cb(void *user_data)
623 g_print("[Player_Test] completed_cb!!!!\n");
626 static void error_cb(int code, void *user_data)
628 g_print("[Player_Test] error_cb!!!! code : %d\n", code);
631 static void interrupted_cb(player_interrupted_code_e code, void *user_data)
633 g_print("[Player_Test] interrupted_cb!!!! code : %d\n", code);
636 static void video_changed_cb(int width, int height, int fps, int bit_rate, void *user_data)
638 g_print("[Player_Test] video_changed_cb!!!! %d x %d, %d, %d \n", width, height, fps, bit_rate);
640 #ifdef USE_EVENT_HANDLER
641 image_size.width = width;
642 image_size.height = height;
643 event_handler_set_window_parameters();
648 static void audio_frame_decoded_cb(unsigned char *data, unsigned int size, void *user_data)
652 if (data && g_pcm_fd)
653 fwrite(data, 1, size, g_pcm_fd);
654 player_get_play_position(g_player[0], &pos);
655 g_print("[Player_Test] audio_frame_decoded_cb [size: %d] --- current pos : %d!!!!\n", size, pos);
659 static void subtitle_updated_cb(unsigned long duration, char *text, void *user_data)
661 g_print("[Player_Test] subtitle_updated_cb!!!! [%ld] %s\n", duration, text);
664 static void video_captured_cb(unsigned char *data, int width, int height, unsigned int size, void *user_data)
666 g_print("[Player_Test] video_captured_cb!!!! width: %d, height : %d, size : %d \n", width, height, size);
670 static int _save(unsigned char *src, int length)
672 /* unlink(CAPTUERD_IMAGE_SAVE_PATH); */
674 char filename[256] = { 0, };
675 static int WRITE_COUNT = 0;
676 /* gchar *filename = CAPTUERD_IMAGE_SAVE_PATH; */
677 snprintf(filename, 256, "/tmp/IMAGE_client%d", WRITE_COUNT);
679 fp = fopen(filename, "w+");
681 g_print("file open error!!\n");
684 g_print("open success\n");
685 if (fwrite(src, 1, length, fp) < 1) {
686 g_print("file write error!!\n");
690 g_print("write success(%s)\n", filename);
697 static void reset_display()
701 /* delete evas window, if it is */
702 for (i = 0; i < MAX_HANDLE; i++) {
704 evas_object_del(g_eo[i]);
710 static void input_filename(char *filename)
712 int len = strlen(filename);
715 if (len < 0 || len > MAX_STRING_LEN - 1)
718 for (i = 0; i < g_handle_num; i++) {
719 if (g_player[i] != NULL) {
720 player_unprepare(g_player[i]);
721 player_destroy(g_player[i]);
725 if (player_create(&g_player[i]) != PLAYER_ERROR_NONE)
726 g_print("player create is failed\n");
729 strncpy(g_uri, filename, len+1);
733 /* ned(APPSRC_TEST) */
738 GError *error = NULL;
739 guint8 *g_media_mem = NULL;
743 file = g_mapped_file_new(ext, FALSE, &error);
744 file_size = g_mapped_file_get_length(file);
745 g_media_mem = (guint8 *) g_mapped_file_get_contents(file);
747 g_sprintf(uri, "mem://ext=%s,size=%d", ext ? ext : "", file_size);
748 g_print("[uri] = %s\n", uri);
750 mm_player_set_attribute(g_player[0], &g_err_name, "profile_uri", uri, strlen(uri), "profile_user_param", g_media_mem, file_size NULL);
752 /* player_set_uri(g_player[0], filename); */
757 player_state_e state;
758 for (i = 0; i < g_handle_num; i++) {
759 ret = player_get_state(g_player[i], &state);
760 g_print("player_get_state returned [%d]\n", ret);
761 g_print("1. After player_create() - Current State : %d \n", state);
765 /* use this API instead of player_set_uri */
766 static void player_set_memory_buffer_test()
770 guint8 *g_media_mem = NULL;
772 file = g_mapped_file_new(g_uri, FALSE, NULL);
773 file_size = g_mapped_file_get_length(file);
774 g_media_mem = (guint8 *) g_mapped_file_get_contents(file);
776 int ret = player_set_memory_buffer(g_player[0], (void *)g_media_mem, file_size);
777 g_print("player_set_memory_buffer ret : %d\n", ret);
780 int video_packet_count = 0;
782 static void buffer_need_video_data_cb(unsigned int size, void *user_data)
784 int real_read_len = 0;
787 static guint64 pts = 0L;
790 guint8 *buff_ptr = NULL;
793 memset(fname, 0, 128);
794 memset(fptsname, 0, 128);
796 video_packet_count++;
798 if (video_packet_count > 1000) {
801 /* player_submit_packet(g_player[0], NULL, 0, 0, 1); */
802 player_push_media_stream(g_player[0], NULL);
806 /* snprintf(fname, 128, "/opt/storage/usb/test/packet/packet_%d.dat", video_packet_count); */
807 /* snprintf(fptsname, 128, "/opt/storage/usb/test/packet/gstpts_%d.dat", video_packet_count); */
808 snprintf(fname, 128, "/home/developer/test/packet/packet_%d.dat", video_packet_count);
809 snprintf(fptsname, 128, "/home/developer/test/packet/gstpts_%d.dat", video_packet_count);
811 fp = fopen(fptsname, "rb");
814 pts_len = fread(&pts, 1, sizeof(guint64), fp);
815 if (pts_len != sizeof(guint64))
816 g_print("Warning, pts value can be wrong.\n");
821 fp = fopen(fname, "rb");
823 buff_ptr = (guint8 *) g_malloc0(1048576);
825 g_print("no free space\n");
830 real_read_len = fread(buff_ptr, 1, size, fp);
834 g_print("video need data - data size : %d, pts : %" G_GUINT64_FORMAT "\n", real_read_len, pts);
836 player_submit_packet(g_player[0], buff_ptr, real_read_len, (pts / 1000000), 1);
838 /* create media packet */
840 media_packet_destroy(g_video_pkt);
844 if (media_packet_create_alloc(g_video_fmt, NULL, NULL, &g_video_pkt) != MEDIA_PACKET_ERROR_NONE) {
845 g_print("media_packet_create_alloc failed\n");
849 g_print("packet = %p, src = %p\n", g_video_pkt, src);
851 if (media_packet_get_buffer_data_ptr(g_video_pkt, &src) != MEDIA_PACKET_ERROR_NONE)
854 if (media_packet_set_pts(g_video_pkt, (uint64_t) pts) != MEDIA_PACKET_ERROR_NONE)
857 if (media_packet_set_buffer_size(g_video_pkt, (uint64_t) real_read_len) != MEDIA_PACKET_ERROR_NONE)
860 memcpy(src, buff_ptr, real_read_len);
863 player_push_media_stream(g_player[0], g_video_pkt);
873 int audio_packet_count = 0;
874 static void buffer_need_audio_data_cb(unsigned int size, void *user_data)
876 int real_read_len = 0;
879 guint8 *buff_ptr = NULL;
882 memset(fname, 0, 128);
883 audio_packet_count++;
885 if (audio_packet_count > 1000) {
887 /* player_submit_packet(g_player[0], NULL, 0, 0, 0); */
888 player_push_media_stream(g_player[0], NULL);
892 /* snprintf(fname, 128, "/opt/storage/usb/test/audio_packet/packet_%d.dat", audio_packet_count); */
893 snprintf(fname, 128, "/home/developer/test/audio_packet/packet_%d.dat", audio_packet_count);
895 static guint64 audio_pts = 0;
896 guint64 audio_dur = 21333333;
898 fp = fopen(fname, "rb");
900 buff_ptr = (guint8 *) g_malloc0(1048576);
902 g_print("no free space\n");
907 real_read_len = fread(buff_ptr, 1, size, fp);
911 g_print("\t audio need data - data size : %d, pts : %" G_GUINT64_FORMAT "\n", real_read_len, audio_pts);
914 player_submit_packet(g_player[0], buff_ptr, real_read_len, (audio_pts / 1000000), 0);
916 /* create media packet */
918 media_packet_destroy(g_audio_pkt);
922 if (media_packet_create_alloc(g_audio_fmt, NULL, NULL, &g_audio_pkt) != MEDIA_PACKET_ERROR_NONE) {
923 g_print("media_packet_create_alloc failed\n");
927 g_print("packet = %p, src = %p\n", g_audio_pkt, src);
929 if (media_packet_get_buffer_data_ptr(g_audio_pkt, &src) != MEDIA_PACKET_ERROR_NONE)
932 if (media_packet_set_pts(g_audio_pkt, (uint64_t) audio_pts) != MEDIA_PACKET_ERROR_NONE)
935 if (media_packet_set_buffer_size(g_audio_pkt, (uint64_t) real_read_len) != MEDIA_PACKET_ERROR_NONE)
938 memcpy(src, buff_ptr, real_read_len);
941 player_push_media_stream(g_player[0], g_audio_pkt);
944 audio_pts += audio_dur;
952 static void set_content_info(bool is_push_mode)
954 /* testcode for es buff src case, please input url as es_buff://123 or es_buff://push_mode */
955 /* 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}; */
957 /* create media format */
958 media_format_create(&g_audio_fmt);
959 media_format_create(&g_video_fmt);
962 /* configure media format for video and set to player */
963 media_format_set_video_mime(g_video_fmt, MEDIA_FORMAT_MPEG4_SP);
964 media_format_set_video_width(g_video_fmt, 640);
965 media_format_set_video_height(g_video_fmt, 272);
966 /* player_set_media_stream_info(g_player[0], PLAYER_STREAM_TYPE_VIDEO, g_video_fmt); */
968 /* Audio--aac--StarWars.mp4 */
969 media_format_set_audio_mime(g_audio_fmt, MEDIA_FORMAT_AAC);
970 media_format_set_audio_channel(g_audio_fmt, 2);
971 media_format_set_audio_samplerate(g_audio_fmt, 48000);
972 /* player_set_media_stream_info(g_player[0], PLAYER_STREAM_TYPE_AUDIO, g_audio_fmt); */
974 /* video_info->mime = g_strdup("video/mpeg"); *//* CODEC_ID_MPEG4VIDEO */
975 video_info->width = 640;
976 video_info->height = 272;
977 video_info->version = 4;
978 video_info->framerate_den = 100;
979 video_info->framerate_num = 2997;
981 video_info->extradata_size = 45;
982 video_info->codec_extradata = codec_data;
983 player_set_video_stream_info(g_player[0], video_info);
985 /* audio--aac--StarWars.mp4 */
986 /* audio_info->mime = g_strdup("audio/mpeg"); */
987 /* audio_info->version = 2; */
988 /* audio_info->user_info = 0; *//* raw */
993 player_set_buffer_need_video_data_cb(g_player[0], buffer_need_video_data_cb, (void *)g_player[0]);
994 player_set_buffer_need_audio_data_cb(g_player[0], buffer_need_audio_data_cb, (void *)g_player[0]);
999 static void feed_video_data_thread_func(void *data)
1001 while (!g_thread_end) {
1002 buffer_need_video_data_cb(1048576, NULL);
1003 buffer_need_audio_data_cb(1048576, NULL);
1007 static void _player_prepare(bool async)
1010 int slen = strlen(g_subtitle_uri);
1012 if (slen > 0 && slen < MAX_STRING_LEN) {
1013 g_print("0. set subtile path() (size : %d) - %s \n", slen, g_subtitle_uri);
1014 player_set_subtitle_path(g_player[0], g_subtitle_uri);
1015 player_set_subtitle_updated_cb(g_player[0], subtitle_updated_cb, (void *)g_player[0]);
1017 if (g_current_surface_type == -1) {
1018 g_print("You must set display surface type before setting prepare.\n");
1022 if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
1023 player_set_buffering_cb(g_player[0], buffering_cb, (void *)g_player[0]);
1024 player_set_completed_cb(g_player[0], completed_cb, (void *)g_player[0]);
1025 player_set_interrupted_cb(g_player[0], interrupted_cb, (void *)g_player[0]);
1026 player_set_error_cb(g_player[0], error_cb, (void *)g_player[0]);
1027 player_set_video_stream_changed_cb(g_player[0], video_changed_cb, (void *)g_player[0]);
1028 if (g_memory_playback)
1029 player_set_memory_buffer_test();
1031 player_set_uri(g_player[0], g_uri);
1034 for (i = 0; i < g_handle_num; i++) {
1035 player_set_buffering_cb(g_player[i], buffering_cb, (void *)g_player[i]);
1036 player_set_completed_cb(g_player[i], completed_cb, (void *)g_player[i]);
1037 player_set_interrupted_cb(g_player[i], interrupted_cb, (void *)g_player[i]);
1038 player_set_error_cb(g_player[i], error_cb, (void *)g_player[i]);
1039 player_set_video_stream_changed_cb(g_player[0], video_changed_cb, (void *)g_player[0]);
1040 if (g_memory_playback)
1041 player_set_memory_buffer_test();
1043 player_set_uri(g_player[i], g_uri);
1047 if (strstr(g_uri, "es_buff://")) {
1048 is_es_push_mode = FALSE;
1049 video_packet_count = 0;
1050 audio_packet_count = 0;
1052 if (strstr(g_uri, "es_buff://push_mode")) {
1053 set_content_info(TRUE);
1055 is_es_push_mode = TRUE;
1058 set_content_info(FALSE);
1063 if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
1065 ret = player_prepare_async(g_player[0], prepared_cb, (void *)g_player[0]);
1067 ret = player_prepare(g_player[0]);
1070 for (i = 0; i < g_handle_num; i++) {
1072 ret = player_prepare_async(g_player[i], prepared_cb, (void *)g_player[i]);
1074 ret = player_prepare(g_player[i]);
1078 if (ret != PLAYER_ERROR_NONE)
1079 g_print("prepare is failed (errno = %d) \n", ret);
1081 player_state_e state;
1082 if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
1083 ret = player_get_state(g_player[0], &state);
1084 g_print("After player_prepare() - Current State : %d \n", state);
1087 for (i = 0; i < g_handle_num; i++) {
1088 ret = player_get_state(g_player[i], &state);
1089 g_print("After player_prepare() - Current State : %d \n", state);
1093 if (is_es_push_mode)
1094 pthread_create(&g_feed_video_thread_id, NULL, (void *)feed_video_data_thread_func, NULL);
1096 #ifdef USE_EVENT_HANDLER
1097 event_handler_set_dov_fov();
1101 static void _player_unprepare()
1105 if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
1106 ret = player_unprepare(g_player[0]);
1107 if (ret != PLAYER_ERROR_NONE)
1108 g_print("unprepare is failed (errno = %d) \n", ret);
1110 ret = player_unset_subtitle_updated_cb(g_player[0]);
1111 g_print("player_unset_subtitle_updated_cb ret %d\n", ret);
1113 ret = player_unset_buffering_cb(g_player[0]);
1114 g_print("player_unset_buffering_cb ret %d\n", ret);
1116 ret = player_unset_completed_cb(g_player[0]);
1117 g_print("player_unset_completed_cb ret %d\n", ret);
1119 ret = player_unset_interrupted_cb(g_player[0]);
1120 g_print("player_unset_interrupted_cb ret %d\n", ret);
1122 ret = player_unset_error_cb(g_player[0]);
1123 g_print("player_unset_error_cb ret %d\n", ret);
1125 for (i = 0; i < g_handle_num; i++) {
1126 if (g_player[i] != NULL) {
1127 ret = player_unprepare(g_player[i]);
1128 if (ret != PLAYER_ERROR_NONE)
1129 g_print("unprepare is failed (errno = %d) \n", ret);
1131 ret = player_unset_subtitle_updated_cb(g_player[i]);
1132 g_print("player_unset_subtitle_updated_cb [%d] ret %d\n", i, ret);
1134 ret = player_unset_buffering_cb(g_player[i]);
1135 g_print("player_unset_buffering_cb [%d] ret %d\n", i, ret);
1137 ret = player_unset_completed_cb(g_player[i]);
1138 g_print("player_unset_completed_cb [%d] ret %d\n", i, ret);
1140 ret = player_unset_interrupted_cb(g_player[i]);
1141 g_print("player_unset_interrupted_cb [%d] ret %d\n", i, ret);
1143 ret = player_unset_error_cb(g_player[i]);
1144 g_print("player_unset_error_cb [%d] ret %d\n", i, ret);
1149 memset(g_subtitle_uri, 0, sizeof(g_subtitle_uri));
1150 player_state_e state;
1151 if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
1152 ret = player_get_state(g_player[0], &state);
1153 g_print(" After player_unprepare() - Current State : %d \n", state);
1155 for (i = 0; i < g_handle_num; i++) {
1156 ret = player_get_state(g_player[i], &state);
1157 g_print(" After player_unprepare() - Current State : %d \n", state);
1162 static void _player_destroy()
1166 if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
1167 player_destroy(g_player[0]);
1170 for (i = 0; i < g_handle_num; i++) {
1171 if (g_player[i] != NULL) {
1172 player_unprepare(g_player[i]);
1173 player_destroy(g_player[i]);
1179 if (g_stream_info_h) {
1180 sound_manager_destroy_stream_information(g_stream_info_h);
1181 g_stream_info_h = NULL;
1185 media_packet_destroy(g_video_pkt);
1188 media_packet_destroy(g_audio_pkt);
1199 static void _player_play()
1203 if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
1204 #ifdef _ACTIVATE_EOM_
1205 /* for checking external display.... */
1206 player_set_display(g_player[0], g_current_surface_type, GET_DISPLAY(selected_win_id));
1208 bRet = player_start(g_player[0]);
1209 g_print("player_start returned [%d]", bRet);
1211 for (i = 0; i < g_handle_num; i++) {
1212 bRet = player_start(g_player[i]);
1213 g_print("player_start returned [%d]", bRet);
1218 static void _player_stop()
1222 if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
1223 bRet = player_stop(g_player[0]);
1224 g_print("player_stop returned [%d]", bRet);
1226 for (i = 0; i < g_handle_num; i++) {
1227 bRet = player_stop(g_player[i]);
1228 g_print("player_stop returned [%d]", bRet);
1232 g_thread_end = TRUE;
1233 if (g_feed_video_thread_id) {
1234 pthread_join(g_feed_video_thread_id, NULL);
1235 g_feed_video_thread_id = 0;
1240 static void _player_resume()
1244 if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
1245 #ifdef _ACTIVATE_EOM_
1246 /* for checking external display.... */
1247 player_set_display(g_player[0], PLAYER_DISPLAY_TYPE_OVERLAY, GET_DISPLAY(selected_win_id));
1249 bRet = player_start(g_player[0]);
1250 g_print("player_start returned [%d]", bRet);
1252 for (i = 0; i < g_handle_num; i++) {
1253 bRet = player_start(g_player[i]);
1254 g_print("player_start returned [%d]", bRet);
1259 static void _player_pause()
1263 if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
1264 bRet = player_pause(g_player[0]);
1265 g_print("player_pause returned [%d]", bRet);
1267 for (i = 0; i < g_handle_num; i++) {
1268 bRet = player_pause(g_player[i]);
1269 g_print("player_pause returned [%d]", bRet);
1274 static void _player_state()
1276 player_state_e state;
1277 player_get_state(g_player[0], &state);
1278 g_print(" ==> [Player_Test] Current Player State : %d\n", state);
1281 static void _player_set_progressive_download()
1283 player_set_progressive_download_path(g_player[0], "/tmp/test.pd");
1284 player_set_progressive_download_message_cb(g_player[0], progress_down_cb, (void *)g_player[0]);
1287 static void _player_get_progressive_download_status()
1290 unsigned long curr = 0, total = 0;
1291 bRet = player_get_progressive_download_status(g_player[0], &curr, &total);
1292 g_print("player_get_progressive_download_status return[%d] ==> [Player_Test] progressive download status : %lu/%lu\n", bRet, curr, total);
1295 static void _player_enable_tsurf_pool(void)
1297 bool enabled = FALSE;
1300 g_print("not support at TV profile");
1304 player_is_enabled_tsurf_pool(g_player[0], &enabled);
1306 g_print("tbm surface pool will be %s", (enabled) ? "disabled" : "enabled");
1307 player_enable_tsurf_pool(g_player[0], !enabled);
1310 static void set_next_uri(char * uri)
1313 g_print("not support at TV profile");
1317 if (player_set_next_uri(g_player[0], uri) != PLAYER_ERROR_NONE)
1318 g_print("fail to set next uri");
1321 static void get_next_uri()
1326 g_print("not support at TV profile");
1330 if (player_get_next_uri(g_player[0], &uri) != PLAYER_ERROR_NONE) {
1331 g_print("fail to get next uri");
1336 g_print("next_uri = %s", uri);
1341 static void set_volume(float volume)
1343 if (player_set_volume(g_player[0], volume, volume) != PLAYER_ERROR_NONE)
1344 g_print("failed to set volume\n");
1347 static void get_volume(float *left, float *right)
1349 player_get_volume(g_player[0], left, right);
1350 g_print(" ==> [Player_Test] volume - left : %f, right : %f\n", *left, *right);
1353 static void set_mute(bool mute)
1355 if (player_set_mute(g_player[0], mute) != PLAYER_ERROR_NONE)
1356 g_print("failed to set_mute\n");
1359 static void get_mute(bool * mute)
1361 player_is_muted(g_player[0], mute);
1362 g_print(" ==> [Player_Test] mute = %d\n", *mute);
1365 void focus_callback(sound_stream_info_h stream_info,
1366 sound_stream_focus_mask_e focus_mask,
1367 sound_stream_focus_state_e focus_state,
1368 sound_stream_focus_change_reason_e reason,
1370 const char *extra_info,
1373 g_print("FOCUS callback is called, reason(%d), extra_info(%s), userdata(%p)", reason, extra_info, user_data);
1377 static void set_sound_stream_info(int type)
1379 sound_device_list_h device_list = NULL;
1380 int ret = SOUND_MANAGER_ERROR_NONE;
1382 if (g_stream_info_h) {
1383 g_print("stream information is already set, please destory handle and try again\n");
1386 if (sound_manager_create_stream_information(type, focus_callback, g_player[0], &g_stream_info_h)) {
1387 g_print("failed to create stream_information()\n");
1390 /* In case of MEDIA_EXTERNAL_ONLY, we need to set external device manually */
1391 if (type == (int)SOUND_STREAM_TYPE_MEDIA_EXTERNAL_ONLY) {
1392 sound_device_h device = NULL;
1393 sound_device_type_e device_type;
1395 if ((ret = sound_manager_get_device_list(SOUND_DEVICE_ALL_MASK, &device_list))) {
1396 g_print("failed to sound_manager_get_device_list(), ret(0x%x)\n", ret);
1399 while (!(ret = sound_manager_get_next_device(device_list, &device))) {
1400 if ((ret = sound_manager_get_device_type(device, &device_type))) {
1401 g_print("failed to sound_manager_get_device_type(), ret(0x%x)\n", ret);
1404 if (device_type == SOUND_DEVICE_BLUETOOTH_MEDIA || device_type == SOUND_DEVICE_USB_AUDIO) {
1405 if ((ret = sound_manager_add_device_for_stream_routing(g_stream_info_h, device))) {
1406 g_print("failed to sound_manager_add_device_for_stream_routing(), ret(0x%x)\n", ret);
1409 if ((ret = sound_manager_apply_stream_routing(g_stream_info_h))) {
1410 g_print("failed to sound_manager_apply_stream_routing(), ret(0x%x)\n", ret);
1416 if (ret != SOUND_MANAGER_ERROR_NONE) {
1417 g_print("failed to sound_manager_get_next_device(), ret(0x%x)\n", ret);
1422 if (player_set_sound_stream_info(g_player[0], g_stream_info_h) != PLAYER_ERROR_NONE)
1423 g_print("failed to set sound stream information(%p)\n", g_stream_info_h);
1425 g_print("set stream information(%p) success", g_stream_info_h);
1429 sound_manager_free_device_list(device_list);
1433 void variant_cb(int bandwidth, int width, int height, void *user_data)
1435 g_print(" ==> [Player_Test][b]%d, [w]%d, [h]%d\n", bandwidth, width, height);
1438 static void get_variant_info()
1440 player_foreach_adaptive_variant(g_player[0], (player_adaptive_variant_cb)variant_cb, g_player[0]);
1443 static void get_variant_limit()
1445 int bandwidth, width, height;
1446 player_get_max_adaptive_variant_limit(g_player[0], &bandwidth, &width, &height);
1447 g_print(" ==> [Player_Test]get [b]%d, [w]%d, [h]%d\n", bandwidth, width, height);
1450 static void set_variant_limit(int bandwidth, int width, int height)
1452 g_print(" ==> [Player_Test]set [b]%d, [w]%d, [h]%d\n", bandwidth, width, height);
1453 player_set_max_adaptive_variant_limit(g_player[0], bandwidth, width, height);
1456 static void set_buffer_size(int prebuffer, int rebuffer)
1459 int buffer_ms = 0, rebuffer_ms = 0;
1461 ret = player_get_streaming_buffering_time(g_player[0], &buffer_ms, &rebuffer_ms);
1462 if (ret != PLAYER_ERROR_NONE)
1463 g_print("failed to get buffering time. 0x%X\n", ret);
1465 g_print("current buffer size %d ms / %d ms\n", buffer_ms, rebuffer_ms);
1467 g_print("new buffer size %d ms / %d ms\n", prebuffer, rebuffer);
1469 player_set_streaming_buffering_time(g_player[0], prebuffer, rebuffer);
1472 static void get_position()
1476 ret = player_get_play_position(g_player[0], &position);
1477 g_print(" ==> [Player_Test] player_get_play_position()%d return : %d\n", ret, position);
1480 static void set_position(int position, bool accurate)
1482 if (player_set_play_position(g_player[0], position, accurate, seek_completed_cb, g_player[0]) != PLAYER_ERROR_NONE)
1483 g_print("failed to set position\n");
1486 static void set_playback_rate(float rate, bool streaming)
1489 if (player_set_streaming_playback_rate(g_player[0], rate) != PLAYER_ERROR_NONE)
1490 g_print("failed to set streaming playback rate\n");
1492 if (player_set_playback_rate(g_player[0], rate) != PLAYER_ERROR_NONE)
1493 g_print("failed to set playback rate\n");
1497 static void get_duration()
1501 ret = player_get_duration(g_player[0], &duration);
1502 g_print(" ==> [Player_Test] player_get_duration() return : %d\n", ret);
1503 g_print(" ==> [Player_Test] Duration: [%d ] msec\n", duration);
1506 static void set_codec_type(int a_codec_type, int v_codec_type)
1510 ret = player_set_codec_type(g_player[0], PLAYER_STREAM_TYPE_AUDIO, a_codec_type);
1511 g_print(" ==> [Player_Test] audio codec type (%d) return: %d\n", a_codec_type, ret);
1513 ret = player_set_codec_type(g_player[0], PLAYER_STREAM_TYPE_VIDEO, v_codec_type);
1514 g_print(" ==> [Player_Test] video codec type (%d) return: %d\n", v_codec_type, ret);
1518 static void get_codec_type(void)
1521 player_codec_type_e atype = 0, vtype = 0;
1523 ret = player_get_codec_type(g_player[0], PLAYER_STREAM_TYPE_AUDIO, &atype);
1524 g_print(" ==> [Player_Test] Audio Codec type: [%d][ret 0x%X]\n", atype, ret);
1526 ret = player_get_codec_type(g_player[0], PLAYER_STREAM_TYPE_VIDEO, &vtype);
1527 g_print(" ==> [Player_Test] Video Codec type: [%d][ret 0x%X]\n", vtype, ret);
1530 static void audio_frame_decoded_cb_ex(bool sync)
1534 fp_out1 = fopen("/tmp/out1.pcm", "wb");
1535 fp_out2 = fopen("/tmp/out2.pcm", "wb");
1536 if (!fp_out1 || !fp_out2) {
1537 g_print("File open error\n");
1542 ret = player_set_pcm_extraction_mode(g_player[0], sync, _audio_frame_decoded_cb_ex, &ret);
1543 g_print(" ==> [Player_Test] player_set_audio_frame_decoded_cb_ex(sync:%d) ret:%d\n", sync, ret);
1545 ret = player_set_pcm_spec(g_player[0], "F32LE", 44100, 2);
1546 g_print("[Player_Test] set_pcm_spec return: %d\n", ret);
1549 static void get_stream_info()
1555 player_get_content_info(g_player[0], PLAYER_CONTENT_INFO_ALBUM, &value);
1556 g_print(" ==> [Player_Test] PLAYER_CONTENT_INFO_ALBUM: [%s ] \n", value);
1557 player_get_content_info(g_player[0], PLAYER_CONTENT_INFO_ARTIST, &value);
1558 g_print(" ==> [Player_Test] PLAYER_CONTENT_INFO_ARTIST: [%s ] \n", value);
1559 player_get_content_info(g_player[0], PLAYER_CONTENT_INFO_AUTHOR, &value);
1560 g_print(" ==> [Player_Test] PLAYER_CONTENT_INFO_AUTHOR: [%s ] \n", value);
1561 player_get_content_info(g_player[0], PLAYER_CONTENT_INFO_GENRE, &value);
1562 g_print(" ==> [Player_Test] PLAYER_CONTENT_INFO_GENRE: [%s ] \n", value);
1563 player_get_content_info(g_player[0], PLAYER_CONTENT_INFO_TITLE, &value);
1564 g_print(" ==> [Player_Test] PLAYER_CONTENT_INFO_TITLE: [%s ] \n", value);
1567 player_get_album_art(g_player[0], &album, &size);
1568 g_print(" ==> [Player_Test] Album art : [ data : %p, size : %d ]\n", (unsigned int *)album, size);
1570 if (value != NULL) {
1578 int fps, v_bit_rate;
1579 player_get_audio_stream_info(g_player[0], &sample_rate, &channel, &bit_rate);
1580 g_print(" ==> [Player_Test] Sample Rate: [%d ] , Channel: [%d ] , Bit Rate: [%d ] \n", sample_rate, channel, bit_rate);
1582 player_get_video_stream_info(g_player[0], &fps, &v_bit_rate);
1583 g_print(" ==> [Player_Test] fps: [%d ] , Bit Rate: [%d ] \n", fps, v_bit_rate);
1585 char *audio_codec = NULL;
1586 char *video_codec = NULL;
1587 player_get_codec_info(g_player[0], &audio_codec, &video_codec);
1588 if (audio_codec != NULL) {
1589 g_print(" ==> [Player_Test] Audio Codec: [%s ] \n", audio_codec);
1593 if (video_codec != NULL) {
1594 g_print(" ==> [Player_Test] Video Codec: [%s ] \n", video_codec);
1598 player_get_video_size(g_player[0], &w, &h);
1599 g_print(" ==> [Player_Test] Width: [%d ] , Height: [%d ] \n", w, h);
1602 static void set_gapless(bool gapless)
1605 g_print("not support at TV profile");
1609 if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
1610 if (player_set_gapless(g_player[0], gapless) != PLAYER_ERROR_NONE)
1611 g_print("failed set_gapless\n");
1614 for (i = 0; i < g_handle_num; i++) {
1615 if (player_set_gapless(g_player[i], gapless) != PLAYER_ERROR_NONE)
1616 g_print("failed to set_gapless\n");
1621 static void set_looping(bool looping)
1623 if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
1624 if (player_set_looping(g_player[0], looping) != PLAYER_ERROR_NONE)
1625 g_print("failed to set_looping\n");
1628 for (i = 0; i < g_handle_num; i++) {
1629 if (player_set_looping(g_player[i], looping) != PLAYER_ERROR_NONE)
1630 g_print("failed to set_looping\n");
1635 static void get_looping(bool * looping)
1637 player_is_looping(g_player[0], looping);
1638 g_print(" ==> [Player_Test] looping = %d\n", *looping);
1641 void _video_decoded_cb(media_packet_h packet, void *user_data)
1643 media_packet_destroy(packet);
1646 static void set_video_frame_decoded_cb(void)
1648 player_set_media_packet_video_frame_decoded_cb(g_player[0], _video_decoded_cb, g_player[0]);
1651 static void change_surface(int option)
1653 player_display_type_e surface_type = 0;
1654 int ret = PLAYER_ERROR_NONE;
1655 #ifdef _ACTIVATE_EOM_
1657 eom_output_mode_e output_mode;
1662 surface_type = PLAYER_DISPLAY_TYPE_OVERLAY;
1663 g_print("change surface type to X\n");
1665 #ifdef TIZEN_FEATURE_EVAS_RENDERER
1668 surface_type = PLAYER_DISPLAY_TYPE_EVAS;
1669 g_print("change surface type to EVAS\n");
1673 g_print("change surface type to NONE\n");
1674 surface_type = g_current_surface_type = PLAYER_DISPLAY_TYPE_NONE;
1675 player_set_display(g_player[0], PLAYER_DISPLAY_TYPE_NONE, NULL);
1678 g_print("invalid surface type\n");
1682 player_state_e player_state = PLAYER_STATE_NONE;
1683 ret = player_get_state(g_player[0], &player_state);
1685 g_print("failed to player_get_state(), ret(0x%x)\n", ret);
1689 if (surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
1690 #ifdef _ACTIVATE_EOM_
1691 hdmi_output_id = eom_get_output_id("HDMI");
1692 if (hdmi_output_id == 0)
1693 g_print("[eom] error : HDMI output id is NULL.\n");
1695 eom_get_output_mode(hdmi_output_id, &output_mode);
1696 if (output_mode == EOM_OUTPUT_MODE_NONE) {
1699 g_win_id = create_win(PACKAGE);
1700 if (g_win_id == NULL)
1702 g_print("create win_id %p\n", g_win_id);
1703 create_render_rect_and_bg(g_win_id);
1704 elm_win_activate(g_win_id);
1705 evas_object_show(g_win_id);
1706 g_win_id = selected_win_id;
1708 #ifdef _ACTIVATE_EOM_
1713 ret = player_set_display(g_player[0], surface_type, GET_DISPLAY(selected_win_id));
1716 g_win_id = create_win(PACKAGE);
1717 if (g_win_id == NULL)
1719 g_print("create win_id %p\n", g_win_id);
1720 create_render_rect_and_bg(g_win_id);
1721 elm_win_activate(g_win_id);
1722 evas_object_show(g_win_id);
1724 if (surface_type == PLAYER_DISPLAY_TYPE_EVAS) {
1725 /* surface type is PLAYER_DISPLAY_TYPE_NONE */
1727 for (i = 0; i < g_handle_num; i++) {
1728 /* Create evas image object for EVAS surface */
1730 g_eo[i] = create_image_object(g_win_id);
1731 g_print("create eo[%d] %p\n", i, g_eo[i]);
1732 evas_object_image_size_set(g_eo[i], 500, 500);
1733 evas_object_image_fill_set(g_eo[i], 0, 0, 500, 500);
1734 evas_object_resize(g_eo[i], 500, 500);
1735 evas_object_move(g_eo[i], i * 20, i * 20);
1737 ret = player_set_display(g_player[i], surface_type, g_eo[i]);
1741 g_print("surface type is PLAYER_DISPLAY_TYPE_NONE\n");
1745 g_print("failed to set display, surface_type(%d)\n", surface_type);
1748 g_current_surface_type = surface_type;
1752 static void set_display_mode(int mode)
1754 if (player_set_display_mode(g_player[0], mode) != PLAYER_ERROR_NONE)
1755 g_print("failed to player_set_display_mode\n");
1758 static void get_display_mode()
1760 player_display_mode_e mode;
1761 player_get_display_mode(g_player[0], &mode);
1762 g_print(" ==> [Player_Test] Display mode: [%d ] \n", mode);
1765 static void set_display_roi_area(int x, int y, int width, int height)
1767 player_set_display_roi_area(g_player[0], x, y, width, height);
1768 g_print(" ==> [Player_Test] Display roi area: [x(%d) y(%d) width(%d) height(%d)] \n", x, y, width, height);
1771 static void set_display_rotation(int rotation)
1773 if (player_set_display_rotation(g_player[0], rotation) != PLAYER_ERROR_NONE)
1774 g_print("failed to set_display_rotation\n");
1775 #ifdef USE_EVENT_HANDLER
1776 event_handler_set_window_parameters();
1780 static void get_display_rotation()
1782 player_display_rotation_e rotation = 0;
1783 player_get_display_rotation(g_player[0], &rotation);
1784 g_print(" ==> [Player_Test] Video Overlay Display rotation: [%d ] \n", rotation);
1787 static void set_display_visible(bool visible)
1789 if (player_set_display_visible(g_player[0], visible) != PLAYER_ERROR_NONE)
1790 g_print("failed to player_set_x11_display_visible\n");
1793 static void get_display_visible(bool * visible)
1795 player_is_display_visible(g_player[0], visible);
1796 g_print(" ==> [Player_Test] Video Overlay Display Visible = %d\n", *visible);
1799 static void input_subtitle_filename(char *subtitle_filename)
1801 int len = strlen(subtitle_filename);
1803 if (len < 1 || len > MAX_STRING_LEN)
1806 strncpy(g_subtitle_uri, subtitle_filename, len);
1807 g_print("subtitle uri is set to %s\n", g_subtitle_uri);
1808 player_set_subtitle_path(g_player[0], g_subtitle_uri);
1811 static void set_track(int type, int index)
1813 char *lang_code = NULL;
1815 if (player_select_track(g_player[0], type, index) != PLAYER_ERROR_NONE)
1816 g_print("player_select_track failed\n");
1818 if (player_get_track_language_code(g_player[0], type, index, &lang_code) == PLAYER_ERROR_NONE) {
1819 g_print("selected track lang code %s\n", lang_code);
1824 static void get_track_info(int index)
1826 int count = 0, cur_index = 0;
1828 char *lang_code = NULL;
1830 if (index != PLAYER_STREAM_TYPE_AUDIO &&
1831 index != PLAYER_STREAM_TYPE_TEXT) {
1832 g_print("invalid stream type %d", index);
1836 ret = player_get_track_count(g_player[0], index, &count);
1837 if (ret != PLAYER_ERROR_NONE)
1838 g_print("player_get_track_count fail!!!!\n");
1841 player_get_current_track(g_player[0], index, &cur_index);
1842 g_print("total track: %d, curr track: %d\n", count, cur_index);
1844 for (idx = 0; idx < count; idx++) {
1845 player_get_track_language_code(g_player[0], index, idx, &lang_code);
1846 g_print("track info = [%d] %s\n", idx, lang_code);
1849 g_print("no track\n");
1853 static void capture_video()
1855 if (player_capture_video(g_player[0], video_captured_cb, NULL) != PLAYER_ERROR_NONE)
1856 g_print("failed to player_capture_video\n");
1859 static void set_audio_only(int val)
1861 int ret = PLAYER_ERROR_NONE;
1862 bool audio_only = false;
1863 ret = player_is_audio_only(g_player[0], &audio_only);
1864 if (ret != PLAYER_ERROR_NONE)
1865 g_print("failed to get current setting. 0x%X\n", ret);
1867 g_print("current audio only mode : %s\n", (audio_only) ? "enabled" : "disabled");
1868 g_print("new audio only mode : %s\n", (val != 0) ? "enabled" : "disabled");
1871 ret = player_set_audio_only(g_player[0], true);
1873 ret = player_set_audio_only(g_player[0], false);
1874 g_print("finished 0x%X\n", ret);
1877 static void decoding_audio()
1881 char *suffix, *dump_path;
1882 GDateTime *time = g_date_time_new_now_local();
1884 suffix = g_date_time_format(time, "%Y%m%d_%H%M%S.pcm");
1885 dump_path = g_strjoin(NULL, PLAYER_TEST_DUMP_PATH_PREFIX, suffix, NULL);
1886 g_pcm_fd = fopen(dump_path, "w+");
1889 g_date_time_unref(time);
1891 g_print("Can not create debug dump file");
1893 ret = player_set_audio_frame_decoded_cb(g_player[0], 0, 0, audio_frame_decoded_cb, (void *)g_player[0]);
1894 if (ret != PLAYER_ERROR_NONE)
1895 g_print("player_set_audio_frame_decoded_cb is failed (errno = %d) \n", ret);
1899 static void set_audio_eq(int value)
1901 bool available = FALSE;
1902 int index, min = 0, max = 0;
1905 if (player_audio_effect_equalizer_is_available(g_player[0], &available) != PLAYER_ERROR_NONE)
1906 g_print("failed to player_audio_effect_equalizer_is_available\n");
1909 if ((player_audio_effect_get_equalizer_bands_count(g_player[0], &index) != PLAYER_ERROR_NONE) ||
1910 (player_audio_effect_get_equalizer_level_range(g_player[0], &min, &max) != PLAYER_ERROR_NONE) ||
1911 (player_audio_effect_set_equalizer_band_level(g_player[0], index / 2, max) != PLAYER_ERROR_NONE))
1912 g_print("failed to player_audio_effect_set_equalizer_band_level index %d, level %d\n", index / 2, max);
1917 if (player_audio_effect_equalizer_clear(g_player[0]) != PLAYER_ERROR_NONE)
1918 g_print("failed to player_audio_effect_equalizer_clear\n");
1923 static void get_audio_eq()
1925 int index, min, max, value;
1926 player_audio_effect_get_equalizer_bands_count(g_player[0], &index);
1927 g_print(" ==> [Player_Test] eq bands count: [%d] \n", index);
1928 player_audio_effect_get_equalizer_level_range(g_player[0], &min, &max);
1929 g_print(" ==> [Player_Test] eq bands range: [%d~%d] \n", min, max);
1930 player_audio_effect_get_equalizer_band_level(g_player[0], index / 2, &value);
1931 g_print(" ==> [Player_Test] eq bands level: [%d] \n", value);
1932 player_audio_effect_get_equalizer_band_frequency(g_player[0], 0, &value);
1933 g_print(" ==> [Player_Test] eq bands frequency: [%d] \n", value);
1934 player_audio_effect_get_equalizer_band_frequency_range(g_player[0], 0, &value);
1935 g_print(" ==> [Player_Test] eq bands frequency range: [%d] \n", value);
1938 static void video360_is_spherical(void)
1942 if (player_360_is_content_spherical(g_player[0], &spherical) != PLAYER_ERROR_NONE)
1943 g_print("failed to get content spherical info\n");
1945 g_print(" ==> [Player_Test] Video 360 content = %s\n", spherical ? "spherical" : "---");
1949 static void video360_set_enable(bool enable)
1951 bool enabled = false;
1953 #ifdef USE_EVENT_HANDLER
1954 event_handler_set_dov_fov();
1957 if (player_360_set_enabled(g_player[0], enable) != PLAYER_ERROR_NONE)
1958 g_print("failed to %s video 360 mode\n", enable ? "enable" : "disable");
1960 if (player_360_is_enabled(g_player[0], &enabled) != PLAYER_ERROR_NONE)
1961 g_print("failed to get video 360 mode status\n");
1963 g_print(" ==> [Player_Test] Video 360 mode = %s\n", enabled ? "enabled" : "disabled");
1966 static void video360_get_fov()
1970 if (player_360_get_field_of_view(g_player[0], &hfov, &vfov) != PLAYER_ERROR_NONE)
1971 g_print("failed to get video 360 field of view\n");
1973 g_print(" ==> [Player_Test] Video 360 FOV = %dx%d deg.\n", hfov, vfov);
1976 static void video360_set_fov(int hfov, int vfov)
1978 #ifdef USE_EVENT_HANDLER
1979 mm_navevent_handler_size_s fov;
1983 mm_navevent_handler_set_fov_size(event_handler, fov);
1985 if (player_360_set_field_of_view(g_player[0], hfov, vfov) != PLAYER_ERROR_NONE)
1986 g_print("failed to set video 360 field of view\n");
1991 static void video360_get_dov()
1995 if (player_360_get_direction_of_view(g_player[0], &yaw, &pitch) != PLAYER_ERROR_NONE)
1996 g_print("failed to get video 360 direction of view\n");
1998 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));
2001 static void video360_set_dov(int yaw_deg, int pitch_deg)
2005 angles[0] = M_PI * yaw_deg / 180.0f;
2006 angles[1] = M_PI * pitch_deg / 180.0f;
2009 #ifdef USE_EVENT_HANDLER
2010 mm_navevent_handler_set_angles(event_handler, angles);
2013 if (player_360_set_direction_of_view(g_player[0], angles[0], angles[1]) != PLAYER_ERROR_NONE)
2014 g_print("failed to set video 360 direction of view\n");
2019 static void video360_get_zoom()
2023 if (player_360_get_zoom(g_player[0], &zoom) != PLAYER_ERROR_NONE)
2024 g_print("failed to get video 360 zoom\n");
2026 g_print(" ==> [Player_Test] Video 360 zoom = %f\n", zoom);
2029 static void video360_set_zoom(float zoom)
2031 if (player_360_set_zoom(g_player[0], zoom) != PLAYER_ERROR_NONE)
2032 g_print("failed to set video 360 zoom\n");
2034 video360_get_zoom();
2037 static void video360_set_zoom_with_fov(float zoom, int hfov, int vfov)
2039 #ifdef USE_EVENT_HANDLER
2040 mm_navevent_handler_size_s fov;
2044 mm_navevent_handler_set_fov_size(event_handler, fov);
2046 if (player_360_set_zoom_with_field_of_view(g_player[0], zoom, hfov, vfov) != PLAYER_ERROR_NONE)
2047 g_print("failed to set video 360 zoom with field of view\n");
2050 video360_get_zoom();
2053 static void set_replaygain_enabled(bool enabled)
2055 if (player_set_replaygain_enabled(g_player[0], enabled) != PLAYER_ERROR_NONE)
2056 g_print("failed to set_replaygain_enabled\n");
2059 static void is_replaygain_enabled(bool *enable)
2061 player_is_replaygain_enabled(g_player[0], enable);
2062 g_print(" ==> [Player_Test] replaygain = %d\n", *enable);
2065 #ifdef USE_EVENT_HANDLER
2066 static void event_handler_cb(enum libinput_event_type ev_t, int x, int y, void * data, float e[3])
2068 if (ev_t == LIBINPUT_EVENT_TOUCH_MOTION)
2069 if (player_360_set_direction_of_view(g_player[0], e[0], e[1]) != PLAYER_ERROR_NONE)
2070 g_print("Event handler callback: failed to set direction of view\n");
2073 static void event_handler_set_dov_fov()
2076 mm_navevent_handler_size_s fov;
2078 if (player_360_get_direction_of_view(g_player[0], &angles[0], &angles[1]) != PLAYER_ERROR_NONE) {
2079 g_print("Failed to get video360 direction of view\n");
2082 if (player_360_get_field_of_view(g_player[0], &fov.width, &fov.height) != PLAYER_ERROR_NONE) {
2083 g_print("Failed to get video360 field of view\n");
2086 mm_navevent_handler_set_angles(event_handler, angles);
2087 mm_navevent_handler_set_fov_size(event_handler, fov);
2090 static void event_handler_set_window_parameters()
2092 player_display_rotation_e window_orientation;
2093 mm_navevent_handler_size_s window_size;
2096 player_get_display_rotation(g_player[0], &window_orientation);
2097 elm_win_screen_size_get(selected_win_id, NULL, NULL, &window_size.width, &window_size.height);
2099 image_ratio = (float) image_size.width / (float) image_size.height;
2101 if (window_orientation == PLAYER_DISPLAY_ROTATION_NONE ||
2102 window_orientation == PLAYER_DISPLAY_ROTATION_180) {
2103 window_size.height = (int)((float) window_size.width / image_ratio);
2105 window_size.height = window_size.width;
2106 window_size.width = (int)((float) window_size.width * image_ratio);
2109 mm_navevent_handler_set_window_parameters(event_handler,
2110 (mm_navevent_handler_orientation_e) window_orientation, window_size);
2120 if (g_player[0] != NULL || g_player[1] != NULL) {
2121 _player_unprepare();
2128 media_format_unref(g_audio_fmt);
2131 media_format_unref(g_video_fmt);
2134 void play_with_ini(char *file_path)
2136 input_filename(file_path);
2140 void _interpret_main_menu(char *cmd)
2142 int len = strlen(cmd);
2144 if (strncmp(cmd, "a", 1) == 0) {
2145 g_menu_state = CURRENT_STATUS_FILENAME;
2146 } else if (strncmp(cmd, "b", 1) == 0) {
2148 } else if (strncmp(cmd, "c", 1) == 0) {
2150 } else if (strncmp(cmd, "d", 1) == 0) {
2152 } else if (strncmp(cmd, "e", 1) == 0) {
2154 } else if (strncmp(cmd, "S", 1) == 0) {
2156 } else if (strncmp(cmd, "f", 1) == 0) {
2157 g_menu_state = CURRENT_STATUS_VOLUME;
2158 } else if (strncmp(cmd, "g", 1) == 0) {
2161 get_volume(&left, &right);
2162 } else if (strncmp(cmd, "k", 1) == 0) {
2163 g_menu_state = CURRENT_STATUS_SOUND_STREAM_INFO;
2164 } else if (strncmp(cmd, "h", 1) == 0) {
2165 g_menu_state = CURRENT_STATUS_MUTE;
2166 } else if (strncmp(cmd, "i", 1) == 0) {
2169 } else if (strncmp(cmd, "j", 1) == 0) {
2170 g_menu_state = CURRENT_STATUS_POSITION_TIME;
2171 } else if (strncmp(cmd, "l", 1) == 0) {
2173 } else if (strncmp(cmd, "m", 1) == 0) {
2175 } else if (strncmp(cmd, "n", 1) == 0) {
2177 } else if (strncmp(cmd, "o", 1) == 0) {
2178 g_menu_state = CURRENT_STATUS_LOOPING;
2179 } else if (strncmp(cmd, "p", 1) == 0) {
2181 get_looping(&looping);
2182 } else if (strncmp(cmd, "r", 1) == 0) {
2183 g_menu_state = CURRENT_STATUS_DISPLAY_MODE;
2184 } else if (strncmp(cmd, "s", 1) == 0) {
2186 } else if (strncmp(cmd, "t", 1) == 0) {
2187 g_menu_state = CURRENT_STATUS_DISPLAY_ROTATION;
2188 } else if (strncmp(cmd, "u", 1) == 0) {
2189 get_display_rotation();
2190 } else if (strncmp(cmd, "v", 1) == 0) {
2191 g_menu_state = CURRENT_STATUS_DISPLAY_VISIBLE;
2192 } else if (strncmp(cmd, "w", 1) == 0) {
2194 get_display_visible(&visible);
2195 } else if (strncmp(cmd, "A", 1) == 0) {
2196 g_menu_state = CURRENT_STATUS_SUBTITLE_FILENAME;
2197 } else if (strncmp(cmd, "C", 1) == 0) {
2199 } else if (strncmp(cmd, "D", 1) == 0) {
2201 } else if (strncmp(cmd, "q", 1) == 0) {
2202 quit_pushing = TRUE;
2204 } else if (strncmp(cmd, "E", 1) == 0) {
2205 g_menu_state = CURRENT_STATUS_AUDIO_EQUALIZER;
2206 } else if (strncmp(cmd, "H", 1) == 0) {
2209 g_print("unknown menu \n");
2211 } else if (len == 2) {
2212 if (strncmp(cmd, "pr", 2) == 0) {
2214 if (g_current_surface_type == -1) {
2215 g_print("You must set display surface type before setting prepare. please 'pr' after setting display surface type.\n");
2216 g_menu_state = CURRENT_STATUS_DISPLAY_SURFACE_CHANGE;
2218 _player_prepare(FALSE);
2219 } else if (strncmp(cmd, "pa", 2) == 0) {
2221 if (g_current_surface_type == -1) {
2222 g_print("You must set display surface type before setting prepare. please 'pr' after setting display surface type.\n");
2223 g_menu_state = CURRENT_STATUS_DISPLAY_SURFACE_CHANGE;
2225 _player_prepare(TRUE);
2226 } else if (strncmp(cmd, "un", 2) == 0) {
2227 _player_unprepare();
2228 } else if (strncmp(cmd, "dt", 2) == 0) {
2230 } else if (strncmp(cmd, "sp", 2) == 0) {
2231 _player_set_progressive_download();
2232 } else if (strncmp(cmd, "gp", 2) == 0) {
2233 _player_get_progressive_download_status();
2234 } else if (strncmp(cmd, "mp", 2) == 0) {
2235 g_memory_playback = (g_memory_playback ? FALSE : TRUE);
2236 g_print("memory playback = %d\n", g_memory_playback);
2237 } else if (strncmp(cmd, "ds", 2) == 0) {
2238 g_menu_state = CURRENT_STATUS_DISPLAY_SURFACE_CHANGE;
2239 } else if (strncmp(cmd, "dr", 2) == 0) {
2240 g_menu_state = CURRENT_STATUS_DISPLAY_DST_ROI_AREA;
2241 } else if (strncmp(cmd, "nb", 2) == 0) {
2242 g_menu_state = CURRENT_STATUS_HANDLE_NUM;
2243 } else if (strncmp(cmd, "tr", 2) == 0) {
2244 g_menu_state = CURRENT_STATUS_PLAYBACK_RATE;
2245 } else if (strncmp(cmd, "X3", 2) == 0) {
2246 audio_frame_decoded_cb_ex(TRUE);
2247 } else if (strncmp(cmd, "X4", 2) == 0) {
2248 audio_frame_decoded_cb_ex(FALSE);
2249 } else if (strncmp(cmd, "ep", 2) == 0) {
2250 _player_enable_tsurf_pool();
2251 } else if (strncmp(cmd, "su", 2) == 0) {
2252 g_menu_state = CURRENT_STATUS_NEXT_URI;
2253 } else if (strncmp(cmd, "gu", 2) == 0) {
2255 } else if (strncmp(cmd, "sg", 2) == 0) {
2256 g_menu_state = CURRENT_STATUS_GAPLESS;
2257 } else if (strncmp(cmd, "tg", 2) == 0) {
2258 g_menu_state = CURRENT_STATUS_GET_TRACK_INFO;
2259 } else if (strncmp(cmd, "ts", 2) == 0) {
2260 g_menu_state = CURRENT_STATUS_SET_TRACK_TYPE;
2261 } else if (strncmp(cmd, "vi", 2) == 0) {
2263 } else if (strncmp(cmd, "vs", 2) == 0) {
2264 g_menu_state = CURRENT_STATUS_SET_MAX_BANDWIDTH_VARIANT;
2265 } else if (strncmp(cmd, "vg", 2) == 0) {
2266 get_variant_limit();
2267 } else if (strncmp(cmd, "ao", 2) == 0) {
2268 g_menu_state = CURRENT_STATUS_SET_AUDIO_ONLY;
2269 } else if (strncmp(cmd, "bf", 2) == 0) {
2270 g_menu_state = CURRENT_STATUS_SET_PRE_BUFFERING_SIZE;
2271 } else if (strncmp(cmd, "C1", 2) == 0) {
2272 g_menu_state = CURRENT_STATUS_AUDIO_CODEC_TYPE;
2273 } else if (strncmp(cmd, "C2", 2) == 0) {
2275 } else if (!strncmp(cmd, "si", 2)) {
2276 video360_is_spherical();
2277 } else if (!strncmp(cmd, "se", 2)) {
2278 g_menu_state = CURRENT_STATUS_VIDEO360_SET_ENABLE;
2279 } else if (!strncmp(cmd, "sd", 2)) {
2280 g_menu_state = CURRENT_STATUS_VIDEO360_SET_DOV;
2281 } else if (!strncmp(cmd, "sf", 2)) {
2282 g_menu_state = CURRENT_STATUS_VIDEO360_SET_FOV;
2283 } else if (!strncmp(cmd, "sz", 2)) {
2284 g_menu_state = CURRENT_STATUS_VIDEO360_SET_ZOOM;
2286 g_print("unknown menu \n");
2288 } else if (len == 3) {
2289 if (strncmp(cmd, "trs", 3) == 0) {
2290 g_menu_state = CURRENT_STATUS_STREAMING_PLAYBACK_RATE;
2291 } else if (strncmp(cmd, "rgs", 3) == 0) {
2292 g_menu_state = CURRENT_STATUS_REPLAYGAIN_ENABLE;
2293 } else if (strncmp(cmd, "rgg", 3) == 0) {
2295 is_replaygain_enabled(&enable);
2296 } else if (!strncmp(cmd, "szz", 3)) {
2297 g_menu_state = CURRENT_STATUS_VIDEO360_SET_ZOOM_WITH_FOV;
2299 g_print("unknown menu \n");
2302 g_print("unknown menu \n");
2305 void display_sub_basic()
2308 g_print("=========================================================================================\n");
2309 g_print(" Player Test (press q to quit) \n");
2310 g_print("-----------------------------------------------------------------------------------------\n");
2311 g_print("[playback] a. Create\t");
2312 g_print("pr. Prepare \t");
2313 g_print("pa. Prepare async \t");
2314 g_print("b. Play \t");
2315 g_print("c. Stop \t");
2316 g_print("d. Resume\t");
2317 g_print("e. Pause \t");
2318 g_print("un. Unprepare \t");
2319 g_print("dt. Destroy \n");
2320 g_print("[State] S. Player State \n");
2321 g_print("[ volume ] f. Set Volume\t");
2322 g_print("g. Get Volume\t");
2323 g_print("z. Set Sound type\t");
2324 g_print("k. Set Sound Stream Info.\n");
2325 g_print("[ mute ] h. Set Mute\t");
2326 g_print("i. Get Mute\n");
2327 g_print("[audio eq] E. Set Audio EQ\t");
2328 g_print("H. Get Audio EQ\n");
2329 g_print("[position] j. Set Position \t");
2330 g_print("l. Get Position\n");
2331 g_print("[trick] tr. set playback rate\n");
2332 g_print("[duration] m. Get Duration\n");
2333 g_print("[Stream Info] n. Get stream info (Video Size, codec, audio stream info, and tag info)\n");
2334 g_print("[Looping] o. Set Looping\t");
2335 g_print("p. Get Looping\n");
2336 g_print("[display] v. Set display visible\t");
2337 g_print("w. Get display visible\n");
2338 g_print("[display] ds. Change display surface type\n");
2339 g_print("[display] dr. set display roi area\n");
2340 g_print("[overlay display] r. Set display mode\t");
2341 g_print("s. Get display mode\n");
2342 g_print("[overlay display] t. Set display Rotation\n");
2343 g_print("[Variant] vi. Get Streaming Variant Info\t");
2344 g_print("vs. Set max limit of variant\t");
2345 g_print("vg. Get max limit of variant\n");
2346 g_print("[audio only] ao. set audio only\n");
2347 g_print("[subtitle] A. Set(or change) subtitle path\n");
2348 g_print("[Track] tg. Get Track info\n");
2349 g_print("[Track] ts. Set track\n");
2350 g_print("[Video Capture] C. Capture \n");
2351 g_print("[Video Codec] C1. Set codec type (1:HW, 2:SW)\t");
2352 g_print("C2. Get codec type\n");
2353 g_print("[next uri] su. set next uri. \t");
2354 g_print("gu. get next uri. \t");
2355 g_print("sg. set gapless. \n");
2356 g_print("[audio_frame_decoded_cb_ex] X3. set audio_cb with sync\t");
2357 g_print("X4. set audio_cb with async \n");
2358 g_print("[video_frame_decoded_cb] ep. enable tbm surface pool\n");
2359 g_print("[buffering] bf. set new buffering size\n");
2360 g_print("[Video 360] si. check spherical info\t");
2361 g_print("se. Set Enable\n");
2362 g_print("[Video 360] sd. Set Direction Of View\t");
2363 g_print("sf. Set Field Of View\n");
2364 g_print("[Video 360] sz. Set Zoom\t\t");
2365 g_print("szz. Set Zoom with FOV\n");
2366 g_print("[Replaygain] rgs. Set Replaygain\t\t");
2367 g_print("rgg. Get replaygain\n");
2368 g_print("[etc] sp. Set Progressive Download\t");
2369 g_print("gp. Get Progressive Download status\t");
2370 g_print("mp. memory playback\n");
2372 g_print("=========================================================================================\n");
2375 static void displaymenu()
2377 if (g_menu_state == CURRENT_STATUS_MAINMENU) {
2378 display_sub_basic();
2379 } else if (g_menu_state == CURRENT_STATUS_HANDLE_NUM) {
2380 g_print("*** input number of handles.(recommended only for EVAS surface)\n");
2381 } else if (g_menu_state == CURRENT_STATUS_FILENAME) {
2382 g_print("*** input mediapath.\n");
2383 } else if (g_menu_state == CURRENT_STATUS_VOLUME) {
2384 g_print("*** input volume value.(0~1.0)\n");
2385 } else if (g_menu_state == CURRENT_STATUS_SOUND_STREAM_INFO) {
2386 g_print("*** input sound stream type.(0:MEDIA 1:SYSTEM 2:ALARM 3:NOTIFICATION 4:EMERGENCY 5:VOICE_INFORMATION 9:MEDIA_EXT_ONLY)\n");
2387 } else if (g_menu_state == CURRENT_STATUS_MUTE) {
2388 g_print("*** input mute value.(0: Not Mute, 1: Mute) \n");
2389 } else if (g_menu_state == CURRENT_STATUS_POSITION_TIME) {
2390 g_print("*** input position value(msec)\n");
2391 } else if (g_menu_state == CURRENT_STATUS_POSITION_ACCURATE) {
2392 g_print("*** input accurate value(0/1)\n");
2393 } else if (g_menu_state == CURRENT_STATUS_LOOPING) {
2394 g_print("*** input looping value.(0: Not Looping, 1: Looping) \n");
2395 } else if (g_menu_state == CURRENT_STATUS_DISPLAY_SURFACE_CHANGE) {
2396 g_print("*** input display surface type.(0: Wayland surface, 1: EVAS surface, 2: No use surface (e.g: audio playback)) \n");
2397 } else if (g_menu_state == CURRENT_STATUS_EXPORT_VIDEO_FRAME) {
2398 g_print("*** set video_decoded_cb (0: none, 1: set cb) \n");
2399 } else if (g_menu_state == CURRENT_STATUS_DISPLAY_MODE) {
2400 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");
2401 } else if (g_menu_state == CURRENT_STATUS_DISPLAY_DST_ROI_AREA) {
2402 g_print("*** input display roi value sequentially.(x, y, w, h)\n");
2403 } else if (g_menu_state == CURRENT_STATUS_DISPLAY_ROTATION) {
2404 g_print("*** input display rotation value.(0: NONE, 1: 90, 2: 180, 3: 270, 4:F LIP_HORZ, 5: FLIP_VERT ) \n");
2405 } else if (g_menu_state == CURRENT_STATUS_DISPLAY_VISIBLE) {
2406 g_print("*** input display visible value.(0: HIDE, 1: SHOW) \n");
2407 } else if (g_menu_state == CURRENT_STATUS_SUBTITLE_FILENAME) {
2408 g_print(" *** input subtitle file path.\n");
2409 } else if (g_menu_state == CURRENT_STATUS_AUDIO_EQUALIZER) {
2410 g_print(" *** input audio eq value.(0: UNSET, 1: SET) \n");
2411 } else if (g_menu_state == CURRENT_STATUS_PLAYBACK_RATE || g_menu_state == CURRENT_STATUS_STREAMING_PLAYBACK_RATE) {
2412 g_print(" *** input playback rate.(-5.0 ~ 5.0)\n");
2413 } else if (g_menu_state == CURRENT_STATUS_SET_TRACK_TYPE) {
2414 g_print(" *** input track type.(1:audio, 3:text)\n");
2415 } else if (g_menu_state == CURRENT_STATUS_SET_TRACK_INDEX) {
2416 g_print(" *** input track index\n");
2417 } else if (g_menu_state == CURRENT_STATUS_NEXT_URI) {
2418 g_print("*** input next uri.\n");
2419 } else if (g_menu_state == CURRENT_STATUS_GAPLESS) {
2420 g_print("*** input gapless value.(0:disable, 1: enable) \n");
2421 } else if (g_menu_state == CURRENT_STATUS_GET_TRACK_INFO) {
2422 g_print("*** input track type.(1:audio, 3:text) \n");
2423 } else if (g_menu_state == CURRENT_STATUS_SET_MAX_BANDWIDTH_VARIANT) {
2424 g_print("*** set max bandwidth (default: -1) \n");
2425 } else if (g_menu_state == CURRENT_STATUS_SET_MAX_WIDTH_VARIANT) {
2426 g_print("*** set max width (default: -1) \n");
2427 } else if (g_menu_state == CURRENT_STATUS_SET_MAX_HEIGHT_VARIANT) {
2428 g_print("*** set max height (default: -1) \n");
2429 } else if (g_menu_state == CURRENT_STATUS_SET_AUDIO_ONLY) {
2430 g_print("*** set audio only mode (0:disable, 1:enable) \n");
2431 } else if (g_menu_state == CURRENT_STATUS_SET_PRE_BUFFERING_SIZE) {
2432 g_print("*** set pre buffering size (ms) \n");
2433 } else if (g_menu_state == CURRENT_STATUS_SET_RE_BUFFERING_SIZE) {
2434 g_print("*** set re buffering size (ms) \n");
2435 } else if (g_menu_state == CURRENT_STATUS_VIDEO360_SET_ENABLE) {
2436 g_print("*** input video 360 status (0: disabled (full panorama), 1: enabled)\n");
2437 } else if (g_menu_state == CURRENT_STATUS_VIDEO360_SET_DOV) {
2438 g_print("*** input direction of view yaw angle (+/- 180 deg.)\n");
2439 } else if (g_menu_state == CURRENT_STATUS_VIDEO360_SET_DOV1) {
2440 g_print("*** input direction of view pitch angle (+/- 90 deg.)\n");
2441 } else if (g_menu_state == CURRENT_STATUS_VIDEO360_SET_FOV) {
2442 g_print("*** input horizontal field of view angle (1~360 deg.)\n");
2443 } else if (g_menu_state == CURRENT_STATUS_VIDEO360_SET_FOV1) {
2444 g_print("*** input vertical field of view angle (1~180 deg.)\n");
2445 } else if (g_menu_state == CURRENT_STATUS_VIDEO360_SET_ZOOM) {
2446 g_print("*** input zoom factor.(1.0~10.0, where 1.0 - no zoom, actual image) \n");
2447 } else if (g_menu_state == CURRENT_STATUS_VIDEO360_SET_ZOOM_WITH_FOV) {
2448 g_print("*** input zoom factor.(1.0~10.0, where 1.0 - no zoom, actual image) \n");
2449 } else if (g_menu_state == CURRENT_STATUS_VIDEO360_SET_ZOOM_WITH_FOV1) {
2450 g_print("*** input horizontal field of view angle (1~360 deg.)\n");
2451 } else if (g_menu_state == CURRENT_STATUS_VIDEO360_SET_ZOOM_WITH_FOV2) {
2452 g_print("*** input vertical field of view angle (1~180 deg.)\n");
2453 } else if (g_menu_state == CURRENT_STATUS_AUDIO_CODEC_TYPE) {
2454 g_print("*** set audio codec type (1: HW, 2: SW) \n");
2455 } else if (g_menu_state == CURRENT_STATUS_VIDEO_CODEC_TYPE) {
2456 g_print("*** set video codec type (1: HW, 2: SW) \n");
2457 } else if (g_menu_state == CURRENT_STATUS_REPLAYGAIN_ENABLE) {
2458 g_print("*** input replaygain value.(0:disable, 1: enable) \n");
2460 g_print("*** unknown status.\n");
2466 gboolean timeout_menu_display(void *data)
2472 gboolean timeout_quit_program(void *data)
2478 void reset_menu_state(void)
2480 g_menu_state = CURRENT_STATUS_MAINMENU;
2483 static void interpret(char *cmd)
2485 static int value1 = 0, value2 = 0, value3 = 0;
2486 static float fval = 0.0;
2488 switch (g_menu_state) {
2489 case CURRENT_STATUS_MAINMENU:
2491 _interpret_main_menu(cmd);
2494 case CURRENT_STATUS_HANDLE_NUM:
2497 if (0 >= value1 || value1 > MAX_HANDLE)
2498 g_print("not supported this number for handles(%d)\n", value1);
2500 g_handle_num = value1;
2505 case CURRENT_STATUS_FILENAME:
2507 input_filename(cmd);
2511 case CURRENT_STATUS_VOLUME:
2518 case CURRENT_STATUS_SOUND_STREAM_INFO:
2521 set_sound_stream_info(value1);
2525 case CURRENT_STATUS_MUTE:
2532 case CURRENT_STATUS_POSITION_TIME:
2535 g_menu_state = CURRENT_STATUS_POSITION_ACCURATE;
2538 case CURRENT_STATUS_POSITION_ACCURATE:
2540 set_position(value1, ((atoi(cmd) != 0) ? (true) : (false)));
2544 case CURRENT_STATUS_LOOPING:
2547 set_looping(value1);
2551 case CURRENT_STATUS_GAPLESS:
2554 set_gapless(value1);
2558 case CURRENT_STATUS_DISPLAY_SURFACE_CHANGE:
2561 change_surface(value1);
2562 if (value1 == 2) { /* null display type */
2563 g_menu_state = CURRENT_STATUS_EXPORT_VIDEO_FRAME;
2569 case CURRENT_STATUS_EXPORT_VIDEO_FRAME:
2573 set_video_frame_decoded_cb();
2576 case CURRENT_STATUS_DISPLAY_MODE:
2579 set_display_mode(value1);
2583 case CURRENT_STATUS_DISPLAY_DST_ROI_AREA:
2608 set_display_roi_area(x, y, w, h);
2617 case CURRENT_STATUS_DISPLAY_ROTATION:
2620 set_display_rotation(value1);
2624 case CURRENT_STATUS_DISPLAY_VISIBLE:
2627 set_display_visible(value1);
2631 case CURRENT_STATUS_SUBTITLE_FILENAME:
2633 input_subtitle_filename(cmd);
2637 case CURRENT_STATUS_AUDIO_EQUALIZER:
2640 set_audio_eq(value1);
2644 case CURRENT_STATUS_PLAYBACK_RATE:
2647 set_playback_rate(fval, FALSE);
2651 case CURRENT_STATUS_STREAMING_PLAYBACK_RATE:
2654 set_playback_rate(fval, TRUE);
2658 case CURRENT_STATUS_SET_TRACK_TYPE:
2661 get_track_info(value1);
2663 g_menu_state = CURRENT_STATUS_SET_TRACK_INDEX;
2666 case CURRENT_STATUS_SET_TRACK_INDEX:
2669 set_track(value1, value2);
2673 case CURRENT_STATUS_NEXT_URI:
2679 case CURRENT_STATUS_GET_TRACK_INFO:
2682 get_track_info(value1);
2686 case CURRENT_STATUS_SET_MAX_BANDWIDTH_VARIANT:
2689 g_menu_state = CURRENT_STATUS_SET_MAX_WIDTH_VARIANT;
2692 case CURRENT_STATUS_SET_MAX_WIDTH_VARIANT:
2695 g_menu_state = CURRENT_STATUS_SET_MAX_HEIGHT_VARIANT;
2698 case CURRENT_STATUS_SET_MAX_HEIGHT_VARIANT:
2701 set_variant_limit(value1, value2, value3);
2705 case CURRENT_STATUS_SET_AUDIO_ONLY:
2708 set_audio_only(value1);
2712 case CURRENT_STATUS_SET_PRE_BUFFERING_SIZE:
2715 g_menu_state = CURRENT_STATUS_SET_RE_BUFFERING_SIZE;
2718 case CURRENT_STATUS_SET_RE_BUFFERING_SIZE:
2721 set_buffer_size(value1, value2);
2725 case CURRENT_STATUS_VIDEO360_SET_ENABLE:
2728 video360_set_enable(value1);
2732 case CURRENT_STATUS_VIDEO360_SET_DOV:
2735 g_menu_state = CURRENT_STATUS_VIDEO360_SET_DOV1;
2738 case CURRENT_STATUS_VIDEO360_SET_DOV1:
2741 video360_set_dov(value1, value2);
2745 case CURRENT_STATUS_VIDEO360_SET_FOV:
2748 g_menu_state = CURRENT_STATUS_VIDEO360_SET_FOV1;
2751 case CURRENT_STATUS_VIDEO360_SET_FOV1:
2754 video360_set_fov(value1, value2);
2758 case CURRENT_STATUS_VIDEO360_SET_ZOOM:
2761 video360_set_zoom(fval);
2765 case CURRENT_STATUS_VIDEO360_SET_ZOOM_WITH_FOV:
2768 g_menu_state = CURRENT_STATUS_VIDEO360_SET_ZOOM_WITH_FOV1;
2771 case CURRENT_STATUS_VIDEO360_SET_ZOOM_WITH_FOV1:
2774 g_menu_state = CURRENT_STATUS_VIDEO360_SET_ZOOM_WITH_FOV2;
2777 case CURRENT_STATUS_VIDEO360_SET_ZOOM_WITH_FOV2:
2780 video360_set_zoom_with_fov(fval, value1, value2);
2784 case CURRENT_STATUS_AUDIO_CODEC_TYPE:
2787 g_menu_state = CURRENT_STATUS_VIDEO_CODEC_TYPE;
2790 case CURRENT_STATUS_VIDEO_CODEC_TYPE:
2793 set_codec_type(value1, value2);
2797 case CURRENT_STATUS_REPLAYGAIN_ENABLE:
2800 set_replaygain_enabled(value1);
2806 g_timeout_add(100, timeout_menu_display, 0);
2809 gboolean input(GIOChannel * channel)
2811 gchar buf[MAX_STRING_LEN];
2813 GError *error = NULL;
2815 g_io_channel_read_chars(channel, buf, MAX_STRING_LEN, &read, &error);
2823 int main(int argc, char *argv[])
2825 GIOChannel *stdin_channel;
2826 stdin_channel = g_io_channel_unix_new(0);
2827 g_io_channel_set_flags(stdin_channel, G_IO_FLAG_NONBLOCK, NULL);
2828 g_io_add_watch(stdin_channel, G_IO_IN, (GIOFunc) input, NULL);
2831 memset(&ad, 0x0, sizeof(appdata));
2834 return appcore_efl_main(PACKAGE, &argc, &argv, &ops);