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,
182 #define MAX_HANDLE 20
184 /* for video display */
185 static Evas_Object *g_win_id;
186 #ifdef _ACTIVATE_EOM_
187 static Evas_Object *g_external_win_id;
189 static Evas_Object *selected_win_id;
190 static Evas_Object *g_eo[MAX_HANDLE] = { 0, };
192 static int g_current_surface_type = -1;
193 static adaptive_variant_info_t max_limit = {-1, -1, -1};
194 static buffer_size_t buff_size = {-1, -1};
198 Evas_Object *layout_main; /* layout widget based on EDJ */
199 /* add more variables here */
200 #ifdef _ACTIVATE_EOM_
206 static player_h g_player[MAX_HANDLE] = { 0, };
207 static player_seek_pos_t seek_info = {0};
208 int g_handle_num = 1;
209 int g_menu_state = CURRENT_STATUS_MAINMENU;
210 gboolean quit_pushing;
211 sound_stream_info_h g_stream_info_h = NULL;
213 static void win_del(void *data, Evas_Object * obj, void *event)
218 static Evas_Object *create_win(const char *name)
220 Evas_Object *eo = NULL;
224 g_print("[%s][%d] name=%s\n", __func__, __LINE__, name);
226 eo = elm_win_add(NULL, name, ELM_WIN_BASIC);
228 elm_win_title_set(eo, name);
229 elm_win_borderless_set(eo, EINA_TRUE);
230 evas_object_smart_callback_add(eo, "delete,request", win_del, NULL);
231 elm_win_screen_size_get(eo, NULL, NULL, &w, &h);
232 g_print("window size :%d,%d", w, h);
233 evas_object_resize(eo, w, h);
234 elm_win_autodel_set(eo, EINA_TRUE);
235 elm_win_alpha_set(eo, EINA_TRUE);
240 static Evas_Object *create_image_object(Evas_Object * eo_parent)
245 Evas *evas = evas_object_evas_get(eo_parent);
246 Evas_Object *eo = NULL;
248 eo = evas_object_image_add(evas);
253 void create_render_rect_and_bg(Evas_Object * win)
259 Evas_Object *bg, *rect;
261 bg = elm_bg_add(win);
262 elm_win_resize_object_add(win, bg);
263 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
264 evas_object_show(bg);
266 rect = evas_object_rectangle_add(evas_object_evas_get(win));
271 evas_object_color_set(rect, 0, 0, 0, 0);
272 evas_object_render_op_set(rect, EVAS_RENDER_COPY);
274 elm_win_resize_object_add(win, rect);
275 evas_object_size_hint_weight_set(rect, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
276 evas_object_show(rect);
277 evas_object_show(win);
280 #ifdef _ACTIVATE_EOM_
281 int eom_get_output_id(const char *output_name)
283 eom_output_id *output_ids = NULL;
284 eom_output_id output_id = 0;
285 eom_output_type_e output_type = EOM_OUTPUT_TYPE_UNKNOWN;
290 output_ids = eom_get_eom_output_ids(&id_cnt);
292 g_print("[eom] no external outuputs supported\n");
296 /* find output ids interested */
297 for (i = 0; i < id_cnt; i++) {
298 eom_get_output_type(output_ids[i], &output_type);
299 if (!strncmp(output_name, "HDMI", 4)) {
300 if (output_type == EOM_OUTPUT_TYPE_HDMIA || output_type == EOM_OUTPUT_TYPE_HDMIB) {
301 output_id = output_ids[i];
304 } else if (!strncmp(output_name, "Virtual", 4)) {
305 if (output_type == EOM_OUTPUT_TYPE_VIRTUAL) {
306 output_id = output_ids[i];
318 static void eom_notify_cb_output_add(eom_output_id output_id, void *user_data)
320 appdata *info = (appdata *) user_data;
322 if (info->hdmi_output_id != output_id) {
323 g_print("[eom] OUTPUT ADDED. SKIP. my output ID is %d\n", info->hdmi_output_id);
326 g_print("[eom] output(%d) connected\n", output_id);
327 /* it is for external window */
328 if (!g_external_win_id) {
329 g_external_win_id = elm_win_add(NULL, "External", ELM_WIN_BASIC);
330 if (eom_set_output_window(info->hdmi_output_id, g_external_win_id) == EOM_ERROR_NONE) {
331 create_render_rect_and_bg(g_external_win_id);
332 g_print("[eom] create external window\n");
334 evas_object_del(g_external_win_id);
335 g_external_win_id = NULL;
336 g_print("[eom] create external window fail\n");
341 static void eom_notify_cb_output_remove(eom_output_id output_id, void *user_data)
343 appdata *info = (appdata *) user_data;
344 player_state_e state;
346 if (info->hdmi_output_id != output_id) {
347 g_print("[eom] OUTPUT REMOVED. SKIP. my output ID is %d\n", info->hdmi_output_id);
350 g_print("[eom] output(%d) disconnected\n", output_id);
352 if (selected_win_id == g_external_win_id && g_player[0]) {
353 player_get_state(g_player[0], &state);
354 if (state >= PLAYER_STATE_READY) {
356 g_win_id = create_win(PACKAGE);
357 if (g_win_id == NULL)
359 g_print("create win_id %p\n", g_win_id);
360 create_render_rect_and_bg(g_win_id);
361 elm_win_activate(g_win_id);
362 evas_object_show(g_win_id);
364 player_set_display(g_player[0], PLAYER_DISPLAY_TYPE_OVERLAY, GET_DISPLAY(g_win_id));
368 /* it is for external window */
369 if (g_external_win_id) {
370 evas_object_del(g_external_win_id);
371 g_external_win_id = NULL;
373 selected_win_id = g_win_id;
376 static void eom_notify_cb_mode_changed(eom_output_id output_id, void *user_data)
378 appdata *info = (appdata *) user_data;
379 eom_output_mode_e mode = EOM_OUTPUT_MODE_NONE;
381 if (info->hdmi_output_id != output_id) {
382 g_print("[eom] MODE CHANGED. SKIP. my output ID is %d\n", info->hdmi_output_id);
386 eom_get_output_mode(output_id, &mode);
387 g_print("[eom] output(%d) mode changed(%d)\n", output_id, mode);
390 static void eom_notify_cb_attribute_changed(eom_output_id output_id, void *user_data)
392 appdata *info = (appdata *) user_data;
394 eom_output_attribute_e attribute = EOM_OUTPUT_ATTRIBUTE_NONE;
395 eom_output_attribute_state_e state = EOM_OUTPUT_ATTRIBUTE_STATE_NONE;
397 if (info->hdmi_output_id != output_id) {
398 g_print("[eom] ATTR CHANGED. SKIP. my output ID is %d\n", info->hdmi_output_id);
402 eom_get_output_attribute(output_id, &attribute);
403 eom_get_output_attribute_state(output_id, &state);
405 g_print("[eom] output(%d) attribute changed(%d, %d)\n", output_id, attribute, state);
406 if (state == EOM_OUTPUT_ATTRIBUTE_STATE_ACTIVE) {
407 g_print("[eom] active\n");
408 if (!g_external_win_id) {
409 g_external_win_id = elm_win_add(NULL, "External", ELM_WIN_BASIC);
410 if (eom_set_output_window(info->hdmi_output_id, g_external_win_id) == EOM_ERROR_NONE) {
411 create_render_rect_and_bg(g_external_win_id);
412 g_print("[eom] create external window\n");
414 evas_object_del(g_external_win_id);
415 g_external_win_id = NULL;
416 g_print("[eom] create external window fail\n");
419 selected_win_id = g_external_win_id;
420 /* play video on external window */
422 player_set_display(g_player[0], PLAYER_DISPLAY_TYPE_OVERLAY, GET_DISPLAY(selected_win_id));
423 } else if (state == EOM_OUTPUT_ATTRIBUTE_STATE_INACTIVE) {
424 g_print("[eom] inactive\n");
426 g_win_id = create_win(PACKAGE);
427 if (g_win_id == NULL)
429 g_print("create win_id %p\n", g_win_id);
430 create_render_rect_and_bg(g_win_id);
431 elm_win_activate(g_win_id);
432 evas_object_show(g_win_id);
434 selected_win_id = g_win_id;
436 player_set_display(g_player[0], PLAYER_DISPLAY_TYPE_OVERLAY, GET_DISPLAY(selected_win_id));
438 if (g_external_win_id) {
439 evas_object_del(g_external_win_id);
440 g_external_win_id = NULL;
442 } else if (state == EOM_OUTPUT_ATTRIBUTE_STATE_LOST) {
443 g_print("[eom] lost\n");
445 g_win_id = create_win(PACKAGE);
446 if (g_win_id == NULL)
448 g_print("create win_id %p\n", g_win_id);
449 create_render_rect_and_bg(g_win_id);
450 elm_win_activate(g_win_id);
451 evas_object_show(g_win_id);
453 selected_win_id = g_win_id;
456 player_set_display(g_player[0], PLAYER_DISPLAY_TYPE_OVERLAY, GET_DISPLAY(selected_win_id));
458 if (g_external_win_id) {
459 evas_object_del(g_external_win_id);
460 g_external_win_id = NULL;
463 eom_unset_output_added_cb(eom_notify_cb_output_add);
464 eom_unset_output_removed_cb(eom_notify_cb_output_remove);
465 eom_unset_mode_changed_cb(eom_notify_cb_mode_changed);
466 eom_unset_attribute_changed_cb(eom_notify_cb_attribute_changed);
472 static int app_create(void *data)
475 Evas_Object *win = NULL;
476 #ifdef _ACTIVATE_EOM_
477 eom_output_mode_e output_mode = EOM_OUTPUT_MODE_NONE;
481 elm_config_accel_preference_set("opengl");
484 win = create_win(PACKAGE);
489 selected_win_id = g_win_id;
490 create_render_rect_and_bg(ad->win);
491 /* Create evas image object for EVAS surface */
492 g_eo[0] = create_image_object(ad->win);
493 evas_object_image_size_set(g_eo[0], 500, 500);
494 evas_object_image_fill_set(g_eo[0], 0, 0, 500, 500);
495 evas_object_resize(g_eo[0], 500, 500);
497 elm_win_activate(win);
498 evas_object_show(win);
499 #ifdef _ACTIVATE_EOM_
500 /* check external device */
502 ad->hdmi_output_id = eom_get_output_id("HDMI");
503 if (ad->hdmi_output_id == 0) {
504 g_print("[eom] error : HDMI output id is NULL.\n");
508 g_print("eom_set_output_attribute EOM_OUTPUT_ATTRIBUTE_NORMAL(id:%d)\n", ad->hdmi_output_id);
509 if (eom_set_output_attribute(ad->hdmi_output_id, EOM_OUTPUT_ATTRIBUTE_NORMAL) != EOM_ERROR_NONE) {
510 g_print("attribute set fail. cannot use external output\n");
514 eom_get_output_mode(ad->hdmi_output_id, &output_mode);
515 if (output_mode != EOM_OUTPUT_MODE_NONE) {
516 g_external_win_id = elm_win_add(NULL, "External", ELM_WIN_BASIC);
517 if (eom_set_output_window(ad->hdmi_output_id, g_external_win_id) == EOM_ERROR_NONE) {
518 create_render_rect_and_bg(g_external_win_id);
519 g_print("[eom] create external window\n");
521 evas_object_del(g_external_win_id);
522 g_external_win_id = NULL;
523 g_print("[eom] create external window fail\n");
525 selected_win_id = g_external_win_id;
528 /* set callback for detecting external device */
529 eom_set_output_added_cb(eom_notify_cb_output_add, ad);
530 eom_set_output_removed_cb(eom_notify_cb_output_remove, ad);
531 eom_set_mode_changed_cb(eom_notify_cb_mode_changed, ad);
532 eom_set_attribute_changed_cb(eom_notify_cb_attribute_changed, ad);
535 #ifdef USE_EVENT_HANDLER
536 if (mm_navevent_handler_create(&event_handler,
537 MM_NAVEVENT_HANDLER_DEVICE_TYPE_TOUCH) != MM_NAVEVENT_HANDLER_ERROR_NONE) {
538 g_print ("Error during handler creation\n");
542 if (mm_navevent_handler_set_cb(event_handler, event_handler_cb, NULL) !=
543 MM_NAVEVENT_HANDLER_ERROR_NONE) {
544 g_print ("Error during callback set\n");
552 static int app_terminate(void *data)
557 #ifdef USE_EVENT_HANDLER
558 mm_navevent_handler_destroy(event_handler);
561 for (i = 0; i < MAX_HANDLE; i++) {
563 evas_object_del(g_eo[i]);
568 evas_object_del(g_win_id);
571 #ifdef _ACTIVATE_EOM_
572 if (g_external_win_id) {
573 evas_object_del(g_external_win_id);
574 g_external_win_id = NULL;
578 selected_win_id = NULL;
579 #ifdef _ACTIVATE_EOM_
580 eom_unset_output_added_cb(eom_notify_cb_output_add);
581 eom_unset_output_removed_cb(eom_notify_cb_output_remove);
582 eom_unset_mode_changed_cb(eom_notify_cb_mode_changed);
583 eom_unset_attribute_changed_cb(eom_notify_cb_attribute_changed);
590 struct appcore_ops ops = {
591 .create = app_create,
592 .terminate = app_terminate,
595 static void prepared_cb(void *user_data)
597 g_print("[Player_Test] prepared_cb!!!!\n");
600 static void _audio_frame_decoded_cb_ex(player_audio_raw_data_s * audio_raw_frame, void *user_data)
602 player_audio_raw_data_s *audio_raw = audio_raw_frame;
607 g_print("[Player_Test] decoded_cb_ex! channel: %d channel_mask: %llu\n", audio_raw->channel, audio_raw->channel_mask);
610 if (audio_raw->channel_mask == 1 && fp_out1)
611 fwrite((guint8 *) audio_raw->data, 1, audio_raw->size, fp_out1);
612 else if (audio_raw->channel_mask == 2 && fp_out2)
613 fwrite((guint8 *) audio_raw->data, 1, audio_raw->size, fp_out2);
617 static void progress_down_cb(player_pd_message_type_e type, void *user_data)
619 g_print("[Player_Test] progress_down_cb!!!! type : %d\n", type);
622 static void buffering_cb(int percent, void *user_data)
624 g_print("[Player_Test] buffering_cb!!!! percent : %d\n", percent);
627 static void seek_completed_cb(void *user_data)
629 g_print("[Player_Test] seek_completed_cb!!! \n");
632 static void completed_cb(void *user_data)
634 g_print("[Player_Test] completed_cb!!!!\n");
637 static void error_cb(int code, void *user_data)
639 g_print("[Player_Test] error_cb!!!! code : %d\n", code);
642 static void interrupted_cb(player_interrupted_code_e code, void *user_data)
644 g_print("[Player_Test] interrupted_cb!!!! code : %d\n", code);
647 static void video_changed_cb(int width, int height, int fps, int bit_rate, void *user_data)
649 g_print("[Player_Test] video_changed_cb!!!! %d x %d, %d, %d \n", width, height, fps, bit_rate);
651 #ifdef USE_EVENT_HANDLER
652 image_size.width = width;
653 image_size.height = height;
654 event_handler_set_window_parameters();
659 static void audio_frame_decoded_cb(unsigned char *data, unsigned int size, void *user_data)
663 if (data && g_pcm_fd)
664 fwrite(data, 1, size, g_pcm_fd);
665 player_get_play_position(g_player[0], &pos);
666 g_print("[Player_Test] audio_frame_decoded_cb [size: %d] --- current pos : %d!!!!\n", size, pos);
670 static void subtitle_updated_cb(unsigned long duration, char *text, void *user_data)
672 g_print("[Player_Test] subtitle_updated_cb!!!! [%ld] %s\n", duration, text);
675 static void video_captured_cb(unsigned char *data, int width, int height, unsigned int size, void *user_data)
677 g_print("[Player_Test] video_captured_cb!!!! width: %d, height : %d, size : %d \n", width, height, size);
681 static int _save(unsigned char *src, int length)
683 /* unlink(CAPTUERD_IMAGE_SAVE_PATH); */
685 char filename[256] = { 0, };
686 static int WRITE_COUNT = 0;
687 /* gchar *filename = CAPTUERD_IMAGE_SAVE_PATH; */
688 snprintf(filename, 256, "/tmp/IMAGE_client%d", WRITE_COUNT);
690 fp = fopen(filename, "w+");
692 g_print("file open error!!\n");
695 g_print("open success\n");
696 if (fwrite(src, 1, length, fp) < 1) {
697 g_print("file write error!!\n");
701 g_print("write success(%s)\n", filename);
708 static void reset_display()
712 /* delete evas window, if it is */
713 for (i = 0; i < MAX_HANDLE; i++) {
715 evas_object_del(g_eo[i]);
721 static void input_filename(char *filename)
723 int len = strlen(filename);
726 if (len < 0 || len > MAX_STRING_LEN - 1)
729 for (i = 0; i < g_handle_num; i++) {
730 if (g_player[i] != NULL) {
731 player_unprepare(g_player[i]);
732 player_destroy(g_player[i]);
736 if (player_create(&g_player[i]) != PLAYER_ERROR_NONE)
737 g_print("player create is failed\n");
740 strncpy(g_uri, filename, len+1);
744 /* ned(APPSRC_TEST) */
749 GError *error = NULL;
750 guint8 *g_media_mem = NULL;
754 file = g_mapped_file_new(ext, FALSE, &error);
755 file_size = g_mapped_file_get_length(file);
756 g_media_mem = (guint8 *) g_mapped_file_get_contents(file);
758 g_sprintf(uri, "mem://ext=%s,size=%d", ext ? ext : "", file_size);
759 g_print("[uri] = %s\n", uri);
761 mm_player_set_attribute(g_player[0], &g_err_name, "profile_uri", uri, strlen(uri), "profile_user_param", g_media_mem, file_size NULL);
763 /* player_set_uri(g_player[0], filename); */
768 player_state_e state;
769 for (i = 0; i < g_handle_num; i++) {
770 ret = player_get_state(g_player[i], &state);
771 g_print("player_get_state returned [%d]\n", ret);
772 g_print("1. After player_create() - Current State : %d \n", state);
776 /* use this API instead of player_set_uri */
777 static void player_set_memory_buffer_test()
781 guint8 *g_media_mem = NULL;
783 file = g_mapped_file_new(g_uri, FALSE, NULL);
784 file_size = g_mapped_file_get_length(file);
785 g_media_mem = (guint8 *) g_mapped_file_get_contents(file);
787 int ret = player_set_memory_buffer(g_player[0], (void *)g_media_mem, file_size);
788 g_print("player_set_memory_buffer ret : %d\n", ret);
791 int video_packet_count = 0;
793 static void buffer_need_video_data_cb(unsigned int size, void *user_data)
795 int real_read_len = 0;
798 static guint64 pts = 0L;
801 guint8 *buff_ptr = NULL;
804 memset(fname, 0, 128);
805 memset(fptsname, 0, 128);
807 video_packet_count++;
809 if (video_packet_count > 1000) {
812 /* player_submit_packet(g_player[0], NULL, 0, 0, 1); */
813 player_push_media_stream(g_player[0], NULL);
817 /* snprintf(fname, 128, "/opt/storage/usb/test/packet/packet_%d.dat", video_packet_count); */
818 /* snprintf(fptsname, 128, "/opt/storage/usb/test/packet/gstpts_%d.dat", video_packet_count); */
819 snprintf(fname, 128, "/home/developer/test/packet/packet_%d.dat", video_packet_count);
820 snprintf(fptsname, 128, "/home/developer/test/packet/gstpts_%d.dat", video_packet_count);
822 fp = fopen(fptsname, "rb");
825 pts_len = fread(&pts, 1, sizeof(guint64), fp);
826 if (pts_len != sizeof(guint64))
827 g_print("Warning, pts value can be wrong.\n");
832 fp = fopen(fname, "rb");
834 buff_ptr = (guint8 *) g_malloc0(1048576);
836 g_print("no free space\n");
841 real_read_len = fread(buff_ptr, 1, size, fp);
845 g_print("video need data - data size : %d, pts : %" G_GUINT64_FORMAT "\n", real_read_len, pts);
847 player_submit_packet(g_player[0], buff_ptr, real_read_len, (pts / 1000000), 1);
849 /* create media packet */
851 media_packet_destroy(g_video_pkt);
855 media_packet_create_alloc(g_video_fmt, NULL, NULL, &g_video_pkt);
857 g_print("packet = %p, src = %p\n", g_video_pkt, src);
859 if (media_packet_get_buffer_data_ptr(g_video_pkt, &src) != MEDIA_PACKET_ERROR_NONE)
862 if (media_packet_set_pts(g_video_pkt, (uint64_t) pts) != MEDIA_PACKET_ERROR_NONE)
865 if (media_packet_set_buffer_size(g_video_pkt, (uint64_t) real_read_len) != MEDIA_PACKET_ERROR_NONE)
868 memcpy(src, buff_ptr, real_read_len);
871 player_push_media_stream(g_player[0], g_video_pkt);
881 int audio_packet_count = 0;
882 static void buffer_need_audio_data_cb(unsigned int size, void *user_data)
884 int real_read_len = 0;
887 guint8 *buff_ptr = NULL;
890 memset(fname, 0, 128);
891 audio_packet_count++;
893 if (audio_packet_count > 1000) {
895 /* player_submit_packet(g_player[0], NULL, 0, 0, 0); */
896 player_push_media_stream(g_player[0], NULL);
900 /* snprintf(fname, 128, "/opt/storage/usb/test/audio_packet/packet_%d.dat", audio_packet_count); */
901 snprintf(fname, 128, "/home/developer/test/audio_packet/packet_%d.dat", audio_packet_count);
903 static guint64 audio_pts = 0;
904 guint64 audio_dur = 21333333;
906 fp = fopen(fname, "rb");
908 buff_ptr = (guint8 *) g_malloc0(1048576);
910 g_print("no free space\n");
915 real_read_len = fread(buff_ptr, 1, size, fp);
919 g_print("\t audio need data - data size : %d, pts : %" G_GUINT64_FORMAT "\n", real_read_len, audio_pts);
922 player_submit_packet(g_player[0], buff_ptr, real_read_len, (audio_pts / 1000000), 0);
924 /* create media packet */
926 media_packet_destroy(g_audio_pkt);
929 media_packet_create_alloc(g_audio_fmt, NULL, NULL, &g_audio_pkt);
931 g_print("packet = %p, src = %p\n", g_audio_pkt, src);
933 if (media_packet_get_buffer_data_ptr(g_audio_pkt, &src) != MEDIA_PACKET_ERROR_NONE)
936 if (media_packet_set_pts(g_audio_pkt, (uint64_t) audio_pts) != MEDIA_PACKET_ERROR_NONE)
939 if (media_packet_set_buffer_size(g_audio_pkt, (uint64_t) real_read_len) != MEDIA_PACKET_ERROR_NONE)
942 memcpy(src, buff_ptr, real_read_len);
945 player_push_media_stream(g_player[0], g_audio_pkt);
948 audio_pts += audio_dur;
956 static void set_content_info(bool is_push_mode)
958 /* testcode for es buff src case, please input url as es_buff://123 or es_buff://push_mode */
959 /* 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}; */
961 /* create media format */
962 media_format_create(&g_audio_fmt);
963 media_format_create(&g_video_fmt);
966 /* configure media format for video and set to player */
967 media_format_set_video_mime(g_video_fmt, MEDIA_FORMAT_MPEG4_SP);
968 media_format_set_video_width(g_video_fmt, 640);
969 media_format_set_video_height(g_video_fmt, 272);
970 /* player_set_media_stream_info(g_player[0], PLAYER_STREAM_TYPE_VIDEO, g_video_fmt); */
972 /* Audio--aac--StarWars.mp4 */
973 media_format_set_audio_mime(g_audio_fmt, MEDIA_FORMAT_AAC);
974 media_format_set_audio_channel(g_audio_fmt, 2);
975 media_format_set_audio_samplerate(g_audio_fmt, 48000);
976 /* player_set_media_stream_info(g_player[0], PLAYER_STREAM_TYPE_AUDIO, g_audio_fmt); */
978 /* video_info->mime = g_strdup("video/mpeg"); *//* CODEC_ID_MPEG4VIDEO */
979 video_info->width = 640;
980 video_info->height = 272;
981 video_info->version = 4;
982 video_info->framerate_den = 100;
983 video_info->framerate_num = 2997;
985 video_info->extradata_size = 45;
986 video_info->codec_extradata = codec_data;
987 player_set_video_stream_info(g_player[0], video_info);
989 /* audio--aac--StarWars.mp4 */
990 /* audio_info->mime = g_strdup("audio/mpeg"); */
991 /* audio_info->version = 2; */
992 /* audio_info->user_info = 0; *//* raw */
997 player_set_buffer_need_video_data_cb(g_player[0], buffer_need_video_data_cb, (void *)g_player[0]);
998 player_set_buffer_need_audio_data_cb(g_player[0], buffer_need_audio_data_cb, (void *)g_player[0]);
1003 static void feed_video_data_thread_func(void *data)
1005 while (!g_thread_end) {
1006 buffer_need_video_data_cb(1048576, NULL);
1007 buffer_need_audio_data_cb(1048576, NULL);
1011 static void _player_prepare(bool async)
1014 int slen = strlen(g_subtitle_uri);
1016 if (slen > 0 && slen < MAX_STRING_LEN) {
1017 g_print("0. set subtile path() (size : %d) - %s \n", slen, g_subtitle_uri);
1018 player_set_subtitle_path(g_player[0], g_subtitle_uri);
1019 player_set_subtitle_updated_cb(g_player[0], subtitle_updated_cb, (void *)g_player[0]);
1021 if (g_current_surface_type == -1) {
1022 g_print("You must set display surface type before setting prepare.\n");
1026 if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
1027 player_set_buffering_cb(g_player[0], buffering_cb, (void *)g_player[0]);
1028 player_set_completed_cb(g_player[0], completed_cb, (void *)g_player[0]);
1029 player_set_interrupted_cb(g_player[0], interrupted_cb, (void *)g_player[0]);
1030 player_set_error_cb(g_player[0], error_cb, (void *)g_player[0]);
1031 player_set_video_stream_changed_cb(g_player[0], video_changed_cb, (void *)g_player[0]);
1032 if (g_memory_playback)
1033 player_set_memory_buffer_test();
1035 player_set_uri(g_player[0], g_uri);
1038 for (i = 0; i < g_handle_num; i++) {
1039 player_set_buffering_cb(g_player[i], buffering_cb, (void *)g_player[i]);
1040 player_set_completed_cb(g_player[i], completed_cb, (void *)g_player[i]);
1041 player_set_interrupted_cb(g_player[i], interrupted_cb, (void *)g_player[i]);
1042 player_set_error_cb(g_player[i], error_cb, (void *)g_player[i]);
1043 player_set_video_stream_changed_cb(g_player[0], video_changed_cb, (void *)g_player[0]);
1044 if (g_memory_playback)
1045 player_set_memory_buffer_test();
1047 player_set_uri(g_player[i], g_uri);
1051 if (strstr(g_uri, "es_buff://")) {
1052 is_es_push_mode = FALSE;
1053 video_packet_count = 0;
1054 audio_packet_count = 0;
1056 if (strstr(g_uri, "es_buff://push_mode")) {
1057 set_content_info(TRUE);
1059 is_es_push_mode = TRUE;
1062 set_content_info(FALSE);
1067 if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
1069 ret = player_prepare_async(g_player[0], prepared_cb, (void *)g_player[0]);
1071 ret = player_prepare(g_player[0]);
1074 for (i = 0; i < g_handle_num; i++) {
1076 ret = player_prepare_async(g_player[i], prepared_cb, (void *)g_player[i]);
1078 ret = player_prepare(g_player[i]);
1082 if (ret != PLAYER_ERROR_NONE)
1083 g_print("prepare is failed (errno = %d) \n", ret);
1085 player_state_e state;
1086 if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
1087 ret = player_get_state(g_player[0], &state);
1088 g_print("After player_prepare() - Current State : %d \n", state);
1091 for (i = 0; i < g_handle_num; i++) {
1092 ret = player_get_state(g_player[i], &state);
1093 g_print("After player_prepare() - Current State : %d \n", state);
1097 if (is_es_push_mode)
1098 pthread_create(&g_feed_video_thread_id, NULL, (void *)feed_video_data_thread_func, NULL);
1100 #ifdef USE_EVENT_HANDLER
1101 event_handler_set_dov_fov();
1105 static void _player_unprepare()
1109 if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
1110 ret = player_unprepare(g_player[0]);
1111 if (ret != PLAYER_ERROR_NONE)
1112 g_print("unprepare is failed (errno = %d) \n", ret);
1114 ret = player_unset_subtitle_updated_cb(g_player[0]);
1115 g_print("player_unset_subtitle_updated_cb ret %d\n", ret);
1117 ret = player_unset_buffering_cb(g_player[0]);
1118 g_print("player_unset_buffering_cb ret %d\n", ret);
1120 ret = player_unset_completed_cb(g_player[0]);
1121 g_print("player_unset_completed_cb ret %d\n", ret);
1123 ret = player_unset_interrupted_cb(g_player[0]);
1124 g_print("player_unset_interrupted_cb ret %d\n", ret);
1126 ret = player_unset_error_cb(g_player[0]);
1127 g_print("player_unset_error_cb ret %d\n", ret);
1129 for (i = 0; i < g_handle_num; i++) {
1130 if (g_player[i] != NULL) {
1131 ret = player_unprepare(g_player[i]);
1132 if (ret != PLAYER_ERROR_NONE)
1133 g_print("unprepare is failed (errno = %d) \n", ret);
1135 ret = player_unset_subtitle_updated_cb(g_player[i]);
1136 g_print("player_unset_subtitle_updated_cb [%d] ret %d\n", i, ret);
1138 ret = player_unset_buffering_cb(g_player[i]);
1139 g_print("player_unset_buffering_cb [%d] ret %d\n", i, ret);
1141 ret = player_unset_completed_cb(g_player[i]);
1142 g_print("player_unset_completed_cb [%d] ret %d\n", i, ret);
1144 ret = player_unset_interrupted_cb(g_player[i]);
1145 g_print("player_unset_interrupted_cb [%d] ret %d\n", i, ret);
1147 ret = player_unset_error_cb(g_player[i]);
1148 g_print("player_unset_error_cb [%d] ret %d\n", i, ret);
1153 memset(g_subtitle_uri, 0, sizeof(g_subtitle_uri));
1154 player_state_e state;
1155 if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
1156 ret = player_get_state(g_player[0], &state);
1157 g_print(" After player_unprepare() - Current State : %d \n", state);
1159 for (i = 0; i < g_handle_num; i++) {
1160 ret = player_get_state(g_player[i], &state);
1161 g_print(" After player_unprepare() - Current State : %d \n", state);
1166 static void _player_destroy()
1170 if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
1171 player_destroy(g_player[0]);
1174 for (i = 0; i < g_handle_num; i++) {
1175 if (g_player[i] != NULL) {
1176 player_unprepare(g_player[i]);
1177 player_destroy(g_player[i]);
1183 if (g_stream_info_h) {
1184 sound_manager_destroy_stream_information(g_stream_info_h);
1185 g_stream_info_h = NULL;
1189 media_packet_destroy(g_video_pkt);
1192 media_packet_destroy(g_audio_pkt);
1203 static void _player_play()
1207 if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
1208 #ifdef _ACTIVATE_EOM_
1209 /* for checking external display.... */
1210 player_set_display(g_player[0], g_current_surface_type, GET_DISPLAY(selected_win_id));
1212 bRet = player_start(g_player[0]);
1213 g_print("player_start returned [%d]", bRet);
1215 for (i = 0; i < g_handle_num; i++) {
1216 bRet = player_start(g_player[i]);
1217 g_print("player_start returned [%d]", bRet);
1222 static void _player_stop()
1226 if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
1227 bRet = player_stop(g_player[0]);
1228 g_print("player_stop returned [%d]", bRet);
1230 for (i = 0; i < g_handle_num; i++) {
1231 bRet = player_stop(g_player[i]);
1232 g_print("player_stop returned [%d]", bRet);
1236 g_thread_end = TRUE;
1237 if (g_feed_video_thread_id) {
1238 pthread_join(g_feed_video_thread_id, NULL);
1239 g_feed_video_thread_id = 0;
1244 static void _player_resume()
1248 if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
1249 #ifdef _ACTIVATE_EOM_
1250 /* for checking external display.... */
1251 player_set_display(g_player[0], PLAYER_DISPLAY_TYPE_OVERLAY, GET_DISPLAY(selected_win_id));
1253 bRet = player_start(g_player[0]);
1254 g_print("player_start returned [%d]", bRet);
1256 for (i = 0; i < g_handle_num; i++) {
1257 bRet = player_start(g_player[i]);
1258 g_print("player_start returned [%d]", bRet);
1263 static void _player_pause()
1267 if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
1268 bRet = player_pause(g_player[0]);
1269 g_print("player_pause returned [%d]", bRet);
1271 for (i = 0; i < g_handle_num; i++) {
1272 bRet = player_pause(g_player[i]);
1273 g_print("player_pause returned [%d]", bRet);
1278 static void _player_state()
1280 player_state_e state;
1281 player_get_state(g_player[0], &state);
1282 g_print(" ==> [Player_Test] Current Player State : %d\n", state);
1285 static void _player_set_progressive_download()
1287 player_set_progressive_download_path(g_player[0], "/home/owner/test.pd");
1288 player_set_progressive_download_message_cb(g_player[0], progress_down_cb, (void *)g_player[0]);
1291 static void _player_get_progressive_download_status()
1294 unsigned long curr = 0, total = 0;
1295 bRet = player_get_progressive_download_status(g_player[0], &curr, &total);
1296 g_print("player_get_progressive_download_status return[%d] ==> [Player_Test] progressive download status : %lu/%lu\n", bRet, curr, total);
1299 static void _player_enable_tsurf_pool(void)
1301 bool enabled = FALSE;
1304 g_print("not support at TV profile");
1308 player_is_enabled_tsurf_pool(g_player[0], &enabled);
1310 g_print("tbm surface pool will be %s", (enabled) ? "disabled" : "enabled");
1311 player_enable_tsurf_pool(g_player[0], !enabled);
1314 static void set_next_uri(char * uri)
1317 g_print("not support at TV profile");
1321 if (player_set_next_uri(g_player[0], uri) != PLAYER_ERROR_NONE)
1322 g_print("fail to set next uri");
1325 static void get_next_uri()
1330 g_print("not support at TV profile");
1334 if (player_get_next_uri(g_player[0], &uri) != PLAYER_ERROR_NONE) {
1335 g_print("fail to get next uri");
1340 g_print("next_uri = %s", uri);
1345 static void set_volume(float volume)
1347 if (player_set_volume(g_player[0], volume, volume) != PLAYER_ERROR_NONE)
1348 g_print("failed to set volume\n");
1351 static void get_volume(float *left, float *right)
1353 player_get_volume(g_player[0], left, right);
1354 g_print(" ==> [Player_Test] volume - left : %f, right : %f\n", *left, *right);
1357 static void set_mute(bool mute)
1359 if (player_set_mute(g_player[0], mute) != PLAYER_ERROR_NONE)
1360 g_print("failed to set_mute\n");
1363 static void get_mute(bool * mute)
1365 player_is_muted(g_player[0], mute);
1366 g_print(" ==> [Player_Test] mute = %d\n", *mute);
1369 static void set_sound_type(sound_type_e type)
1371 if (player_set_sound_type(g_player[0], type) != PLAYER_ERROR_NONE)
1372 g_print("failed to set sound type(%d)\n", type);
1374 g_print("set sound type(%d) success", type);
1377 void focus_callback(sound_stream_info_h stream_info,
1378 sound_stream_focus_mask_e focus_mask,
1379 sound_stream_focus_state_e focus_state,
1380 sound_stream_focus_change_reason_e reason,
1382 const char *extra_info,
1385 g_print("FOCUS callback is called, reason(%d), extra_info(%s), userdata(%p)", reason, extra_info, user_data);
1389 static void set_sound_stream_info(int type)
1391 sound_device_list_h device_list = NULL;
1392 int ret = SOUND_MANAGER_ERROR_NONE;
1394 if (g_stream_info_h) {
1395 g_print("stream information is already set, please destory handle and try again\n");
1398 if (sound_manager_create_stream_information(type, focus_callback, g_player[0], &g_stream_info_h)) {
1399 g_print("failed to create stream_information()\n");
1402 /* In case of MEDIA_EXTERNAL_ONLY, we need to set external device manually */
1403 if (type == (int)SOUND_STREAM_TYPE_MEDIA_EXTERNAL_ONLY) {
1404 sound_device_h device = NULL;
1405 sound_device_type_e device_type;
1407 if ((ret = sound_manager_get_device_list(SOUND_DEVICE_ALL_MASK, &device_list))) {
1408 g_print("failed to sound_manager_get_device_list(), ret(0x%x)\n", ret);
1411 while (!(ret = sound_manager_get_next_device(device_list, &device))) {
1412 if ((ret = sound_manager_get_device_type(device, &device_type))) {
1413 g_print("failed to sound_manager_get_device_type(), ret(0x%x)\n", ret);
1416 if (device_type == SOUND_DEVICE_BLUETOOTH || device_type == SOUND_DEVICE_USB_AUDIO) {
1417 if ((ret = sound_manager_add_device_for_stream_routing(g_stream_info_h, device))) {
1418 g_print("failed to sound_manager_add_device_for_stream_routing(), ret(0x%x)\n", ret);
1421 if ((ret = sound_manager_apply_stream_routing(g_stream_info_h))) {
1422 g_print("failed to sound_manager_apply_stream_routing(), ret(0x%x)\n", ret);
1428 if (ret != SOUND_MANAGER_ERROR_NONE) {
1429 g_print("failed to sound_manager_get_next_device(), ret(0x%x)\n", ret);
1434 if (player_set_sound_stream_info(g_player[0], g_stream_info_h) != PLAYER_ERROR_NONE)
1435 g_print("failed to set sound stream information(%p)\n", g_stream_info_h);
1437 g_print("set stream information(%p) success", g_stream_info_h);
1441 sound_manager_free_device_list(device_list);
1445 void variant_cb(int bandwidth, int width, int height, void *user_data)
1447 g_print(" ==> [Player_Test][b]%d, [w]%d, [h]%d\n", bandwidth, width, height);
1450 static void get_variant_info()
1452 player_foreach_adaptive_variant(g_player[0], (player_adaptive_variant_cb)variant_cb, g_player[0]);
1455 static void get_variant_limit()
1457 int bandwidth, width, height;
1458 player_get_max_adaptive_variant_limit(g_player[0], &bandwidth, &width, &height);
1459 g_print(" ==> [Player_Test]get [b]%d, [w]%d, [h]%d\n", bandwidth, width, height);
1462 static void set_variant_limit()
1464 g_print(" ==> [Player_Test]set [b]%d, [w]%d, [h]%d\n", max_limit.bandwidth, max_limit.width, max_limit.height);
1465 player_set_max_adaptive_variant_limit(g_player[0], max_limit.bandwidth, max_limit.width, max_limit.height);
1468 static void set_buffer_size()
1471 int buffer_ms = 0, rebuffer_ms = 0;
1473 ret = player_get_streaming_buffering_time(g_player[0], &buffer_ms, &rebuffer_ms);
1474 if (ret != PLAYER_ERROR_NONE)
1475 g_print("failed to get buffering time. 0x%X\n", ret);
1477 g_print("current buffer size %d ms / %d ms\n", buffer_ms, rebuffer_ms);
1479 g_print("new buffer size %d ms / %d ms\n", buff_size.buffer_ms, buff_size.rebuffer_ms);
1481 player_set_streaming_buffering_time(g_player[0], buff_size.buffer_ms, buff_size.rebuffer_ms);
1484 static void get_position()
1488 ret = player_get_play_position(g_player[0], &position);
1489 g_print(" ==> [Player_Test] player_get_play_position()%d return : %d\n", ret, position);
1492 static void set_position(int position, bool accurate)
1494 if (player_set_play_position(g_player[0], position, accurate, seek_completed_cb, g_player[0]) != PLAYER_ERROR_NONE)
1495 g_print("failed to set position\n");
1498 static void set_playback_rate(float rate, bool streaming)
1501 if (player_set_streaming_playback_rate(g_player[0], rate) != PLAYER_ERROR_NONE)
1502 g_print("failed to set streaming playback rate\n");
1504 if (player_set_playback_rate(g_player[0], rate) != PLAYER_ERROR_NONE)
1505 g_print("failed to set playback rate\n");
1509 static void get_duration()
1513 ret = player_get_duration(g_player[0], &duration);
1514 g_print(" ==> [Player_Test] player_get_duration() return : %d\n", ret);
1515 g_print(" ==> [Player_Test] Duration: [%d ] msec\n", duration);
1518 static void audio_frame_decoded_cb_ex(bool sync)
1522 fp_out1 = fopen("/tmp/out1.pcm", "wb");
1523 fp_out2 = fopen("/tmp/out2.pcm", "wb");
1524 if (!fp_out1 || !fp_out2) {
1525 g_print("File open error\n");
1530 ret = player_set_pcm_extraction_mode(g_player[0], sync, _audio_frame_decoded_cb_ex, &ret);
1531 g_print(" ==> [Player_Test] player_set_audio_frame_decoded_cb_ex(sync:%d) ret:%d\n", sync, ret);
1533 ret = player_set_pcm_spec(g_player[0], "F32LE", 44100, 2);
1534 g_print("[Player_Test] set_pcm_spec return: %d\n", ret);
1537 static void get_stream_info()
1543 player_get_content_info(g_player[0], PLAYER_CONTENT_INFO_ALBUM, &value);
1544 g_print(" ==> [Player_Test] PLAYER_CONTENT_INFO_ALBUM: [%s ] \n", value);
1545 player_get_content_info(g_player[0], PLAYER_CONTENT_INFO_ARTIST, &value);
1546 g_print(" ==> [Player_Test] PLAYER_CONTENT_INFO_ARTIST: [%s ] \n", value);
1547 player_get_content_info(g_player[0], PLAYER_CONTENT_INFO_AUTHOR, &value);
1548 g_print(" ==> [Player_Test] PLAYER_CONTENT_INFO_AUTHOR: [%s ] \n", value);
1549 player_get_content_info(g_player[0], PLAYER_CONTENT_INFO_GENRE, &value);
1550 g_print(" ==> [Player_Test] PLAYER_CONTENT_INFO_GENRE: [%s ] \n", value);
1551 player_get_content_info(g_player[0], PLAYER_CONTENT_INFO_TITLE, &value);
1552 g_print(" ==> [Player_Test] PLAYER_CONTENT_INFO_TITLE: [%s ] \n", value);
1555 player_get_album_art(g_player[0], &album, &size);
1556 g_print(" ==> [Player_Test] Album art : [ data : %p, size : %d ]\n", (unsigned int *)album, size);
1558 if (value != NULL) {
1566 int fps, v_bit_rate;
1567 player_get_audio_stream_info(g_player[0], &sample_rate, &channel, &bit_rate);
1568 g_print(" ==> [Player_Test] Sample Rate: [%d ] , Channel: [%d ] , Bit Rate: [%d ] \n", sample_rate, channel, bit_rate);
1570 player_get_video_stream_info(g_player[0], &fps, &v_bit_rate);
1571 g_print(" ==> [Player_Test] fps: [%d ] , Bit Rate: [%d ] \n", fps, v_bit_rate);
1573 char *audio_codec = NULL;
1574 char *video_codec = NULL;
1575 player_get_codec_info(g_player[0], &audio_codec, &video_codec);
1576 if (audio_codec != NULL) {
1577 g_print(" ==> [Player_Test] Audio Codec: [%s ] \n", audio_codec);
1581 if (video_codec != NULL) {
1582 g_print(" ==> [Player_Test] Video Codec: [%s ] \n", video_codec);
1586 player_get_video_size(g_player[0], &w, &h);
1587 g_print(" ==> [Player_Test] Width: [%d ] , Height: [%d ] \n", w, h);
1590 static void set_gapless(bool gapless)
1593 g_print("not support at TV profile");
1597 if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
1598 if (player_set_gapless(g_player[0], gapless) != PLAYER_ERROR_NONE)
1599 g_print("failed set_gapless\n");
1602 for (i = 0; i < g_handle_num; i++) {
1603 if (player_set_gapless(g_player[i], gapless) != PLAYER_ERROR_NONE)
1604 g_print("failed to set_gapless\n");
1609 static void set_looping(bool looping)
1611 if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
1612 if (player_set_looping(g_player[0], looping) != PLAYER_ERROR_NONE)
1613 g_print("failed to set_looping\n");
1616 for (i = 0; i < g_handle_num; i++) {
1617 if (player_set_looping(g_player[i], looping) != PLAYER_ERROR_NONE)
1618 g_print("failed to set_looping\n");
1623 static void get_looping(bool * looping)
1625 player_is_looping(g_player[0], looping);
1626 g_print(" ==> [Player_Test] looping = %d\n", *looping);
1629 static void change_surface(int option)
1631 player_display_type_e surface_type = 0;
1632 int ret = PLAYER_ERROR_NONE;
1633 #ifdef _ACTIVATE_EOM_
1635 eom_output_mode_e output_mode;
1640 surface_type = PLAYER_DISPLAY_TYPE_OVERLAY;
1641 g_print("change surface type to X\n");
1643 #ifdef TIZEN_FEATURE_EVAS_RENDERER
1646 surface_type = PLAYER_DISPLAY_TYPE_EVAS;
1647 g_print("change surface type to EVAS\n");
1651 g_print("change surface type to NONE\n");
1652 surface_type = g_current_surface_type = PLAYER_DISPLAY_TYPE_NONE;
1653 player_set_display(g_player[0], PLAYER_DISPLAY_TYPE_NONE, NULL);
1656 g_print("invalid surface type\n");
1660 if (surface_type == g_current_surface_type) {
1661 g_print("same with the previous surface type(%d)\n", g_current_surface_type);
1664 player_state_e player_state = PLAYER_STATE_NONE;
1665 ret = player_get_state(g_player[0], &player_state);
1667 g_print("failed to player_get_state(), ret(0x%x)\n", ret);
1671 if (surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
1672 #ifdef _ACTIVATE_EOM_
1673 hdmi_output_id = eom_get_output_id("HDMI");
1674 if (hdmi_output_id == 0)
1675 g_print("[eom] error : HDMI output id is NULL.\n");
1677 eom_get_output_mode(hdmi_output_id, &output_mode);
1678 if (output_mode == EOM_OUTPUT_MODE_NONE) {
1681 g_win_id = create_win(PACKAGE);
1682 if (g_win_id == NULL)
1684 g_print("create win_id %p\n", g_win_id);
1685 create_render_rect_and_bg(g_win_id);
1686 elm_win_activate(g_win_id);
1687 evas_object_show(g_win_id);
1688 g_win_id = selected_win_id;
1690 #ifdef _ACTIVATE_EOM_
1695 ret = player_set_display(g_player[0], surface_type, GET_DISPLAY(selected_win_id));
1698 g_win_id = create_win(PACKAGE);
1699 if (g_win_id == NULL)
1701 g_print("create win_id %p\n", g_win_id);
1702 create_render_rect_and_bg(g_win_id);
1703 elm_win_activate(g_win_id);
1704 evas_object_show(g_win_id);
1707 for (i = 0; i < g_handle_num; i++) {
1708 /* Create evas image object for EVAS surface */
1710 g_eo[i] = create_image_object(g_win_id);
1711 g_print("create eo[%d] %p\n", i, g_eo[i]);
1712 evas_object_image_size_set(g_eo[i], 500, 500);
1713 evas_object_image_fill_set(g_eo[i], 0, 0, 500, 500);
1714 evas_object_resize(g_eo[i], 500, 500);
1715 evas_object_move(g_eo[i], i * 20, i * 20);
1717 ret = player_set_display(g_player[i], surface_type, g_eo[i]);
1722 g_print("failed to set display, surface_type(%d)\n", surface_type);
1725 g_current_surface_type = surface_type;
1730 static void set_display_mode(int mode)
1732 if (player_set_display_mode(g_player[0], mode) != PLAYER_ERROR_NONE)
1733 g_print("failed to player_set_display_mode\n");
1736 static void get_display_mode()
1738 player_display_mode_e mode;
1739 player_get_display_mode(g_player[0], &mode);
1740 g_print(" ==> [Player_Test] Display mode: [%d ] \n", mode);
1743 static void set_display_roi_area(int x, int y, int width, int height)
1745 player_set_display_roi_area(g_player[0], x, y, width, height);
1746 g_print(" ==> [Player_Test] Display roi area: [x(%d) y(%d) width(%d) height(%d)] \n", x, y, width, height);
1749 static void set_display_rotation(int rotation)
1751 if (player_set_display_rotation(g_player[0], rotation) != PLAYER_ERROR_NONE)
1752 g_print("failed to set_display_rotation\n");
1753 #ifdef USE_EVENT_HANDLER
1754 event_handler_set_window_parameters();
1758 static void get_display_rotation()
1760 player_display_rotation_e rotation = 0;
1761 player_get_display_rotation(g_player[0], &rotation);
1762 g_print(" ==> [Player_Test] Video Overlay Display rotation: [%d ] \n", rotation);
1765 static void set_display_visible(bool visible)
1767 if (player_set_display_visible(g_player[0], visible) != PLAYER_ERROR_NONE)
1768 g_print("failed to player_set_x11_display_visible\n");
1771 static void get_display_visible(bool * visible)
1773 player_is_display_visible(g_player[0], visible);
1774 g_print(" ==> [Player_Test] Video Overlay Display Visible = %d\n", *visible);
1777 static void input_subtitle_filename(char *subtitle_filename)
1779 int len = strlen(subtitle_filename);
1781 if (len < 1 || len > MAX_STRING_LEN)
1784 strncpy(g_subtitle_uri, subtitle_filename, len);
1785 g_print("subtitle uri is set to %s\n", g_subtitle_uri);
1786 player_set_subtitle_path(g_player[0], g_subtitle_uri);
1789 static void switch_subtitle(int index)
1791 char *lang_code = NULL;
1792 if (player_select_track(g_player[0], PLAYER_STREAM_TYPE_TEXT, index) != PLAYER_ERROR_NONE)
1793 g_print("player_select_track failed\n");
1795 if (player_get_track_language_code(g_player[0], PLAYER_STREAM_TYPE_TEXT, index, &lang_code) == PLAYER_ERROR_NONE) {
1796 g_print("selected track code %s\n", lang_code);
1801 static void get_track_info(int index)
1803 int count = 0, cur_index = 0;
1805 char *lang_code = NULL;
1807 if (index != PLAYER_STREAM_TYPE_AUDIO &&
1808 index != PLAYER_STREAM_TYPE_TEXT) {
1809 g_print("invalid stream type %d", index);
1813 ret = player_get_track_count(g_player[0], index, &count);
1814 if (ret != PLAYER_ERROR_NONE)
1815 g_print("player_get_track_count fail!!!!\n");
1818 player_get_current_track(g_player[0], index, &cur_index);
1819 g_print("total track: %d, curr track: %d\n", count, cur_index);
1821 for (idx = 0; idx < count; idx++) {
1822 player_get_track_language_code(g_player[0], index, idx, &lang_code);
1823 g_print("track info = [%d] %s\n", idx, lang_code);
1826 g_print("no track\n");
1830 static void capture_video()
1832 if (player_capture_video(g_player[0], video_captured_cb, NULL) != PLAYER_ERROR_NONE)
1833 g_print("failed to player_capture_video\n");
1836 static void set_audio_only(int val)
1838 int ret = PLAYER_ERROR_NONE;
1839 bool audio_only = false;
1840 ret = player_is_audio_only(g_player[0], &audio_only);
1841 if (ret != PLAYER_ERROR_NONE)
1842 g_print("failed to get current setting. 0x%X\n", ret);
1844 g_print("current audio only mode : %s\n", (audio_only) ? "enabled" : "disabled");
1845 g_print("new audio only mode : %s\n", (val != 0) ? "enabled" : "disabled");
1848 ret = player_set_audio_only(g_player[0], true);
1850 ret = player_set_audio_only(g_player[0], false);
1851 g_print("finished 0x%X\n", ret);
1854 static void decoding_audio()
1858 char *suffix, *dump_path;
1859 GDateTime *time = g_date_time_new_now_local();
1861 suffix = g_date_time_format(time, "%Y%m%d_%H%M%S.pcm");
1862 dump_path = g_strjoin(NULL, PLAYER_TEST_DUMP_PATH_PREFIX, suffix, NULL);
1863 g_pcm_fd = fopen(dump_path, "w+");
1866 g_date_time_unref(time);
1868 g_print("Can not create debug dump file");
1870 ret = player_set_audio_frame_decoded_cb(g_player[0], 0, 0, audio_frame_decoded_cb, (void *)g_player[0]);
1871 if (ret != PLAYER_ERROR_NONE)
1872 g_print("player_set_audio_frame_decoded_cb is failed (errno = %d) \n", ret);
1876 static void set_audio_eq(int value)
1878 bool available = FALSE;
1879 int index, min = 0, max = 0;
1882 if (player_audio_effect_equalizer_is_available(g_player[0], &available) != PLAYER_ERROR_NONE)
1883 g_print("failed to player_audio_effect_equalizer_is_available\n");
1886 if ((player_audio_effect_get_equalizer_bands_count(g_player[0], &index) != PLAYER_ERROR_NONE) ||
1887 (player_audio_effect_get_equalizer_level_range(g_player[0], &min, &max) != PLAYER_ERROR_NONE) ||
1888 (player_audio_effect_set_equalizer_band_level(g_player[0], index / 2, max) != PLAYER_ERROR_NONE))
1889 g_print("failed to player_audio_effect_set_equalizer_band_level index %d, level %d\n", index / 2, max);
1894 if (player_audio_effect_equalizer_clear(g_player[0]) != PLAYER_ERROR_NONE)
1895 g_print("failed to player_audio_effect_equalizer_clear\n");
1900 static void get_audio_eq()
1902 int index, min, max, value;
1903 player_audio_effect_get_equalizer_bands_count(g_player[0], &index);
1904 g_print(" ==> [Player_Test] eq bands count: [%d] \n", index);
1905 player_audio_effect_get_equalizer_level_range(g_player[0], &min, &max);
1906 g_print(" ==> [Player_Test] eq bands range: [%d~%d] \n", min, max);
1907 player_audio_effect_get_equalizer_band_level(g_player[0], index / 2, &value);
1908 g_print(" ==> [Player_Test] eq bands level: [%d] \n", value);
1909 player_audio_effect_get_equalizer_band_frequency(g_player[0], 0, &value);
1910 g_print(" ==> [Player_Test] eq bands frequency: [%d] \n", value);
1911 player_audio_effect_get_equalizer_band_frequency_range(g_player[0], 0, &value);
1912 g_print(" ==> [Player_Test] eq bands frequency range: [%d] \n", value);
1915 static void video360_set_enable(bool enable)
1917 #ifdef USE_EVENT_HANDLER
1918 event_handler_set_dov_fov();
1921 if (player_360_set_enable(g_player[0], enable) != PLAYER_ERROR_NONE)
1922 g_print("failed to %s video 360 mode\n", enable ? "enable" : "disable");
1925 static void video360_get_enable()
1929 if (player_360_is_enabled(g_player[0], &enable) != PLAYER_ERROR_NONE)
1930 g_print("failed to get video 360 mode status\n");
1932 g_print(" ==> [Player_Test] Video 360 mode = %s\n", enable ? "enabled" : "disabled");
1935 static void video360_set_fov(int hfov, int vfov)
1937 #ifdef USE_EVENT_HANDLER
1938 mm_navevent_handler_size_s fov;
1942 mm_navevent_handler_set_fov_size(event_handler, fov);
1944 if (player_360_set_field_of_view(g_player[0], hfov, vfov) != PLAYER_ERROR_NONE)
1945 g_print("failed to set video 360 field of view\n");
1948 static void video360_get_fov()
1952 if (player_360_get_field_of_view(g_player[0], &hfov, &vfov) != PLAYER_ERROR_NONE)
1953 g_print("failed to get video 360 field of view\n");
1955 g_print(" ==> [Player_Test] Video 360 FOV = %dx%d deg.\n", hfov, vfov);
1958 static void video360_set_dov(int yaw_deg, int pitch_deg)
1962 angles[0] = M_PI * yaw_deg / 180.0f;
1963 angles[1] = M_PI * pitch_deg / 180.0f;
1966 #ifdef USE_EVENT_HANDLER
1967 mm_navevent_handler_set_angles(event_handler, angles);
1969 if (player_360_set_direction_of_view(g_player[0], angles[0], angles[1]) != PLAYER_ERROR_NONE)
1970 g_print("failed to set video 360 direction of view\n");
1973 static void video360_get_dov()
1977 if (player_360_get_direction_of_view(g_player[0], &yaw, &pitch) != PLAYER_ERROR_NONE)
1978 g_print("failed to get video 360 direction of view\n");
1980 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));
1983 static void video360_set_zoom(float zoom)
1985 if (player_360_set_zoom(g_player[0], zoom) != PLAYER_ERROR_NONE)
1986 g_print("failed to set video 360 zoom\n");
1989 static void video360_get_zoom()
1993 if (player_360_get_zoom(g_player[0], &zoom) != PLAYER_ERROR_NONE)
1994 g_print("failed to get video 360 zoom\n");
1996 g_print(" ==> [Player_Test] Video 360 zoom = %f\n", zoom);
1999 #ifdef USE_EVENT_HANDLER
2000 static void event_handler_cb(enum libinput_event_type ev_t, int x, int y, void * data, float e[3])
2002 if (ev_t == LIBINPUT_EVENT_TOUCH_MOTION)
2003 if (player_360_set_direction_of_view(g_player[0], e[0], e[1]) != PLAYER_ERROR_NONE)
2004 g_print("Event handler callback: failed to set direction of view\n");
2007 static void event_handler_set_dov_fov()
2010 mm_navevent_handler_size_s fov;
2012 if (player_360_get_direction_of_view(g_player[0], &angles[0], &angles[1]) != PLAYER_ERROR_NONE) {
2013 g_print("Failed to get video360 direction of view\n");
2016 if (player_360_get_field_of_view(g_player[0], &fov.width, &fov.height) != PLAYER_ERROR_NONE) {
2017 g_print("Failed to get video360 field of view\n");
2020 mm_navevent_handler_set_angles(event_handler, angles);
2021 mm_navevent_handler_set_fov_size(event_handler, fov);
2024 static void event_handler_set_window_parameters()
2026 player_display_rotation_e window_orientation;
2027 mm_navevent_handler_size_s window_size;
2030 player_get_display_rotation(g_player[0], &window_orientation);
2031 elm_win_screen_size_get(selected_win_id, NULL, NULL, &window_size.width, &window_size.height);
2033 image_ratio = (float) image_size.width / (float) image_size.height;
2035 if (window_orientation == PLAYER_DISPLAY_ROTATION_NONE ||
2036 window_orientation == PLAYER_DISPLAY_ROTATION_180) {
2037 window_size.height = (int)((float) window_size.width / image_ratio);
2039 window_size.height = window_size.width;
2040 window_size.width = (int)((float) window_size.width * image_ratio);
2043 mm_navevent_handler_set_window_parameters(event_handler,
2044 (mm_navevent_handler_orientation_e) window_orientation, window_size);
2054 if (g_player[0] != NULL || g_player[1] != NULL) {
2055 _player_unprepare();
2062 media_format_unref(g_audio_fmt);
2065 media_format_unref(g_video_fmt);
2068 void play_with_ini(char *file_path)
2070 input_filename(file_path);
2074 void _interpret_main_menu(char *cmd)
2076 int len = strlen(cmd);
2078 if (strncmp(cmd, "a", 1) == 0) {
2079 g_menu_state = CURRENT_STATUS_FILENAME;
2080 } else if (strncmp(cmd, "b", 1) == 0) {
2082 } else if (strncmp(cmd, "c", 1) == 0) {
2084 } else if (strncmp(cmd, "d", 1) == 0) {
2086 } else if (strncmp(cmd, "e", 1) == 0) {
2088 } else if (strncmp(cmd, "S", 1) == 0) {
2090 } else if (strncmp(cmd, "f", 1) == 0) {
2091 g_menu_state = CURRENT_STATUS_VOLUME;
2092 } else if (strncmp(cmd, "g", 1) == 0) {
2095 get_volume(&left, &right);
2096 } else if (strncmp(cmd, "z", 1) == 0) {
2097 g_menu_state = CURRENT_STATUS_SOUND_TYPE;
2098 } else if (strncmp(cmd, "k", 1) == 0) {
2099 g_menu_state = CURRENT_STATUS_SOUND_STREAM_INFO;
2100 } else if (strncmp(cmd, "h", 1) == 0) {
2101 g_menu_state = CURRENT_STATUS_MUTE;
2102 } else if (strncmp(cmd, "i", 1) == 0) {
2105 } else if (strncmp(cmd, "j", 1) == 0) {
2106 g_menu_state = CURRENT_STATUS_POSITION_TIME;
2107 } else if (strncmp(cmd, "l", 1) == 0) {
2109 } else if (strncmp(cmd, "m", 1) == 0) {
2111 } else if (strncmp(cmd, "n", 1) == 0) {
2113 } else if (strncmp(cmd, "o", 1) == 0) {
2114 g_menu_state = CURRENT_STATUS_LOOPING;
2115 } else if (strncmp(cmd, "p", 1) == 0) {
2117 get_looping(&looping);
2118 } else if (strncmp(cmd, "r", 1) == 0) {
2119 g_menu_state = CURRENT_STATUS_DISPLAY_MODE;
2120 } else if (strncmp(cmd, "s", 1) == 0) {
2122 } else if (strncmp(cmd, "t", 1) == 0) {
2123 g_menu_state = CURRENT_STATUS_DISPLAY_ROTATION;
2124 } else if (strncmp(cmd, "u", 1) == 0) {
2125 get_display_rotation();
2126 } else if (strncmp(cmd, "v", 1) == 0) {
2127 g_menu_state = CURRENT_STATUS_DISPLAY_VISIBLE;
2128 } else if (strncmp(cmd, "w", 1) == 0) {
2130 get_display_visible(&visible);
2131 } else if (strncmp(cmd, "A", 1) == 0) {
2132 g_menu_state = CURRENT_STATUS_SUBTITLE_FILENAME;
2133 } else if (strncmp(cmd, "C", 1) == 0) {
2135 } else if (strncmp(cmd, "D", 1) == 0) {
2137 } else if (strncmp(cmd, "q", 1) == 0) {
2138 quit_pushing = TRUE;
2140 } else if (strncmp(cmd, "E", 1) == 0) {
2141 g_menu_state = CURRENT_STATUS_AUDIO_EQUALIZER;
2142 } else if (strncmp(cmd, "H", 1) == 0) {
2145 g_print("unknown menu \n");
2147 } else if (len == 2) {
2148 if (strncmp(cmd, "pr", 2) == 0) {
2150 if (g_current_surface_type == -1) {
2151 g_print("You must set display surface type before setting prepare. please 'pr' after setting display surface type.\n");
2152 g_menu_state = CURRENT_STATUS_DISPLAY_SURFACE_CHANGE;
2154 _player_prepare(FALSE);
2155 } else if (strncmp(cmd, "pa", 2) == 0) {
2157 if (g_current_surface_type == -1) {
2158 g_print("You must set display surface type before setting prepare. please 'pr' after setting display surface type.\n");
2159 g_menu_state = CURRENT_STATUS_DISPLAY_SURFACE_CHANGE;
2161 _player_prepare(TRUE);
2162 } else if (strncmp(cmd, "un", 2) == 0) {
2163 _player_unprepare();
2164 } else if (strncmp(cmd, "dt", 2) == 0) {
2166 } else if (strncmp(cmd, "sp", 2) == 0) {
2167 _player_set_progressive_download();
2168 } else if (strncmp(cmd, "gp", 2) == 0) {
2169 _player_get_progressive_download_status();
2170 } else if (strncmp(cmd, "mp", 2) == 0) {
2171 g_memory_playback = (g_memory_playback ? FALSE : TRUE);
2172 g_print("memory playback = %d\n", g_memory_playback);
2173 } else if (strncmp(cmd, "ds", 2) == 0) {
2174 g_menu_state = CURRENT_STATUS_DISPLAY_SURFACE_CHANGE;
2175 } else if (strncmp(cmd, "dr", 2) == 0) {
2176 g_print("now, PLAYER_DISPLAY_MODE_DST_ROI(display mode) is set\n");
2177 g_menu_state = CURRENT_STATUS_DISPLAY_DST_ROI;
2178 } else if (strncmp(cmd, "nb", 2) == 0) {
2179 g_menu_state = CURRENT_STATUS_HANDLE_NUM;
2180 } else if (strncmp(cmd, "tr", 2) == 0) {
2181 g_menu_state = CURRENT_STATUS_PLAYBACK_RATE;
2182 } else if (strncmp(cmd, "ss", 2) == 0) {
2183 g_menu_state = CURRENT_STATUS_SWITCH_SUBTITLE;
2184 } else if (strncmp(cmd, "X3", 2) == 0) {
2185 audio_frame_decoded_cb_ex(TRUE);
2186 } else if (strncmp(cmd, "X4", 2) == 0) {
2187 audio_frame_decoded_cb_ex(FALSE);
2188 } else if (strncmp(cmd, "ep", 2) == 0) {
2189 _player_enable_tsurf_pool();
2190 } else if (strncmp(cmd, "su", 2) == 0) {
2191 g_menu_state = CURRENT_STATUS_NEXT_URI;
2192 } else if (strncmp(cmd, "gu", 2) == 0) {
2194 } else if (strncmp(cmd, "sg", 2) == 0) {
2195 g_menu_state = CURRENT_STATUS_GAPLESS;
2196 } else if (strncmp(cmd, "tl", 2) == 0) {
2197 g_menu_state = CURRENT_STATUS_GET_TRACK_INFO;
2198 } else if (strncmp(cmd, "vi", 2) == 0) {
2200 } else if (strncmp(cmd, "vs", 2) == 0) {
2201 g_menu_state = CURRENT_STATUS_SET_MAX_BANDWIDTH_VARIANT;
2202 } else if (strncmp(cmd, "vg", 2) == 0) {
2203 get_variant_limit();
2204 } else if (strncmp(cmd, "ao", 2) == 0) {
2205 g_menu_state = CURRENT_STATUS_SET_AUDIO_ONLY;
2206 } else if (strncmp(cmd, "bf", 2) == 0) {
2207 g_menu_state = CURRENT_STATUS_SET_PRE_BUFFERING_SIZE;
2209 g_print("unknown menu \n");
2211 } else if (len == 3) {
2212 if (strncmp(cmd, "trs", 3) == 0)
2213 g_menu_state = CURRENT_STATUS_STREAMING_PLAYBACK_RATE;
2215 g_print("unknown menu \n");
2216 } else if (len == 4) {
2217 if (!strncmp(cmd, "v3se", 4))
2218 g_menu_state = CURRENT_STATUS_VIDEO360_SET_ENABLE;
2219 else if (!strncmp(cmd, "v3ge", 4))
2220 video360_get_enable();
2221 else if (!strncmp(cmd, "v3sd", 4))
2222 g_menu_state = CURRENT_STATUS_VIDEO360_SET_DOV;
2223 else if (!strncmp(cmd, "v3gd", 4))
2225 else if (!strncmp(cmd, "v3sf", 4))
2226 g_menu_state = CURRENT_STATUS_VIDEO360_SET_FOV;
2227 else if (!strncmp(cmd, "v3gf", 4))
2229 else if (!strncmp(cmd, "v3sz", 4))
2230 g_menu_state = CURRENT_STATUS_VIDEO360_SET_ZOOM;
2231 else if (!strncmp(cmd, "v3gz", 4))
2232 video360_get_zoom();
2234 g_print("unknown menu \n");
2236 g_print("unknown menu \n");
2239 void display_sub_basic()
2242 g_print("=========================================================================================\n");
2243 g_print(" Player Test (press q to quit) \n");
2244 g_print("-----------------------------------------------------------------------------------------\n");
2245 g_print("[playback] a. Create\t");
2246 g_print("pr. Prepare \t");
2247 g_print("pa. Prepare async \t");
2248 g_print("b. Play \t");
2249 g_print("c. Stop \t");
2250 g_print("d. Resume\t");
2251 g_print("e. Pause \t");
2252 g_print("un. Unprepare \t");
2253 g_print("dt. Destroy \n");
2254 g_print("[State] S. Player State \n");
2255 g_print("[ volume ] f. Set Volume\t");
2256 g_print("g. Get Volume\t");
2257 g_print("z. Set Sound type\t");
2258 g_print("k. Set Sound Stream Info.\n");
2259 g_print("[ mute ] h. Set Mute\t");
2260 g_print("i. Get Mute\n");
2261 g_print("[audio eq] E. Set Audio EQ\t");
2262 g_print("H. Get Audio EQ\n");
2263 g_print("[position] j. Set Position \t");
2264 g_print("l. Get Position\n");
2265 g_print("[trick] tr. set playback rate\n");
2266 g_print("[duration] m. Get Duration\n");
2267 g_print("[Stream Info] n. Get stream info (Video Size, codec, audio stream info, and tag info)\n");
2268 g_print("[Looping] o. Set Looping\t");
2269 g_print("p. Get Looping\n");
2270 g_print("[display] v. Set display visible\t");
2271 g_print("w. Get display visible\n");
2272 g_print("[display] ds. Change display surface type\n");
2273 g_print("[display] dr. set display roi area\n");
2274 g_print("[overlay display] r. Set display mode\t");
2275 g_print("s. Get display mode\n");
2276 g_print("[overlay display] t. Set display Rotation\n");
2277 g_print("[Track] tl. Get Track language info(single only)\n");
2278 g_print("[Variant] vi. Get Streaming Variant Info\t");
2279 g_print("vs. Set max limit of variant\t");
2280 g_print("vg. Get max limit of variant\n");
2281 g_print("[audio only] ao. set audio only\n");
2282 g_print("[subtitle] A. Set(or change) subtitle path\n");
2283 g_print("[subtitle] ss. Select(or change) subtitle track\n");
2284 g_print("[Video Capture] C. Capture \n");
2285 g_print("[next uri] su. set next uri. \t");
2286 g_print("gu. get next uri. \t");
2287 g_print("sg. set gapless. \n");
2288 g_print("[audio_frame_decoded_cb_ex] X3. set audio_cb with sync\t");
2289 g_print("X4. set audio_cb with async \n");
2290 g_print("[video_frame_decoded_cb] ep. enable tbm surface pool\n");
2291 g_print("[buffering] bf. set new buffering size\n");
2292 g_print("[Video 360] v3se. Set Enable\t\t");
2293 g_print("v3ge. Get Enable\n");
2294 g_print("[Video 360] v3sd. Set Direction Of View\t");
2295 g_print("v3gd. Get Direction Of View\n");
2296 g_print("[Video 360] v3sf. Set Field Of View\t");
2297 g_print("v3gf. Get Field Of View\n");
2298 g_print("[Video 360] v3sz. Set Zoom\t\t");
2299 g_print("v3gz. Get Zoom\n");
2300 g_print("[etc] sp. Set Progressive Download\t");
2301 g_print("gp. Get Progressive Download status\t");
2302 g_print("mp. memory playback\n");
2304 g_print("=========================================================================================\n");
2307 static void displaymenu()
2309 if (g_menu_state == CURRENT_STATUS_MAINMENU) {
2310 display_sub_basic();
2311 } else if (g_menu_state == CURRENT_STATUS_HANDLE_NUM) {
2312 g_print("*** input number of handles.(recommended only for EVAS surface)\n");
2313 } else if (g_menu_state == CURRENT_STATUS_FILENAME) {
2314 g_print("*** input mediapath.\n");
2315 } else if (g_menu_state == CURRENT_STATUS_VOLUME) {
2316 g_print("*** input volume value.(0~1.0)\n");
2317 } else if (g_menu_state == CURRENT_STATUS_SOUND_TYPE) {
2318 g_print("*** input sound type.(0:SYSTEM 1:NOTIFICATION 2:ALARM 3:RINGTONE 4:MEDIA 5:CALL 6:VOIP 7:FIXED)\n");
2319 } else if (g_menu_state == CURRENT_STATUS_SOUND_STREAM_INFO) {
2320 g_print("*** input sound stream type.(0:MEDIA 1:SYSTEM 2:ALARM 3:NOTIFICATION 4:EMERGENCY 5:VOICE_INFORMATION 9:MEDIA_EXT_ONLY)\n");
2321 } else if (g_menu_state == CURRENT_STATUS_MUTE) {
2322 g_print("*** input mute value.(0: Not Mute, 1: Mute) \n");
2323 } else if (g_menu_state == CURRENT_STATUS_POSITION_TIME) {
2324 g_print("*** input position value(msec)\n");
2325 } else if (g_menu_state == CURRENT_STATUS_POSITION_ACCURATE) {
2326 g_print("*** input accurate value(0/1)\n");
2327 } else if (g_menu_state == CURRENT_STATUS_LOOPING) {
2328 g_print("*** input looping value.(0: Not Looping, 1: Looping) \n");
2329 } else if (g_menu_state == CURRENT_STATUS_DISPLAY_SURFACE_CHANGE) {
2330 g_print("*** input display surface type.(0: Wayland surface, 1: EVAS surface, 2: No use surface (e.g: audio playback)) \n");
2331 } else if (g_menu_state == CURRENT_STATUS_DISPLAY_MODE) {
2332 g_print("*** input display mode value.(0: LETTER BOX, 1: ORIGIN SIZE, 2: FULL_SCREEN, 3: CROPPED_FULL, 4: ORIGIN_OR_LETTER) \n");
2333 } else if (g_menu_state == CURRENT_STATUS_DISPLAY_DST_ROI) {
2334 g_print("*** input display roi value sequentially.(x, y, w, h)\n");
2335 } else if (g_menu_state == CURRENT_STATUS_DISPLAY_ROTATION) {
2336 g_print("*** input display rotation value.(0: NONE, 1: 90, 2: 180, 3: 270, 4:F LIP_HORZ, 5: FLIP_VERT ) \n");
2337 } else if (g_menu_state == CURRENT_STATUS_DISPLAY_VISIBLE) {
2338 g_print("*** input display visible value.(0: HIDE, 1: SHOW) \n");
2339 } else if (g_menu_state == CURRENT_STATUS_SUBTITLE_FILENAME) {
2340 g_print(" *** input subtitle file path.\n");
2341 } else if (g_menu_state == CURRENT_STATUS_AUDIO_EQUALIZER) {
2342 g_print(" *** input audio eq value.(0: UNSET, 1: SET) \n");
2343 } else if (g_menu_state == CURRENT_STATUS_PLAYBACK_RATE || g_menu_state == CURRENT_STATUS_STREAMING_PLAYBACK_RATE) {
2344 g_print(" *** input playback rate.(-5.0 ~ 5.0)\n");
2345 } else if (g_menu_state == CURRENT_STATUS_SWITCH_SUBTITLE) {
2346 int count = 0, cur_index = 0;
2349 ret = player_get_track_count(g_player[0], PLAYER_STREAM_TYPE_TEXT, &count);
2350 if (ret != PLAYER_ERROR_NONE)
2351 g_print("player_get_track_count fail!!!!\n");
2353 g_print("Total subtitle tracks = %d \n", count);
2354 player_get_current_track(g_player[0], PLAYER_STREAM_TYPE_TEXT, &cur_index);
2355 g_print("Current index = %d \n", cur_index);
2356 g_print(" *** input correct index 0 to %d\n:", (count - 1));
2358 g_print("no track\n");
2359 } else if (g_menu_state == CURRENT_STATUS_NEXT_URI) {
2360 g_print("*** input next uri.\n");
2361 } else if (g_menu_state == CURRENT_STATUS_GAPLESS) {
2362 g_print("*** input gapless value.(0:disable, 1: enable) \n");
2363 } else if (g_menu_state == CURRENT_STATUS_GET_TRACK_INFO) {
2364 g_print("*** input stream type.(1:audio, 3:text) \n");
2365 } else if (g_menu_state == CURRENT_STATUS_SET_MAX_BANDWIDTH_VARIANT) {
2366 g_print("*** set max bandwidth (default: -1) \n");
2367 } else if (g_menu_state == CURRENT_STATUS_SET_MAX_WIDTH_VARIANT) {
2368 g_print("*** set max width (default: -1) \n");
2369 } else if (g_menu_state == CURRENT_STATUS_SET_MAX_HEIGHT_VARIANT) {
2370 g_print("*** set max height (default: -1) \n");
2371 } else if (g_menu_state == CURRENT_STATUS_SET_AUDIO_ONLY) {
2372 g_print("*** set audio only mode (0:disable, 1:enable) \n");
2373 } else if (g_menu_state == CURRENT_STATUS_SET_PRE_BUFFERING_SIZE) {
2374 g_print("*** set pre buffering size (ms) \n");
2375 } else if (g_menu_state == CURRENT_STATUS_SET_RE_BUFFERING_SIZE) {
2376 g_print("*** set re buffering size (ms) \n");
2377 } else if (g_menu_state == CURRENT_STATUS_VIDEO360_SET_ENABLE) {
2378 g_print("*** input video 360 status (0: disabled (full panorama), 1: enabled)\n");
2379 } else if (g_menu_state == CURRENT_STATUS_VIDEO360_SET_DOV) {
2380 g_print("*** input direction of view yaw angle (+/- 180 deg.)\n");
2381 } else if (g_menu_state == CURRENT_STATUS_VIDEO360_SET_DOV1) {
2382 g_print("*** input direction of view pitch angle (+/- 90 deg.)\n");
2383 } else if (g_menu_state == CURRENT_STATUS_VIDEO360_SET_FOV) {
2384 g_print("*** input horizontal field of view angle (1~360 deg.)\n");
2385 } else if (g_menu_state == CURRENT_STATUS_VIDEO360_SET_FOV1) {
2386 g_print("*** input vertical field of view angle (1~180 deg.)\n");
2387 } else if (g_menu_state == CURRENT_STATUS_VIDEO360_SET_ZOOM) {
2388 g_print("*** input zoom factor.(1.0~10.0, where 1.0 - no zoom, actual image) \n");
2390 g_print("*** unknown status.\n");
2396 gboolean timeout_menu_display(void *data)
2402 gboolean timeout_quit_program(void *data)
2408 void reset_menu_state(void)
2410 g_menu_state = CURRENT_STATUS_MAINMENU;
2413 static void interpret(char *cmd)
2415 static int value1, value2;
2417 switch (g_menu_state) {
2418 case CURRENT_STATUS_MAINMENU:
2420 _interpret_main_menu(cmd);
2423 case CURRENT_STATUS_HANDLE_NUM:
2425 int num_handle = atoi(cmd);
2426 if (0 >= num_handle || num_handle > MAX_HANDLE)
2427 g_print("not supported this number for handles(%d)\n", num_handle);
2429 g_handle_num = num_handle;
2434 case CURRENT_STATUS_FILENAME:
2436 input_filename(cmd);
2440 case CURRENT_STATUS_VOLUME:
2442 float level = atof(cmd);
2447 case CURRENT_STATUS_SOUND_TYPE:
2449 int type = atoi(cmd);
2450 set_sound_type(type);
2454 case CURRENT_STATUS_SOUND_STREAM_INFO:
2456 int type = atoi(cmd);
2457 set_sound_stream_info(type);
2461 case CURRENT_STATUS_MUTE:
2463 int mute = atoi(cmd);
2468 case CURRENT_STATUS_POSITION_TIME:
2470 seek_info.pos = atoi(cmd);
2471 g_menu_state = CURRENT_STATUS_POSITION_ACCURATE;
2474 case CURRENT_STATUS_POSITION_ACCURATE:
2476 seek_info.accurate = (atoi(cmd) != 0) ? (true) : (false);
2477 set_position(seek_info.pos, seek_info.accurate);
2481 case CURRENT_STATUS_LOOPING:
2483 int looping = atoi(cmd);
2484 set_looping(looping);
2488 case CURRENT_STATUS_GAPLESS:
2490 int gapless = atoi(cmd);
2491 set_gapless(gapless);
2495 case CURRENT_STATUS_DISPLAY_SURFACE_CHANGE:
2497 int type = atoi(cmd);
2498 change_surface(type);
2502 case CURRENT_STATUS_DISPLAY_MODE:
2504 int mode = atoi(cmd);
2505 set_display_mode(mode);
2509 case CURRENT_STATUS_DISPLAY_DST_ROI:
2511 int value = atoi(cmd);
2518 set_display_mode(PLAYER_DISPLAY_MODE_DST_ROI);
2535 set_display_roi_area(x, y, w, h);
2544 case CURRENT_STATUS_DISPLAY_ROTATION:
2546 int rotation = atoi(cmd);
2547 set_display_rotation(rotation);
2551 case CURRENT_STATUS_DISPLAY_VISIBLE:
2553 int visible = atoi(cmd);
2554 set_display_visible(visible);
2558 case CURRENT_STATUS_SUBTITLE_FILENAME:
2560 input_subtitle_filename(cmd);
2564 case CURRENT_STATUS_AUDIO_EQUALIZER:
2566 int value = atoi(cmd);
2567 set_audio_eq(value);
2571 case CURRENT_STATUS_PLAYBACK_RATE:
2573 float rate = atof(cmd);
2574 set_playback_rate(rate, FALSE);
2578 case CURRENT_STATUS_STREAMING_PLAYBACK_RATE:
2580 float rate = atof(cmd);
2581 set_playback_rate(rate, TRUE);
2585 case CURRENT_STATUS_SWITCH_SUBTITLE:
2587 int index = atoi(cmd);
2588 switch_subtitle(index);
2592 case CURRENT_STATUS_NEXT_URI:
2598 case CURRENT_STATUS_GET_TRACK_INFO:
2600 int index = atoi(cmd);
2601 get_track_info(index);
2605 case CURRENT_STATUS_SET_MAX_BANDWIDTH_VARIANT:
2607 int value = atoi(cmd);
2608 max_limit.bandwidth = value;
2609 g_menu_state = CURRENT_STATUS_SET_MAX_WIDTH_VARIANT;
2612 case CURRENT_STATUS_SET_MAX_WIDTH_VARIANT:
2614 int value = atoi(cmd);
2615 max_limit.width = value;
2616 g_menu_state = CURRENT_STATUS_SET_MAX_HEIGHT_VARIANT;
2619 case CURRENT_STATUS_SET_MAX_HEIGHT_VARIANT:
2621 int value = atoi(cmd);
2622 max_limit.height = value;
2623 set_variant_limit();
2627 case CURRENT_STATUS_SET_AUDIO_ONLY:
2629 int value = atoi(cmd);
2630 set_audio_only(value);
2634 case CURRENT_STATUS_SET_PRE_BUFFERING_SIZE:
2636 int value = atoi(cmd);
2637 buff_size.buffer_ms = value;
2638 g_menu_state = CURRENT_STATUS_SET_RE_BUFFERING_SIZE;
2641 case CURRENT_STATUS_SET_RE_BUFFERING_SIZE:
2643 int value = atoi(cmd);
2644 buff_size.rebuffer_ms = value;
2649 case CURRENT_STATUS_VIDEO360_SET_ENABLE:
2651 int enable = atoi(cmd);
2652 video360_set_enable(enable);
2656 case CURRENT_STATUS_VIDEO360_SET_DOV:
2659 g_menu_state = CURRENT_STATUS_VIDEO360_SET_DOV1;
2662 case CURRENT_STATUS_VIDEO360_SET_DOV1:
2665 video360_set_dov(value1, value2);
2669 case CURRENT_STATUS_VIDEO360_SET_FOV:
2672 g_menu_state = CURRENT_STATUS_VIDEO360_SET_FOV1;
2675 case CURRENT_STATUS_VIDEO360_SET_FOV1:
2678 video360_set_fov(value1, value2);
2682 case CURRENT_STATUS_VIDEO360_SET_ZOOM:
2684 float zoom = atof(cmd);
2685 video360_set_zoom(zoom);
2692 g_timeout_add(100, timeout_menu_display, 0);
2695 gboolean input(GIOChannel * channel)
2697 gchar buf[MAX_STRING_LEN];
2699 GError *error = NULL;
2701 g_io_channel_read_chars(channel, buf, MAX_STRING_LEN, &read, &error);
2709 int main(int argc, char *argv[])
2711 GIOChannel *stdin_channel;
2712 stdin_channel = g_io_channel_unix_new(0);
2713 g_io_channel_set_flags(stdin_channel, G_IO_FLAG_NONBLOCK, NULL);
2714 g_io_add_watch(stdin_channel, G_IO_IN, (GIOFunc) input, NULL);
2717 memset(&ad, 0x0, sizeof(appdata));
2720 return appcore_efl_main(PACKAGE, &argc, &argv, &ops);