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.
17 #include <player_internal.h>
18 #include <sound_manager.h>
22 #include <appcore-efl.h>
23 #include <Elementary.h>
25 #include <Ecore_Wayland.h>
33 #define PACKAGE "player_test"
38 #define LOG_TAG "PLAYER_TEST"
40 #define MAX_STRING_LEN 2048
41 #define PLAYER_TEST_DUMP_PATH_PREFIX "/home/owner/dump_pcm_"
42 #define DEFAULT_HTTP_TIMEOUT -1
44 #include <system_info.h>
47 TIZEN_PROFILE_UNKNOWN = 0,
48 TIZEN_PROFILE_MOBILE = 0x1,
49 TIZEN_PROFILE_WEARABLE = 0x2,
50 TIZEN_PROFILE_TV = 0x4,
51 TIZEN_PROFILE_IVI = 0x8,
52 TIZEN_PROFILE_COMMON = 0x10,
59 } adaptive_variant_info_t;
66 static tizen_profile_t _get_tizen_profile()
69 static tizen_profile_t profile = TIZEN_PROFILE_UNKNOWN;
71 if (__builtin_expect(profile != TIZEN_PROFILE_UNKNOWN, 1))
74 system_info_get_platform_string("http://tizen.org/feature/profile", &profileName);
75 switch (*profileName) {
78 profile = TIZEN_PROFILE_MOBILE;
82 profile = TIZEN_PROFILE_WEARABLE;
86 profile = TIZEN_PROFILE_TV;
90 profile = TIZEN_PROFILE_IVI;
92 default: // common or unknown ==> ALL ARE COMMON.
93 profile = TIZEN_PROFILE_COMMON;
99 #define TIZEN_TV ((_get_tizen_profile()) == TIZEN_PROFILE_TV)
101 static gboolean g_memory_playback = FALSE;
102 static char g_uri[MAX_STRING_LEN];
103 static char g_subtitle_uri[MAX_STRING_LEN];
104 static FILE *g_pcm_fd;
106 static gboolean is_es_push_mode = FALSE;
107 static pthread_t g_feed_video_thread_id = 0;
108 static bool g_thread_end = FALSE;
109 static media_packet_h g_audio_pkt = NULL;
110 static media_format_h g_audio_fmt = NULL;
112 static media_packet_h g_video_pkt = NULL;
113 static media_format_h g_video_fmt = NULL;
115 static int _save(unsigned char *src, int length);
117 #define DUMP_OUTBUF 1
119 FILE *fp_out1 = NULL;
120 FILE *fp_out2 = NULL;
124 CURRENT_STATUS_MAINMENU,
125 CURRENT_STATUS_HANDLE_NUM,
126 CURRENT_STATUS_FILENAME,
127 CURRENT_STATUS_VOLUME,
128 CURRENT_STATUS_SOUND_TYPE,
129 CURRENT_STATUS_SOUND_STREAM_INFO,
131 CURRENT_STATUS_POSITION_TIME,
132 CURRENT_STATUS_LOOPING,
133 CURRENT_STATUS_DISPLAY_SURFACE_CHANGE,
134 CURRENT_STATUS_DISPLAY_MODE,
135 CURRENT_STATUS_DISPLAY_DST_ROI,
136 CURRENT_STATUS_DISPLAY_ROTATION,
137 CURRENT_STATUS_DISPLAY_VISIBLE,
138 CURRENT_STATUS_SUBTITLE_FILENAME,
139 CURRENT_STATUS_AUDIO_EQUALIZER,
140 CURRENT_STATUS_PLAYBACK_RATE,
141 CURRENT_STATUS_STREAMING_PLAYBACK_RATE,
142 CURRENT_STATUS_SWITCH_SUBTITLE,
143 CURRENT_STATUS_NEXT_URI,
144 CURRENT_STATUS_GAPLESS,
145 CURRENT_STATUS_GET_TRACK_INFO,
146 CURRENT_STATUS_POSITION_ACCURATE,
147 CURRENT_STATUS_SET_MAX_BANDWIDTH_VARIANT,
148 CURRENT_STATUS_SET_MAX_WIDTH_VARIANT,
149 CURRENT_STATUS_SET_MAX_HEIGHT_VARIANT,
150 CURRENT_STATUS_SET_AUDIO_ONLY,
151 CURRENT_STATUS_SET_PRE_BUFFERING_SIZE,
152 CURRENT_STATUS_SET_RE_BUFFERING_SIZE,
160 #define MAX_HANDLE 20
162 /* for video display */
163 static Evas_Object *g_win_id;
164 #ifdef _ACTIVATE_EOM_
165 static Evas_Object *g_external_win_id;
167 static Evas_Object *selected_win_id;
168 static Evas_Object *g_eo[MAX_HANDLE] = { 0, };
170 static int g_current_surface_type = -1;
171 static adaptive_variant_info_t max_limit = {-1, -1, -1};
172 static buffer_size_t buff_size = {-1, -1};
176 Evas_Object *layout_main; /* layout widget based on EDJ */
177 /* add more variables here */
178 #ifdef _ACTIVATE_EOM_
184 static player_h g_player[MAX_HANDLE] = { 0, };
185 static player_seek_pos_t seek_info = {0};
186 int g_handle_num = 1;
187 int g_menu_state = CURRENT_STATUS_MAINMENU;
188 gboolean quit_pushing;
189 sound_stream_info_h g_stream_info_h = NULL;
191 static void win_del(void *data, Evas_Object * obj, void *event)
196 static Evas_Object *create_win(const char *name)
198 Evas_Object *eo = NULL;
202 g_print("[%s][%d] name=%s\n", __func__, __LINE__, name);
204 eo = elm_win_add(NULL, name, ELM_WIN_BASIC);
206 elm_win_title_set(eo, name);
207 elm_win_borderless_set(eo, EINA_TRUE);
208 evas_object_smart_callback_add(eo, "delete,request", win_del, NULL);
209 elm_win_screen_size_get(eo, NULL, NULL, &w, &h);
210 g_print("window size :%d,%d", w, h);
211 evas_object_resize(eo, w, h);
212 elm_win_autodel_set(eo, EINA_TRUE);
213 elm_win_alpha_set(eo, EINA_TRUE);
218 static Evas_Object *create_image_object(Evas_Object * eo_parent)
223 Evas *evas = evas_object_evas_get(eo_parent);
224 Evas_Object *eo = NULL;
226 eo = evas_object_image_add(evas);
231 void create_render_rect_and_bg(Evas_Object * win)
237 Evas_Object *bg, *rect;
239 bg = elm_bg_add(win);
240 elm_win_resize_object_add(win, bg);
241 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
242 evas_object_show(bg);
244 rect = evas_object_rectangle_add(evas_object_evas_get(win));
249 evas_object_color_set(rect, 0, 0, 0, 0);
250 evas_object_render_op_set(rect, EVAS_RENDER_COPY);
252 elm_win_resize_object_add(win, rect);
253 evas_object_size_hint_weight_set(rect, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
254 evas_object_show(rect);
255 evas_object_show(win);
258 #ifdef _ACTIVATE_EOM_
259 int eom_get_output_id(const char *output_name)
261 eom_output_id *output_ids = NULL;
262 eom_output_id output_id = 0;
263 eom_output_type_e output_type = EOM_OUTPUT_TYPE_UNKNOWN;
268 output_ids = eom_get_eom_output_ids(&id_cnt);
270 g_print("[eom] no external outuputs supported\n");
274 /* find output ids interested */
275 for (i = 0; i < id_cnt; i++) {
276 eom_get_output_type(output_ids[i], &output_type);
277 if (!strncmp(output_name, "HDMI", 4)) {
278 if (output_type == EOM_OUTPUT_TYPE_HDMIA || output_type == EOM_OUTPUT_TYPE_HDMIB) {
279 output_id = output_ids[i];
282 } else if (!strncmp(output_name, "Virtual", 4)) {
283 if (output_type == EOM_OUTPUT_TYPE_VIRTUAL) {
284 output_id = output_ids[i];
296 static void eom_notify_cb_output_add(eom_output_id output_id, void *user_data)
298 appdata *info = (appdata *) user_data;
300 if (info->hdmi_output_id != output_id) {
301 g_print("[eom] OUTPUT ADDED. SKIP. my output ID is %d\n", info->hdmi_output_id);
304 g_print("[eom] output(%d) connected\n", output_id);
305 /* it is for external window */
306 if (!g_external_win_id) {
307 g_external_win_id = elm_win_add(NULL, "External", ELM_WIN_BASIC);
308 if (eom_set_output_window(info->hdmi_output_id, g_external_win_id) == EOM_ERROR_NONE) {
309 create_render_rect_and_bg(g_external_win_id);
310 g_print("[eom] create external window\n");
312 evas_object_del(g_external_win_id);
313 g_external_win_id = NULL;
314 g_print("[eom] create external window fail\n");
319 static void eom_notify_cb_output_remove(eom_output_id output_id, void *user_data)
321 appdata *info = (appdata *) user_data;
322 player_state_e state;
324 if (info->hdmi_output_id != output_id) {
325 g_print("[eom] OUTPUT REMOVED. SKIP. my output ID is %d\n", info->hdmi_output_id);
328 g_print("[eom] output(%d) disconnected\n", output_id);
330 if (selected_win_id == g_external_win_id && g_player[0]) {
331 player_get_state(g_player[0], &state);
332 if (state >= PLAYER_STATE_READY) {
334 g_win_id = create_win(PACKAGE);
335 if (g_win_id == NULL)
337 g_print("create win_id %p\n", g_win_id);
338 create_render_rect_and_bg(g_win_id);
339 elm_win_activate(g_win_id);
340 evas_object_show(g_win_id);
342 player_set_display(g_player[0], PLAYER_DISPLAY_TYPE_OVERLAY, GET_DISPLAY(g_win_id));
346 /* it is for external window */
347 if (g_external_win_id) {
348 evas_object_del(g_external_win_id);
349 g_external_win_id = NULL;
351 selected_win_id = g_win_id;
354 static void eom_notify_cb_mode_changed(eom_output_id output_id, void *user_data)
356 appdata *info = (appdata *) user_data;
357 eom_output_mode_e mode = EOM_OUTPUT_MODE_NONE;
359 if (info->hdmi_output_id != output_id) {
360 g_print("[eom] MODE CHANGED. SKIP. my output ID is %d\n", info->hdmi_output_id);
364 eom_get_output_mode(output_id, &mode);
365 g_print("[eom] output(%d) mode changed(%d)\n", output_id, mode);
368 static void eom_notify_cb_attribute_changed(eom_output_id output_id, void *user_data)
370 appdata *info = (appdata *) user_data;
372 eom_output_attribute_e attribute = EOM_OUTPUT_ATTRIBUTE_NONE;
373 eom_output_attribute_state_e state = EOM_OUTPUT_ATTRIBUTE_STATE_NONE;
375 if (info->hdmi_output_id != output_id) {
376 g_print("[eom] ATTR CHANGED. SKIP. my output ID is %d\n", info->hdmi_output_id);
380 eom_get_output_attribute(output_id, &attribute);
381 eom_get_output_attribute_state(output_id, &state);
383 g_print("[eom] output(%d) attribute changed(%d, %d)\n", output_id, attribute, state);
384 if (state == EOM_OUTPUT_ATTRIBUTE_STATE_ACTIVE) {
385 g_print("[eom] active\n");
386 if (!g_external_win_id) {
387 g_external_win_id = elm_win_add(NULL, "External", ELM_WIN_BASIC);
388 if (eom_set_output_window(info->hdmi_output_id, g_external_win_id) == EOM_ERROR_NONE) {
389 create_render_rect_and_bg(g_external_win_id);
390 g_print("[eom] create external window\n");
392 evas_object_del(g_external_win_id);
393 g_external_win_id = NULL;
394 g_print("[eom] create external window fail\n");
397 selected_win_id = g_external_win_id;
398 /* play video on external window */
400 player_set_display(g_player[0], PLAYER_DISPLAY_TYPE_OVERLAY, GET_DISPLAY(selected_win_id));
401 } else if (state == EOM_OUTPUT_ATTRIBUTE_STATE_INACTIVE) {
402 g_print("[eom] inactive\n");
404 g_win_id = create_win(PACKAGE);
405 if (g_win_id == NULL)
407 g_print("create win_id %p\n", g_win_id);
408 create_render_rect_and_bg(g_win_id);
409 elm_win_activate(g_win_id);
410 evas_object_show(g_win_id);
412 selected_win_id = g_win_id;
414 player_set_display(g_player[0], PLAYER_DISPLAY_TYPE_OVERLAY, GET_DISPLAY(selected_win_id));
416 if (g_external_win_id) {
417 evas_object_del(g_external_win_id);
418 g_external_win_id = NULL;
420 } else if (state == EOM_OUTPUT_ATTRIBUTE_STATE_LOST) {
421 g_print("[eom] lost\n");
423 g_win_id = create_win(PACKAGE);
424 if (g_win_id == NULL)
426 g_print("create win_id %p\n", g_win_id);
427 create_render_rect_and_bg(g_win_id);
428 elm_win_activate(g_win_id);
429 evas_object_show(g_win_id);
431 selected_win_id = g_win_id;
434 player_set_display(g_player[0], PLAYER_DISPLAY_TYPE_OVERLAY, GET_DISPLAY(selected_win_id));
436 if (g_external_win_id) {
437 evas_object_del(g_external_win_id);
438 g_external_win_id = NULL;
441 eom_unset_output_added_cb(eom_notify_cb_output_add);
442 eom_unset_output_removed_cb(eom_notify_cb_output_remove);
443 eom_unset_mode_changed_cb(eom_notify_cb_mode_changed);
444 eom_unset_attribute_changed_cb(eom_notify_cb_attribute_changed);
450 static int app_create(void *data)
453 Evas_Object *win = NULL;
454 #ifdef _ACTIVATE_EOM_
455 eom_output_mode_e output_mode = EOM_OUTPUT_MODE_NONE;
458 elm_config_accel_preference_set("opengl");
461 win = create_win(PACKAGE);
466 selected_win_id = g_win_id;
467 create_render_rect_and_bg(ad->win);
468 /* Create evas image object for EVAS surface */
469 g_eo[0] = create_image_object(ad->win);
470 evas_object_image_size_set(g_eo[0], 500, 500);
471 evas_object_image_fill_set(g_eo[0], 0, 0, 500, 500);
472 evas_object_resize(g_eo[0], 500, 500);
474 elm_win_activate(win);
475 evas_object_show(win);
476 #ifdef _ACTIVATE_EOM_
477 /* check external device */
479 ad->hdmi_output_id = eom_get_output_id("HDMI");
480 if (ad->hdmi_output_id == 0) {
481 g_print("[eom] error : HDMI output id is NULL.\n");
485 g_print("eom_set_output_attribute EOM_OUTPUT_ATTRIBUTE_NORMAL(id:%d)\n", ad->hdmi_output_id);
486 if (eom_set_output_attribute(ad->hdmi_output_id, EOM_OUTPUT_ATTRIBUTE_NORMAL) != EOM_ERROR_NONE) {
487 g_print("attribute set fail. cannot use external output\n");
491 eom_get_output_mode(ad->hdmi_output_id, &output_mode);
492 if (output_mode != EOM_OUTPUT_MODE_NONE) {
493 g_external_win_id = elm_win_add(NULL, "External", ELM_WIN_BASIC);
494 if (eom_set_output_window(ad->hdmi_output_id, g_external_win_id) == EOM_ERROR_NONE) {
495 create_render_rect_and_bg(g_external_win_id);
496 g_print("[eom] create external window\n");
498 evas_object_del(g_external_win_id);
499 g_external_win_id = NULL;
500 g_print("[eom] create external window fail\n");
502 selected_win_id = g_external_win_id;
505 /* set callback for detecting external device */
506 eom_set_output_added_cb(eom_notify_cb_output_add, ad);
507 eom_set_output_removed_cb(eom_notify_cb_output_remove, ad);
508 eom_set_mode_changed_cb(eom_notify_cb_mode_changed, ad);
509 eom_set_attribute_changed_cb(eom_notify_cb_attribute_changed, ad);
514 static int app_terminate(void *data)
519 for (i = 0; i < MAX_HANDLE; i++) {
521 evas_object_del(g_eo[i]);
526 evas_object_del(g_win_id);
529 #ifdef _ACTIVATE_EOM_
530 if (g_external_win_id) {
531 evas_object_del(g_external_win_id);
532 g_external_win_id = NULL;
536 selected_win_id = NULL;
537 #ifdef _ACTIVATE_EOM_
538 eom_unset_output_added_cb(eom_notify_cb_output_add);
539 eom_unset_output_removed_cb(eom_notify_cb_output_remove);
540 eom_unset_mode_changed_cb(eom_notify_cb_mode_changed);
541 eom_unset_attribute_changed_cb(eom_notify_cb_attribute_changed);
548 struct appcore_ops ops = {
549 .create = app_create,
550 .terminate = app_terminate,
553 static void prepared_cb(void *user_data)
555 g_print("[Player_Test] prepared_cb!!!!\n");
558 static void _audio_frame_decoded_cb_ex(player_audio_raw_data_s * audio_raw_frame, void *user_data)
560 player_audio_raw_data_s *audio_raw = audio_raw_frame;
565 g_print("[Player_Test] decoded_cb_ex! channel: %d channel_mask: %llu\n", audio_raw->channel, audio_raw->channel_mask);
568 if (audio_raw->channel_mask == 1 && fp_out1)
569 fwrite((guint8 *) audio_raw->data, 1, audio_raw->size, fp_out1);
570 else if (audio_raw->channel_mask == 2 && fp_out2)
571 fwrite((guint8 *) audio_raw->data, 1, audio_raw->size, fp_out2);
575 static void progress_down_cb(player_pd_message_type_e type, void *user_data)
577 g_print("[Player_Test] progress_down_cb!!!! type : %d\n", type);
580 static void buffering_cb(int percent, void *user_data)
582 g_print("[Player_Test] buffering_cb!!!! percent : %d\n", percent);
585 static void seek_completed_cb(void *user_data)
587 g_print("[Player_Test] seek_completed_cb!!! \n");
590 static void completed_cb(void *user_data)
592 g_print("[Player_Test] completed_cb!!!!\n");
595 static void error_cb(int code, void *user_data)
597 g_print("[Player_Test] error_cb!!!! code : %d\n", code);
600 static void interrupted_cb(player_interrupted_code_e code, void *user_data)
602 g_print("[Player_Test] interrupted_cb!!!! code : %d\n", code);
605 static void video_changed_cb(int width, int height, int fps, int bit_rate, void *user_data)
607 g_print("[Player_Test] video_changed_cb!!!! %d x %d, %d, %d \n", width, height, fps, bit_rate);
611 static void audio_frame_decoded_cb(unsigned char *data, unsigned int size, void *user_data)
615 if (data && g_pcm_fd)
616 fwrite(data, 1, size, g_pcm_fd);
617 player_get_play_position(g_player[0], &pos);
618 g_print("[Player_Test] audio_frame_decoded_cb [size: %d] --- current pos : %d!!!!\n", size, pos);
622 static void subtitle_updated_cb(unsigned long duration, char *text, void *user_data)
624 g_print("[Player_Test] subtitle_updated_cb!!!! [%ld] %s\n", duration, text);
627 static void video_captured_cb(unsigned char *data, int width, int height, unsigned int size, void *user_data)
629 g_print("[Player_Test] video_captured_cb!!!! width: %d, height : %d, size : %d \n", width, height, size);
633 static int _save(unsigned char *src, int length)
635 /* unlink(CAPTUERD_IMAGE_SAVE_PATH); */
637 char filename[256] = { 0, };
638 static int WRITE_COUNT = 0;
639 /* gchar *filename = CAPTUERD_IMAGE_SAVE_PATH; */
640 snprintf(filename, 256, "/tmp/IMAGE_client%d", WRITE_COUNT);
642 fp = fopen(filename, "w+");
644 g_print("file open error!!\n");
647 g_print("open success\n");
648 if (fwrite(src, 1, length, fp) < 1) {
649 g_print("file write error!!\n");
653 g_print("write success(%s)\n", filename);
660 static void reset_display()
664 /* delete evas window, if it is */
665 for (i = 0; i < MAX_HANDLE; i++) {
667 evas_object_del(g_eo[i]);
673 static void input_filename(char *filename)
675 int len = strlen(filename);
678 if (len < 0 || len > MAX_STRING_LEN - 1)
681 for (i = 0; i < g_handle_num; i++) {
682 if (g_player[i] != NULL) {
683 player_unprepare(g_player[i]);
684 player_destroy(g_player[i]);
688 if (player_create(&g_player[i]) != PLAYER_ERROR_NONE)
689 g_print("player create is failed\n");
692 strncpy(g_uri, filename, len);
696 /* ned(APPSRC_TEST) */
701 GError *error = NULL;
702 guint8 *g_media_mem = NULL;
706 file = g_mapped_file_new(ext, FALSE, &error);
707 file_size = g_mapped_file_get_length(file);
708 g_media_mem = (guint8 *) g_mapped_file_get_contents(file);
710 g_sprintf(uri, "mem://ext=%s,size=%d", ext ? ext : "", file_size);
711 g_print("[uri] = %s\n", uri);
713 mm_player_set_attribute(g_player[0], &g_err_name, "profile_uri", uri, strlen(uri), "profile_user_param", g_media_mem, file_size NULL);
715 /* player_set_uri(g_player[0], filename); */
720 player_state_e state;
721 for (i = 0; i < g_handle_num; i++) {
722 ret = player_get_state(g_player[i], &state);
723 g_print("player_get_state returned [%d]\n", ret);
724 g_print("1. After player_create() - Current State : %d \n", state);
728 /* use this API instead of player_set_uri */
729 static void player_set_memory_buffer_test()
733 guint8 *g_media_mem = NULL;
735 file = g_mapped_file_new(g_uri, FALSE, NULL);
736 file_size = g_mapped_file_get_length(file);
737 g_media_mem = (guint8 *) g_mapped_file_get_contents(file);
739 int ret = player_set_memory_buffer(g_player[0], (void *)g_media_mem, file_size);
740 g_print("player_set_memory_buffer ret : %d\n", ret);
743 int video_packet_count = 0;
745 static void buffer_need_video_data_cb(unsigned int size, void *user_data)
747 int real_read_len = 0;
750 static guint64 pts = 0L;
753 guint8 *buff_ptr = NULL;
756 memset(fname, 0, 128);
757 memset(fptsname, 0, 128);
759 video_packet_count++;
761 if (video_packet_count > 1000) {
764 /* player_submit_packet(g_player[0], NULL, 0, 0, 1); */
765 player_push_media_stream(g_player[0], NULL);
769 /* snprintf(fname, 128, "/opt/storage/usb/test/packet/packet_%d.dat", video_packet_count); */
770 /* snprintf(fptsname, 128, "/opt/storage/usb/test/packet/gstpts_%d.dat", video_packet_count); */
771 snprintf(fname, 128, "/home/developer/test/packet/packet_%d.dat", video_packet_count);
772 snprintf(fptsname, 128, "/home/developer/test/packet/gstpts_%d.dat", video_packet_count);
774 fp = fopen(fptsname, "rb");
777 pts_len = fread(&pts, 1, sizeof(guint64), fp);
778 if (pts_len != sizeof(guint64))
779 g_print("Warning, pts value can be wrong.\n");
784 fp = fopen(fname, "rb");
786 buff_ptr = (guint8 *) g_malloc0(1048576);
788 g_print("no free space\n");
793 real_read_len = fread(buff_ptr, 1, size, fp);
797 g_print("video need data - data size : %d, pts : %" G_GUINT64_FORMAT "\n", real_read_len, pts);
799 player_submit_packet(g_player[0], buff_ptr, real_read_len, (pts / 1000000), 1);
801 /* create media packet */
803 media_packet_destroy(g_video_pkt);
807 media_packet_create_alloc(g_video_fmt, NULL, NULL, &g_video_pkt);
809 g_print("packet = %p, src = %p\n", g_video_pkt, src);
811 if (media_packet_get_buffer_data_ptr(g_video_pkt, &src) != MEDIA_PACKET_ERROR_NONE)
814 if (media_packet_set_pts(g_video_pkt, (uint64_t) pts) != MEDIA_PACKET_ERROR_NONE)
817 if (media_packet_set_buffer_size(g_video_pkt, (uint64_t) real_read_len) != MEDIA_PACKET_ERROR_NONE)
820 memcpy(src, buff_ptr, real_read_len);
823 player_push_media_stream(g_player[0], g_video_pkt);
833 int audio_packet_count = 0;
834 static void buffer_need_audio_data_cb(unsigned int size, void *user_data)
836 int real_read_len = 0;
839 guint8 *buff_ptr = NULL;
842 memset(fname, 0, 128);
843 audio_packet_count++;
845 if (audio_packet_count > 1000) {
847 /* player_submit_packet(g_player[0], NULL, 0, 0, 0); */
848 player_push_media_stream(g_player[0], NULL);
852 /* snprintf(fname, 128, "/opt/storage/usb/test/audio_packet/packet_%d.dat", audio_packet_count); */
853 snprintf(fname, 128, "/home/developer/test/audio_packet/packet_%d.dat", audio_packet_count);
855 static guint64 audio_pts = 0;
856 guint64 audio_dur = 21333333;
858 fp = fopen(fname, "rb");
860 buff_ptr = (guint8 *) g_malloc0(1048576);
862 g_print("no free space\n");
867 real_read_len = fread(buff_ptr, 1, size, fp);
871 g_print("\t audio need data - data size : %d, pts : %" G_GUINT64_FORMAT "\n", real_read_len, audio_pts);
874 player_submit_packet(g_player[0], buff_ptr, real_read_len, (audio_pts / 1000000), 0);
876 /* create media packet */
878 media_packet_destroy(g_audio_pkt);
881 media_packet_create_alloc(g_audio_fmt, NULL, NULL, &g_audio_pkt);
883 g_print("packet = %p, src = %p\n", g_audio_pkt, src);
885 if (media_packet_get_buffer_data_ptr(g_audio_pkt, &src) != MEDIA_PACKET_ERROR_NONE)
888 if (media_packet_set_pts(g_audio_pkt, (uint64_t) audio_pts) != MEDIA_PACKET_ERROR_NONE)
891 if (media_packet_set_buffer_size(g_audio_pkt, (uint64_t) real_read_len) != MEDIA_PACKET_ERROR_NONE)
894 memcpy(src, buff_ptr, real_read_len);
897 player_push_media_stream(g_player[0], g_audio_pkt);
900 audio_pts += audio_dur;
908 static void set_content_info(bool is_push_mode)
910 /* testcode for es buff src case, please input url as es_buff://123 or es_buff://push_mode */
911 /* 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}; */
913 /* create media format */
914 media_format_create(&g_audio_fmt);
915 media_format_create(&g_video_fmt);
918 /* configure media format for video and set to player */
919 media_format_set_video_mime(g_video_fmt, MEDIA_FORMAT_MPEG4_SP);
920 media_format_set_video_width(g_video_fmt, 640);
921 media_format_set_video_height(g_video_fmt, 272);
922 /* player_set_media_stream_info(g_player[0], PLAYER_STREAM_TYPE_VIDEO, g_video_fmt); */
924 /* Audio--aac--StarWars.mp4 */
925 media_format_set_audio_mime(g_audio_fmt, MEDIA_FORMAT_AAC);
926 media_format_set_audio_channel(g_audio_fmt, 2);
927 media_format_set_audio_samplerate(g_audio_fmt, 48000);
928 /* player_set_media_stream_info(g_player[0], PLAYER_STREAM_TYPE_AUDIO, g_audio_fmt); */
930 /* video_info->mime = g_strdup("video/mpeg"); *//* CODEC_ID_MPEG4VIDEO */
931 video_info->width = 640;
932 video_info->height = 272;
933 video_info->version = 4;
934 video_info->framerate_den = 100;
935 video_info->framerate_num = 2997;
937 video_info->extradata_size = 45;
938 video_info->codec_extradata = codec_data;
939 player_set_video_stream_info(g_player[0], video_info);
941 /* audio--aac--StarWars.mp4 */
942 /* audio_info->mime = g_strdup("audio/mpeg"); */
943 /* audio_info->version = 2; */
944 /* audio_info->user_info = 0; *//* raw */
949 player_set_buffer_need_video_data_cb(g_player[0], buffer_need_video_data_cb, (void *)g_player[0]);
950 player_set_buffer_need_audio_data_cb(g_player[0], buffer_need_audio_data_cb, (void *)g_player[0]);
955 static void feed_video_data_thread_func(void *data)
957 while (!g_thread_end) {
958 buffer_need_video_data_cb(1048576, NULL);
959 buffer_need_audio_data_cb(1048576, NULL);
963 static void _player_prepare(bool async)
966 int slen = strlen(g_subtitle_uri);
968 if (slen > 0 && slen < MAX_STRING_LEN) {
969 g_print("0. set subtile path() (size : %d) - %s \n", slen, g_subtitle_uri);
970 player_set_subtitle_path(g_player[0], g_subtitle_uri);
971 player_set_subtitle_updated_cb(g_player[0], subtitle_updated_cb, (void *)g_player[0]);
973 if (g_current_surface_type == -1) {
974 g_print("You must set display surface type before setting prepare.\n");
978 if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
979 player_set_buffering_cb(g_player[0], buffering_cb, (void *)g_player[0]);
980 player_set_completed_cb(g_player[0], completed_cb, (void *)g_player[0]);
981 player_set_interrupted_cb(g_player[0], interrupted_cb, (void *)g_player[0]);
982 player_set_error_cb(g_player[0], error_cb, (void *)g_player[0]);
983 player_set_video_stream_changed_cb(g_player[0], video_changed_cb, (void *)g_player[0]);
984 if (g_memory_playback)
985 player_set_memory_buffer_test();
987 player_set_uri(g_player[0], g_uri);
990 for (i = 0; i < g_handle_num; i++) {
991 player_set_buffering_cb(g_player[i], buffering_cb, (void *)g_player[i]);
992 player_set_completed_cb(g_player[i], completed_cb, (void *)g_player[i]);
993 player_set_interrupted_cb(g_player[i], interrupted_cb, (void *)g_player[i]);
994 player_set_error_cb(g_player[i], error_cb, (void *)g_player[i]);
995 player_set_video_stream_changed_cb(g_player[0], video_changed_cb, (void *)g_player[0]);
996 if (g_memory_playback)
997 player_set_memory_buffer_test();
999 player_set_uri(g_player[i], g_uri);
1003 if (strstr(g_uri, "es_buff://")) {
1004 is_es_push_mode = FALSE;
1005 video_packet_count = 0;
1006 audio_packet_count = 0;
1008 if (strstr(g_uri, "es_buff://push_mode")) {
1009 set_content_info(TRUE);
1011 is_es_push_mode = TRUE;
1014 set_content_info(FALSE);
1019 if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
1021 ret = player_prepare_async(g_player[0], prepared_cb, (void *)g_player[0]);
1023 ret = player_prepare(g_player[0]);
1026 for (i = 0; i < g_handle_num; i++) {
1028 ret = player_prepare_async(g_player[i], prepared_cb, (void *)g_player[i]);
1030 ret = player_prepare(g_player[i]);
1034 if (ret != PLAYER_ERROR_NONE)
1035 g_print("prepare is failed (errno = %d) \n", ret);
1037 player_state_e state;
1038 if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
1039 ret = player_get_state(g_player[0], &state);
1040 g_print("After player_prepare() - Current State : %d \n", state);
1043 for (i = 0; i < g_handle_num; i++) {
1044 ret = player_get_state(g_player[i], &state);
1045 g_print("After player_prepare() - Current State : %d \n", state);
1049 if (is_es_push_mode)
1050 pthread_create(&g_feed_video_thread_id, NULL, (void *)feed_video_data_thread_func, NULL);
1054 static void _player_unprepare()
1058 if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
1059 ret = player_unprepare(g_player[0]);
1060 if (ret != PLAYER_ERROR_NONE)
1061 g_print("unprepare is failed (errno = %d) \n", ret);
1063 ret = player_unset_subtitle_updated_cb(g_player[0]);
1064 g_print("player_unset_subtitle_updated_cb ret %d\n", ret);
1066 ret = player_unset_buffering_cb(g_player[0]);
1067 g_print("player_unset_buffering_cb ret %d\n", ret);
1069 ret = player_unset_completed_cb(g_player[0]);
1070 g_print("player_unset_completed_cb ret %d\n", ret);
1072 ret = player_unset_interrupted_cb(g_player[0]);
1073 g_print("player_unset_interrupted_cb ret %d\n", ret);
1075 ret = player_unset_error_cb(g_player[0]);
1076 g_print("player_unset_error_cb ret %d\n", ret);
1078 for (i = 0; i < g_handle_num; i++) {
1079 if (g_player[i] != NULL) {
1080 ret = player_unprepare(g_player[i]);
1081 if (ret != PLAYER_ERROR_NONE)
1082 g_print("unprepare is failed (errno = %d) \n", ret);
1084 ret = player_unset_subtitle_updated_cb(g_player[i]);
1085 g_print("player_unset_subtitle_updated_cb [%d] ret %d\n", i, ret);
1087 ret = player_unset_buffering_cb(g_player[i]);
1088 g_print("player_unset_buffering_cb [%d] ret %d\n", i, ret);
1090 ret = player_unset_completed_cb(g_player[i]);
1091 g_print("player_unset_completed_cb [%d] ret %d\n", i, ret);
1093 ret = player_unset_interrupted_cb(g_player[i]);
1094 g_print("player_unset_interrupted_cb [%d] ret %d\n", i, ret);
1096 ret = player_unset_error_cb(g_player[i]);
1097 g_print("player_unset_error_cb [%d] ret %d\n", i, ret);
1102 memset(g_subtitle_uri, 0, sizeof(g_subtitle_uri));
1103 player_state_e state;
1104 if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
1105 ret = player_get_state(g_player[0], &state);
1106 g_print(" After player_unprepare() - Current State : %d \n", state);
1108 for (i = 0; i < g_handle_num; i++) {
1109 ret = player_get_state(g_player[i], &state);
1110 g_print(" After player_unprepare() - Current State : %d \n", state);
1115 static void _player_destroy()
1119 if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
1120 player_destroy(g_player[0]);
1123 for (i = 0; i < g_handle_num; i++) {
1124 if (g_player[i] != NULL) {
1125 player_unprepare(g_player[i]);
1126 player_destroy(g_player[i]);
1132 if (g_stream_info_h) {
1133 sound_manager_destroy_stream_information(g_stream_info_h);
1134 g_stream_info_h = NULL;
1138 media_packet_destroy(g_video_pkt);
1141 media_packet_destroy(g_audio_pkt);
1152 static void _player_play()
1156 if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
1157 #ifdef _ACTIVATE_EOM_
1158 /* for checking external display.... */
1159 player_set_display(g_player[0], g_current_surface_type, GET_DISPLAY(selected_win_id));
1161 bRet = player_start(g_player[0]);
1162 g_print("player_start returned [%d]", bRet);
1164 for (i = 0; i < g_handle_num; i++) {
1165 bRet = player_start(g_player[i]);
1166 g_print("player_start returned [%d]", bRet);
1171 static void _player_stop()
1175 if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
1176 bRet = player_stop(g_player[0]);
1177 g_print("player_stop returned [%d]", bRet);
1179 for (i = 0; i < g_handle_num; i++) {
1180 bRet = player_stop(g_player[i]);
1181 g_print("player_stop returned [%d]", bRet);
1185 g_thread_end = TRUE;
1186 if (g_feed_video_thread_id) {
1187 pthread_join(g_feed_video_thread_id, NULL);
1188 g_feed_video_thread_id = 0;
1193 static void _player_resume()
1197 if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
1198 #ifdef _ACTIVATE_EOM_
1199 /* for checking external display.... */
1200 player_set_display(g_player[0], PLAYER_DISPLAY_TYPE_OVERLAY, GET_DISPLAY(selected_win_id));
1202 bRet = player_start(g_player[0]);
1203 g_print("player_start returned [%d]", bRet);
1205 for (i = 0; i < g_handle_num; i++) {
1206 bRet = player_start(g_player[i]);
1207 g_print("player_start returned [%d]", bRet);
1212 static void _player_pause()
1216 if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
1217 bRet = player_pause(g_player[0]);
1218 g_print("player_pause returned [%d]", bRet);
1220 for (i = 0; i < g_handle_num; i++) {
1221 bRet = player_pause(g_player[i]);
1222 g_print("player_pause returned [%d]", bRet);
1227 static void _player_state()
1229 player_state_e state;
1230 player_get_state(g_player[0], &state);
1231 g_print(" ==> [Player_Test] Current Player State : %d\n", state);
1234 static void _player_set_progressive_download()
1236 player_set_progressive_download_path(g_player[0], "/home/owner/test.pd");
1237 player_set_progressive_download_message_cb(g_player[0], progress_down_cb, (void *)g_player[0]);
1240 static void _player_get_progressive_download_status()
1243 unsigned long curr = 0, total = 0;
1244 bRet = player_get_progressive_download_status(g_player[0], &curr, &total);
1245 g_print("player_get_progressive_download_status return[%d] ==> [Player_Test] progressive download status : %lu/%lu\n", bRet, curr, total);
1248 static void _player_enable_tsurf_pool(void)
1250 bool enabled = FALSE;
1253 g_print("not support at TV profile");
1257 player_is_enabled_tsurf_pool(g_player[0], &enabled);
1259 g_print("tbm surface pool will be %s", (enabled) ? "disabled" : "enabled");
1260 player_enable_tsurf_pool(g_player[0], !enabled);
1263 static void set_next_uri(char * uri)
1266 g_print("not support at TV profile");
1270 if (player_set_next_uri(g_player[0], uri) != PLAYER_ERROR_NONE)
1271 g_print("fail to set next uri");
1274 static void get_next_uri()
1279 g_print("not support at TV profile");
1283 if (player_get_next_uri(g_player[0], &uri) != PLAYER_ERROR_NONE) {
1284 g_print("fail to get next uri");
1289 g_print("next_uri = %s", uri);
1294 static void set_volume(float volume)
1296 if (player_set_volume(g_player[0], volume, volume) != PLAYER_ERROR_NONE)
1297 g_print("failed to set volume\n");
1300 static void get_volume(float *left, float *right)
1302 player_get_volume(g_player[0], left, right);
1303 g_print(" ==> [Player_Test] volume - left : %f, right : %f\n", *left, *right);
1306 static void set_mute(bool mute)
1308 if (player_set_mute(g_player[0], mute) != PLAYER_ERROR_NONE)
1309 g_print("failed to set_mute\n");
1312 static void get_mute(bool * mute)
1314 player_is_muted(g_player[0], mute);
1315 g_print(" ==> [Player_Test] mute = %d\n", *mute);
1318 static void set_sound_type(sound_type_e type)
1320 if (player_set_sound_type(g_player[0], type) != PLAYER_ERROR_NONE)
1321 g_print("failed to set sound type(%d)\n", type);
1323 g_print("set sound type(%d) success", type);
1326 void focus_callback(sound_stream_info_h stream_info,
1327 sound_stream_focus_mask_e focus_mask,
1328 sound_stream_focus_state_e focus_state,
1329 sound_stream_focus_change_reason_e reason,
1331 const char *extra_info,
1334 g_print("FOCUS callback is called, reason(%d), extra_info(%s), userdata(%p)", reason, extra_info, user_data);
1338 static void set_sound_stream_info(int type)
1340 sound_device_list_h device_list = NULL;
1341 int ret = SOUND_MANAGER_ERROR_NONE;
1343 if (g_stream_info_h) {
1344 g_print("stream information is already set, please destory handle and try again\n");
1347 if (sound_manager_create_stream_information(type, focus_callback, g_player[0], &g_stream_info_h)) {
1348 g_print("failed to create stream_information()\n");
1351 /* In case of MEDIA_EXTERNAL_ONLY, we need to set external device manually */
1352 if (type == (int)SOUND_STREAM_TYPE_MEDIA_EXTERNAL_ONLY) {
1353 sound_device_h device = NULL;
1354 sound_device_type_e device_type;
1356 if ((ret = sound_manager_get_device_list(SOUND_DEVICE_ALL_MASK, &device_list))) {
1357 g_print("failed to sound_manager_get_device_list(), ret(0x%x)\n", ret);
1360 while (!(ret = sound_manager_get_next_device(device_list, &device))) {
1361 if ((ret = sound_manager_get_device_type(device, &device_type))) {
1362 g_print("failed to sound_manager_get_device_type(), ret(0x%x)\n", ret);
1365 if (device_type == SOUND_DEVICE_BLUETOOTH || device_type == SOUND_DEVICE_USB_AUDIO) {
1366 if ((ret = sound_manager_add_device_for_stream_routing(g_stream_info_h, device))) {
1367 g_print("failed to sound_manager_add_device_for_stream_routing(), ret(0x%x)\n", ret);
1370 if ((ret = sound_manager_apply_stream_routing(g_stream_info_h))) {
1371 g_print("failed to sound_manager_apply_stream_routing(), ret(0x%x)\n", ret);
1377 if (ret != SOUND_MANAGER_ERROR_NONE) {
1378 g_print("failed to sound_manager_get_next_device(), ret(0x%x)\n", ret);
1383 if (player_set_sound_stream_info(g_player[0], g_stream_info_h) != PLAYER_ERROR_NONE)
1384 g_print("failed to set sound stream information(%p)\n", g_stream_info_h);
1386 g_print("set stream information(%p) success", g_stream_info_h);
1390 sound_manager_free_device_list(device_list);
1394 void variant_cb(int bandwidth, int width, int height, void *user_data)
1396 g_print(" ==> [Player_Test][b]%d, [w]%d, [h]%d\n", bandwidth, width, height);
1399 static void get_variant_info()
1401 player_foreach_adaptive_variant(g_player[0], (player_adaptive_variant_cb)variant_cb, g_player[0]);
1404 static void get_variant_limit()
1406 int bandwidth, width, height;
1407 player_get_max_adaptive_variant_limit(g_player[0], &bandwidth, &width, &height);
1408 g_print(" ==> [Player_Test]get [b]%d, [w]%d, [h]%d\n", bandwidth, width, height);
1411 static void set_variant_limit()
1413 g_print(" ==> [Player_Test]set [b]%d, [w]%d, [h]%d\n", max_limit.bandwidth, max_limit.width, max_limit.height);
1414 player_set_max_adaptive_variant_limit(g_player[0], max_limit.bandwidth, max_limit.width, max_limit.height);
1417 static void set_buffer_size()
1420 int buffer_ms = 0, rebuffer_ms = 0;
1422 ret = player_get_streaming_buffering_time(g_player[0], &buffer_ms, &rebuffer_ms);
1423 if (ret != PLAYER_ERROR_NONE)
1424 g_print("failed to get buffering time. 0x%X\n", ret);
1426 g_print("current buffer size %d ms / %d ms\n", buffer_ms, rebuffer_ms);
1428 g_print("new buffer size %d ms / %d ms\n", buff_size.buffer_ms, buff_size.rebuffer_ms);
1430 player_set_streaming_buffering_time(g_player[0], buff_size.buffer_ms, buff_size.rebuffer_ms);
1433 static void get_position()
1437 ret = player_get_play_position(g_player[0], &position);
1438 g_print(" ==> [Player_Test] player_get_play_position()%d return : %d\n", ret, position);
1441 static void set_position(int position, bool accurate)
1443 if (player_set_play_position(g_player[0], position, accurate, seek_completed_cb, g_player[0]) != PLAYER_ERROR_NONE)
1444 g_print("failed to set position\n");
1447 static void set_playback_rate(float rate, bool streaming)
1450 if (player_set_streaming_playback_rate(g_player[0], rate) != PLAYER_ERROR_NONE)
1451 g_print("failed to set streaming playback rate\n");
1453 if (player_set_playback_rate(g_player[0], rate) != PLAYER_ERROR_NONE)
1454 g_print("failed to set playback rate\n");
1458 static void get_duration()
1462 ret = player_get_duration(g_player[0], &duration);
1463 g_print(" ==> [Player_Test] player_get_duration() return : %d\n", ret);
1464 g_print(" ==> [Player_Test] Duration: [%d ] msec\n", duration);
1467 static void audio_frame_decoded_cb_ex(bool sync)
1471 fp_out1 = fopen("/tmp/out1.pcm", "wb");
1472 fp_out2 = fopen("/tmp/out2.pcm", "wb");
1473 if (!fp_out1 || !fp_out2) {
1474 g_print("File open error\n");
1479 ret = player_set_pcm_extraction_mode(g_player[0], sync, _audio_frame_decoded_cb_ex, &ret);
1480 g_print(" ==> [Player_Test] player_set_audio_frame_decoded_cb_ex(sync:%d) ret:%d\n", sync, ret);
1482 ret = player_set_pcm_spec(g_player[0], "F32LE", 44100, 2);
1483 g_print("[Player_Test] set_pcm_spec return: %d\n", ret);
1486 static void get_stream_info()
1492 player_get_content_info(g_player[0], PLAYER_CONTENT_INFO_ALBUM, &value);
1493 g_print(" ==> [Player_Test] PLAYER_CONTENT_INFO_ALBUM: [%s ] \n", value);
1494 player_get_content_info(g_player[0], PLAYER_CONTENT_INFO_ARTIST, &value);
1495 g_print(" ==> [Player_Test] PLAYER_CONTENT_INFO_ARTIST: [%s ] \n", value);
1496 player_get_content_info(g_player[0], PLAYER_CONTENT_INFO_AUTHOR, &value);
1497 g_print(" ==> [Player_Test] PLAYER_CONTENT_INFO_AUTHOR: [%s ] \n", value);
1498 player_get_content_info(g_player[0], PLAYER_CONTENT_INFO_GENRE, &value);
1499 g_print(" ==> [Player_Test] PLAYER_CONTENT_INFO_GENRE: [%s ] \n", value);
1500 player_get_content_info(g_player[0], PLAYER_CONTENT_INFO_TITLE, &value);
1501 g_print(" ==> [Player_Test] PLAYER_CONTENT_INFO_TITLE: [%s ] \n", value);
1504 player_get_album_art(g_player[0], &album, &size);
1505 g_print(" ==> [Player_Test] Album art : [ data : %p, size : %d ]\n", (unsigned int *)album, size);
1507 if (value != NULL) {
1515 int fps, v_bit_rate;
1516 player_get_audio_stream_info(g_player[0], &sample_rate, &channel, &bit_rate);
1517 g_print(" ==> [Player_Test] Sample Rate: [%d ] , Channel: [%d ] , Bit Rate: [%d ] \n", sample_rate, channel, bit_rate);
1519 player_get_video_stream_info(g_player[0], &fps, &v_bit_rate);
1520 g_print(" ==> [Player_Test] fps: [%d ] , Bit Rate: [%d ] \n", fps, v_bit_rate);
1522 char *audio_codec = NULL;
1523 char *video_codec = NULL;
1524 player_get_codec_info(g_player[0], &audio_codec, &video_codec);
1525 if (audio_codec != NULL) {
1526 g_print(" ==> [Player_Test] Audio Codec: [%s ] \n", audio_codec);
1530 if (video_codec != NULL) {
1531 g_print(" ==> [Player_Test] Video Codec: [%s ] \n", video_codec);
1535 player_get_video_size(g_player[0], &w, &h);
1536 g_print(" ==> [Player_Test] Width: [%d ] , Height: [%d ] \n", w, h);
1539 static void set_gapless(bool gapless)
1542 g_print("not support at TV profile");
1546 if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
1547 if (player_set_gapless(g_player[0], gapless) != PLAYER_ERROR_NONE)
1548 g_print("failed set_gapless\n");
1551 for (i = 0; i < g_handle_num; i++) {
1552 if (player_set_gapless(g_player[i], gapless) != PLAYER_ERROR_NONE)
1553 g_print("failed to set_gapless\n");
1558 static void set_looping(bool looping)
1560 if (g_current_surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
1561 if (player_set_looping(g_player[0], looping) != PLAYER_ERROR_NONE)
1562 g_print("failed to set_looping\n");
1565 for (i = 0; i < g_handle_num; i++) {
1566 if (player_set_looping(g_player[i], looping) != PLAYER_ERROR_NONE)
1567 g_print("failed to set_looping\n");
1572 static void get_looping(bool * looping)
1574 player_is_looping(g_player[0], looping);
1575 g_print(" ==> [Player_Test] looping = %d\n", *looping);
1578 static void change_surface(int option)
1580 player_display_type_e surface_type = 0;
1581 int ret = PLAYER_ERROR_NONE;
1582 #ifdef _ACTIVATE_EOM_
1584 eom_output_mode_e output_mode;
1589 surface_type = PLAYER_DISPLAY_TYPE_OVERLAY;
1590 g_print("change surface type to X\n");
1592 #ifdef TIZEN_FEATURE_EVAS_RENDERER
1595 surface_type = PLAYER_DISPLAY_TYPE_EVAS;
1596 g_print("change surface type to EVAS\n");
1600 g_print("change surface type to NONE\n");
1601 surface_type = g_current_surface_type = PLAYER_DISPLAY_TYPE_NONE;
1602 player_set_display(g_player[0], PLAYER_DISPLAY_TYPE_NONE, NULL);
1605 g_print("invalid surface type\n");
1609 if (surface_type == g_current_surface_type) {
1610 g_print("same with the previous surface type(%d)\n", g_current_surface_type);
1613 player_state_e player_state = PLAYER_STATE_NONE;
1614 ret = player_get_state(g_player[0], &player_state);
1616 g_print("failed to player_get_state(), ret(0x%x)\n", ret);
1620 if (surface_type == PLAYER_DISPLAY_TYPE_OVERLAY) {
1621 #ifdef _ACTIVATE_EOM_
1622 hdmi_output_id = eom_get_output_id("HDMI");
1623 if (hdmi_output_id == 0)
1624 g_print("[eom] error : HDMI output id is NULL.\n");
1626 eom_get_output_mode(hdmi_output_id, &output_mode);
1627 if (output_mode == EOM_OUTPUT_MODE_NONE) {
1630 g_win_id = create_win(PACKAGE);
1631 if (g_win_id == NULL)
1633 g_print("create win_id %p\n", g_win_id);
1634 create_render_rect_and_bg(g_win_id);
1635 elm_win_activate(g_win_id);
1636 evas_object_show(g_win_id);
1637 g_win_id = selected_win_id;
1639 #ifdef _ACTIVATE_EOM_
1644 ret = player_set_display(g_player[0], surface_type, GET_DISPLAY(selected_win_id));
1647 g_win_id = create_win(PACKAGE);
1648 if (g_win_id == NULL)
1650 g_print("create win_id %p\n", g_win_id);
1651 create_render_rect_and_bg(g_win_id);
1652 elm_win_activate(g_win_id);
1653 evas_object_show(g_win_id);
1656 for (i = 0; i < g_handle_num; i++) {
1657 /* Create evas image object for EVAS surface */
1659 g_eo[i] = create_image_object(g_win_id);
1660 g_print("create eo[%d] %p\n", i, g_eo[i]);
1661 evas_object_image_size_set(g_eo[i], 500, 500);
1662 evas_object_image_fill_set(g_eo[i], 0, 0, 500, 500);
1663 evas_object_resize(g_eo[i], 500, 500);
1664 evas_object_move(g_eo[i], i * 20, i * 20);
1666 ret = player_set_display(g_player[i], surface_type, g_eo[i]);
1671 g_print("failed to set display, surface_type(%d)\n", surface_type);
1674 g_current_surface_type = surface_type;
1679 static void set_display_mode(int mode)
1681 if (player_set_display_mode(g_player[0], mode) != PLAYER_ERROR_NONE)
1682 g_print("failed to player_set_display_mode\n");
1685 static void get_display_mode()
1687 player_display_mode_e mode;
1688 player_get_display_mode(g_player[0], &mode);
1689 g_print(" ==> [Player_Test] Display mode: [%d ] \n", mode);
1692 static void set_display_roi_area(int x, int y, int width, int height)
1694 player_set_display_roi_area(g_player[0], x, y, width, height);
1695 g_print(" ==> [Player_Test] Display roi area: [x(%d) y(%d) width(%d) height(%d)] \n", x, y, width, height);
1698 static void set_display_rotation(int rotation)
1700 if (player_set_display_rotation(g_player[0], rotation) != PLAYER_ERROR_NONE)
1701 g_print("failed to set_display_rotation\n");
1704 static void get_display_rotation()
1706 player_display_rotation_e rotation = 0;
1707 player_get_display_rotation(g_player[0], &rotation);
1708 g_print(" ==> [Player_Test] Video Overlay Display rotation: [%d ] \n", rotation);
1711 static void set_display_visible(bool visible)
1713 if (player_set_display_visible(g_player[0], visible) != PLAYER_ERROR_NONE)
1714 g_print("failed to player_set_x11_display_visible\n");
1717 static void get_display_visible(bool * visible)
1719 player_is_display_visible(g_player[0], visible);
1720 g_print(" ==> [Player_Test] Video Overlay Display Visible = %d\n", *visible);
1723 static void input_subtitle_filename(char *subtitle_filename)
1725 int len = strlen(subtitle_filename);
1727 if (len < 1 || len > MAX_STRING_LEN)
1730 strncpy(g_subtitle_uri, subtitle_filename, len);
1731 g_print("subtitle uri is set to %s\n", g_subtitle_uri);
1732 player_set_subtitle_path(g_player[0], g_subtitle_uri);
1735 static void switch_subtitle(int index)
1737 char *lang_code = NULL;
1738 if (player_select_track(g_player[0], PLAYER_STREAM_TYPE_TEXT, index) != PLAYER_ERROR_NONE)
1739 g_print("player_select_track failed\n");
1741 if (player_get_track_language_code(g_player[0], PLAYER_STREAM_TYPE_TEXT, index, &lang_code) == PLAYER_ERROR_NONE) {
1742 g_print("selected track code %s\n", lang_code);
1747 static void get_track_info(int index)
1749 int count = 0, cur_index = 0;
1751 char *lang_code = NULL;
1753 if (index != PLAYER_STREAM_TYPE_AUDIO &&
1754 index != PLAYER_STREAM_TYPE_TEXT) {
1755 g_print("invalid stream type %d", index);
1759 ret = player_get_track_count(g_player[0], index, &count);
1760 if (ret != PLAYER_ERROR_NONE)
1761 g_print("player_get_track_count fail!!!!\n");
1764 player_get_current_track(g_player[0], index, &cur_index);
1765 g_print("total track: %d, curr track: %d\n", count, cur_index);
1767 for (idx = 0; idx < count; idx++) {
1768 player_get_track_language_code(g_player[0], index, idx, &lang_code);
1769 g_print("track info = [%d] %s\n", idx, lang_code);
1772 g_print("no track\n");
1776 static void capture_video()
1778 if (player_capture_video(g_player[0], video_captured_cb, NULL) != PLAYER_ERROR_NONE)
1779 g_print("failed to player_capture_video\n");
1782 static void set_audio_only(int val)
1784 int ret = PLAYER_ERROR_NONE;
1785 bool audio_only = false;
1786 ret = player_is_audio_only(g_player[0], &audio_only);
1787 if (ret != PLAYER_ERROR_NONE)
1788 g_print("failed to get current setting. 0x%X\n", ret);
1790 g_print("current audio only mode : %s\n", (audio_only) ? "enabled" : "disabled");
1791 g_print("new audio only mode : %s\n", (val != 0) ? "enabled" : "disabled");
1794 ret = player_set_audio_only(g_player[0], true);
1796 ret = player_set_audio_only(g_player[0], false);
1797 g_print("finished 0x%X\n", ret);
1800 static void decoding_audio()
1804 char *suffix, *dump_path;
1805 GDateTime *time = g_date_time_new_now_local();
1807 suffix = g_date_time_format(time, "%Y%m%d_%H%M%S.pcm");
1808 dump_path = g_strjoin(NULL, PLAYER_TEST_DUMP_PATH_PREFIX, suffix, NULL);
1809 g_pcm_fd = fopen(dump_path, "w+");
1812 g_date_time_unref(time);
1814 g_print("Can not create debug dump file");
1816 ret = player_set_audio_frame_decoded_cb(g_player[0], 0, 0, audio_frame_decoded_cb, (void *)g_player[0]);
1817 if (ret != PLAYER_ERROR_NONE)
1818 g_print("player_set_audio_frame_decoded_cb is failed (errno = %d) \n", ret);
1822 static void set_audio_eq(int value)
1824 bool available = FALSE;
1825 int index, min = 0, max = 0;
1828 if (player_audio_effect_equalizer_is_available(g_player[0], &available) != PLAYER_ERROR_NONE)
1829 g_print("failed to player_audio_effect_equalizer_is_available\n");
1832 if ((player_audio_effect_get_equalizer_bands_count(g_player[0], &index) != PLAYER_ERROR_NONE) ||
1833 (player_audio_effect_get_equalizer_level_range(g_player[0], &min, &max) != PLAYER_ERROR_NONE) ||
1834 (player_audio_effect_set_equalizer_band_level(g_player[0], index / 2, max) != PLAYER_ERROR_NONE))
1835 g_print("failed to player_audio_effect_set_equalizer_band_level index %d, level %d\n", index / 2, max);
1840 if (player_audio_effect_equalizer_clear(g_player[0]) != PLAYER_ERROR_NONE)
1841 g_print("failed to player_audio_effect_equalizer_clear\n");
1846 static void get_audio_eq()
1848 int index, min, max, value;
1849 player_audio_effect_get_equalizer_bands_count(g_player[0], &index);
1850 g_print(" ==> [Player_Test] eq bands count: [%d] \n", index);
1851 player_audio_effect_get_equalizer_level_range(g_player[0], &min, &max);
1852 g_print(" ==> [Player_Test] eq bands range: [%d~%d] \n", min, max);
1853 player_audio_effect_get_equalizer_band_level(g_player[0], index / 2, &value);
1854 g_print(" ==> [Player_Test] eq bands level: [%d] \n", value);
1855 player_audio_effect_get_equalizer_band_frequency(g_player[0], 0, &value);
1856 g_print(" ==> [Player_Test] eq bands frequency: [%d] \n", value);
1857 player_audio_effect_get_equalizer_band_frequency_range(g_player[0], 0, &value);
1858 g_print(" ==> [Player_Test] eq bands frequency range: [%d] \n", value);
1867 if (g_player[0] != NULL || g_player[1] != NULL) {
1868 _player_unprepare();
1875 media_format_unref(g_audio_fmt);
1878 media_format_unref(g_video_fmt);
1881 void play_with_ini(char *file_path)
1883 input_filename(file_path);
1887 void _interpret_main_menu(char *cmd)
1889 int len = strlen(cmd);
1891 if (strncmp(cmd, "a", 1) == 0) {
1892 g_menu_state = CURRENT_STATUS_FILENAME;
1893 } else if (strncmp(cmd, "b", 1) == 0) {
1895 } else if (strncmp(cmd, "c", 1) == 0) {
1897 } else if (strncmp(cmd, "d", 1) == 0) {
1899 } else if (strncmp(cmd, "e", 1) == 0) {
1901 } else if (strncmp(cmd, "S", 1) == 0) {
1903 } else if (strncmp(cmd, "f", 1) == 0) {
1904 g_menu_state = CURRENT_STATUS_VOLUME;
1905 } else if (strncmp(cmd, "g", 1) == 0) {
1908 get_volume(&left, &right);
1909 } else if (strncmp(cmd, "z", 1) == 0) {
1910 g_menu_state = CURRENT_STATUS_SOUND_TYPE;
1911 } else if (strncmp(cmd, "k", 1) == 0) {
1912 g_menu_state = CURRENT_STATUS_SOUND_STREAM_INFO;
1913 } else if (strncmp(cmd, "h", 1) == 0) {
1914 g_menu_state = CURRENT_STATUS_MUTE;
1915 } else if (strncmp(cmd, "i", 1) == 0) {
1918 } else if (strncmp(cmd, "j", 1) == 0) {
1919 g_menu_state = CURRENT_STATUS_POSITION_TIME;
1920 } else if (strncmp(cmd, "l", 1) == 0) {
1922 } else if (strncmp(cmd, "m", 1) == 0) {
1924 } else if (strncmp(cmd, "n", 1) == 0) {
1926 } else if (strncmp(cmd, "o", 1) == 0) {
1927 g_menu_state = CURRENT_STATUS_LOOPING;
1928 } else if (strncmp(cmd, "p", 1) == 0) {
1930 get_looping(&looping);
1931 } else if (strncmp(cmd, "r", 1) == 0) {
1932 g_menu_state = CURRENT_STATUS_DISPLAY_MODE;
1933 } else if (strncmp(cmd, "s", 1) == 0) {
1935 } else if (strncmp(cmd, "t", 1) == 0) {
1936 g_menu_state = CURRENT_STATUS_DISPLAY_ROTATION;
1937 } else if (strncmp(cmd, "u", 1) == 0) {
1938 get_display_rotation();
1939 } else if (strncmp(cmd, "v", 1) == 0) {
1940 g_menu_state = CURRENT_STATUS_DISPLAY_VISIBLE;
1941 } else if (strncmp(cmd, "w", 1) == 0) {
1943 get_display_visible(&visible);
1944 } else if (strncmp(cmd, "A", 1) == 0) {
1945 g_menu_state = CURRENT_STATUS_SUBTITLE_FILENAME;
1946 } else if (strncmp(cmd, "C", 1) == 0) {
1948 } else if (strncmp(cmd, "D", 1) == 0) {
1950 } else if (strncmp(cmd, "q", 1) == 0) {
1951 quit_pushing = TRUE;
1953 } else if (strncmp(cmd, "E", 1) == 0) {
1954 g_menu_state = CURRENT_STATUS_AUDIO_EQUALIZER;
1955 } else if (strncmp(cmd, "H", 1) == 0) {
1958 g_print("unknown menu \n");
1960 } else if (len == 2) {
1961 if (strncmp(cmd, "pr", 2) == 0) {
1963 if (g_current_surface_type == -1) {
1964 g_print("You must set display surface type before setting prepare. please 'pr' after setting display surface type.\n");
1965 g_menu_state = CURRENT_STATUS_DISPLAY_SURFACE_CHANGE;
1967 _player_prepare(FALSE);
1968 } else if (strncmp(cmd, "pa", 2) == 0) {
1970 if (g_current_surface_type == -1) {
1971 g_print("You must set display surface type before setting prepare. please 'pr' after setting display surface type.\n");
1972 g_menu_state = CURRENT_STATUS_DISPLAY_SURFACE_CHANGE;
1974 _player_prepare(TRUE);
1975 } else if (strncmp(cmd, "un", 2) == 0) {
1976 _player_unprepare();
1977 } else if (strncmp(cmd, "dt", 2) == 0) {
1979 } else if (strncmp(cmd, "sp", 2) == 0) {
1980 _player_set_progressive_download();
1981 } else if (strncmp(cmd, "gp", 2) == 0) {
1982 _player_get_progressive_download_status();
1983 } else if (strncmp(cmd, "mp", 2) == 0) {
1984 g_memory_playback = (g_memory_playback ? FALSE : TRUE);
1985 g_print("memory playback = %d\n", g_memory_playback);
1986 } else if (strncmp(cmd, "ds", 2) == 0) {
1987 g_menu_state = CURRENT_STATUS_DISPLAY_SURFACE_CHANGE;
1988 } else if (strncmp(cmd, "dr", 2) == 0) {
1989 g_print("now, PLAYER_DISPLAY_MODE_DST_ROI(display mode) is set\n");
1990 g_menu_state = CURRENT_STATUS_DISPLAY_DST_ROI;
1991 } else if (strncmp(cmd, "nb", 2) == 0) {
1992 g_menu_state = CURRENT_STATUS_HANDLE_NUM;
1993 } else if (strncmp(cmd, "tr", 2) == 0) {
1994 g_menu_state = CURRENT_STATUS_PLAYBACK_RATE;
1995 } else if (strncmp(cmd, "ss", 2) == 0) {
1996 g_menu_state = CURRENT_STATUS_SWITCH_SUBTITLE;
1997 } else if (strncmp(cmd, "X3", 2) == 0) {
1998 audio_frame_decoded_cb_ex(TRUE);
1999 } else if (strncmp(cmd, "X4", 2) == 0) {
2000 audio_frame_decoded_cb_ex(FALSE);
2001 } else if (strncmp(cmd, "ep", 2) == 0) {
2002 _player_enable_tsurf_pool();
2003 } else if (strncmp(cmd, "su", 2) == 0) {
2004 g_menu_state = CURRENT_STATUS_NEXT_URI;
2005 } else if (strncmp(cmd, "gu", 2) == 0) {
2007 } else if (strncmp(cmd, "sg", 2) == 0) {
2008 g_menu_state = CURRENT_STATUS_GAPLESS;
2009 } else if (strncmp(cmd, "tl", 2) == 0) {
2010 g_menu_state = CURRENT_STATUS_GET_TRACK_INFO;
2011 } else if (strncmp(cmd, "vi", 2) == 0) {
2013 } else if (strncmp(cmd, "vs", 2) == 0) {
2014 g_menu_state = CURRENT_STATUS_SET_MAX_BANDWIDTH_VARIANT;
2015 } else if (strncmp(cmd, "vg", 2) == 0) {
2016 get_variant_limit();
2017 } else if (strncmp(cmd, "ao", 2) == 0) {
2018 g_menu_state = CURRENT_STATUS_SET_AUDIO_ONLY;
2019 } else if (strncmp(cmd, "bf", 2) == 0) {
2020 g_menu_state = CURRENT_STATUS_SET_PRE_BUFFERING_SIZE;
2022 g_print("unknown menu \n");
2025 if (strncmp(cmd, "trs", 3) == 0)
2026 g_menu_state = CURRENT_STATUS_STREAMING_PLAYBACK_RATE;
2028 g_print("unknown menu \n");
2032 void display_sub_basic()
2035 g_print("=========================================================================================\n");
2036 g_print(" Player Test (press q to quit) \n");
2037 g_print("-----------------------------------------------------------------------------------------\n");
2038 g_print("[playback] a. Create\t");
2039 g_print("pr. Prepare \t");
2040 g_print("pa. Prepare async \t");
2041 g_print("b. Play \t");
2042 g_print("c. Stop \t");
2043 g_print("d. Resume\t");
2044 g_print("e. Pause \t");
2045 g_print("un. Unprepare \t");
2046 g_print("dt. Destroy \n");
2047 g_print("[State] S. Player State \n");
2048 g_print("[ volume ] f. Set Volume\t");
2049 g_print("g. Get Volume\t");
2050 g_print("z. Set Sound type\t");
2051 g_print("k. Set Sound Stream Info.\n");
2052 g_print("[ mute ] h. Set Mute\t");
2053 g_print("i. Get Mute\n");
2054 g_print("[audio eq] E. Set Audio EQ\t");
2055 g_print("H. Get Audio EQ\n");
2056 g_print("[position] j. Set Position \t");
2057 g_print("l. Get Position\n");
2058 g_print("[trick] tr. set playback rate\n");
2059 g_print("[duration] m. Get Duration\n");
2060 g_print("[Stream Info] n. Get stream info (Video Size, codec, audio stream info, and tag info)\n");
2061 g_print("[Looping] o. Set Looping\t");
2062 g_print("p. Get Looping\n");
2063 g_print("[display] v. Set display visible\t");
2064 g_print("w. Get display visible\n");
2065 g_print("[display] ds. Change display surface type\n");
2066 g_print("[display] dr. set display roi area\n");
2067 g_print("[overlay display] r. Set display mode\t");
2068 g_print("s. Get display mode\n");
2069 g_print("[overlay display] t. Set display Rotation\n");
2070 g_print("[Track] tl. Get Track language info(single only)\n");
2071 g_print("[Variant] vi. Get Streaming Variant Info\t");
2072 g_print("vs. Set max limit of variant\t");
2073 g_print("vg. Get max limit of variant\n");
2074 g_print("[audio only] ao. set audio only\n");
2075 g_print("[subtitle] A. Set(or change) subtitle path\n");
2076 g_print("[subtitle] ss. Select(or change) subtitle track\n");
2077 g_print("[Video Capture] C. Capture \n");
2078 g_print("[next uri] su. set next uri. \t");
2079 g_print("gu. get next uri. \t");
2080 g_print("sg. set gapless. \n");
2081 g_print("[audio_frame_decoded_cb_ex] X3. set audio_cb with sync\t");
2082 g_print("X4. set audio_cb with async \n");
2083 g_print("[video_frame_decoded_cb] ep. enable tbm surface pool\n");
2084 g_print("[buffering] bf. set new buffering size\n");
2085 g_print("[etc] sp. Set Progressive Download\t");
2086 g_print("gp. Get Progressive Download status\t");
2087 g_print("mp. memory playback\n");
2089 g_print("=========================================================================================\n");
2092 static void displaymenu()
2094 if (g_menu_state == CURRENT_STATUS_MAINMENU) {
2095 display_sub_basic();
2096 } else if (g_menu_state == CURRENT_STATUS_HANDLE_NUM) {
2097 g_print("*** input number of handles.(recommended only for EVAS surface)\n");
2098 } else if (g_menu_state == CURRENT_STATUS_FILENAME) {
2099 g_print("*** input mediapath.\n");
2100 } else if (g_menu_state == CURRENT_STATUS_VOLUME) {
2101 g_print("*** input volume value.(0~1.0)\n");
2102 } else if (g_menu_state == CURRENT_STATUS_SOUND_TYPE) {
2103 g_print("*** input sound type.(0:SYSTEM 1:NOTIFICATION 2:ALARM 3:RINGTONE 4:MEDIA 5:CALL 6:VOIP 7:FIXED)\n");
2104 } else if (g_menu_state == CURRENT_STATUS_SOUND_STREAM_INFO) {
2105 g_print("*** input sound stream type.(0:MEDIA 1:SYSTEM 2:ALARM 3:NOTIFICATION 4:EMERGENCY 5:VOICE_INFORMATION 9:MEDIA_EXT_ONLY)\n");
2106 } else if (g_menu_state == CURRENT_STATUS_MUTE) {
2107 g_print("*** input mute value.(0: Not Mute, 1: Mute) \n");
2108 } else if (g_menu_state == CURRENT_STATUS_POSITION_TIME) {
2109 g_print("*** input position value(msec)\n");
2110 } else if (g_menu_state == CURRENT_STATUS_POSITION_ACCURATE) {
2111 g_print("*** input accurate value(0/1)\n");
2112 } else if (g_menu_state == CURRENT_STATUS_LOOPING) {
2113 g_print("*** input looping value.(0: Not Looping, 1: Looping) \n");
2114 } else if (g_menu_state == CURRENT_STATUS_DISPLAY_SURFACE_CHANGE) {
2115 g_print("*** input display surface type.(0: Wayland surface, 1: EVAS surface, 2: No use surface (e.g: audio playback)) \n");
2116 } else if (g_menu_state == CURRENT_STATUS_DISPLAY_MODE) {
2117 g_print("*** input display mode value.(0: LETTER BOX, 1: ORIGIN SIZE, 2: FULL_SCREEN, 3: CROPPED_FULL, 4: ORIGIN_OR_LETTER) \n");
2118 } else if (g_menu_state == CURRENT_STATUS_DISPLAY_DST_ROI) {
2119 g_print("*** input display roi value sequentially.(x, y, w, h)\n");
2120 } else if (g_menu_state == CURRENT_STATUS_DISPLAY_ROTATION) {
2121 g_print("*** input display rotation value.(0: NONE, 1: 90, 2: 180, 3: 270, 4:F LIP_HORZ, 5: FLIP_VERT ) \n");
2122 } else if (g_menu_state == CURRENT_STATUS_DISPLAY_VISIBLE) {
2123 g_print("*** input display visible value.(0: HIDE, 1: SHOW) \n");
2124 } else if (g_menu_state == CURRENT_STATUS_SUBTITLE_FILENAME) {
2125 g_print(" *** input subtitle file path.\n");
2126 } else if (g_menu_state == CURRENT_STATUS_AUDIO_EQUALIZER) {
2127 g_print(" *** input audio eq value.(0: UNSET, 1: SET) \n");
2128 } else if (g_menu_state == CURRENT_STATUS_PLAYBACK_RATE || g_menu_state == CURRENT_STATUS_STREAMING_PLAYBACK_RATE) {
2129 g_print(" *** input playback rate.(-5.0 ~ 5.0)\n");
2130 } else if (g_menu_state == CURRENT_STATUS_SWITCH_SUBTITLE) {
2131 int count = 0, cur_index = 0;
2134 ret = player_get_track_count(g_player[0], PLAYER_STREAM_TYPE_TEXT, &count);
2135 if (ret != PLAYER_ERROR_NONE)
2136 g_print("player_get_track_count fail!!!!\n");
2138 g_print("Total subtitle tracks = %d \n", count);
2139 player_get_current_track(g_player[0], PLAYER_STREAM_TYPE_TEXT, &cur_index);
2140 g_print("Current index = %d \n", cur_index);
2141 g_print(" *** input correct index 0 to %d\n:", (count - 1));
2143 g_print("no track\n");
2144 } else if (g_menu_state == CURRENT_STATUS_NEXT_URI) {
2145 g_print("*** input next uri.\n");
2146 } else if (g_menu_state == CURRENT_STATUS_GAPLESS) {
2147 g_print("*** input gapless value.(0:disable, 1: enable) \n");
2148 } else if (g_menu_state == CURRENT_STATUS_GET_TRACK_INFO) {
2149 g_print("*** input stream type.(1:audio, 3:text) \n");
2150 } else if (g_menu_state == CURRENT_STATUS_SET_MAX_BANDWIDTH_VARIANT) {
2151 g_print("*** set max bandwidth (default: -1) \n");
2152 } else if (g_menu_state == CURRENT_STATUS_SET_MAX_WIDTH_VARIANT) {
2153 g_print("*** set max width (default: -1) \n");
2154 } else if (g_menu_state == CURRENT_STATUS_SET_MAX_HEIGHT_VARIANT) {
2155 g_print("*** set max height (default: -1) \n");
2156 } else if (g_menu_state == CURRENT_STATUS_SET_AUDIO_ONLY) {
2157 g_print("*** set audio only mode (0:disable, 1:enable) \n");
2158 } else if (g_menu_state == CURRENT_STATUS_SET_PRE_BUFFERING_SIZE) {
2159 g_print("*** set pre buffering size (ms) \n");
2161 g_print("*** unknown status.\n");
2167 gboolean timeout_menu_display(void *data)
2173 gboolean timeout_quit_program(void *data)
2179 void reset_menu_state(void)
2181 g_menu_state = CURRENT_STATUS_MAINMENU;
2184 static void interpret(char *cmd)
2186 switch (g_menu_state) {
2187 case CURRENT_STATUS_MAINMENU:
2189 _interpret_main_menu(cmd);
2192 case CURRENT_STATUS_HANDLE_NUM:
2194 int num_handle = atoi(cmd);
2195 if (0 >= num_handle || num_handle > MAX_HANDLE)
2196 g_print("not supported this number for handles(%d)\n", num_handle);
2198 g_handle_num = num_handle;
2203 case CURRENT_STATUS_FILENAME:
2205 input_filename(cmd);
2209 case CURRENT_STATUS_VOLUME:
2211 float level = atof(cmd);
2216 case CURRENT_STATUS_SOUND_TYPE:
2218 int type = atoi(cmd);
2219 set_sound_type(type);
2223 case CURRENT_STATUS_SOUND_STREAM_INFO:
2225 int type = atoi(cmd);
2226 set_sound_stream_info(type);
2230 case CURRENT_STATUS_MUTE:
2232 int mute = atoi(cmd);
2237 case CURRENT_STATUS_POSITION_TIME:
2239 seek_info.pos = atoi(cmd);
2240 g_menu_state = CURRENT_STATUS_POSITION_ACCURATE;
2243 case CURRENT_STATUS_POSITION_ACCURATE:
2245 seek_info.accurate = (atoi(cmd) != 0) ? (true) : (false);
2246 set_position(seek_info.pos, seek_info.accurate);
2250 case CURRENT_STATUS_LOOPING:
2252 int looping = atoi(cmd);
2253 set_looping(looping);
2257 case CURRENT_STATUS_GAPLESS:
2259 int gapless = atoi(cmd);
2260 set_gapless(gapless);
2264 case CURRENT_STATUS_DISPLAY_SURFACE_CHANGE:
2266 int type = atoi(cmd);
2267 change_surface(type);
2271 case CURRENT_STATUS_DISPLAY_MODE:
2273 int mode = atoi(cmd);
2274 set_display_mode(mode);
2278 case CURRENT_STATUS_DISPLAY_DST_ROI:
2280 int value = atoi(cmd);
2287 set_display_mode(PLAYER_DISPLAY_MODE_DST_ROI);
2304 set_display_roi_area(x, y, w, h);
2313 case CURRENT_STATUS_DISPLAY_ROTATION:
2315 int rotation = atoi(cmd);
2316 set_display_rotation(rotation);
2320 case CURRENT_STATUS_DISPLAY_VISIBLE:
2322 int visible = atoi(cmd);
2323 set_display_visible(visible);
2327 case CURRENT_STATUS_SUBTITLE_FILENAME:
2329 input_subtitle_filename(cmd);
2333 case CURRENT_STATUS_AUDIO_EQUALIZER:
2335 int value = atoi(cmd);
2336 set_audio_eq(value);
2340 case CURRENT_STATUS_PLAYBACK_RATE:
2342 float rate = atof(cmd);
2343 set_playback_rate(rate, FALSE);
2347 case CURRENT_STATUS_STREAMING_PLAYBACK_RATE:
2349 float rate = atof(cmd);
2350 set_playback_rate(rate, TRUE);
2354 case CURRENT_STATUS_SWITCH_SUBTITLE:
2356 int index = atoi(cmd);
2357 switch_subtitle(index);
2361 case CURRENT_STATUS_NEXT_URI:
2367 case CURRENT_STATUS_GET_TRACK_INFO:
2369 int index = atoi(cmd);
2370 get_track_info(index);
2374 case CURRENT_STATUS_SET_MAX_BANDWIDTH_VARIANT:
2376 int value = atoi(cmd);
2377 max_limit.bandwidth = value;
2378 g_menu_state = CURRENT_STATUS_SET_MAX_WIDTH_VARIANT;
2381 case CURRENT_STATUS_SET_MAX_WIDTH_VARIANT:
2383 int value = atoi(cmd);
2384 max_limit.width = value;
2385 g_menu_state = CURRENT_STATUS_SET_MAX_HEIGHT_VARIANT;
2388 case CURRENT_STATUS_SET_MAX_HEIGHT_VARIANT:
2390 int value = atoi(cmd);
2391 max_limit.height = value;
2392 set_variant_limit();
2396 case CURRENT_STATUS_SET_AUDIO_ONLY:
2398 int value = atoi(cmd);
2399 set_audio_only(value);
2403 case CURRENT_STATUS_SET_PRE_BUFFERING_SIZE:
2405 int value = atoi(cmd);
2406 buff_size.buffer_ms = value;
2407 g_menu_state = CURRENT_STATUS_SET_RE_BUFFERING_SIZE;
2410 case CURRENT_STATUS_SET_RE_BUFFERING_SIZE:
2412 int value = atoi(cmd);
2413 buff_size.rebuffer_ms = value;
2421 g_timeout_add(100, timeout_menu_display, 0);
2424 gboolean input(GIOChannel * channel)
2426 gchar buf[MAX_STRING_LEN];
2428 GError *error = NULL;
2430 g_io_channel_read_chars(channel, buf, MAX_STRING_LEN, &read, &error);
2438 int main(int argc, char *argv[])
2440 GIOChannel *stdin_channel;
2441 stdin_channel = g_io_channel_unix_new(0);
2442 g_io_channel_set_flags(stdin_channel, G_IO_FLAG_NONBLOCK, NULL);
2443 g_io_add_watch(stdin_channel, G_IO_IN, (GIOFunc) input, NULL);
2446 memset(&ad, 0x0, sizeof(appdata));
2449 return appcore_efl_main(PACKAGE, &argc, &argv, &ops);