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,
67 } adaptive_variant_info_t;
74 #ifdef USE_EVENT_HANDLER
75 static void event_handler_cb(enum libinput_event_type ev_t, int x, int y, void * data, float e[3]);
76 static void event_handler_set_dov_fov();
77 static void event_handler_set_window_parameters();
78 mm_navevent_handler_h event_handler;
79 mm_navevent_handler_size_s image_size;
82 static tizen_profile_t _get_tizen_profile()
85 static tizen_profile_t profile = TIZEN_PROFILE_UNKNOWN;
87 if (__builtin_expect(profile != TIZEN_PROFILE_UNKNOWN, 1))
90 system_info_get_platform_string("http://tizen.org/feature/profile", &profileName);
91 switch (*profileName) {
94 profile = TIZEN_PROFILE_MOBILE;
98 profile = TIZEN_PROFILE_WEARABLE;
102 profile = TIZEN_PROFILE_TV;
106 profile = TIZEN_PROFILE_IVI;
108 default: // common or unknown ==> ALL ARE COMMON.
109 profile = TIZEN_PROFILE_COMMON;
115 #define TIZEN_TV ((_get_tizen_profile()) == TIZEN_PROFILE_TV)
117 static gboolean g_memory_playback = FALSE;
118 static char g_uri[MAX_STRING_LEN];
119 static char g_subtitle_uri[MAX_STRING_LEN];
120 static FILE *g_pcm_fd;
122 static gboolean is_es_push_mode = FALSE;
123 static pthread_t g_feed_video_thread_id = 0;
124 static bool g_thread_end = FALSE;
125 static media_packet_h g_audio_pkt = NULL;
126 static media_format_h g_audio_fmt = NULL;
128 static media_packet_h g_video_pkt = NULL;
129 static media_format_h g_video_fmt = NULL;
131 static int _save(unsigned char *src, int length);
133 #define DUMP_OUTBUF 1
135 FILE *fp_out1 = NULL;
136 FILE *fp_out2 = NULL;
140 CURRENT_STATUS_MAINMENU,
141 CURRENT_STATUS_HANDLE_NUM,
142 CURRENT_STATUS_FILENAME,
143 CURRENT_STATUS_VOLUME,
144 CURRENT_STATUS_SOUND_TYPE,
145 CURRENT_STATUS_SOUND_STREAM_INFO,
147 CURRENT_STATUS_POSITION_TIME,
148 CURRENT_STATUS_LOOPING,
149 CURRENT_STATUS_DISPLAY_SURFACE_CHANGE,
150 CURRENT_STATUS_DISPLAY_MODE,
151 CURRENT_STATUS_DISPLAY_DST_ROI,
152 CURRENT_STATUS_DISPLAY_ROTATION,
153 CURRENT_STATUS_DISPLAY_VISIBLE,
154 CURRENT_STATUS_SUBTITLE_FILENAME,
155 CURRENT_STATUS_AUDIO_EQUALIZER,
156 CURRENT_STATUS_PLAYBACK_RATE,
157 CURRENT_STATUS_STREAMING_PLAYBACK_RATE,
158 CURRENT_STATUS_SWITCH_SUBTITLE,
159 CURRENT_STATUS_NEXT_URI,
160 CURRENT_STATUS_GAPLESS,
161 CURRENT_STATUS_GET_TRACK_INFO,
162 CURRENT_STATUS_POSITION_ACCURATE,
163 CURRENT_STATUS_SET_MAX_BANDWIDTH_VARIANT,
164 CURRENT_STATUS_SET_MAX_WIDTH_VARIANT,
165 CURRENT_STATUS_SET_MAX_HEIGHT_VARIANT,
166 CURRENT_STATUS_SET_AUDIO_ONLY,
167 CURRENT_STATUS_SET_PRE_BUFFERING_SIZE,
168 CURRENT_STATUS_SET_RE_BUFFERING_SIZE,
169 CURRENT_STATUS_VIDEO360_SET_ENABLE,
170 CURRENT_STATUS_VIDEO360_SET_DOV,
171 CURRENT_STATUS_VIDEO360_SET_DOV1,
172 CURRENT_STATUS_VIDEO360_SET_FOV,
173 CURRENT_STATUS_VIDEO360_SET_FOV1,
174 CURRENT_STATUS_VIDEO360_SET_ZOOM,
175 CURRENT_STATUS_VIDEO_CODEC_TYPE,
176 CURRENT_STATUS_AUDIO_CODEC_TYPE,
187 } player_codec_type_t;
189 #define MAX_HANDLE 20
191 /* for video display */
192 static Evas_Object *g_win_id;
193 #ifdef _ACTIVATE_EOM_
194 static Evas_Object *g_external_win_id;
196 static Evas_Object *selected_win_id;
197 static Evas_Object *g_eo[MAX_HANDLE] = { 0, };
199 static int g_current_surface_type = -1;
200 static adaptive_variant_info_t max_limit = {-1, -1, -1};
201 static buffer_size_t buff_size = {-1, -1};
205 Evas_Object *layout_main; /* layout widget based on EDJ */
206 /* add more variables here */
207 #ifdef _ACTIVATE_EOM_
213 static player_h g_player[MAX_HANDLE] = { 0, };
214 static player_seek_pos_t seek_info = {0};
215 static player_codec_type_t codec_type = {0};
216 int g_handle_num = 1;
217 int g_menu_state = CURRENT_STATUS_MAINMENU;
218 gboolean quit_pushing;
219 sound_stream_info_h g_stream_info_h = NULL;
221 static void win_del(void *data, Evas_Object * obj, void *event)
226 static Evas_Object *create_win(const char *name)
228 Evas_Object *eo = NULL;
232 g_print("[%s][%d] name=%s\n", __func__, __LINE__, name);
234 eo = elm_win_add(NULL, name, ELM_WIN_BASIC);
236 elm_win_title_set(eo, name);
237 elm_win_borderless_set(eo, EINA_TRUE);
238 evas_object_smart_callback_add(eo, "delete,request", win_del, NULL);
239 elm_win_screen_size_get(eo, NULL, NULL, &w, &h);
240 g_print("window size :%d,%d", w, h);
241 evas_object_resize(eo, w, h);
242 elm_win_autodel_set(eo, EINA_TRUE);
243 elm_win_alpha_set(eo, EINA_TRUE);
248 static Evas_Object *create_image_object(Evas_Object * eo_parent)
253 Evas *evas = evas_object_evas_get(eo_parent);
254 Evas_Object *eo = NULL;
256 eo = evas_object_image_add(evas);
261 void create_render_rect_and_bg(Evas_Object * win)
267 Evas_Object *bg, *rect;
269 bg = elm_bg_add(win);
270 elm_win_resize_object_add(win, bg);
271 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
272 evas_object_show(bg);
274 rect = evas_object_rectangle_add(evas_object_evas_get(win));
279 evas_object_color_set(rect, 0, 0, 0, 0);
280 evas_object_render_op_set(rect, EVAS_RENDER_COPY);
282 elm_win_resize_object_add(win, rect);
283 evas_object_size_hint_weight_set(rect, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
284 evas_object_show(rect);
285 evas_object_show(win);
288 #ifdef _ACTIVATE_EOM_
289 int eom_get_output_id(const char *output_name)
291 eom_output_id *output_ids = NULL;
292 eom_output_id output_id = 0;
293 eom_output_type_e output_type = EOM_OUTPUT_TYPE_UNKNOWN;
298 output_ids = eom_get_eom_output_ids(&id_cnt);
300 g_print("[eom] no external outuputs supported\n");
304 /* find output ids interested */
305 for (i = 0; i < id_cnt; i++) {
306 eom_get_output_type(output_ids[i], &output_type);
307 if (!strncmp(output_name, "HDMI", 4)) {
308 if (output_type == EOM_OUTPUT_TYPE_HDMIA || output_type == EOM_OUTPUT_TYPE_HDMIB) {
309 output_id = output_ids[i];
312 } else if (!strncmp(output_name, "Virtual", 4)) {
313 if (output_type == EOM_OUTPUT_TYPE_VIRTUAL) {
314 output_id = output_ids[i];
326 static void eom_notify_cb_output_add(eom_output_id output_id, void *user_data)
328 appdata *info = (appdata *) user_data;
330 if (info->hdmi_output_id != output_id) {
331 g_print("[eom] OUTPUT ADDED. SKIP. my output ID is %d\n", info->hdmi_output_id);
334 g_print("[eom] output(%d) connected\n", output_id);
335 /* it is for external window */
336 if (!g_external_win_id) {
337 g_external_win_id = elm_win_add(NULL, "External", ELM_WIN_BASIC);
338 if (eom_set_output_window(info->hdmi_output_id, g_external_win_id) == EOM_ERROR_NONE) {
339 create_render_rect_and_bg(g_external_win_id);
340 g_print("[eom] create external window\n");
342 evas_object_del(g_external_win_id);
343 g_external_win_id = NULL;
344 g_print("[eom] create external window fail\n");
349 static void eom_notify_cb_output_remove(eom_output_id output_id, void *user_data)
351 appdata *info = (appdata *) user_data;
352 player_state_e state;
354 if (info->hdmi_output_id != output_id) {
355 g_print("[eom] OUTPUT REMOVED. SKIP. my output ID is %d\n", info->hdmi_output_id);
358 g_print("[eom] output(%d) disconnected\n", output_id);
360 if (selected_win_id == g_external_win_id && g_player[0]) {
361 player_get_state(g_player[0], &state);
362 if (state >= PLAYER_STATE_READY) {
364 g_win_id = create_win(PACKAGE);
365 if (g_win_id == NULL)
367 g_print("create win_id %p\n", g_win_id);
368 create_render_rect_and_bg(g_win_id);
369 elm_win_activate(g_win_id);
370 evas_object_show(g_win_id);
372 player_set_display(g_player[0], PLAYER_DISPLAY_TYPE_OVERLAY, GET_DISPLAY(g_win_id));
376 /* it is for external window */
377 if (g_external_win_id) {
378 evas_object_del(g_external_win_id);
379 g_external_win_id = NULL;
381 selected_win_id = g_win_id;
384 static void eom_notify_cb_mode_changed(eom_output_id output_id, void *user_data)
386 appdata *info = (appdata *) user_data;
387 eom_output_mode_e mode = EOM_OUTPUT_MODE_NONE;
389 if (info->hdmi_output_id != output_id) {
390 g_print("[eom] MODE CHANGED. SKIP. my output ID is %d\n", info->hdmi_output_id);
394 eom_get_output_mode(output_id, &mode);
395 g_print("[eom] output(%d) mode changed(%d)\n", output_id, mode);
398 static void eom_notify_cb_attribute_changed(eom_output_id output_id, void *user_data)
400 appdata *info = (appdata *) user_data;
402 eom_output_attribute_e attribute = EOM_OUTPUT_ATTRIBUTE_NONE;
403 eom_output_attribute_state_e state = EOM_OUTPUT_ATTRIBUTE_STATE_NONE;
405 if (info->hdmi_output_id != output_id) {
406 g_print("[eom] ATTR CHANGED. SKIP. my output ID is %d\n", info->hdmi_output_id);
410 eom_get_output_attribute(output_id, &attribute);
411 eom_get_output_attribute_state(output_id, &state);
413 g_print("[eom] output(%d) attribute changed(%d, %d)\n", output_id, attribute, state);
414 if (state == EOM_OUTPUT_ATTRIBUTE_STATE_ACTIVE) {
415 g_print("[eom] active\n");
416 if (!g_external_win_id) {
417 g_external_win_id = elm_win_add(NULL, "External", ELM_WIN_BASIC);
418 if (eom_set_output_window(info->hdmi_output_id, g_external_win_id) == EOM_ERROR_NONE) {
419 create_render_rect_and_bg(g_external_win_id);
420 g_print("[eom] create external window\n");
422 evas_object_del(g_external_win_id);
423 g_external_win_id = NULL;
424 g_print("[eom] create external window fail\n");
427 selected_win_id = g_external_win_id;
428 /* play video on external window */
430 player_set_display(g_player[0], PLAYER_DISPLAY_TYPE_OVERLAY, GET_DISPLAY(selected_win_id));
431 } else if (state == EOM_OUTPUT_ATTRIBUTE_STATE_INACTIVE) {
432 g_print("[eom] inactive\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;
444 player_set_display(g_player[0], PLAYER_DISPLAY_TYPE_OVERLAY, GET_DISPLAY(selected_win_id));
446 if (g_external_win_id) {
447 evas_object_del(g_external_win_id);
448 g_external_win_id = NULL;
450 } else if (state == EOM_OUTPUT_ATTRIBUTE_STATE_LOST) {
451 g_print("[eom] lost\n");
453 g_win_id = create_win(PACKAGE);
454 if (g_win_id == NULL)
456 g_print("create win_id %p\n", g_win_id);
457 create_render_rect_and_bg(g_win_id);
458 elm_win_activate(g_win_id);
459 evas_object_show(g_win_id);
461 selected_win_id = g_win_id;
464 player_set_display(g_player[0], PLAYER_DISPLAY_TYPE_OVERLAY, GET_DISPLAY(selected_win_id));
466 if (g_external_win_id) {
467 evas_object_del(g_external_win_id);
468 g_external_win_id = NULL;
471 eom_unset_output_added_cb(eom_notify_cb_output_add);
472 eom_unset_output_removed_cb(eom_notify_cb_output_remove);
473 eom_unset_mode_changed_cb(eom_notify_cb_mode_changed);
474 eom_unset_attribute_changed_cb(eom_notify_cb_attribute_changed);
480 static int app_create(void *data)
483 Evas_Object *win = NULL;
484 #ifdef _ACTIVATE_EOM_
485 eom_output_mode_e output_mode = EOM_OUTPUT_MODE_NONE;
489 elm_config_accel_preference_set("opengl");
492 win = create_win(PACKAGE);
497 selected_win_id = g_win_id;
498 create_render_rect_and_bg(ad->win);
499 /* Create evas image object for EVAS surface */
500 g_eo[0] = create_image_object(ad->win);
501 evas_object_image_size_set(g_eo[0], 500, 500);
502 evas_object_image_fill_set(g_eo[0], 0, 0, 500, 500);
503 evas_object_resize(g_eo[0], 500, 500);
505 elm_win_activate(win);
506 evas_object_show(win);
507 #ifdef _ACTIVATE_EOM_
508 /* check external device */
510 ad->hdmi_output_id = eom_get_output_id("HDMI");
511 if (ad->hdmi_output_id == 0) {
512 g_print("[eom] error : HDMI output id is NULL.\n");
516 g_print("eom_set_output_attribute EOM_OUTPUT_ATTRIBUTE_NORMAL(id:%d)\n", ad->hdmi_output_id);
517 if (eom_set_output_attribute(ad->hdmi_output_id, EOM_OUTPUT_ATTRIBUTE_NORMAL) != EOM_ERROR_NONE) {
518 g_print("attribute set fail. cannot use external output\n");
522 eom_get_output_mode(ad->hdmi_output_id, &output_mode);
523 if (output_mode != EOM_OUTPUT_MODE_NONE) {
524 g_external_win_id = elm_win_add(NULL, "External", ELM_WIN_BASIC);
525 if (eom_set_output_window(ad->hdmi_output_id, g_external_win_id) == EOM_ERROR_NONE) {
526 create_render_rect_and_bg(g_external_win_id);
527 g_print("[eom] create external window\n");
529 evas_object_del(g_external_win_id);
530 g_external_win_id = NULL;
531 g_print("[eom] create external window fail\n");
533 selected_win_id = g_external_win_id;
536 /* set callback for detecting external device */
537 eom_set_output_added_cb(eom_notify_cb_output_add, ad);
538 eom_set_output_removed_cb(eom_notify_cb_output_remove, ad);
539 eom_set_mode_changed_cb(eom_notify_cb_mode_changed, ad);
540 eom_set_attribute_changed_cb(eom_notify_cb_attribute_changed, ad);
543 #ifdef USE_EVENT_HANDLER
544 if (mm_navevent_handler_create(&event_handler,
545 MM_NAVEVENT_HANDLER_DEVICE_TYPE_TOUCH) != MM_NAVEVENT_HANDLER_ERROR_NONE) {
546 g_print ("Error during handler creation\n");
550 if (mm_navevent_handler_set_cb(event_handler, event_handler_cb, NULL) !=
551 MM_NAVEVENT_HANDLER_ERROR_NONE) {
552 g_print ("Error during callback set\n");
560 static int app_terminate(void *data)
565 #ifdef USE_EVENT_HANDLER
566 mm_navevent_handler_destroy(event_handler);
569 for (i = 0; i < MAX_HANDLE; i++) {
571 evas_object_del(g_eo[i]);
576 evas_object_del(g_win_id);
579 #ifdef _ACTIVATE_EOM_
580 if (g_external_win_id) {
581 evas_object_del(g_external_win_id);
582 g_external_win_id = NULL;
586 selected_win_id = NULL;
587 #ifdef _ACTIVATE_EOM_
588 eom_unset_output_added_cb(eom_notify_cb_output_add);
589 eom_unset_output_removed_cb(eom_notify_cb_output_remove);
590 eom_unset_mode_changed_cb(eom_notify_cb_mode_changed);
591 eom_unset_attribute_changed_cb(eom_notify_cb_attribute_changed);
598 struct appcore_ops ops = {
599 .create = app_create,
600 .terminate = app_terminate,
603 static void prepared_cb(void *user_data)
605 g_print("[Player_Test] prepared_cb!!!!\n");
608 static void _audio_frame_decoded_cb_ex(player_audio_raw_data_s * audio_raw_frame, void *user_data)
610 player_audio_raw_data_s *audio_raw = audio_raw_frame;
615 g_print("[Player_Test] decoded_cb_ex! channel: %d channel_mask: %llu\n", audio_raw->channel, audio_raw->channel_mask);
618 if (audio_raw->channel_mask == 1 && fp_out1)
619 fwrite((guint8 *) audio_raw->data, 1, audio_raw->size, fp_out1);
620 else if (audio_raw->channel_mask == 2 && fp_out2)
621 fwrite((guint8 *) audio_raw->data, 1, audio_raw->size, fp_out2);
625 static void progress_down_cb(player_pd_message_type_e type, void *user_data)
627 g_print("[Player_Test] progress_down_cb!!!! type : %d\n", type);
630 static void buffering_cb(int percent, void *user_data)
632 g_print("[Player_Test] buffering_cb!!!! percent : %d\n", percent);
635 static void seek_completed_cb(void *user_data)
637 g_print("[Player_Test] seek_completed_cb!!! \n");
640 static void completed_cb(void *user_data)
642 g_print("[Player_Test] completed_cb!!!!\n");
645 static void error_cb(int code, void *user_data)
647 g_print("[Player_Test] error_cb!!!! code : %d\n", code);
650 static void interrupted_cb(player_interrupted_code_e code, void *user_data)
652 g_print("[Player_Test] interrupted_cb!!!! code : %d\n", code);
655 static void video_changed_cb(int width, int height, int fps, int bit_rate, void *user_data)
657 g_print("[Player_Test] video_changed_cb!!!! %d x %d, %d, %d \n", width, height, fps, bit_rate);
659 #ifdef USE_EVENT_HANDLER
660 image_size.width = width;
661 image_size.height = height;
662 event_handler_set_window_parameters();
667 static void audio_frame_decoded_cb(unsigned char *data, unsigned int size, void *user_data)
671 if (data && g_pcm_fd)
672 fwrite(data, 1, size, g_pcm_fd);
673 player_get_play_position(g_player[0], &pos);
674 g_print("[Player_Test] audio_frame_decoded_cb [size: %d] --- current pos : %d!!!!\n", size, pos);
678 static void subtitle_updated_cb(unsigned long duration, char *text, void *user_data)
680 g_print("[Player_Test] subtitle_updated_cb!!!! [%ld] %s\n", duration, text);
683 static void video_captured_cb(unsigned char *data, int width, int height, unsigned int size, void *user_data)
685 g_print("[Player_Test] video_captured_cb!!!! width: %d, height : %d, size : %d \n", width, height, size);
689 static int _save(unsigned char *src, int length)
691 /* unlink(CAPTUERD_IMAGE_SAVE_PATH); */
693 char filename[256] = { 0, };
694 static int WRITE_COUNT = 0;
695 /* gchar *filename = CAPTUERD_IMAGE_SAVE_PATH; */
696 snprintf(filename, 256, "/tmp/IMAGE_client%d", WRITE_COUNT);
698 fp = fopen(filename, "w+");
700 g_print("file open error!!\n");
703 g_print("open success\n");
704 if (fwrite(src, 1, length, fp) < 1) {
705 g_print("file write error!!\n");
709 g_print("write success(%s)\n", filename);
716 static void reset_display()
720 /* delete evas window, if it is */
721 for (i = 0; i < MAX_HANDLE; i++) {
723 evas_object_del(g_eo[i]);
729 static void input_filename(char *filename)
731 int len = strlen(filename);
734 if (len < 0 || len > MAX_STRING_LEN - 1)
737 for (i = 0; i < g_handle_num; i++) {
738 if (g_player[i] != NULL) {
739 player_unprepare(g_player[i]);
740 player_destroy(g_player[i]);
744 if (player_create(&g_player[i]) != PLAYER_ERROR_NONE)
745 g_print("player create is failed\n");
748 strncpy(g_uri, filename, len+1);
752 /* ned(APPSRC_TEST) */
757 GError *error = NULL;
758 guint8 *g_media_mem = NULL;
762 file = g_mapped_file_new(ext, FALSE, &error);
763 file_size = g_mapped_file_get_length(file);
764 g_media_mem = (guint8 *) g_mapped_file_get_contents(file);
766 g_sprintf(uri, "mem://ext=%s,size=%d", ext ? ext : "", file_size);
767 g_print("[uri] = %s\n", uri);
769 mm_player_set_attribute(g_player[0], &g_err_name, "profile_uri", uri, strlen(uri), "profile_user_param", g_media_mem, file_size NULL);
771 /* player_set_uri(g_player[0], filename); */
776 player_state_e state;
777 for (i = 0; i < g_handle_num; i++) {
778 ret = player_get_state(g_player[i], &state);
779 g_print("player_get_state returned [%d]\n", ret);
780 g_print("1. After player_create() - Current State : %d \n", state);
784 /* use this API instead of player_set_uri */
785 static void player_set_memory_buffer_test()
789 guint8 *g_media_mem = NULL;
791 file = g_mapped_file_new(g_uri, FALSE, NULL);
792 file_size = g_mapped_file_get_length(file);
793 g_media_mem = (guint8 *) g_mapped_file_get_contents(file);
795 int ret = player_set_memory_buffer(g_player[0], (void *)g_media_mem, file_size);
796 g_print("player_set_memory_buffer ret : %d\n", ret);
799 int video_packet_count = 0;
801 static void buffer_need_video_data_cb(unsigned int size, void *user_data)
803 int real_read_len = 0;
806 static guint64 pts = 0L;
809 guint8 *buff_ptr = NULL;
812 memset(fname, 0, 128);
813 memset(fptsname, 0, 128);
815 video_packet_count++;
817 if (video_packet_count > 1000) {
820 /* player_submit_packet(g_player[0], NULL, 0, 0, 1); */
821 player_push_media_stream(g_player[0], NULL);
825 /* snprintf(fname, 128, "/opt/storage/usb/test/packet/packet_%d.dat", video_packet_count); */
826 /* snprintf(fptsname, 128, "/opt/storage/usb/test/packet/gstpts_%d.dat", video_packet_count); */
827 snprintf(fname, 128, "/home/developer/test/packet/packet_%d.dat", video_packet_count);
828 snprintf(fptsname, 128, "/home/developer/test/packet/gstpts_%d.dat", video_packet_count);
830 fp = fopen(fptsname, "rb");
833 pts_len = fread(&pts, 1, sizeof(guint64), fp);
834 if (pts_len != sizeof(guint64))
835 g_print("Warning, pts value can be wrong.\n");
840 fp = fopen(fname, "rb");
842 buff_ptr = (guint8 *) g_malloc0(1048576);
844 g_print("no free space\n");
849 real_read_len = fread(buff_ptr, 1, size, fp);
853 g_print("video need data - data size : %d, pts : %" G_GUINT64_FORMAT "\n", real_read_len, pts);
855 player_submit_packet(g_player[0], buff_ptr, real_read_len, (pts / 1000000), 1);
857 /* create media packet */
859 media_packet_destroy(g_video_pkt);
863 media_packet_create_alloc(g_video_fmt, NULL, NULL, &g_video_pkt);
865 g_print("packet = %p, src = %p\n", g_video_pkt, src);
867 if (media_packet_get_buffer_data_ptr(g_video_pkt, &src) != MEDIA_PACKET_ERROR_NONE)
870 if (media_packet_set_pts(g_video_pkt, (uint64_t) pts) != MEDIA_PACKET_ERROR_NONE)
873 if (media_packet_set_buffer_size(g_video_pkt, (uint64_t) real_read_len) != MEDIA_PACKET_ERROR_NONE)
876 memcpy(src, buff_ptr, real_read_len);
879 player_push_media_stream(g_player[0], g_video_pkt);
889 int audio_packet_count = 0;
890 static void buffer_need_audio_data_cb(unsigned int size, void *user_data)
892 int real_read_len = 0;
895 guint8 *buff_ptr = NULL;
898 memset(fname, 0, 128);
899 audio_packet_count++;
901 if (audio_packet_count > 1000) {
903 /* player_submit_packet(g_player[0], NULL, 0, 0, 0); */
904 player_push_media_stream(g_player[0], NULL);
908 /* snprintf(fname, 128, "/opt/storage/usb/test/audio_packet/packet_%d.dat", audio_packet_count); */
909 snprintf(fname, 128, "/home/developer/test/audio_packet/packet_%d.dat", audio_packet_count);
911 static guint64 audio_pts = 0;
912 guint64 audio_dur = 21333333;
914 fp = fopen(fname, "rb");
916 buff_ptr = (guint8 *) g_malloc0(1048576);
918 g_print("no free space\n");
923 real_read_len = fread(buff_ptr, 1, size, fp);
927 g_print("\t audio need data - data size : %d, pts : %" G_GUINT64_FORMAT "\n", real_read_len, audio_pts);
930 player_submit_packet(g_player[0], buff_ptr, real_read_len, (audio_pts / 1000000), 0);
932 /* create media packet */
934 media_packet_destroy(g_audio_pkt);
937 media_packet_create_alloc(g_audio_fmt, NULL, NULL, &g_audio_pkt);
939 g_print("packet = %p, src = %p\n", g_audio_pkt, src);
941 if (media_packet_get_buffer_data_ptr(g_audio_pkt, &src) != MEDIA_PACKET_ERROR_NONE)
944 if (media_packet_set_pts(g_audio_pkt, (uint64_t) audio_pts) != MEDIA_PACKET_ERROR_NONE)
947 if (media_packet_set_buffer_size(g_audio_pkt, (uint64_t) real_read_len) != MEDIA_PACKET_ERROR_NONE)
950 memcpy(src, buff_ptr, real_read_len);
953 player_push_media_stream(g_player[0], g_audio_pkt);
956 audio_pts += audio_dur;
964 static void set_content_info(bool is_push_mode)
966 /* testcode for es buff src case, please input url as es_buff://123 or es_buff://push_mode */
967 /* 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}; */
969 /* create media format */
970 media_format_create(&g_audio_fmt);
971 media_format_create(&g_video_fmt);
974 /* configure media format for video and set to player */
975 media_format_set_video_mime(g_video_fmt, MEDIA_FORMAT_MPEG4_SP);
976 media_format_set_video_width(g_video_fmt, 640);
977 media_format_set_video_height(g_video_fmt, 272);
978 /* player_set_media_stream_info(g_player[0], PLAYER_STREAM_TYPE_VIDEO, g_video_fmt); */
980 /* Audio--aac--StarWars.mp4 */
981 media_format_set_audio_mime(g_audio_fmt, MEDIA_FORMAT_AAC);
982 media_format_set_audio_channel(g_audio_fmt, 2);
983 media_format_set_audio_samplerate(g_audio_fmt, 48000);
984 /* player_set_media_stream_info(g_player[0], PLAYER_STREAM_TYPE_AUDIO, g_audio_fmt); */
986 /* video_info->mime = g_strdup("video/mpeg"); *//* CODEC_ID_MPEG4VIDEO */
987 video_info->width = 640;
988 video_info->height = 272;
989 video_info->version = 4;
990 video_info->framerate_den = 100;
991 video_info->framerate_num = 2997;
993 video_info->extradata_size = 45;
994 video_info->codec_extradata = codec_data;
995 player_set_video_stream_info(g_player[0], video_info);
997 /* audio--aac--StarWars.mp4 */
998 /* audio_info->mime = g_strdup("audio/mpeg"); */
999 /* audio_info->version = 2; */
1000 /* audio_info->user_info = 0; *//* raw */
1004 if (!is_push_mode) {
1005 player_set_buffer_need_video_data_cb(g_player[0], buffer_need_video_data_cb, (void *)g_player[0]);
1006 player_set_buffer_need_audio_data_cb(g_player[0], buffer_need_audio_data_cb, (void *)g_player[0]);
1011 static void feed_video_data_thread_func(void *data)
1013 while (!g_thread_end) {
1014 buffer_need_video_data_cb(1048576, NULL);
1015 buffer_need_audio_data_cb(1048576, NULL);
1019 static void _player_prepare(bool async)
1022 int slen = strlen(g_subtitle_uri);
1024 if (slen > 0 && slen < MAX_STRING_LEN) {
1025 g_print("0. set subtile path() (size : %d) - %s \n", slen, g_subtitle_uri);
1026 player_set_subtitle_path(g_player[0], g_subtitle_uri);
1027 player_set_subtitle_updated_cb(g_player[0], subtitle_updated_cb, (void *)g_player[0]);
1029 if (g_current_surface_type == -1) {
1030 g_print("You must set display surface type before setting prepare.\n");
1034 if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
1035 player_set_buffering_cb(g_player[0], buffering_cb, (void *)g_player[0]);
1036 player_set_completed_cb(g_player[0], completed_cb, (void *)g_player[0]);
1037 player_set_interrupted_cb(g_player[0], interrupted_cb, (void *)g_player[0]);
1038 player_set_error_cb(g_player[0], error_cb, (void *)g_player[0]);
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[0], g_uri);
1046 for (i = 0; i < g_handle_num; i++) {
1047 player_set_buffering_cb(g_player[i], buffering_cb, (void *)g_player[i]);
1048 player_set_completed_cb(g_player[i], completed_cb, (void *)g_player[i]);
1049 player_set_interrupted_cb(g_player[i], interrupted_cb, (void *)g_player[i]);
1050 player_set_error_cb(g_player[i], error_cb, (void *)g_player[i]);
1051 player_set_video_stream_changed_cb(g_player[0], video_changed_cb, (void *)g_player[0]);
1052 if (g_memory_playback)
1053 player_set_memory_buffer_test();
1055 player_set_uri(g_player[i], g_uri);
1059 if (strstr(g_uri, "es_buff://")) {
1060 is_es_push_mode = FALSE;
1061 video_packet_count = 0;
1062 audio_packet_count = 0;
1064 if (strstr(g_uri, "es_buff://push_mode")) {
1065 set_content_info(TRUE);
1067 is_es_push_mode = TRUE;
1070 set_content_info(FALSE);
1075 if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
1077 ret = player_prepare_async(g_player[0], prepared_cb, (void *)g_player[0]);
1079 ret = player_prepare(g_player[0]);
1082 for (i = 0; i < g_handle_num; i++) {
1084 ret = player_prepare_async(g_player[i], prepared_cb, (void *)g_player[i]);
1086 ret = player_prepare(g_player[i]);
1090 if (ret != PLAYER_ERROR_NONE)
1091 g_print("prepare is failed (errno = %d) \n", ret);
1093 player_state_e state;
1094 if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
1095 ret = player_get_state(g_player[0], &state);
1096 g_print("After player_prepare() - Current State : %d \n", state);
1099 for (i = 0; i < g_handle_num; i++) {
1100 ret = player_get_state(g_player[i], &state);
1101 g_print("After player_prepare() - Current State : %d \n", state);
1105 if (is_es_push_mode)
1106 pthread_create(&g_feed_video_thread_id, NULL, (void *)feed_video_data_thread_func, NULL);
1108 #ifdef USE_EVENT_HANDLER
1109 event_handler_set_dov_fov();
1113 static void _player_unprepare()
1117 if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
1118 ret = player_unprepare(g_player[0]);
1119 if (ret != PLAYER_ERROR_NONE)
1120 g_print("unprepare is failed (errno = %d) \n", ret);
1122 ret = player_unset_subtitle_updated_cb(g_player[0]);
1123 g_print("player_unset_subtitle_updated_cb ret %d\n", ret);
1125 ret = player_unset_buffering_cb(g_player[0]);
1126 g_print("player_unset_buffering_cb ret %d\n", ret);
1128 ret = player_unset_completed_cb(g_player[0]);
1129 g_print("player_unset_completed_cb ret %d\n", ret);
1131 ret = player_unset_interrupted_cb(g_player[0]);
1132 g_print("player_unset_interrupted_cb ret %d\n", ret);
1134 ret = player_unset_error_cb(g_player[0]);
1135 g_print("player_unset_error_cb ret %d\n", ret);
1137 for (i = 0; i < g_handle_num; i++) {
1138 if (g_player[i] != NULL) {
1139 ret = player_unprepare(g_player[i]);
1140 if (ret != PLAYER_ERROR_NONE)
1141 g_print("unprepare is failed (errno = %d) \n", ret);
1143 ret = player_unset_subtitle_updated_cb(g_player[i]);
1144 g_print("player_unset_subtitle_updated_cb [%d] ret %d\n", i, ret);
1146 ret = player_unset_buffering_cb(g_player[i]);
1147 g_print("player_unset_buffering_cb [%d] ret %d\n", i, ret);
1149 ret = player_unset_completed_cb(g_player[i]);
1150 g_print("player_unset_completed_cb [%d] ret %d\n", i, ret);
1152 ret = player_unset_interrupted_cb(g_player[i]);
1153 g_print("player_unset_interrupted_cb [%d] ret %d\n", i, ret);
1155 ret = player_unset_error_cb(g_player[i]);
1156 g_print("player_unset_error_cb [%d] ret %d\n", i, ret);
1161 memset(g_subtitle_uri, 0, sizeof(g_subtitle_uri));
1162 player_state_e state;
1163 if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
1164 ret = player_get_state(g_player[0], &state);
1165 g_print(" After player_unprepare() - Current State : %d \n", state);
1167 for (i = 0; i < g_handle_num; i++) {
1168 ret = player_get_state(g_player[i], &state);
1169 g_print(" After player_unprepare() - Current State : %d \n", state);
1174 static void _player_destroy()
1178 if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
1179 player_destroy(g_player[0]);
1182 for (i = 0; i < g_handle_num; i++) {
1183 if (g_player[i] != NULL) {
1184 player_unprepare(g_player[i]);
1185 player_destroy(g_player[i]);
1191 if (g_stream_info_h) {
1192 sound_manager_destroy_stream_information(g_stream_info_h);
1193 g_stream_info_h = NULL;
1197 media_packet_destroy(g_video_pkt);
1200 media_packet_destroy(g_audio_pkt);
1211 static void _player_play()
1215 if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
1216 #ifdef _ACTIVATE_EOM_
1217 /* for checking external display.... */
1218 player_set_display(g_player[0], g_current_surface_type, GET_DISPLAY(selected_win_id));
1220 bRet = player_start(g_player[0]);
1221 g_print("player_start returned [%d]", bRet);
1223 for (i = 0; i < g_handle_num; i++) {
1224 bRet = player_start(g_player[i]);
1225 g_print("player_start returned [%d]", bRet);
1230 static void _player_stop()
1234 if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
1235 bRet = player_stop(g_player[0]);
1236 g_print("player_stop returned [%d]", bRet);
1238 for (i = 0; i < g_handle_num; i++) {
1239 bRet = player_stop(g_player[i]);
1240 g_print("player_stop returned [%d]", bRet);
1244 g_thread_end = TRUE;
1245 if (g_feed_video_thread_id) {
1246 pthread_join(g_feed_video_thread_id, NULL);
1247 g_feed_video_thread_id = 0;
1252 static void _player_resume()
1256 if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
1257 #ifdef _ACTIVATE_EOM_
1258 /* for checking external display.... */
1259 player_set_display(g_player[0], PLAYER_DISPLAY_TYPE_OVERLAY, GET_DISPLAY(selected_win_id));
1261 bRet = player_start(g_player[0]);
1262 g_print("player_start returned [%d]", bRet);
1264 for (i = 0; i < g_handle_num; i++) {
1265 bRet = player_start(g_player[i]);
1266 g_print("player_start returned [%d]", bRet);
1271 static void _player_pause()
1275 if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
1276 bRet = player_pause(g_player[0]);
1277 g_print("player_pause returned [%d]", bRet);
1279 for (i = 0; i < g_handle_num; i++) {
1280 bRet = player_pause(g_player[i]);
1281 g_print("player_pause returned [%d]", bRet);
1286 static void _player_state()
1288 player_state_e state;
1289 player_get_state(g_player[0], &state);
1290 g_print(" ==> [Player_Test] Current Player State : %d\n", state);
1293 static void _player_set_progressive_download()
1295 player_set_progressive_download_path(g_player[0], "/home/owner/test.pd");
1296 player_set_progressive_download_message_cb(g_player[0], progress_down_cb, (void *)g_player[0]);
1299 static void _player_get_progressive_download_status()
1302 unsigned long curr = 0, total = 0;
1303 bRet = player_get_progressive_download_status(g_player[0], &curr, &total);
1304 g_print("player_get_progressive_download_status return[%d] ==> [Player_Test] progressive download status : %lu/%lu\n", bRet, curr, total);
1307 static void _player_enable_tsurf_pool(void)
1309 bool enabled = FALSE;
1312 g_print("not support at TV profile");
1316 player_is_enabled_tsurf_pool(g_player[0], &enabled);
1318 g_print("tbm surface pool will be %s", (enabled) ? "disabled" : "enabled");
1319 player_enable_tsurf_pool(g_player[0], !enabled);
1322 static void set_next_uri(char * uri)
1325 g_print("not support at TV profile");
1329 if (player_set_next_uri(g_player[0], uri) != PLAYER_ERROR_NONE)
1330 g_print("fail to set next uri");
1333 static void get_next_uri()
1338 g_print("not support at TV profile");
1342 if (player_get_next_uri(g_player[0], &uri) != PLAYER_ERROR_NONE) {
1343 g_print("fail to get next uri");
1348 g_print("next_uri = %s", uri);
1353 static void set_volume(float volume)
1355 if (player_set_volume(g_player[0], volume, volume) != PLAYER_ERROR_NONE)
1356 g_print("failed to set volume\n");
1359 static void get_volume(float *left, float *right)
1361 player_get_volume(g_player[0], left, right);
1362 g_print(" ==> [Player_Test] volume - left : %f, right : %f\n", *left, *right);
1365 static void set_mute(bool mute)
1367 if (player_set_mute(g_player[0], mute) != PLAYER_ERROR_NONE)
1368 g_print("failed to set_mute\n");
1371 static void get_mute(bool * mute)
1373 player_is_muted(g_player[0], mute);
1374 g_print(" ==> [Player_Test] mute = %d\n", *mute);
1377 static void set_sound_type(sound_type_e type)
1379 if (player_set_sound_type(g_player[0], type) != PLAYER_ERROR_NONE)
1380 g_print("failed to set sound type(%d)\n", type);
1382 g_print("set sound type(%d) success", type);
1385 void focus_callback(sound_stream_info_h stream_info,
1386 sound_stream_focus_mask_e focus_mask,
1387 sound_stream_focus_state_e focus_state,
1388 sound_stream_focus_change_reason_e reason,
1390 const char *extra_info,
1393 g_print("FOCUS callback is called, reason(%d), extra_info(%s), userdata(%p)", reason, extra_info, user_data);
1397 static void set_sound_stream_info(int type)
1399 sound_device_list_h device_list = NULL;
1400 int ret = SOUND_MANAGER_ERROR_NONE;
1402 if (g_stream_info_h) {
1403 g_print("stream information is already set, please destory handle and try again\n");
1406 if (sound_manager_create_stream_information(type, focus_callback, g_player[0], &g_stream_info_h)) {
1407 g_print("failed to create stream_information()\n");
1410 /* In case of MEDIA_EXTERNAL_ONLY, we need to set external device manually */
1411 if (type == (int)SOUND_STREAM_TYPE_MEDIA_EXTERNAL_ONLY) {
1412 sound_device_h device = NULL;
1413 sound_device_type_e device_type;
1415 if ((ret = sound_manager_get_device_list(SOUND_DEVICE_ALL_MASK, &device_list))) {
1416 g_print("failed to sound_manager_get_device_list(), ret(0x%x)\n", ret);
1419 while (!(ret = sound_manager_get_next_device(device_list, &device))) {
1420 if ((ret = sound_manager_get_device_type(device, &device_type))) {
1421 g_print("failed to sound_manager_get_device_type(), ret(0x%x)\n", ret);
1424 if (device_type == SOUND_DEVICE_BLUETOOTH_MEDIA || device_type == SOUND_DEVICE_USB_AUDIO) {
1425 if ((ret = sound_manager_add_device_for_stream_routing(g_stream_info_h, device))) {
1426 g_print("failed to sound_manager_add_device_for_stream_routing(), ret(0x%x)\n", ret);
1429 if ((ret = sound_manager_apply_stream_routing(g_stream_info_h))) {
1430 g_print("failed to sound_manager_apply_stream_routing(), ret(0x%x)\n", ret);
1436 if (ret != SOUND_MANAGER_ERROR_NONE) {
1437 g_print("failed to sound_manager_get_next_device(), ret(0x%x)\n", ret);
1442 if (player_set_sound_stream_info(g_player[0], g_stream_info_h) != PLAYER_ERROR_NONE)
1443 g_print("failed to set sound stream information(%p)\n", g_stream_info_h);
1445 g_print("set stream information(%p) success", g_stream_info_h);
1449 sound_manager_free_device_list(device_list);
1453 void variant_cb(int bandwidth, int width, int height, void *user_data)
1455 g_print(" ==> [Player_Test][b]%d, [w]%d, [h]%d\n", bandwidth, width, height);
1458 static void get_variant_info()
1460 player_foreach_adaptive_variant(g_player[0], (player_adaptive_variant_cb)variant_cb, g_player[0]);
1463 static void get_variant_limit()
1465 int bandwidth, width, height;
1466 player_get_max_adaptive_variant_limit(g_player[0], &bandwidth, &width, &height);
1467 g_print(" ==> [Player_Test]get [b]%d, [w]%d, [h]%d\n", bandwidth, width, height);
1470 static void set_variant_limit()
1472 g_print(" ==> [Player_Test]set [b]%d, [w]%d, [h]%d\n", max_limit.bandwidth, max_limit.width, max_limit.height);
1473 player_set_max_adaptive_variant_limit(g_player[0], max_limit.bandwidth, max_limit.width, max_limit.height);
1476 static void set_buffer_size()
1479 int buffer_ms = 0, rebuffer_ms = 0;
1481 ret = player_get_streaming_buffering_time(g_player[0], &buffer_ms, &rebuffer_ms);
1482 if (ret != PLAYER_ERROR_NONE)
1483 g_print("failed to get buffering time. 0x%X\n", ret);
1485 g_print("current buffer size %d ms / %d ms\n", buffer_ms, rebuffer_ms);
1487 g_print("new buffer size %d ms / %d ms\n", buff_size.buffer_ms, buff_size.rebuffer_ms);
1489 player_set_streaming_buffering_time(g_player[0], buff_size.buffer_ms, buff_size.rebuffer_ms);
1492 static void get_position()
1496 ret = player_get_play_position(g_player[0], &position);
1497 g_print(" ==> [Player_Test] player_get_play_position()%d return : %d\n", ret, position);
1500 static void set_position(int position, bool accurate)
1502 if (player_set_play_position(g_player[0], position, accurate, seek_completed_cb, g_player[0]) != PLAYER_ERROR_NONE)
1503 g_print("failed to set position\n");
1506 static void set_playback_rate(float rate, bool streaming)
1509 if (player_set_streaming_playback_rate(g_player[0], rate) != PLAYER_ERROR_NONE)
1510 g_print("failed to set streaming playback rate\n");
1512 if (player_set_playback_rate(g_player[0], rate) != PLAYER_ERROR_NONE)
1513 g_print("failed to set playback rate\n");
1517 static void get_duration()
1521 ret = player_get_duration(g_player[0], &duration);
1522 g_print(" ==> [Player_Test] player_get_duration() return : %d\n", ret);
1523 g_print(" ==> [Player_Test] Duration: [%d ] msec\n", duration);
1526 static void set_codec_type(void)
1530 ret = player_set_codec_type(g_player[0], PLAYER_STREAM_TYPE_AUDIO, codec_type.a_codec_type);
1531 g_print(" ==> [Player_Test] audio codec type (%d) return: %d\n", codec_type.a_codec_type, ret);
1533 ret = player_set_codec_type(g_player[0], PLAYER_STREAM_TYPE_VIDEO, codec_type.v_codec_type);
1534 g_print(" ==> [Player_Test] video codec type (%d) return: %d\n", codec_type.v_codec_type, ret);
1538 static void get_codec_type(void)
1541 player_codec_type_e atype = 0, vtype = 0;
1543 ret = player_get_codec_type(g_player[0], PLAYER_STREAM_TYPE_AUDIO, &atype);
1544 g_print(" ==> [Player_Test] Audio Codec type: [%d][ret 0x%X]\n", atype, ret);
1546 ret = player_get_codec_type(g_player[0], PLAYER_STREAM_TYPE_VIDEO, &vtype);
1547 g_print(" ==> [Player_Test] Video Codec type: [%d][ret 0x%X]\n", vtype, ret);
1550 static void audio_frame_decoded_cb_ex(bool sync)
1554 fp_out1 = fopen("/tmp/out1.pcm", "wb");
1555 fp_out2 = fopen("/tmp/out2.pcm", "wb");
1556 if (!fp_out1 || !fp_out2) {
1557 g_print("File open error\n");
1562 ret = player_set_pcm_extraction_mode(g_player[0], sync, _audio_frame_decoded_cb_ex, &ret);
1563 g_print(" ==> [Player_Test] player_set_audio_frame_decoded_cb_ex(sync:%d) ret:%d\n", sync, ret);
1565 ret = player_set_pcm_spec(g_player[0], "F32LE", 44100, 2);
1566 g_print("[Player_Test] set_pcm_spec return: %d\n", ret);
1569 static void get_stream_info()
1575 player_get_content_info(g_player[0], PLAYER_CONTENT_INFO_ALBUM, &value);
1576 g_print(" ==> [Player_Test] PLAYER_CONTENT_INFO_ALBUM: [%s ] \n", value);
1577 player_get_content_info(g_player[0], PLAYER_CONTENT_INFO_ARTIST, &value);
1578 g_print(" ==> [Player_Test] PLAYER_CONTENT_INFO_ARTIST: [%s ] \n", value);
1579 player_get_content_info(g_player[0], PLAYER_CONTENT_INFO_AUTHOR, &value);
1580 g_print(" ==> [Player_Test] PLAYER_CONTENT_INFO_AUTHOR: [%s ] \n", value);
1581 player_get_content_info(g_player[0], PLAYER_CONTENT_INFO_GENRE, &value);
1582 g_print(" ==> [Player_Test] PLAYER_CONTENT_INFO_GENRE: [%s ] \n", value);
1583 player_get_content_info(g_player[0], PLAYER_CONTENT_INFO_TITLE, &value);
1584 g_print(" ==> [Player_Test] PLAYER_CONTENT_INFO_TITLE: [%s ] \n", value);
1587 player_get_album_art(g_player[0], &album, &size);
1588 g_print(" ==> [Player_Test] Album art : [ data : %p, size : %d ]\n", (unsigned int *)album, size);
1590 if (value != NULL) {
1598 int fps, v_bit_rate;
1599 player_get_audio_stream_info(g_player[0], &sample_rate, &channel, &bit_rate);
1600 g_print(" ==> [Player_Test] Sample Rate: [%d ] , Channel: [%d ] , Bit Rate: [%d ] \n", sample_rate, channel, bit_rate);
1602 player_get_video_stream_info(g_player[0], &fps, &v_bit_rate);
1603 g_print(" ==> [Player_Test] fps: [%d ] , Bit Rate: [%d ] \n", fps, v_bit_rate);
1605 char *audio_codec = NULL;
1606 char *video_codec = NULL;
1607 player_get_codec_info(g_player[0], &audio_codec, &video_codec);
1608 if (audio_codec != NULL) {
1609 g_print(" ==> [Player_Test] Audio Codec: [%s ] \n", audio_codec);
1613 if (video_codec != NULL) {
1614 g_print(" ==> [Player_Test] Video Codec: [%s ] \n", video_codec);
1618 player_get_video_size(g_player[0], &w, &h);
1619 g_print(" ==> [Player_Test] Width: [%d ] , Height: [%d ] \n", w, h);
1622 static void set_gapless(bool gapless)
1625 g_print("not support at TV profile");
1629 if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
1630 if (player_set_gapless(g_player[0], gapless) != PLAYER_ERROR_NONE)
1631 g_print("failed set_gapless\n");
1634 for (i = 0; i < g_handle_num; i++) {
1635 if (player_set_gapless(g_player[i], gapless) != PLAYER_ERROR_NONE)
1636 g_print("failed to set_gapless\n");
1641 static void set_looping(bool looping)
1643 if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
1644 if (player_set_looping(g_player[0], looping) != PLAYER_ERROR_NONE)
1645 g_print("failed to set_looping\n");
1648 for (i = 0; i < g_handle_num; i++) {
1649 if (player_set_looping(g_player[i], looping) != PLAYER_ERROR_NONE)
1650 g_print("failed to set_looping\n");
1655 static void get_looping(bool * looping)
1657 player_is_looping(g_player[0], looping);
1658 g_print(" ==> [Player_Test] looping = %d\n", *looping);
1661 static void change_surface(int option)
1663 player_display_type_e surface_type = 0;
1664 int ret = PLAYER_ERROR_NONE;
1665 #ifdef _ACTIVATE_EOM_
1667 eom_output_mode_e output_mode;
1672 surface_type = PLAYER_DISPLAY_TYPE_OVERLAY;
1673 g_print("change surface type to X\n");
1675 #ifdef TIZEN_FEATURE_EVAS_RENDERER
1678 surface_type = PLAYER_DISPLAY_TYPE_EVAS;
1679 g_print("change surface type to EVAS\n");
1683 g_print("change surface type to NONE\n");
1684 surface_type = g_current_surface_type = PLAYER_DISPLAY_TYPE_NONE;
1685 player_set_display(g_player[0], PLAYER_DISPLAY_TYPE_NONE, NULL);
1688 g_print("invalid surface type\n");
1692 if (surface_type == g_current_surface_type) {
1693 g_print("same with the previous surface type(%d)\n", g_current_surface_type);
1696 player_state_e player_state = PLAYER_STATE_NONE;
1697 ret = player_get_state(g_player[0], &player_state);
1699 g_print("failed to player_get_state(), ret(0x%x)\n", ret);
1703 if (surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
1704 #ifdef _ACTIVATE_EOM_
1705 hdmi_output_id = eom_get_output_id("HDMI");
1706 if (hdmi_output_id == 0)
1707 g_print("[eom] error : HDMI output id is NULL.\n");
1709 eom_get_output_mode(hdmi_output_id, &output_mode);
1710 if (output_mode == EOM_OUTPUT_MODE_NONE) {
1713 g_win_id = create_win(PACKAGE);
1714 if (g_win_id == NULL)
1716 g_print("create win_id %p\n", g_win_id);
1717 create_render_rect_and_bg(g_win_id);
1718 elm_win_activate(g_win_id);
1719 evas_object_show(g_win_id);
1720 g_win_id = selected_win_id;
1722 #ifdef _ACTIVATE_EOM_
1727 ret = player_set_display(g_player[0], surface_type, GET_DISPLAY(selected_win_id));
1730 g_win_id = create_win(PACKAGE);
1731 if (g_win_id == NULL)
1733 g_print("create win_id %p\n", g_win_id);
1734 create_render_rect_and_bg(g_win_id);
1735 elm_win_activate(g_win_id);
1736 evas_object_show(g_win_id);
1739 for (i = 0; i < g_handle_num; i++) {
1740 /* Create evas image object for EVAS surface */
1742 g_eo[i] = create_image_object(g_win_id);
1743 g_print("create eo[%d] %p\n", i, g_eo[i]);
1744 evas_object_image_size_set(g_eo[i], 500, 500);
1745 evas_object_image_fill_set(g_eo[i], 0, 0, 500, 500);
1746 evas_object_resize(g_eo[i], 500, 500);
1747 evas_object_move(g_eo[i], i * 20, i * 20);
1749 ret = player_set_display(g_player[i], surface_type, g_eo[i]);
1754 g_print("failed to set display, surface_type(%d)\n", surface_type);
1757 g_current_surface_type = surface_type;
1762 static void set_display_mode(int mode)
1764 if (player_set_display_mode(g_player[0], mode) != PLAYER_ERROR_NONE)
1765 g_print("failed to player_set_display_mode\n");
1768 static void get_display_mode()
1770 player_display_mode_e mode;
1771 player_get_display_mode(g_player[0], &mode);
1772 g_print(" ==> [Player_Test] Display mode: [%d ] \n", mode);
1775 static void set_display_roi_area(int x, int y, int width, int height)
1777 player_set_display_roi_area(g_player[0], x, y, width, height);
1778 g_print(" ==> [Player_Test] Display roi area: [x(%d) y(%d) width(%d) height(%d)] \n", x, y, width, height);
1781 static void set_display_rotation(int rotation)
1783 if (player_set_display_rotation(g_player[0], rotation) != PLAYER_ERROR_NONE)
1784 g_print("failed to set_display_rotation\n");
1785 #ifdef USE_EVENT_HANDLER
1786 event_handler_set_window_parameters();
1790 static void get_display_rotation()
1792 player_display_rotation_e rotation = 0;
1793 player_get_display_rotation(g_player[0], &rotation);
1794 g_print(" ==> [Player_Test] Video Overlay Display rotation: [%d ] \n", rotation);
1797 static void set_display_visible(bool visible)
1799 if (player_set_display_visible(g_player[0], visible) != PLAYER_ERROR_NONE)
1800 g_print("failed to player_set_x11_display_visible\n");
1803 static void get_display_visible(bool * visible)
1805 player_is_display_visible(g_player[0], visible);
1806 g_print(" ==> [Player_Test] Video Overlay Display Visible = %d\n", *visible);
1809 static void input_subtitle_filename(char *subtitle_filename)
1811 int len = strlen(subtitle_filename);
1813 if (len < 1 || len > MAX_STRING_LEN)
1816 strncpy(g_subtitle_uri, subtitle_filename, len);
1817 g_print("subtitle uri is set to %s\n", g_subtitle_uri);
1818 player_set_subtitle_path(g_player[0], g_subtitle_uri);
1821 static void switch_subtitle(int index)
1823 char *lang_code = NULL;
1824 if (player_select_track(g_player[0], PLAYER_STREAM_TYPE_TEXT, index) != PLAYER_ERROR_NONE)
1825 g_print("player_select_track failed\n");
1827 if (player_get_track_language_code(g_player[0], PLAYER_STREAM_TYPE_TEXT, index, &lang_code) == PLAYER_ERROR_NONE) {
1828 g_print("selected track code %s\n", lang_code);
1833 static void get_track_info(int index)
1835 int count = 0, cur_index = 0;
1837 char *lang_code = NULL;
1839 if (index != PLAYER_STREAM_TYPE_AUDIO &&
1840 index != PLAYER_STREAM_TYPE_TEXT) {
1841 g_print("invalid stream type %d", index);
1845 ret = player_get_track_count(g_player[0], index, &count);
1846 if (ret != PLAYER_ERROR_NONE)
1847 g_print("player_get_track_count fail!!!!\n");
1850 player_get_current_track(g_player[0], index, &cur_index);
1851 g_print("total track: %d, curr track: %d\n", count, cur_index);
1853 for (idx = 0; idx < count; idx++) {
1854 player_get_track_language_code(g_player[0], index, idx, &lang_code);
1855 g_print("track info = [%d] %s\n", idx, lang_code);
1858 g_print("no track\n");
1862 static void capture_video()
1864 if (player_capture_video(g_player[0], video_captured_cb, NULL) != PLAYER_ERROR_NONE)
1865 g_print("failed to player_capture_video\n");
1868 static void set_audio_only(int val)
1870 int ret = PLAYER_ERROR_NONE;
1871 bool audio_only = false;
1872 ret = player_is_audio_only(g_player[0], &audio_only);
1873 if (ret != PLAYER_ERROR_NONE)
1874 g_print("failed to get current setting. 0x%X\n", ret);
1876 g_print("current audio only mode : %s\n", (audio_only) ? "enabled" : "disabled");
1877 g_print("new audio only mode : %s\n", (val != 0) ? "enabled" : "disabled");
1880 ret = player_set_audio_only(g_player[0], true);
1882 ret = player_set_audio_only(g_player[0], false);
1883 g_print("finished 0x%X\n", ret);
1886 static void decoding_audio()
1890 char *suffix, *dump_path;
1891 GDateTime *time = g_date_time_new_now_local();
1893 suffix = g_date_time_format(time, "%Y%m%d_%H%M%S.pcm");
1894 dump_path = g_strjoin(NULL, PLAYER_TEST_DUMP_PATH_PREFIX, suffix, NULL);
1895 g_pcm_fd = fopen(dump_path, "w+");
1898 g_date_time_unref(time);
1900 g_print("Can not create debug dump file");
1902 ret = player_set_audio_frame_decoded_cb(g_player[0], 0, 0, audio_frame_decoded_cb, (void *)g_player[0]);
1903 if (ret != PLAYER_ERROR_NONE)
1904 g_print("player_set_audio_frame_decoded_cb is failed (errno = %d) \n", ret);
1908 static void set_audio_eq(int value)
1910 bool available = FALSE;
1911 int index, min = 0, max = 0;
1914 if (player_audio_effect_equalizer_is_available(g_player[0], &available) != PLAYER_ERROR_NONE)
1915 g_print("failed to player_audio_effect_equalizer_is_available\n");
1918 if ((player_audio_effect_get_equalizer_bands_count(g_player[0], &index) != PLAYER_ERROR_NONE) ||
1919 (player_audio_effect_get_equalizer_level_range(g_player[0], &min, &max) != PLAYER_ERROR_NONE) ||
1920 (player_audio_effect_set_equalizer_band_level(g_player[0], index / 2, max) != PLAYER_ERROR_NONE))
1921 g_print("failed to player_audio_effect_set_equalizer_band_level index %d, level %d\n", index / 2, max);
1926 if (player_audio_effect_equalizer_clear(g_player[0]) != PLAYER_ERROR_NONE)
1927 g_print("failed to player_audio_effect_equalizer_clear\n");
1932 static void get_audio_eq()
1934 int index, min, max, value;
1935 player_audio_effect_get_equalizer_bands_count(g_player[0], &index);
1936 g_print(" ==> [Player_Test] eq bands count: [%d] \n", index);
1937 player_audio_effect_get_equalizer_level_range(g_player[0], &min, &max);
1938 g_print(" ==> [Player_Test] eq bands range: [%d~%d] \n", min, max);
1939 player_audio_effect_get_equalizer_band_level(g_player[0], index / 2, &value);
1940 g_print(" ==> [Player_Test] eq bands level: [%d] \n", value);
1941 player_audio_effect_get_equalizer_band_frequency(g_player[0], 0, &value);
1942 g_print(" ==> [Player_Test] eq bands frequency: [%d] \n", value);
1943 player_audio_effect_get_equalizer_band_frequency_range(g_player[0], 0, &value);
1944 g_print(" ==> [Player_Test] eq bands frequency range: [%d] \n", value);
1947 static void video360_set_enable(bool enable)
1949 #ifdef USE_EVENT_HANDLER
1950 event_handler_set_dov_fov();
1953 if (player_360_set_enable(g_player[0], enable) != PLAYER_ERROR_NONE)
1954 g_print("failed to %s video 360 mode\n", enable ? "enable" : "disable");
1957 static void video360_get_enable()
1961 if (player_360_is_enabled(g_player[0], &enable) != PLAYER_ERROR_NONE)
1962 g_print("failed to get video 360 mode status\n");
1964 g_print(" ==> [Player_Test] Video 360 mode = %s\n", enable ? "enabled" : "disabled");
1967 static void video360_set_fov(int hfov, int vfov)
1969 #ifdef USE_EVENT_HANDLER
1970 mm_navevent_handler_size_s fov;
1974 mm_navevent_handler_set_fov_size(event_handler, fov);
1976 if (player_360_set_field_of_view(g_player[0], hfov, vfov) != PLAYER_ERROR_NONE)
1977 g_print("failed to set video 360 field of view\n");
1980 static void video360_get_fov()
1984 if (player_360_get_field_of_view(g_player[0], &hfov, &vfov) != PLAYER_ERROR_NONE)
1985 g_print("failed to get video 360 field of view\n");
1987 g_print(" ==> [Player_Test] Video 360 FOV = %dx%d deg.\n", hfov, vfov);
1990 static void video360_set_dov(int yaw_deg, int pitch_deg)
1994 angles[0] = M_PI * yaw_deg / 180.0f;
1995 angles[1] = M_PI * pitch_deg / 180.0f;
1998 #ifdef USE_EVENT_HANDLER
1999 mm_navevent_handler_set_angles(event_handler, angles);
2001 if (player_360_set_direction_of_view(g_player[0], angles[0], angles[1]) != PLAYER_ERROR_NONE)
2002 g_print("failed to set video 360 direction of view\n");
2005 static void video360_get_dov()
2009 if (player_360_get_direction_of_view(g_player[0], &yaw, &pitch) != PLAYER_ERROR_NONE)
2010 g_print("failed to get video 360 direction of view\n");
2012 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));
2015 static void video360_set_zoom(float zoom)
2017 if (player_360_set_zoom(g_player[0], zoom) != PLAYER_ERROR_NONE)
2018 g_print("failed to set video 360 zoom\n");
2021 static void video360_get_zoom()
2025 if (player_360_get_zoom(g_player[0], &zoom) != PLAYER_ERROR_NONE)
2026 g_print("failed to get video 360 zoom\n");
2028 g_print(" ==> [Player_Test] Video 360 zoom = %f\n", zoom);
2031 #ifdef USE_EVENT_HANDLER
2032 static void event_handler_cb(enum libinput_event_type ev_t, int x, int y, void * data, float e[3])
2034 if (ev_t == LIBINPUT_EVENT_TOUCH_MOTION)
2035 if (player_360_set_direction_of_view(g_player[0], e[0], e[1]) != PLAYER_ERROR_NONE)
2036 g_print("Event handler callback: failed to set direction of view\n");
2039 static void event_handler_set_dov_fov()
2042 mm_navevent_handler_size_s fov;
2044 if (player_360_get_direction_of_view(g_player[0], &angles[0], &angles[1]) != PLAYER_ERROR_NONE) {
2045 g_print("Failed to get video360 direction of view\n");
2048 if (player_360_get_field_of_view(g_player[0], &fov.width, &fov.height) != PLAYER_ERROR_NONE) {
2049 g_print("Failed to get video360 field of view\n");
2052 mm_navevent_handler_set_angles(event_handler, angles);
2053 mm_navevent_handler_set_fov_size(event_handler, fov);
2056 static void event_handler_set_window_parameters()
2058 player_display_rotation_e window_orientation;
2059 mm_navevent_handler_size_s window_size;
2062 player_get_display_rotation(g_player[0], &window_orientation);
2063 elm_win_screen_size_get(selected_win_id, NULL, NULL, &window_size.width, &window_size.height);
2065 image_ratio = (float) image_size.width / (float) image_size.height;
2067 if (window_orientation == PLAYER_DISPLAY_ROTATION_NONE ||
2068 window_orientation == PLAYER_DISPLAY_ROTATION_180) {
2069 window_size.height = (int)((float) window_size.width / image_ratio);
2071 window_size.height = window_size.width;
2072 window_size.width = (int)((float) window_size.width * image_ratio);
2075 mm_navevent_handler_set_window_parameters(event_handler,
2076 (mm_navevent_handler_orientation_e) window_orientation, window_size);
2086 if (g_player[0] != NULL || g_player[1] != NULL) {
2087 _player_unprepare();
2094 media_format_unref(g_audio_fmt);
2097 media_format_unref(g_video_fmt);
2100 void play_with_ini(char *file_path)
2102 input_filename(file_path);
2106 void _interpret_main_menu(char *cmd)
2108 int len = strlen(cmd);
2110 if (strncmp(cmd, "a", 1) == 0) {
2111 g_menu_state = CURRENT_STATUS_FILENAME;
2112 } else if (strncmp(cmd, "b", 1) == 0) {
2114 } else if (strncmp(cmd, "c", 1) == 0) {
2116 } else if (strncmp(cmd, "d", 1) == 0) {
2118 } else if (strncmp(cmd, "e", 1) == 0) {
2120 } else if (strncmp(cmd, "S", 1) == 0) {
2122 } else if (strncmp(cmd, "f", 1) == 0) {
2123 g_menu_state = CURRENT_STATUS_VOLUME;
2124 } else if (strncmp(cmd, "g", 1) == 0) {
2127 get_volume(&left, &right);
2128 } else if (strncmp(cmd, "z", 1) == 0) {
2129 g_menu_state = CURRENT_STATUS_SOUND_TYPE;
2130 } else if (strncmp(cmd, "k", 1) == 0) {
2131 g_menu_state = CURRENT_STATUS_SOUND_STREAM_INFO;
2132 } else if (strncmp(cmd, "h", 1) == 0) {
2133 g_menu_state = CURRENT_STATUS_MUTE;
2134 } else if (strncmp(cmd, "i", 1) == 0) {
2137 } else if (strncmp(cmd, "j", 1) == 0) {
2138 g_menu_state = CURRENT_STATUS_POSITION_TIME;
2139 } else if (strncmp(cmd, "l", 1) == 0) {
2141 } else if (strncmp(cmd, "m", 1) == 0) {
2143 } else if (strncmp(cmd, "n", 1) == 0) {
2145 } else if (strncmp(cmd, "o", 1) == 0) {
2146 g_menu_state = CURRENT_STATUS_LOOPING;
2147 } else if (strncmp(cmd, "p", 1) == 0) {
2149 get_looping(&looping);
2150 } else if (strncmp(cmd, "r", 1) == 0) {
2151 g_menu_state = CURRENT_STATUS_DISPLAY_MODE;
2152 } else if (strncmp(cmd, "s", 1) == 0) {
2154 } else if (strncmp(cmd, "t", 1) == 0) {
2155 g_menu_state = CURRENT_STATUS_DISPLAY_ROTATION;
2156 } else if (strncmp(cmd, "u", 1) == 0) {
2157 get_display_rotation();
2158 } else if (strncmp(cmd, "v", 1) == 0) {
2159 g_menu_state = CURRENT_STATUS_DISPLAY_VISIBLE;
2160 } else if (strncmp(cmd, "w", 1) == 0) {
2162 get_display_visible(&visible);
2163 } else if (strncmp(cmd, "A", 1) == 0) {
2164 g_menu_state = CURRENT_STATUS_SUBTITLE_FILENAME;
2165 } else if (strncmp(cmd, "C", 1) == 0) {
2167 } else if (strncmp(cmd, "D", 1) == 0) {
2169 } else if (strncmp(cmd, "q", 1) == 0) {
2170 quit_pushing = TRUE;
2172 } else if (strncmp(cmd, "E", 1) == 0) {
2173 g_menu_state = CURRENT_STATUS_AUDIO_EQUALIZER;
2174 } else if (strncmp(cmd, "H", 1) == 0) {
2177 g_print("unknown menu \n");
2179 } else if (len == 2) {
2180 if (strncmp(cmd, "pr", 2) == 0) {
2182 if (g_current_surface_type == -1) {
2183 g_print("You must set display surface type before setting prepare. please 'pr' after setting display surface type.\n");
2184 g_menu_state = CURRENT_STATUS_DISPLAY_SURFACE_CHANGE;
2186 _player_prepare(FALSE);
2187 } else if (strncmp(cmd, "pa", 2) == 0) {
2189 if (g_current_surface_type == -1) {
2190 g_print("You must set display surface type before setting prepare. please 'pr' after setting display surface type.\n");
2191 g_menu_state = CURRENT_STATUS_DISPLAY_SURFACE_CHANGE;
2193 _player_prepare(TRUE);
2194 } else if (strncmp(cmd, "un", 2) == 0) {
2195 _player_unprepare();
2196 } else if (strncmp(cmd, "dt", 2) == 0) {
2198 } else if (strncmp(cmd, "sp", 2) == 0) {
2199 _player_set_progressive_download();
2200 } else if (strncmp(cmd, "gp", 2) == 0) {
2201 _player_get_progressive_download_status();
2202 } else if (strncmp(cmd, "mp", 2) == 0) {
2203 g_memory_playback = (g_memory_playback ? FALSE : TRUE);
2204 g_print("memory playback = %d\n", g_memory_playback);
2205 } else if (strncmp(cmd, "ds", 2) == 0) {
2206 g_menu_state = CURRENT_STATUS_DISPLAY_SURFACE_CHANGE;
2207 } else if (strncmp(cmd, "dr", 2) == 0) {
2208 g_print("now, PLAYER_DISPLAY_MODE_DST_ROI(display mode) is set\n");
2209 g_menu_state = CURRENT_STATUS_DISPLAY_DST_ROI;
2210 } else if (strncmp(cmd, "nb", 2) == 0) {
2211 g_menu_state = CURRENT_STATUS_HANDLE_NUM;
2212 } else if (strncmp(cmd, "tr", 2) == 0) {
2213 g_menu_state = CURRENT_STATUS_PLAYBACK_RATE;
2214 } else if (strncmp(cmd, "ss", 2) == 0) {
2215 g_menu_state = CURRENT_STATUS_SWITCH_SUBTITLE;
2216 } else if (strncmp(cmd, "X3", 2) == 0) {
2217 audio_frame_decoded_cb_ex(TRUE);
2218 } else if (strncmp(cmd, "X4", 2) == 0) {
2219 audio_frame_decoded_cb_ex(FALSE);
2220 } else if (strncmp(cmd, "ep", 2) == 0) {
2221 _player_enable_tsurf_pool();
2222 } else if (strncmp(cmd, "su", 2) == 0) {
2223 g_menu_state = CURRENT_STATUS_NEXT_URI;
2224 } else if (strncmp(cmd, "gu", 2) == 0) {
2226 } else if (strncmp(cmd, "sg", 2) == 0) {
2227 g_menu_state = CURRENT_STATUS_GAPLESS;
2228 } else if (strncmp(cmd, "tl", 2) == 0) {
2229 g_menu_state = CURRENT_STATUS_GET_TRACK_INFO;
2230 } else if (strncmp(cmd, "vi", 2) == 0) {
2232 } else if (strncmp(cmd, "vs", 2) == 0) {
2233 g_menu_state = CURRENT_STATUS_SET_MAX_BANDWIDTH_VARIANT;
2234 } else if (strncmp(cmd, "vg", 2) == 0) {
2235 get_variant_limit();
2236 } else if (strncmp(cmd, "ao", 2) == 0) {
2237 g_menu_state = CURRENT_STATUS_SET_AUDIO_ONLY;
2238 } else if (strncmp(cmd, "bf", 2) == 0) {
2239 g_menu_state = CURRENT_STATUS_SET_PRE_BUFFERING_SIZE;
2240 } else if (strncmp(cmd, "C1", 2) == 0) {
2241 g_menu_state = CURRENT_STATUS_VIDEO_CODEC_TYPE;
2242 } else if (strncmp(cmd, "C2", 2) == 0) {
2245 g_print("unknown menu \n");
2247 } else if (len == 3) {
2248 if (strncmp(cmd, "trs", 3) == 0)
2249 g_menu_state = CURRENT_STATUS_STREAMING_PLAYBACK_RATE;
2251 g_print("unknown menu \n");
2252 } else if (len == 4) {
2253 if (!strncmp(cmd, "v3se", 4))
2254 g_menu_state = CURRENT_STATUS_VIDEO360_SET_ENABLE;
2255 else if (!strncmp(cmd, "v3ge", 4))
2256 video360_get_enable();
2257 else if (!strncmp(cmd, "v3sd", 4))
2258 g_menu_state = CURRENT_STATUS_VIDEO360_SET_DOV;
2259 else if (!strncmp(cmd, "v3gd", 4))
2261 else if (!strncmp(cmd, "v3sf", 4))
2262 g_menu_state = CURRENT_STATUS_VIDEO360_SET_FOV;
2263 else if (!strncmp(cmd, "v3gf", 4))
2265 else if (!strncmp(cmd, "v3sz", 4))
2266 g_menu_state = CURRENT_STATUS_VIDEO360_SET_ZOOM;
2267 else if (!strncmp(cmd, "v3gz", 4))
2268 video360_get_zoom();
2270 g_print("unknown menu \n");
2272 g_print("unknown menu \n");
2275 void display_sub_basic()
2278 g_print("=========================================================================================\n");
2279 g_print(" Player Test (press q to quit) \n");
2280 g_print("-----------------------------------------------------------------------------------------\n");
2281 g_print("[playback] a. Create\t");
2282 g_print("pr. Prepare \t");
2283 g_print("pa. Prepare async \t");
2284 g_print("b. Play \t");
2285 g_print("c. Stop \t");
2286 g_print("d. Resume\t");
2287 g_print("e. Pause \t");
2288 g_print("un. Unprepare \t");
2289 g_print("dt. Destroy \n");
2290 g_print("[State] S. Player State \n");
2291 g_print("[ volume ] f. Set Volume\t");
2292 g_print("g. Get Volume\t");
2293 g_print("z. Set Sound type\t");
2294 g_print("k. Set Sound Stream Info.\n");
2295 g_print("[ mute ] h. Set Mute\t");
2296 g_print("i. Get Mute\n");
2297 g_print("[audio eq] E. Set Audio EQ\t");
2298 g_print("H. Get Audio EQ\n");
2299 g_print("[position] j. Set Position \t");
2300 g_print("l. Get Position\n");
2301 g_print("[trick] tr. set playback rate\n");
2302 g_print("[duration] m. Get Duration\n");
2303 g_print("[Stream Info] n. Get stream info (Video Size, codec, audio stream info, and tag info)\n");
2304 g_print("[Looping] o. Set Looping\t");
2305 g_print("p. Get Looping\n");
2306 g_print("[display] v. Set display visible\t");
2307 g_print("w. Get display visible\n");
2308 g_print("[display] ds. Change display surface type\n");
2309 g_print("[display] dr. set display roi area\n");
2310 g_print("[overlay display] r. Set display mode\t");
2311 g_print("s. Get display mode\n");
2312 g_print("[overlay display] t. Set display Rotation\n");
2313 g_print("[Track] tl. Get Track language info(single only)\n");
2314 g_print("[Variant] vi. Get Streaming Variant Info\t");
2315 g_print("vs. Set max limit of variant\t");
2316 g_print("vg. Get max limit of variant\n");
2317 g_print("[audio only] ao. set audio only\n");
2318 g_print("[subtitle] A. Set(or change) subtitle path\n");
2319 g_print("[subtitle] ss. Select(or change) subtitle track\n");
2320 g_print("[Video Capture] C. Capture \n");
2321 g_print("[Video Codec] C1. Set vcodec type (1:HW, 2:SW)\t");
2322 g_print("C2. Get vcodec type\n");
2323 g_print("[next uri] su. set next uri. \t");
2324 g_print("gu. get next uri. \t");
2325 g_print("sg. set gapless. \n");
2326 g_print("[audio_frame_decoded_cb_ex] X3. set audio_cb with sync\t");
2327 g_print("X4. set audio_cb with async \n");
2328 g_print("[video_frame_decoded_cb] ep. enable tbm surface pool\n");
2329 g_print("[buffering] bf. set new buffering size\n");
2330 g_print("[Video 360] v3se. Set Enable\t\t");
2331 g_print("v3ge. Get Enable\n");
2332 g_print("[Video 360] v3sd. Set Direction Of View\t");
2333 g_print("v3gd. Get Direction Of View\n");
2334 g_print("[Video 360] v3sf. Set Field Of View\t");
2335 g_print("v3gf. Get Field Of View\n");
2336 g_print("[Video 360] v3sz. Set Zoom\t\t");
2337 g_print("v3gz. Get Zoom\n");
2338 g_print("[etc] sp. Set Progressive Download\t");
2339 g_print("gp. Get Progressive Download status\t");
2340 g_print("mp. memory playback\n");
2342 g_print("=========================================================================================\n");
2345 static void displaymenu()
2347 if (g_menu_state == CURRENT_STATUS_MAINMENU) {
2348 display_sub_basic();
2349 } else if (g_menu_state == CURRENT_STATUS_HANDLE_NUM) {
2350 g_print("*** input number of handles.(recommended only for EVAS surface)\n");
2351 } else if (g_menu_state == CURRENT_STATUS_FILENAME) {
2352 g_print("*** input mediapath.\n");
2353 } else if (g_menu_state == CURRENT_STATUS_VOLUME) {
2354 g_print("*** input volume value.(0~1.0)\n");
2355 } else if (g_menu_state == CURRENT_STATUS_SOUND_TYPE) {
2356 g_print("*** input sound type.(0:SYSTEM 1:NOTIFICATION 2:ALARM 3:RINGTONE 4:MEDIA 5:CALL 6:VOIP 7:FIXED)\n");
2357 } else if (g_menu_state == CURRENT_STATUS_SOUND_STREAM_INFO) {
2358 g_print("*** input sound stream type.(0:MEDIA 1:SYSTEM 2:ALARM 3:NOTIFICATION 4:EMERGENCY 5:VOICE_INFORMATION 9:MEDIA_EXT_ONLY)\n");
2359 } else if (g_menu_state == CURRENT_STATUS_MUTE) {
2360 g_print("*** input mute value.(0: Not Mute, 1: Mute) \n");
2361 } else if (g_menu_state == CURRENT_STATUS_POSITION_TIME) {
2362 g_print("*** input position value(msec)\n");
2363 } else if (g_menu_state == CURRENT_STATUS_POSITION_ACCURATE) {
2364 g_print("*** input accurate value(0/1)\n");
2365 } else if (g_menu_state == CURRENT_STATUS_LOOPING) {
2366 g_print("*** input looping value.(0: Not Looping, 1: Looping) \n");
2367 } else if (g_menu_state == CURRENT_STATUS_DISPLAY_SURFACE_CHANGE) {
2368 g_print("*** input display surface type.(0: Wayland surface, 1: EVAS surface, 2: No use surface (e.g: audio playback)) \n");
2369 } else if (g_menu_state == CURRENT_STATUS_DISPLAY_MODE) {
2370 g_print("*** input display mode value.(0: LETTER BOX, 1: ORIGIN SIZE, 2: FULL_SCREEN, 3: CROPPED_FULL, 4: ORIGIN_OR_LETTER) \n");
2371 } else if (g_menu_state == CURRENT_STATUS_DISPLAY_DST_ROI) {
2372 g_print("*** input display roi value sequentially.(x, y, w, h)\n");
2373 } else if (g_menu_state == CURRENT_STATUS_DISPLAY_ROTATION) {
2374 g_print("*** input display rotation value.(0: NONE, 1: 90, 2: 180, 3: 270, 4:F LIP_HORZ, 5: FLIP_VERT ) \n");
2375 } else if (g_menu_state == CURRENT_STATUS_DISPLAY_VISIBLE) {
2376 g_print("*** input display visible value.(0: HIDE, 1: SHOW) \n");
2377 } else if (g_menu_state == CURRENT_STATUS_SUBTITLE_FILENAME) {
2378 g_print(" *** input subtitle file path.\n");
2379 } else if (g_menu_state == CURRENT_STATUS_AUDIO_EQUALIZER) {
2380 g_print(" *** input audio eq value.(0: UNSET, 1: SET) \n");
2381 } else if (g_menu_state == CURRENT_STATUS_PLAYBACK_RATE || g_menu_state == CURRENT_STATUS_STREAMING_PLAYBACK_RATE) {
2382 g_print(" *** input playback rate.(-5.0 ~ 5.0)\n");
2383 } else if (g_menu_state == CURRENT_STATUS_SWITCH_SUBTITLE) {
2384 int count = 0, cur_index = 0;
2387 ret = player_get_track_count(g_player[0], PLAYER_STREAM_TYPE_TEXT, &count);
2388 if (ret != PLAYER_ERROR_NONE)
2389 g_print("player_get_track_count fail!!!!\n");
2391 g_print("Total subtitle tracks = %d \n", count);
2392 player_get_current_track(g_player[0], PLAYER_STREAM_TYPE_TEXT, &cur_index);
2393 g_print("Current index = %d \n", cur_index);
2394 g_print(" *** input correct index 0 to %d\n:", (count - 1));
2396 g_print("no track\n");
2397 } else if (g_menu_state == CURRENT_STATUS_NEXT_URI) {
2398 g_print("*** input next uri.\n");
2399 } else if (g_menu_state == CURRENT_STATUS_GAPLESS) {
2400 g_print("*** input gapless value.(0:disable, 1: enable) \n");
2401 } else if (g_menu_state == CURRENT_STATUS_GET_TRACK_INFO) {
2402 g_print("*** input stream type.(1:audio, 3:text) \n");
2403 } else if (g_menu_state == CURRENT_STATUS_SET_MAX_BANDWIDTH_VARIANT) {
2404 g_print("*** set max bandwidth (default: -1) \n");
2405 } else if (g_menu_state == CURRENT_STATUS_SET_MAX_WIDTH_VARIANT) {
2406 g_print("*** set max width (default: -1) \n");
2407 } else if (g_menu_state == CURRENT_STATUS_SET_MAX_HEIGHT_VARIANT) {
2408 g_print("*** set max height (default: -1) \n");
2409 } else if (g_menu_state == CURRENT_STATUS_SET_AUDIO_ONLY) {
2410 g_print("*** set audio only mode (0:disable, 1:enable) \n");
2411 } else if (g_menu_state == CURRENT_STATUS_SET_PRE_BUFFERING_SIZE) {
2412 g_print("*** set pre buffering size (ms) \n");
2413 } else if (g_menu_state == CURRENT_STATUS_SET_RE_BUFFERING_SIZE) {
2414 g_print("*** set re buffering size (ms) \n");
2415 } else if (g_menu_state == CURRENT_STATUS_VIDEO360_SET_ENABLE) {
2416 g_print("*** input video 360 status (0: disabled (full panorama), 1: enabled)\n");
2417 } else if (g_menu_state == CURRENT_STATUS_VIDEO360_SET_DOV) {
2418 g_print("*** input direction of view yaw angle (+/- 180 deg.)\n");
2419 } else if (g_menu_state == CURRENT_STATUS_VIDEO360_SET_DOV1) {
2420 g_print("*** input direction of view pitch angle (+/- 90 deg.)\n");
2421 } else if (g_menu_state == CURRENT_STATUS_VIDEO360_SET_FOV) {
2422 g_print("*** input horizontal field of view angle (1~360 deg.)\n");
2423 } else if (g_menu_state == CURRENT_STATUS_VIDEO360_SET_FOV1) {
2424 g_print("*** input vertical field of view angle (1~180 deg.)\n");
2425 } else if (g_menu_state == CURRENT_STATUS_VIDEO360_SET_ZOOM) {
2426 g_print("*** input zoom factor.(1.0~10.0, where 1.0 - no zoom, actual image) \n");
2427 } else if (g_menu_state == CURRENT_STATUS_VIDEO_CODEC_TYPE) {
2428 g_print("*** set video codec type (1: HW, 2: SW) \n");
2429 } else if (g_menu_state == CURRENT_STATUS_AUDIO_CODEC_TYPE) {
2430 g_print("*** set audio codec type (1: HW, 2: SW) \n");
2432 g_print("*** unknown status.\n");
2438 gboolean timeout_menu_display(void *data)
2444 gboolean timeout_quit_program(void *data)
2450 void reset_menu_state(void)
2452 g_menu_state = CURRENT_STATUS_MAINMENU;
2455 static void interpret(char *cmd)
2457 static int value1, value2;
2459 switch (g_menu_state) {
2460 case CURRENT_STATUS_MAINMENU:
2462 _interpret_main_menu(cmd);
2465 case CURRENT_STATUS_HANDLE_NUM:
2467 int num_handle = atoi(cmd);
2468 if (0 >= num_handle || num_handle > MAX_HANDLE)
2469 g_print("not supported this number for handles(%d)\n", num_handle);
2471 g_handle_num = num_handle;
2476 case CURRENT_STATUS_FILENAME:
2478 input_filename(cmd);
2482 case CURRENT_STATUS_VOLUME:
2484 float level = atof(cmd);
2489 case CURRENT_STATUS_SOUND_TYPE:
2491 int type = atoi(cmd);
2492 set_sound_type(type);
2496 case CURRENT_STATUS_SOUND_STREAM_INFO:
2498 int type = atoi(cmd);
2499 set_sound_stream_info(type);
2503 case CURRENT_STATUS_MUTE:
2505 int mute = atoi(cmd);
2510 case CURRENT_STATUS_POSITION_TIME:
2512 seek_info.pos = atoi(cmd);
2513 g_menu_state = CURRENT_STATUS_POSITION_ACCURATE;
2516 case CURRENT_STATUS_POSITION_ACCURATE:
2518 seek_info.accurate = (atoi(cmd) != 0) ? (true) : (false);
2519 set_position(seek_info.pos, seek_info.accurate);
2523 case CURRENT_STATUS_LOOPING:
2525 int looping = atoi(cmd);
2526 set_looping(looping);
2530 case CURRENT_STATUS_GAPLESS:
2532 int gapless = atoi(cmd);
2533 set_gapless(gapless);
2537 case CURRENT_STATUS_DISPLAY_SURFACE_CHANGE:
2539 int type = atoi(cmd);
2540 change_surface(type);
2544 case CURRENT_STATUS_DISPLAY_MODE:
2546 int mode = atoi(cmd);
2547 set_display_mode(mode);
2551 case CURRENT_STATUS_DISPLAY_DST_ROI:
2553 int value = atoi(cmd);
2560 set_display_mode(PLAYER_DISPLAY_MODE_DST_ROI);
2577 set_display_roi_area(x, y, w, h);
2586 case CURRENT_STATUS_DISPLAY_ROTATION:
2588 int rotation = atoi(cmd);
2589 set_display_rotation(rotation);
2593 case CURRENT_STATUS_DISPLAY_VISIBLE:
2595 int visible = atoi(cmd);
2596 set_display_visible(visible);
2600 case CURRENT_STATUS_SUBTITLE_FILENAME:
2602 input_subtitle_filename(cmd);
2606 case CURRENT_STATUS_AUDIO_EQUALIZER:
2608 int value = atoi(cmd);
2609 set_audio_eq(value);
2613 case CURRENT_STATUS_PLAYBACK_RATE:
2615 float rate = atof(cmd);
2616 set_playback_rate(rate, FALSE);
2620 case CURRENT_STATUS_STREAMING_PLAYBACK_RATE:
2622 float rate = atof(cmd);
2623 set_playback_rate(rate, TRUE);
2627 case CURRENT_STATUS_SWITCH_SUBTITLE:
2629 int index = atoi(cmd);
2630 switch_subtitle(index);
2634 case CURRENT_STATUS_NEXT_URI:
2640 case CURRENT_STATUS_GET_TRACK_INFO:
2642 int index = atoi(cmd);
2643 get_track_info(index);
2647 case CURRENT_STATUS_SET_MAX_BANDWIDTH_VARIANT:
2649 int value = atoi(cmd);
2650 max_limit.bandwidth = value;
2651 g_menu_state = CURRENT_STATUS_SET_MAX_WIDTH_VARIANT;
2654 case CURRENT_STATUS_SET_MAX_WIDTH_VARIANT:
2656 int value = atoi(cmd);
2657 max_limit.width = value;
2658 g_menu_state = CURRENT_STATUS_SET_MAX_HEIGHT_VARIANT;
2661 case CURRENT_STATUS_SET_MAX_HEIGHT_VARIANT:
2663 int value = atoi(cmd);
2664 max_limit.height = value;
2665 set_variant_limit();
2669 case CURRENT_STATUS_SET_AUDIO_ONLY:
2671 int value = atoi(cmd);
2672 set_audio_only(value);
2676 case CURRENT_STATUS_SET_PRE_BUFFERING_SIZE:
2678 int value = atoi(cmd);
2679 buff_size.buffer_ms = value;
2680 g_menu_state = CURRENT_STATUS_SET_RE_BUFFERING_SIZE;
2683 case CURRENT_STATUS_SET_RE_BUFFERING_SIZE:
2685 int value = atoi(cmd);
2686 buff_size.rebuffer_ms = value;
2691 case CURRENT_STATUS_VIDEO360_SET_ENABLE:
2693 int enable = atoi(cmd);
2694 video360_set_enable(enable);
2698 case CURRENT_STATUS_VIDEO360_SET_DOV:
2701 g_menu_state = CURRENT_STATUS_VIDEO360_SET_DOV1;
2704 case CURRENT_STATUS_VIDEO360_SET_DOV1:
2707 video360_set_dov(value1, value2);
2711 case CURRENT_STATUS_VIDEO360_SET_FOV:
2714 g_menu_state = CURRENT_STATUS_VIDEO360_SET_FOV1;
2717 case CURRENT_STATUS_VIDEO360_SET_FOV1:
2720 video360_set_fov(value1, value2);
2724 case CURRENT_STATUS_VIDEO360_SET_ZOOM:
2726 float zoom = atof(cmd);
2727 video360_set_zoom(zoom);
2731 case CURRENT_STATUS_VIDEO_CODEC_TYPE:
2733 int value = atoi(cmd);
2734 codec_type.v_codec_type = value;
2735 g_menu_state = CURRENT_STATUS_AUDIO_CODEC_TYPE;
2739 case CURRENT_STATUS_AUDIO_CODEC_TYPE:
2741 int value = atoi(cmd);
2742 codec_type.a_codec_type = value;
2749 g_timeout_add(100, timeout_menu_display, 0);
2752 gboolean input(GIOChannel * channel)
2754 gchar buf[MAX_STRING_LEN];
2756 GError *error = NULL;
2758 g_io_channel_read_chars(channel, buf, MAX_STRING_LEN, &read, &error);
2766 int main(int argc, char *argv[])
2768 GIOChannel *stdin_channel;
2769 stdin_channel = g_io_channel_unix_new(0);
2770 g_io_channel_set_flags(stdin_channel, G_IO_FLAG_NONBLOCK, NULL);
2771 g_io_add_watch(stdin_channel, G_IO_IN, (GIOFunc) input, NULL);
2774 memset(&ad, 0x0, sizeof(appdata));
2777 return appcore_efl_main(PACKAGE, &argc, &argv, &ops);