--- /dev/null
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+#include <player.h>
+#include <player_internal.h>
+#include <sound_manager.h>
+#include <pthread.h>
+#include <glib.h>
+#include <dlfcn.h>
+#include <appcore-efl.h>
+#include <Ecore.h>
+
+#ifdef PACKAGE
+#undef PACKAGE
+#endif
+#define PACKAGE "player_audio_test"
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+#define LOG_TAG "PLAYER_AUDIO_TEST"
+
+#define MAX_STRING_LEN 2048
+#define PLAYER_AUDIO_TEST_DUMP_PATH_PREFIX "/home/owner/dump_pcm_"
+#define DEFAULT_HTTP_TIMEOUT -1
+
+#include <system_info.h>
+#include <stdlib.h>
+typedef enum {
+ TIZEN_PROFILE_UNKNOWN = 0,
+ TIZEN_PROFILE_MOBILE = 0x1,
+ TIZEN_PROFILE_WEARABLE = 0x2,
+ TIZEN_PROFILE_TV = 0x4,
+ TIZEN_PROFILE_IVI = 0x8,
+ TIZEN_PROFILE_COMMON = 0x10,
+} tizen_profile_t;
+
+typedef struct {
+ int bandwidth;
+ int width;
+ int height;
+} adaptive_variant_info_t;
+
+static tizen_profile_t _get_tizen_profile()
+{
+ char *profileName;
+ static tizen_profile_t profile = TIZEN_PROFILE_UNKNOWN;
+
+ if (__builtin_expect(profile != TIZEN_PROFILE_UNKNOWN, 1))
+ return profile;
+
+ system_info_get_platform_string("http://tizen.org/feature/profile", &profileName);
+ switch (*profileName) {
+ case 'm':
+ case 'M':
+ profile = TIZEN_PROFILE_MOBILE;
+ break;
+ case 'w':
+ case 'W':
+ profile = TIZEN_PROFILE_WEARABLE;
+ break;
+ case 't':
+ case 'T':
+ profile = TIZEN_PROFILE_TV;
+ break;
+ case 'i':
+ case 'I':
+ profile = TIZEN_PROFILE_IVI;
+ break;
+ default: // common or unknown ==> ALL ARE COMMON.
+ profile = TIZEN_PROFILE_COMMON;
+ }
+ free(profileName);
+
+ return profile;
+}
+#define TIZEN_TV ((_get_tizen_profile()) == TIZEN_PROFILE_TV)
+
+static gboolean g_memory_playback = FALSE;
+static char g_uri[MAX_STRING_LEN];
+static FILE *g_pcm_fd;
+
+static gboolean is_es_push_mode = FALSE;
+static pthread_t g_feed_audio_thread_id = 0;
+static bool g_thread_end = FALSE;
+static media_packet_h g_audio_pkt = NULL;
+static media_format_h g_audio_fmt = NULL;
+
+static int _save(unsigned char *src, int length);
+
+#define DUMP_OUTBUF 1
+#if DUMP_OUTBUF
+FILE *fp_out1 = NULL;
+FILE *fp_out2 = NULL;
+#endif
+
+enum {
+ CURRENT_STATUS_MAINMENU,
+ CURRENT_STATUS_HANDLE_NUM,
+ CURRENT_STATUS_FILENAME,
+ CURRENT_STATUS_VOLUME,
+ CURRENT_STATUS_SOUND_TYPE,
+ CURRENT_STATUS_SOUND_STREAM_INFO,
+ CURRENT_STATUS_MUTE,
+ CURRENT_STATUS_POSITION_TIME,
+ CURRENT_STATUS_LOOPING,
+ CURRENT_STATUS_AUDIO_EQUALIZER,
+ CURRENT_STATUS_PLAYBACK_RATE,
+ CURRENT_STATUS_STREAMING_PLAYBACK_RATE,
+ CURRENT_STATUS_NEXT_URI,
+ CURRENT_STATUS_GAPLESS,
+ CURRENT_STATUS_GET_TRACK_INFO,
+ CURRENT_STATUS_POSITION_ACCURATE,
+ CURRENT_STATUS_SET_MAX_BANDWIDTH_VARIANT,
+ CURRENT_STATUS_SET_MAX_WIDTH_VARIANT,
+ CURRENT_STATUS_SET_MAX_HEIGHT_VARIANT,
+};
+
+typedef struct {
+ int pos;
+ bool accurate;
+} player_seek_pos_t;
+
+#define MAX_HANDLE 20
+
+static player_h g_player[MAX_HANDLE] = { 0, };
+static player_seek_pos_t seek_info = {0};
+int g_handle_num = 1;
+int g_menu_state = CURRENT_STATUS_MAINMENU;
+gboolean quit_pushing;
+sound_stream_info_h g_stream_info_h = NULL;
+static adaptive_variant_info_t max_limit = {-1, -1, -1};
+
+static int app_create(void *data)
+{
+ return 0;
+}
+static int app_terminate(void *data)
+{
+ return 0;
+}
+
+struct appcore_ops ops = {
+ .create = app_create,
+ .terminate = app_terminate,
+};
+
+static void prepared_cb(void *user_data)
+{
+ g_print("[Player_Audio_Test] prepared_cb!!!!\n");
+}
+
+static void _audio_frame_decoded_cb_ex(player_audio_raw_data_s * audio_raw_frame, void *user_data)
+{
+ player_audio_raw_data_s *audio_raw = audio_raw_frame;
+
+ if (!audio_raw)
+ return;
+
+ g_print("[Player_Audio_Test] decoded_cb_ex! channel: %d channel_mask: %llu\n", audio_raw->channel, audio_raw->channel_mask);
+
+#if DUMP_OUTBUF
+ if (audio_raw->channel_mask == 1 && fp_out1)
+ fwrite((guint8 *) audio_raw->data, 1, audio_raw->size, fp_out1);
+ else if (audio_raw->channel_mask == 2 && fp_out2)
+ fwrite((guint8 *) audio_raw->data, 1, audio_raw->size, fp_out2);
+#endif
+}
+
+static void progress_down_cb(player_pd_message_type_e type, void *user_data)
+{
+ g_print("[Player_Audio_Test] progress_down_cb!!!! type : %d\n", type);
+}
+
+static void buffering_cb(int percent, void *user_data)
+{
+ g_print("[Player_Audio_Test] buffering_cb!!!! percent : %d\n", percent);
+}
+
+static void seek_completed_cb(void *user_data)
+{
+ g_print("[Player_Audio_Test] seek_completed_cb!!! \n");
+}
+
+static void completed_cb(void *user_data)
+{
+ g_print("[Player_Audio_Test] completed_cb!!!!\n");
+}
+
+static void error_cb(int code, void *user_data)
+{
+ g_print("[Player_Audio_Test] error_cb!!!! code : %d\n", code);
+}
+
+static void interrupted_cb(player_interrupted_code_e code, void *user_data)
+{
+ g_print("[Player_Audio_Test] interrupted_cb!!!! code : %d\n", code);
+}
+
+static void video_changed_cb(int width, int height, int fps, int bit_rate, void *user_data)
+{
+ g_print("[Player_Audio_Test] video_changed_cb!!!! %d x %d, %d, %d \n", width, height, fps, bit_rate);
+}
+
+#if 0
+static void audio_frame_decoded_cb(unsigned char *data, unsigned int size, void *user_data)
+{
+ int pos = 0;
+
+ if (data && g_pcm_fd)
+ fwrite(data, 1, size, g_pcm_fd);
+ player_get_play_position(g_player[0], &pos);
+ g_print("[Player_Audio_Test] audio_frame_decoded_cb [size: %d] --- current pos : %d!!!!\n", size, pos);
+}
+#endif
+
+static int _save(unsigned char *src, int length)
+{
+ /* unlink(CAPTUERD_IMAGE_SAVE_PATH); */
+ FILE *fp;
+ char filename[256] = { 0, };
+ static int WRITE_COUNT = 0;
+ /* gchar *filename = CAPTUERD_IMAGE_SAVE_PATH; */
+ snprintf(filename, 256, "/tmp/IMAGE_client%d", WRITE_COUNT);
+ WRITE_COUNT++;
+ fp = fopen(filename, "w+");
+ if (fp == NULL) {
+ g_print("file open error!!\n");
+ return FALSE;
+ } else {
+ g_print("open success\n");
+ if (fwrite(src, 1, length, fp) < 1) {
+ g_print("file write error!!\n");
+ fclose(fp);
+ return FALSE;
+ }
+ g_print("write success(%s)\n", filename);
+ fclose(fp);
+ }
+
+ return TRUE;
+}
+
+static void input_filename(char *filename)
+{
+ int len = strlen(filename);
+ int i = 0;
+
+ if (len < 0 || len > MAX_STRING_LEN - 1)
+ return;
+
+ for (i = 0; i < g_handle_num; i++) {
+ if (g_player[i] != NULL) {
+ player_unprepare(g_player[i]);
+ player_destroy(g_player[i]);
+ }
+ g_player[i] = 0;
+
+ if (player_create(&g_player[i]) != PLAYER_ERROR_NONE)
+ g_print("player create is failed\n");
+ }
+ strncpy(g_uri, filename, len+1);
+
+#if 0
+ /* ned(APPSRC_TEST) */
+ gchar uri[100];
+ gchar *ext;
+ gsize file_size;
+ GMappedFile *file;
+ GError *error = NULL;
+ guint8 *g_media_mem = NULL;
+
+ ext = filename;
+
+ file = g_mapped_file_new(ext, FALSE, &error);
+ file_size = g_mapped_file_get_length(file);
+ g_media_mem = (guint8 *) g_mapped_file_get_contents(file);
+
+ g_sprintf(uri, "mem://ext=%s,size=%d", ext ? ext : "", file_size);
+ g_print("[uri] = %s\n", uri);
+
+ mm_player_set_attribute(g_player[0], &g_err_name, "profile_uri", uri, strlen(uri), "profile_user_param", g_media_mem, file_size NULL);
+#else
+ /* player_set_uri(g_player[0], filename); */
+#endif
+ /* APPSRC_TEST */
+
+ int ret;
+ player_state_e state;
+ for (i = 0; i < g_handle_num; i++) {
+ ret = player_get_state(g_player[i], &state);
+ g_print("player_get_state returned [%d]\n", ret);
+ g_print("1. After player_create() - Current State : %d \n", state);
+ }
+}
+
+/* use this API instead of player_set_uri */
+static void player_set_memory_buffer_test()
+{
+ GMappedFile *file;
+ gsize file_size;
+ guint8 *g_media_mem = NULL;
+
+ file = g_mapped_file_new(g_uri, FALSE, NULL);
+ file_size = g_mapped_file_get_length(file);
+ g_media_mem = (guint8 *) g_mapped_file_get_contents(file);
+
+ int ret = player_set_memory_buffer(g_player[0], (void *)g_media_mem, file_size);
+ g_print("player_set_memory_buffer ret : %d\n", ret);
+}
+
+
+int audio_packet_count = 0;
+static void buffer_need_audio_data_cb(unsigned int size, void *user_data)
+{
+ int real_read_len = 0;
+ char fname[128];
+ FILE *fp = NULL;
+ guint8 *buff_ptr = NULL;
+ void *src = NULL;
+
+ memset(fname, 0, 128);
+ audio_packet_count++;
+
+ if (audio_packet_count > 1000) {
+ g_print("EOS.\n");
+ /* player_submit_packet(g_player[0], NULL, 0, 0, 0); */
+ player_push_media_stream(g_player[0], NULL);
+ g_thread_end = TRUE;
+ }
+
+ /* snprintf(fname, 128, "/opt/storage/usb/test/audio_packet/packet_%d.dat", audio_packet_count); */
+ snprintf(fname, 128, "/home/developer/test/audio_packet/packet_%d.dat", audio_packet_count);
+
+ static guint64 audio_pts = 0;
+ guint64 audio_dur = 21333333;
+
+ fp = fopen(fname, "rb");
+ if (fp) {
+ buff_ptr = (guint8 *) g_malloc0(1048576);
+ if (!buff_ptr) {
+ g_print("no free space\n");
+ fclose(fp);
+ fp = NULL;
+ return;
+ }
+ real_read_len = fread(buff_ptr, 1, size, fp);
+ fclose(fp);
+ fp = NULL;
+
+ g_print("\t audio need data - data size : %d, pts : %" G_GUINT64_FORMAT "\n", real_read_len, audio_pts);
+ }
+#if 0
+ player_submit_packet(g_player[0], buff_ptr, real_read_len, (audio_pts / 1000000), 0);
+#else
+ /* create media packet */
+ if (g_audio_pkt) {
+ media_packet_destroy(g_audio_pkt);
+ g_audio_pkt = NULL;
+ }
+ media_packet_create_alloc(g_audio_fmt, NULL, NULL, &g_audio_pkt);
+
+ g_print("packet = %p, src = %p\n", g_audio_pkt, src);
+
+ if (media_packet_get_buffer_data_ptr(g_audio_pkt, &src) != MEDIA_PACKET_ERROR_NONE)
+ goto EXIT;
+
+ if (media_packet_set_pts(g_audio_pkt, (uint64_t) audio_pts) != MEDIA_PACKET_ERROR_NONE)
+ goto EXIT;
+
+ if (media_packet_set_buffer_size(g_audio_pkt, (uint64_t) real_read_len) != MEDIA_PACKET_ERROR_NONE)
+ goto EXIT;
+
+ memcpy(src, buff_ptr, real_read_len);
+
+ /* then, push it */
+ player_push_media_stream(g_player[0], g_audio_pkt);
+#endif
+
+ audio_pts += audio_dur;
+ EXIT:
+ if (buff_ptr) {
+ g_free(buff_ptr);
+ buff_ptr = NULL;
+ }
+}
+
+static void set_content_info(bool is_push_mode)
+{
+ /* testcode for es buff src case, please input url as es_buff://123 or es_buff://push_mode */
+ /* 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}; */
+
+ /* create media format */
+ media_format_create(&g_audio_fmt);
+
+ /* Audio--aac--StarWars.mp4 */
+ media_format_set_audio_mime(g_audio_fmt, MEDIA_FORMAT_AAC);
+ media_format_set_audio_channel(g_audio_fmt, 2);
+ media_format_set_audio_samplerate(g_audio_fmt, 48000);
+ /* player_set_media_stream_info(g_player[0], PLAYER_STREAM_TYPE_AUDIO, g_audio_fmt); */
+#if 0
+ /* audio--aac--StarWars.mp4 */
+ /* audio_info->mime = g_strdup("audio/mpeg"); */
+ /* audio_info->version = 2; */
+ /* audio_info->user_info = 0; *//* raw */
+#endif
+
+#ifdef _ES_PULL_
+ if (!is_push_mode) {
+ player_set_buffer_need_audio_data_cb(g_player[0], buffer_need_audio_data_cb, (void *)g_player[0]);
+ }
+#endif
+}
+
+static void feed_audio_data_thread_func(void *data)
+{
+ while (!g_thread_end) {
+ buffer_need_audio_data_cb(1048576, NULL);
+ }
+}
+
+static void _player_prepare(bool async)
+{
+ int ret = FALSE;
+ int i = 0;
+ for (i = 0; i < g_handle_num; i++) {
+ player_set_buffering_cb(g_player[i], buffering_cb, (void *)g_player[i]);
+ player_set_completed_cb(g_player[i], completed_cb, (void *)g_player[i]);
+ player_set_interrupted_cb(g_player[i], interrupted_cb, (void *)g_player[i]);
+ player_set_error_cb(g_player[i], error_cb, (void *)g_player[i]);
+ player_set_video_stream_changed_cb(g_player[0], video_changed_cb, (void *)g_player[0]);
+ if (g_memory_playback)
+ player_set_memory_buffer_test();
+ else
+ player_set_uri(g_player[i], g_uri);
+ }
+
+ if (strstr(g_uri, "es_buff://")) {
+ is_es_push_mode = FALSE;
+ audio_packet_count = 0;
+
+ if (strstr(g_uri, "es_buff://push_mode")) {
+ set_content_info(TRUE);
+ async = TRUE;
+ is_es_push_mode = TRUE;
+#ifdef _ES_PULL_
+ } else {
+ set_content_info(FALSE);
+#endif
+ }
+ }
+
+ for (i = 0; i < g_handle_num; i++) {
+ if (async)
+ ret = player_prepare_async(g_player[i], prepared_cb, (void *)g_player[i]);
+ else
+ ret = player_prepare(g_player[i]);
+ }
+
+ if (ret != PLAYER_ERROR_NONE)
+ g_print("prepare is failed (errno = %d) \n", ret);
+
+ player_state_e state;
+
+ for (i = 0; i < g_handle_num; i++) {
+ ret = player_get_state(g_player[i], &state);
+ g_print("After player_prepare() - Current State : %d \n", state);
+ }
+
+ if (is_es_push_mode)
+ pthread_create(&g_feed_audio_thread_id, NULL, (void *)feed_audio_data_thread_func, NULL);
+
+}
+
+static void _player_unprepare()
+{
+ int ret = FALSE;
+ int i = 0;
+ player_state_e state;
+
+ for (i = 0; i < g_handle_num; i++) {
+ if (g_player[i] != NULL) {
+ ret = player_unprepare(g_player[i]);
+ if (ret != PLAYER_ERROR_NONE)
+ g_print("unprepare is failed (errno = %d) \n", ret);
+
+ ret = player_unset_subtitle_updated_cb(g_player[i]);
+ g_print("player_unset_subtitle_updated_cb [%d] ret %d\n", i, ret);
+
+ ret = player_unset_buffering_cb(g_player[i]);
+ g_print("player_unset_buffering_cb [%d] ret %d\n", i, ret);
+
+ ret = player_unset_completed_cb(g_player[i]);
+ g_print("player_unset_completed_cb [%d] ret %d\n", i, ret);
+
+ ret = player_unset_interrupted_cb(g_player[i]);
+ g_print("player_unset_interrupted_cb [%d] ret %d\n", i, ret);
+
+ ret = player_unset_error_cb(g_player[i]);
+ g_print("player_unset_error_cb [%d] ret %d\n", i, ret);
+ }
+ }
+
+ for (i = 0; i < g_handle_num; i++) {
+ ret = player_get_state(g_player[i], &state);
+ g_print(" After player_unprepare() - Current State : %d \n", state);
+ }
+}
+
+static void _player_destroy()
+{
+ int i = 0;
+
+ for (i = 0; i < g_handle_num; i++) {
+ if (g_player[i] != NULL) {
+ player_unprepare(g_player[i]);
+ player_destroy(g_player[i]);
+ g_player[i] = 0;
+ }
+ }
+
+ if (g_stream_info_h) {
+ sound_manager_destroy_stream_information(g_stream_info_h);
+ g_stream_info_h = NULL;
+ }
+
+ if (g_audio_pkt)
+ media_packet_destroy(g_audio_pkt);
+
+#if DUMP_OUTBUF
+ if (fp_out1)
+ fclose(fp_out1);
+ if (fp_out2)
+ fclose(fp_out2);
+#endif
+
+}
+
+static void _player_play()
+{
+ int bRet = FALSE;
+ int i = 0;
+ for (i = 0; i < g_handle_num; i++) {
+ bRet = player_start(g_player[i]);
+ g_print("player_start returned [%d]", bRet);
+ }
+}
+
+static void _player_stop()
+{
+ int bRet = FALSE;
+ int i = 0;
+
+ for (i = 0; i < g_handle_num; i++) {
+ bRet = player_stop(g_player[i]);
+ g_print("player_stop returned [%d]", bRet);
+ }
+
+ g_thread_end = TRUE;
+ if (g_feed_audio_thread_id) {
+ pthread_join(g_feed_audio_thread_id, NULL);
+ g_feed_audio_thread_id = 0;
+ }
+
+}
+
+static void _player_resume()
+{
+ int bRet = FALSE;
+ int i = 0;
+
+ for (i = 0; i < g_handle_num; i++) {
+ bRet = player_start(g_player[i]);
+ g_print("player_start returned [%d]", bRet);
+ }
+}
+
+static void _player_pause()
+{
+ int bRet = FALSE;
+ int i = 0;
+ for (i = 0; i < g_handle_num; i++) {
+ bRet = player_pause(g_player[i]);
+ g_print("player_pause returned [%d]", bRet);
+ }
+}
+
+static void _player_state()
+{
+ player_state_e state;
+ player_get_state(g_player[0], &state);
+ g_print(" ==> [Player_Audio_Test] Current Player State : %d\n", state);
+}
+
+static void _player_set_progressive_download()
+{
+ player_set_progressive_download_path(g_player[0], "/home/owner/test.pd");
+ player_set_progressive_download_message_cb(g_player[0], progress_down_cb, (void *)g_player[0]);
+}
+
+static void _player_get_progressive_download_status()
+{
+ int bRet = 0;
+ unsigned long curr = 0, total = 0;
+ bRet = player_get_progressive_download_status(g_player[0], &curr, &total);
+ g_print("player_get_progressive_download_status return[%d] ==> [Player_Audio_Test] progressive download status : %lu/%lu\n", bRet, curr, total);
+}
+
+static void set_next_uri(char * uri)
+{
+ if (TIZEN_TV) {
+ g_print("not support at TV profile");
+ return;
+ }
+
+ if (player_set_next_uri(g_player[0], uri) != PLAYER_ERROR_NONE)
+ g_print("fail to set next uri");
+}
+
+static void get_next_uri()
+{
+ char *uri;
+
+ if (TIZEN_TV) {
+ g_print("not support at TV profile");
+ return;
+ }
+
+ if (player_get_next_uri(g_player[0], &uri) != PLAYER_ERROR_NONE) {
+ g_print("fail to get next uri");
+ return;
+ }
+
+ if (uri != NULL) {
+ g_print("next_uri = %s", uri);
+ free(uri);
+ }
+}
+
+static void set_volume(float volume)
+{
+ if (player_set_volume(g_player[0], volume, volume) != PLAYER_ERROR_NONE)
+ g_print("failed to set volume\n");
+}
+
+static void get_volume(float *left, float *right)
+{
+ player_get_volume(g_player[0], left, right);
+ g_print(" ==> [Player_Audio_Test] volume - left : %f, right : %f\n", *left, *right);
+}
+
+static void set_mute(bool mute)
+{
+ if (player_set_mute(g_player[0], mute) != PLAYER_ERROR_NONE)
+ g_print("failed to set_mute\n");
+}
+
+static void get_mute(bool * mute)
+{
+ player_is_muted(g_player[0], mute);
+ g_print(" ==> [Player_Audio_Test] mute = %d\n", *mute);
+}
+
+static void set_sound_type(sound_type_e type)
+{
+ if (player_set_sound_type(g_player[0], type) != PLAYER_ERROR_NONE)
+ g_print("failed to set sound type(%d)\n", type);
+ else
+ g_print("set sound type(%d) success", type);
+}
+
+void focus_callback(sound_stream_info_h stream_info,
+ sound_stream_focus_mask_e focus_mask,
+ sound_stream_focus_state_e focus_state,
+ sound_stream_focus_change_reason_e reason,
+ int sound_behavior,
+ const char *extra_info,
+ void *user_data)
+{
+ g_print("FOCUS callback is called, reason(%d), extra_info(%s), userdata(%p)", reason, extra_info, user_data);
+ return;
+}
+
+static void set_sound_stream_info(int type)
+{
+ sound_device_list_h device_list = NULL;
+ int ret = SOUND_MANAGER_ERROR_NONE;
+
+ if (g_stream_info_h) {
+ g_print("stream information is already set, please destory handle and try again\n");
+ return;
+ }
+ if (sound_manager_create_stream_information(type, focus_callback, g_player[0], &g_stream_info_h)) {
+ g_print("failed to create stream_information()\n");
+ return;
+ }
+ /* In case of MEDIA_EXTERNAL_ONLY, we need to set external device manually */
+ if (type == (int)SOUND_STREAM_TYPE_MEDIA_EXTERNAL_ONLY) {
+ sound_device_h device = NULL;
+ sound_device_type_e device_type;
+
+ if ((ret = sound_manager_get_device_list(SOUND_DEVICE_ALL_MASK, &device_list))) {
+ g_print("failed to sound_manager_get_device_list(), ret(0x%x)\n", ret);
+ goto END;
+ }
+ while (!(ret = sound_manager_get_next_device(device_list, &device))) {
+ if ((ret = sound_manager_get_device_type(device, &device_type))) {
+ g_print("failed to sound_manager_get_device_type(), ret(0x%x)\n", ret);
+ goto END;
+ }
+ if (device_type == SOUND_DEVICE_BLUETOOTH || device_type == SOUND_DEVICE_USB_AUDIO) {
+ if ((ret = sound_manager_add_device_for_stream_routing(g_stream_info_h, device))) {
+ g_print("failed to sound_manager_add_device_for_stream_routing(), ret(0x%x)\n", ret);
+ goto END;
+ }
+ if ((ret = sound_manager_apply_stream_routing(g_stream_info_h))) {
+ g_print("failed to sound_manager_apply_stream_routing(), ret(0x%x)\n", ret);
+ goto END;
+ }
+ break;
+ }
+ }
+ if (ret != SOUND_MANAGER_ERROR_NONE) {
+ g_print("failed to sound_manager_get_next_device(), ret(0x%x)\n", ret);
+ goto END;
+ }
+ }
+
+ if (player_set_sound_stream_info(g_player[0], g_stream_info_h) != PLAYER_ERROR_NONE)
+ g_print("failed to set sound stream information(%p)\n", g_stream_info_h);
+ else
+ g_print("set stream information(%p) success", g_stream_info_h);
+
+ END:
+ if (device_list)
+ sound_manager_free_device_list(device_list);
+ return;
+}
+
+void variant_cb(int bandwidth, int width, int height, void *user_data)
+{
+ g_print(" ==> [Player_Audio_Test][b]%d, [w]%d, [h]%d\n", bandwidth, width, height);
+}
+
+static void get_variant_info()
+{
+ player_foreach_adaptive_variant(g_player[0], (player_adaptive_variant_cb)variant_cb, g_player[0]);
+}
+
+static void get_variant_limit()
+{
+ int bandwidth, width, height;
+ player_get_max_adaptive_variant_limit(g_player[0], &bandwidth, &width, &height);
+ g_print(" ==> [Player_Audio_Test]get [b]%d, [w]%d, [h]%d\n", bandwidth, width, height);
+}
+
+static void set_variant_limit()
+{
+ g_print(" ==> [Player_Audio_Test]set [b]%d, [w]%d, [h]%d\n", max_limit.bandwidth, max_limit.width, max_limit.height);
+ player_set_max_adaptive_variant_limit(g_player[0], max_limit.bandwidth, max_limit.width, max_limit.height);
+}
+
+static void get_position()
+{
+ int position = 0;
+ int ret;
+ ret = player_get_play_position(g_player[0], &position);
+ g_print(" ==> [Player_Audio_Test] player_get_play_position()%d return : %d\n", ret, position);
+}
+
+static void set_position(int position, bool accurate)
+{
+ if (player_set_play_position(g_player[0], position, accurate, seek_completed_cb, g_player[0]) != PLAYER_ERROR_NONE)
+ g_print("failed to set position\n");
+}
+
+static void set_playback_rate(float rate, bool streaming)
+{
+ if (streaming) {
+ if (player_set_streaming_playback_rate(g_player[0], rate) != PLAYER_ERROR_NONE)
+ g_print("failed to set streaming playback rate\n");
+ } else {
+ if (player_set_playback_rate(g_player[0], rate) != PLAYER_ERROR_NONE)
+ g_print("failed to set playback rate\n");
+ }
+}
+
+static void get_duration()
+{
+ int duration = 0;
+ int ret;
+ ret = player_get_duration(g_player[0], &duration);
+ g_print(" ==> [Player_Audio_Test] player_get_duration() return : %d\n", ret);
+ g_print(" ==> [Player_Audio_Test] Duration: [%d ] msec\n", duration);
+}
+
+static void audio_frame_decoded_cb_ex(bool sync)
+{
+ int ret;
+#if DUMP_OUTBUF
+ fp_out1 = fopen("/tmp/out1.pcm", "wb");
+ fp_out2 = fopen("/tmp/out2.pcm", "wb");
+ if (!fp_out1 || !fp_out2) {
+ g_print("File open error\n");
+ return;
+ }
+#endif
+
+ ret = player_set_pcm_extraction_mode(g_player[0], sync, _audio_frame_decoded_cb_ex, &ret);
+ g_print(" ==> [Player_Audio_Test] player_set_audio_frame_decoded_cb_ex(sync:%d) ret:%d\n", sync, ret);
+
+ ret = player_set_pcm_spec(g_player[0], "F32LE", 44100, 2);
+ g_print("[Player_Audio_Test] set_pcm_spec return: %d\n", ret);
+}
+
+static void get_stream_info()
+{
+ int w = 0;
+ int h = 0;
+
+ char *value = NULL;
+ player_get_content_info(g_player[0], PLAYER_CONTENT_INFO_ALBUM, &value);
+ g_print(" ==> [Player_Audio_Test] PLAYER_CONTENT_INFO_ALBUM: [%s ] \n", value);
+ player_get_content_info(g_player[0], PLAYER_CONTENT_INFO_ARTIST, &value);
+ g_print(" ==> [Player_Audio_Test] PLAYER_CONTENT_INFO_ARTIST: [%s ] \n", value);
+ player_get_content_info(g_player[0], PLAYER_CONTENT_INFO_AUTHOR, &value);
+ g_print(" ==> [Player_Audio_Test] PLAYER_CONTENT_INFO_AUTHOR: [%s ] \n", value);
+ player_get_content_info(g_player[0], PLAYER_CONTENT_INFO_GENRE, &value);
+ g_print(" ==> [Player_Audio_Test] PLAYER_CONTENT_INFO_GENRE: [%s ] \n", value);
+ player_get_content_info(g_player[0], PLAYER_CONTENT_INFO_TITLE, &value);
+ g_print(" ==> [Player_Audio_Test] PLAYER_CONTENT_INFO_TITLE: [%s ] \n", value);
+ void *album;
+ int size;
+ player_get_album_art(g_player[0], &album, &size);
+ g_print(" ==> [Player_Audio_Test] Album art : [ data : %p, size : %d ]\n", (unsigned int *)album, size);
+ _save(album, size);
+ if (value != NULL) {
+ free(value);
+ value = NULL;
+ }
+
+ int sample_rate;
+ int channel;
+ int bit_rate;
+ int fps, v_bit_rate;
+ player_get_audio_stream_info(g_player[0], &sample_rate, &channel, &bit_rate);
+ g_print(" ==> [Player_Audio_Test] Sample Rate: [%d ] , Channel: [%d ] , Bit Rate: [%d ] \n", sample_rate, channel, bit_rate);
+
+ player_get_video_stream_info(g_player[0], &fps, &v_bit_rate);
+ g_print(" ==> [Player_Audio_Test] fps: [%d ] , Bit Rate: [%d ] \n", fps, v_bit_rate);
+
+ char *audio_codec = NULL;
+ char *video_codec = NULL;
+ player_get_codec_info(g_player[0], &audio_codec, &video_codec);
+ if (audio_codec != NULL) {
+ g_print(" ==> [Player_Audio_Test] Audio Codec: [%s ] \n", audio_codec);
+ free(audio_codec);
+ audio_codec = NULL;
+ }
+ if (video_codec != NULL) {
+ g_print(" ==> [Player_Audio_Test] Video Codec: [%s ] \n", video_codec);
+ free(video_codec);
+ video_codec = NULL;
+ }
+ player_get_video_size(g_player[0], &w, &h);
+ g_print(" ==> [Player_Audio_Test] Width: [%d ] , Height: [%d ] \n", w, h);
+}
+
+static void set_gapless(bool gapless)
+{
+ int i = 0;
+
+ if (TIZEN_TV) {
+ g_print("not support at TV profile");
+ return;
+ }
+
+ for (i = 0; i < g_handle_num; i++) {
+ if (player_set_gapless(g_player[i], gapless) != PLAYER_ERROR_NONE)
+ g_print("failed to set_gapless\n");
+ }
+}
+
+static void set_looping(bool looping)
+{
+ int i = 0;
+ for (i = 0; i < g_handle_num; i++) {
+ if (player_set_looping(g_player[i], looping) != PLAYER_ERROR_NONE)
+ g_print("failed to set_looping\n");
+ }
+}
+
+static void get_looping(bool * looping)
+{
+ player_is_looping(g_player[0], looping);
+ g_print(" ==> [Player_Audio_Test] looping = %d\n", *looping);
+}
+
+static void get_track_info(int index)
+{
+ int count = 0, cur_index = 0;
+ int ret = 0;
+ char *lang_code = NULL;
+
+ if (index != PLAYER_STREAM_TYPE_AUDIO &&
+ index != PLAYER_STREAM_TYPE_TEXT) {
+ g_print("invalid stream type %d", index);
+ return;
+ }
+
+ ret = player_get_track_count(g_player[0], index, &count);
+ if (ret != PLAYER_ERROR_NONE)
+ g_print("player_get_track_count fail!!!!\n");
+ else if (count) {
+ int idx = 0;
+ player_get_current_track(g_player[0], index, &cur_index);
+ g_print("total track: %d, curr track: %d\n", count, cur_index);
+
+ for (idx = 0; idx < count; idx++) {
+ player_get_track_language_code(g_player[0], index, idx, &lang_code);
+ g_print("track info = [%d] %s\n", idx, lang_code);
+ }
+ } else {
+ g_print("no track\n");
+ }
+}
+
+static void decoding_audio()
+{
+#if 0
+ int ret;
+ char *suffix, *dump_path;
+ GDateTime *time = g_date_time_new_now_local();
+
+ suffix = g_date_time_format(time, "%Y%m%d_%H%M%S.pcm");
+ dump_path = g_strjoin(NULL, PLAYER_AUDIO_TEST_DUMP_PATH_PREFIX, suffix, NULL);
+ g_pcm_fd = fopen(dump_path, "w+");
+ g_free(dump_path);
+ g_free(suffix);
+ g_date_time_unref(time);
+ if (!g_pcm_fd)
+ g_print("Can not create debug dump file");
+
+ ret = player_set_audio_frame_decoded_cb(g_player[0], 0, 0, audio_frame_decoded_cb, (void *)g_player[0]);
+ if (ret != PLAYER_ERROR_NONE)
+ g_print("player_set_audio_frame_decoded_cb is failed (errno = %d) \n", ret);
+#endif
+}
+
+static void set_audio_eq(int value)
+{
+ bool available = FALSE;
+ int index, min = 0, max = 0;
+
+ if (value) {
+ if (player_audio_effect_equalizer_is_available(g_player[0], &available) != PLAYER_ERROR_NONE)
+ g_print("failed to player_audio_effect_equalizer_is_available\n");
+
+ if (available) {
+ if ((player_audio_effect_get_equalizer_bands_count(g_player[0], &index) != PLAYER_ERROR_NONE) ||
+ (player_audio_effect_get_equalizer_level_range(g_player[0], &min, &max) != PLAYER_ERROR_NONE) ||
+ (player_audio_effect_set_equalizer_band_level(g_player[0], index / 2, max) != PLAYER_ERROR_NONE))
+ g_print("failed to player_audio_effect_set_equalizer_band_level index %d, level %d\n", index / 2, max);
+ }
+ }
+
+ else {
+ if (player_audio_effect_equalizer_clear(g_player[0]) != PLAYER_ERROR_NONE)
+ g_print("failed to player_audio_effect_equalizer_clear\n");
+ }
+
+}
+
+static void get_audio_eq()
+{
+ int index, min, max, value;
+ player_audio_effect_get_equalizer_bands_count(g_player[0], &index);
+ g_print(" ==> [Player_Audio_Test] eq bands count: [%d] \n", index);
+ player_audio_effect_get_equalizer_level_range(g_player[0], &min, &max);
+ g_print(" ==> [Player_Audio_Test] eq bands range: [%d~%d] \n", min, max);
+ player_audio_effect_get_equalizer_band_level(g_player[0], index / 2, &value);
+ g_print(" ==> [Player_Audio_Test] eq bands level: [%d] \n", value);
+ player_audio_effect_get_equalizer_band_frequency(g_player[0], 0, &value);
+ g_print(" ==> [Player_Audio_Test] eq bands frequency: [%d] \n", value);
+ player_audio_effect_get_equalizer_band_frequency_range(g_player[0], 0, &value);
+ g_print(" ==> [Player_Audio_Test] eq bands frequency range: [%d] \n", value);
+}
+
+void quit_program()
+{
+
+ if (g_pcm_fd)
+ fclose(g_pcm_fd);
+
+ if (g_player[0] != NULL || g_player[1] != NULL) {
+ _player_unprepare();
+ _player_destroy();
+ }
+ printf("call quit_program, but can not call elm_exit()..please Ctrl+c\n");
+#ifdef TIZEN_PLAYER_TEST_ENABLE_VIDEO
+ elm_exit();
+#endif
+ if (g_audio_fmt)
+ media_format_unref(g_audio_fmt);
+}
+
+void play_with_ini(char *file_path)
+{
+ input_filename(file_path);
+ _player_play();
+}
+
+void _interpret_main_menu(char *cmd)
+{
+ int len = strlen(cmd);
+ if (len == 1) {
+ if (strncmp(cmd, "a", 1) == 0) {
+ g_menu_state = CURRENT_STATUS_FILENAME;
+ } else if (strncmp(cmd, "b", 1) == 0) {
+ _player_play();
+ } else if (strncmp(cmd, "c", 1) == 0) {
+ _player_stop();
+ } else if (strncmp(cmd, "d", 1) == 0) {
+ _player_resume();
+ } else if (strncmp(cmd, "e", 1) == 0) {
+ _player_pause();
+ } else if (strncmp(cmd, "S", 1) == 0) {
+ _player_state();
+ } else if (strncmp(cmd, "f", 1) == 0) {
+ g_menu_state = CURRENT_STATUS_VOLUME;
+ } else if (strncmp(cmd, "g", 1) == 0) {
+ float left;
+ float right;
+ get_volume(&left, &right);
+ } else if (strncmp(cmd, "z", 1) == 0) {
+ g_menu_state = CURRENT_STATUS_SOUND_TYPE;
+ } else if (strncmp(cmd, "k", 1) == 0) {
+ g_menu_state = CURRENT_STATUS_SOUND_STREAM_INFO;
+ } else if (strncmp(cmd, "h", 1) == 0) {
+ g_menu_state = CURRENT_STATUS_MUTE;
+ } else if (strncmp(cmd, "i", 1) == 0) {
+ bool mute;
+ get_mute(&mute);
+ } else if (strncmp(cmd, "j", 1) == 0) {
+ g_menu_state = CURRENT_STATUS_POSITION_TIME;
+ } else if (strncmp(cmd, "l", 1) == 0) {
+ get_position();
+ } else if (strncmp(cmd, "m", 1) == 0) {
+ get_duration();
+ } else if (strncmp(cmd, "n", 1) == 0) {
+ get_stream_info();
+ } else if (strncmp(cmd, "o", 1) == 0) {
+ g_menu_state = CURRENT_STATUS_LOOPING;
+ } else if (strncmp(cmd, "p", 1) == 0) {
+ bool looping;
+ get_looping(&looping);
+ } else if (strncmp(cmd, "D", 1) == 0) {
+ decoding_audio();
+ } else if (strncmp(cmd, "q", 1) == 0) {
+ quit_pushing = TRUE;
+ quit_program();
+ } else if (strncmp(cmd, "E", 1) == 0) {
+ g_menu_state = CURRENT_STATUS_AUDIO_EQUALIZER;
+ } else if (strncmp(cmd, "H", 1) == 0) {
+ get_audio_eq();
+ } else {
+ g_print("unknown menu \n");
+ }
+ } else if (len == 2) {
+ if (strncmp(cmd, "pr", 2) == 0) {
+ _player_prepare(FALSE);
+ } else if (strncmp(cmd, "pa", 2) == 0) {
+ _player_prepare(TRUE);
+ } else if (strncmp(cmd, "un", 2) == 0) {
+ _player_unprepare();
+ } else if (strncmp(cmd, "dt", 2) == 0) {
+ _player_destroy();
+ } else if (strncmp(cmd, "sp", 2) == 0) {
+ _player_set_progressive_download();
+ } else if (strncmp(cmd, "gp", 2) == 0) {
+ _player_get_progressive_download_status();
+ } else if (strncmp(cmd, "mp", 2) == 0) {
+ g_memory_playback = (g_memory_playback ? FALSE : TRUE);
+ g_print("memory playback = %d\n", g_memory_playback);
+ } else if (strncmp(cmd, "nb", 2) == 0) {
+ g_menu_state = CURRENT_STATUS_HANDLE_NUM;
+ } else if (strncmp(cmd, "tr", 2) == 0) {
+ g_menu_state = CURRENT_STATUS_PLAYBACK_RATE;
+ } else if (strncmp(cmd, "X3", 2) == 0) {
+ audio_frame_decoded_cb_ex(TRUE);
+ } else if (strncmp(cmd, "X4", 2) == 0) {
+ audio_frame_decoded_cb_ex(FALSE);
+ } else if (strncmp(cmd, "su", 2) == 0) {
+ g_menu_state = CURRENT_STATUS_NEXT_URI;
+ } else if (strncmp(cmd, "gu", 2) == 0) {
+ get_next_uri();
+ } else if (strncmp(cmd, "sg", 2) == 0) {
+ g_menu_state = CURRENT_STATUS_GAPLESS;
+ } else if (strncmp(cmd, "tl", 2) == 0) {
+ g_menu_state = CURRENT_STATUS_GET_TRACK_INFO;
+ } else if (strncmp(cmd, "vi", 2) == 0) {
+ get_variant_info();
+ } else if (strncmp(cmd, "vs", 2) == 0) {
+ g_menu_state = CURRENT_STATUS_SET_MAX_BANDWIDTH_VARIANT;
+ } else if (strncmp(cmd, "vg", 2) == 0) {
+ get_variant_limit();
+ } else {
+ g_print("unknown menu \n");
+ }
+ } else {
+ if (strncmp(cmd, "trs", 3) == 0)
+ g_menu_state = CURRENT_STATUS_STREAMING_PLAYBACK_RATE;
+ else
+ g_print("unknown menu \n");
+ }
+}
+
+void display_sub_basic()
+{
+ g_print("\n");
+ g_print("=========================================================================================\n");
+ g_print(" Player Audio Test (press q to quit) \n");
+ g_print("-----------------------------------------------------------------------------------------\n");
+ g_print("[playback] a. Create\t");
+ g_print("pr. Prepare \t");
+ g_print("pa. Prepare async \t");
+ g_print("b. Play \t");
+ g_print("c. Stop \t");
+ g_print("d. Resume\t");
+ g_print("e. Pause \t");
+ g_print("un. Unprepare \t");
+ g_print("dt. Destroy \n");
+ g_print("[State] S. Player State \n");
+ g_print("[ volume ] f. Set Volume\t");
+ g_print("g. Get Volume\t");
+ g_print("z. Set Sound type\t");
+ g_print("k. Set Sound Stream Info.\n");
+ g_print("[ mute ] h. Set Mute\t");
+ g_print("i. Get Mute\n");
+ g_print("[audio eq] E. Set Audio EQ\t");
+ g_print("H. Get Audio EQ\n");
+ g_print("[position] j. Set Position \t");
+ g_print("l. Get Position\n");
+ g_print("[trick] tr. set playback rate\n");
+ g_print("[duration] m. Get Duration\n");
+ g_print("[Stream Info] n. Get stream info (Video Size, codec, audio stream info, and tag info)\n");
+ g_print("[Looping] o. Set Looping\t");
+ g_print("p. Get Looping\n");
+ g_print("[Track] tl. Get Track language info(single only)\n");
+ g_print("[Variant] vi. Get Streaming Variant Info\t");
+ g_print("vs. Set max limit of variant\t");
+ g_print("vg. Get max limit of variant\n");
+ g_print("[next uri] su. set next uri. \t");
+ g_print("gu. get next uri. \t");
+ g_print("sg. set gapless. \n");
+ g_print("[audio_frame_decoded_cb_ex] X3. set audio_cb with sync\t");
+ g_print("X4. set audio_cb with async \n");
+ g_print("[etc] sp. Set Progressive Download\t");
+ g_print("gp. Get Progressive Download status\t");
+ g_print("mp. memory playback\n");
+ g_print("\n");
+ g_print("=========================================================================================\n");
+}
+
+static void displaymenu()
+{
+ if (g_menu_state == CURRENT_STATUS_MAINMENU) {
+ display_sub_basic();
+ } else if (g_menu_state == CURRENT_STATUS_HANDLE_NUM) {
+ g_print("*** input number of handles.(recommended only for EVAS surface)\n");
+ } else if (g_menu_state == CURRENT_STATUS_FILENAME) {
+ g_print("*** input mediapath.\n");
+ } else if (g_menu_state == CURRENT_STATUS_VOLUME) {
+ g_print("*** input volume value.(0~1.0)\n");
+ } else if (g_menu_state == CURRENT_STATUS_SOUND_TYPE) {
+ g_print("*** input sound type.(0:SYSTEM 1:NOTIFICATION 2:ALARM 3:RINGTONE 4:MEDIA 5:CALL 6:VOIP 7:FIXED)\n");
+ } else if (g_menu_state == CURRENT_STATUS_SOUND_STREAM_INFO) {
+ g_print("*** input sound stream type.(0:MEDIA 1:SYSTEM 2:ALARM 3:NOTIFICATION 4:EMERGENCY 5:VOICE_INFORMATION 9:MEDIA_EXT_ONLY)\n");
+ } else if (g_menu_state == CURRENT_STATUS_MUTE) {
+ g_print("*** input mute value.(0: Not Mute, 1: Mute) \n");
+ } else if (g_menu_state == CURRENT_STATUS_POSITION_TIME) {
+ g_print("*** input position value(msec)\n");
+ } else if (g_menu_state == CURRENT_STATUS_POSITION_ACCURATE) {
+ g_print("*** input accurate value(0/1)\n");
+ } else if (g_menu_state == CURRENT_STATUS_LOOPING) {
+ g_print("*** input looping value.(0: Not Looping, 1: Looping) \n");
+ } else if (g_menu_state == CURRENT_STATUS_AUDIO_EQUALIZER) {
+ g_print(" *** input audio eq value.(0: UNSET, 1: SET) \n");
+ } else if (g_menu_state == CURRENT_STATUS_PLAYBACK_RATE || g_menu_state == CURRENT_STATUS_STREAMING_PLAYBACK_RATE) {
+ g_print(" *** input playback rate.(-5.0 ~ 5.0)\n");
+ } else if (g_menu_state == CURRENT_STATUS_NEXT_URI) {
+ g_print("*** input next uri.\n");
+ } else if (g_menu_state == CURRENT_STATUS_GAPLESS) {
+ g_print("*** input gapless value.(0:disable, 1: enable) \n");
+ } else if (g_menu_state == CURRENT_STATUS_GET_TRACK_INFO) {
+ g_print("*** input stream type.(1:audio, 3:text) \n");
+ } else if (g_menu_state == CURRENT_STATUS_SET_MAX_BANDWIDTH_VARIANT) {
+ g_print("*** set max bandwidth (default: -1) \n");
+ } else if (g_menu_state == CURRENT_STATUS_SET_MAX_WIDTH_VARIANT) {
+ g_print("*** set max width (default: -1) \n");
+ } else if (g_menu_state == CURRENT_STATUS_SET_MAX_HEIGHT_VARIANT) {
+ g_print("*** set max height (default: -1) \n");
+ } else {
+ g_print("*** unknown status.\n");
+ quit_program();
+ }
+ g_print(" >>> ");
+}
+
+gboolean timeout_menu_display(void *data)
+{
+ displaymenu();
+ return FALSE;
+}
+
+gboolean timeout_quit_program(void *data)
+{
+ quit_program();
+ return FALSE;
+}
+
+void reset_menu_state(void)
+{
+ g_menu_state = CURRENT_STATUS_MAINMENU;
+}
+
+static void interpret(char *cmd)
+{
+ switch (g_menu_state) {
+ case CURRENT_STATUS_MAINMENU:
+ {
+ _interpret_main_menu(cmd);
+ }
+ break;
+ case CURRENT_STATUS_HANDLE_NUM:
+ {
+ int num_handle = atoi(cmd);
+ if (0 >= num_handle || num_handle > MAX_HANDLE)
+ g_print("not supported this number for handles(%d)\n", num_handle);
+ else
+ g_handle_num = num_handle;
+
+ reset_menu_state();
+ }
+ break;
+ case CURRENT_STATUS_FILENAME:
+ {
+ input_filename(cmd);
+ reset_menu_state();
+ }
+ break;
+ case CURRENT_STATUS_VOLUME:
+ {
+ float level = atof(cmd);
+ set_volume(level);
+ reset_menu_state();
+ }
+ break;
+ case CURRENT_STATUS_SOUND_TYPE:
+ {
+ int type = atoi(cmd);
+ set_sound_type(type);
+ reset_menu_state();
+ }
+ break;
+ case CURRENT_STATUS_SOUND_STREAM_INFO:
+ {
+ int type = atoi(cmd);
+ set_sound_stream_info(type);
+ reset_menu_state();
+ }
+ break;
+ case CURRENT_STATUS_MUTE:
+ {
+ int mute = atoi(cmd);
+ set_mute(mute);
+ reset_menu_state();
+ }
+ break;
+ case CURRENT_STATUS_POSITION_TIME:
+ {
+ seek_info.pos = atoi(cmd);
+ g_menu_state = CURRENT_STATUS_POSITION_ACCURATE;
+ }
+ break;
+ case CURRENT_STATUS_POSITION_ACCURATE:
+ {
+ seek_info.accurate = (atoi(cmd) != 0) ? (true) : (false);
+ set_position(seek_info.pos, seek_info.accurate);
+ reset_menu_state();
+ }
+ break;
+ case CURRENT_STATUS_LOOPING:
+ {
+ int looping = atoi(cmd);
+ set_looping(looping);
+ reset_menu_state();
+ }
+ break;
+ case CURRENT_STATUS_GAPLESS:
+ {
+ int gapless = atoi(cmd);
+ set_gapless(gapless);
+ reset_menu_state();
+ }
+ break;
+ case CURRENT_STATUS_AUDIO_EQUALIZER:
+ {
+ int value = atoi(cmd);
+ set_audio_eq(value);
+ reset_menu_state();
+ }
+ break;
+ case CURRENT_STATUS_PLAYBACK_RATE:
+ {
+ float rate = atof(cmd);
+ set_playback_rate(rate, FALSE);
+ reset_menu_state();
+ }
+ break;
+ case CURRENT_STATUS_STREAMING_PLAYBACK_RATE:
+ {
+ float rate = atof(cmd);
+ set_playback_rate(rate, TRUE);
+ reset_menu_state();
+ }
+ break;
+ case CURRENT_STATUS_NEXT_URI:
+ {
+ set_next_uri(cmd);
+ reset_menu_state();
+ }
+ break;
+ case CURRENT_STATUS_GET_TRACK_INFO:
+ {
+ int index = atoi(cmd);
+ get_track_info(index);
+ reset_menu_state();
+ }
+ break;
+ case CURRENT_STATUS_SET_MAX_BANDWIDTH_VARIANT:
+ {
+ int value = atoi(cmd);
+ max_limit.bandwidth = value;
+ g_menu_state = CURRENT_STATUS_SET_MAX_WIDTH_VARIANT;
+ }
+ break;
+ case CURRENT_STATUS_SET_MAX_WIDTH_VARIANT:
+ {
+ int value = atoi(cmd);
+ max_limit.width = value;
+ g_menu_state = CURRENT_STATUS_SET_MAX_HEIGHT_VARIANT;
+ }
+ break;
+ case CURRENT_STATUS_SET_MAX_HEIGHT_VARIANT:
+ {
+ int value = atoi(cmd);
+ max_limit.height = value;
+ set_variant_limit();
+ reset_menu_state();
+ }
+ break;
+ }
+
+ g_timeout_add(100, timeout_menu_display, 0);
+}
+
+gboolean input(GIOChannel * channel)
+{
+ gchar buf[MAX_STRING_LEN];
+ gsize read;
+ GError *error = NULL;
+
+ g_io_channel_read_chars(channel, buf, MAX_STRING_LEN, &read, &error);
+ buf[read] = '\0';
+ g_strstrip(buf);
+ interpret(buf);
+
+ return TRUE;
+}
+
+int main(int argc, char *argv[])
+{
+ GIOChannel *stdin_channel;
+ stdin_channel = g_io_channel_unix_new(0);
+ g_io_channel_set_flags(stdin_channel, G_IO_FLAG_NONBLOCK, NULL);
+ g_io_add_watch(stdin_channel, G_IO_IN, (GIOFunc) input, NULL);
+
+ displaymenu();
+ return appcore_efl_main(PACKAGE, &argc, &argv, &ops);
+
+}