/* ** Copyright (C) 2002-2004 Daniel Caujolle-Bert ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include #include #include #include #include #include #include #include #include "tilde.h" #include "common.h" #include "utils.h" #include "commands.h" #include "xine_commands.h" static struct xine_status_s { char *name; int status; } xine_status[] = { { "XINE_STATUS_IDLE", XINE_STATUS_IDLE }, { "XINE_STATUS_STOP", XINE_STATUS_STOP }, { "XINE_STATUS_PLAY" , XINE_STATUS_PLAY }, { "XINE_STATUS_QUIT" , XINE_STATUS_QUIT }, { NULL , 0 } }; #if 0 static struct video_props_s { char *name; int prop; } video_props[] = { /* Property name Property value Require capability */ { "XINE_PARAM_VO_DEINTERLACE", XINE_PARAM_VO_DEINTERLACE }, { "XINE_PARAM_VO_ASPECT_RATIO", XINE_PARAM_VO_ASPECT_RATIO }, { "XINE_PARAM_VO_HUE", XINE_PARAM_VO_HUE }, { "XINE_PARAM_VO_SATURATION", XINE_PARAM_VO_SATURATION }, { "XINE_PARAM_VO_CONTRAST", XINE_PARAM_VO_CONTRAST }, { "XINE_PARAM_VO_BRIGHTNESS", XINE_PARAM_VO_BRIGHTNESS }, { "XINE_PARAM_VO_ZOOM_X", XINE_PARAM_VO_ZOOM_X }, { "XINE_PARAM_VO_ZOOM_Y", XINE_PARAM_VO_ZOOM_Y }, { "XINE_PARAM_VO_PAN_SCAN", XINE_PARAM_VO_PAN_SCAN }, { "XINE_PARAM_VO_TVMODE", XINE_PARAM_VO_TVMODE }, { NULL, 0 } /* What is do it for ? XINE_VO_ZOOM_STEP XINE_VO_ZOOM_MAX XINE_VO_ZOOM_MIN */ }; #endif #if 0 static struct visual_types_s { char *name; int type; } visual_types[] = { { "XINE_VISUAL_TYPE_NONE", XINE_VISUAL_TYPE_NONE }, { "XINE_VISUAL_TYPE_X11" , XINE_VISUAL_TYPE_X11 }, { "XINE_VISUAL_TYPE_AA" , XINE_VISUAL_TYPE_AA }, { "XINE_VISUAL_TYPE_FB" , XINE_VISUAL_TYPE_FB }, { "XINE_VISUAL_TYPE_GTK" , XINE_VISUAL_TYPE_GTK }, { "XINE_VISUAL_TYPE_DFB" , XINE_VISUAL_TYPE_DFB }, { "XINE_VISUAL_TYPE_PM" , XINE_VISUAL_TYPE_PM }, { NULL , 0 } }; #endif static struct event_types_s { char *name; int type; } event_types[] = { { "XINE_EVENT_UI_PLAYBACK_FINISHED", XINE_EVENT_UI_PLAYBACK_FINISHED }, { "XINE_EVENT_UI_CHANNELS_CHANGED" , XINE_EVENT_UI_CHANNELS_CHANGED }, { "XINE_EVENT_UI_SET_TITLE" , XINE_EVENT_UI_SET_TITLE }, { "XINE_EVENT_UI_MESSAGE" , XINE_EVENT_UI_MESSAGE }, { "XINE_EVENT_FRAME_FORMAT_CHANGE" , XINE_EVENT_FRAME_FORMAT_CHANGE }, { "XINE_EVENT_AUDIO_LEVEL" , XINE_EVENT_AUDIO_LEVEL }, { "XINE_EVENT_QUIT" , XINE_EVENT_QUIT }, { "XINE_EVENT_PROGRESS" , XINE_EVENT_PROGRESS }, { "XINE_EVENT_MRL_REFERENCE" , XINE_EVENT_MRL_REFERENCE }, { "XINE_EVENT_UI_NUM_BUTTONS" , XINE_EVENT_UI_NUM_BUTTONS }, { "XINE_EVENT_SPU_BUTTON" , XINE_EVENT_SPU_BUTTON }, { "XINE_EVENT_DROPPED_FRAMES" , XINE_EVENT_DROPPED_FRAMES }, { "XINE_EVENT_INPUT_MOUSE_BUTTON" , XINE_EVENT_INPUT_MOUSE_BUTTON }, { "XINE_EVENT_INPUT_MOUSE_MOVE" , XINE_EVENT_INPUT_MOUSE_MOVE }, { "XINE_EVENT_INPUT_MENU1" , XINE_EVENT_INPUT_MENU1 }, { "XINE_EVENT_INPUT_MENU2" , XINE_EVENT_INPUT_MENU2 }, { "XINE_EVENT_INPUT_MENU3" , XINE_EVENT_INPUT_MENU3 }, { "XINE_EVENT_INPUT_MENU4" , XINE_EVENT_INPUT_MENU4 }, { "XINE_EVENT_INPUT_MENU5" , XINE_EVENT_INPUT_MENU5 }, { "XINE_EVENT_INPUT_MENU6" , XINE_EVENT_INPUT_MENU6 }, { "XINE_EVENT_INPUT_MENU7" , XINE_EVENT_INPUT_MENU7 }, { "XINE_EVENT_INPUT_UP" , XINE_EVENT_INPUT_UP }, { "XINE_EVENT_INPUT_DOWN" , XINE_EVENT_INPUT_DOWN }, { "XINE_EVENT_INPUT_LEFT" , XINE_EVENT_INPUT_LEFT }, { "XINE_EVENT_INPUT_RIGHT" , XINE_EVENT_INPUT_RIGHT }, { "XINE_EVENT_INPUT_SELECT" , XINE_EVENT_INPUT_SELECT }, { "XINE_EVENT_INPUT_NEXT" , XINE_EVENT_INPUT_NEXT }, { "XINE_EVENT_INPUT_PREVIOUS" , XINE_EVENT_INPUT_PREVIOUS }, { "XINE_EVENT_INPUT_ANGLE_NEXT" , XINE_EVENT_INPUT_ANGLE_NEXT }, { "XINE_EVENT_INPUT_ANGLE_PREVIOUS", XINE_EVENT_INPUT_ANGLE_PREVIOUS }, { "XINE_EVENT_INPUT_BUTTON_FORCE" , XINE_EVENT_INPUT_BUTTON_FORCE }, { "XINE_EVENT_INPUT_NUMBER_0" , XINE_EVENT_INPUT_NUMBER_0 }, { "XINE_EVENT_INPUT_NUMBER_1" , XINE_EVENT_INPUT_NUMBER_1 }, { "XINE_EVENT_INPUT_NUMBER_2" , XINE_EVENT_INPUT_NUMBER_2 }, { "XINE_EVENT_INPUT_NUMBER_3" , XINE_EVENT_INPUT_NUMBER_3 }, { "XINE_EVENT_INPUT_NUMBER_4" , XINE_EVENT_INPUT_NUMBER_4 }, { "XINE_EVENT_INPUT_NUMBER_5" , XINE_EVENT_INPUT_NUMBER_5 }, { "XINE_EVENT_INPUT_NUMBER_6" , XINE_EVENT_INPUT_NUMBER_6 }, { "XINE_EVENT_INPUT_NUMBER_7" , XINE_EVENT_INPUT_NUMBER_7 }, { "XINE_EVENT_INPUT_NUMBER_8" , XINE_EVENT_INPUT_NUMBER_8 }, { "XINE_EVENT_INPUT_NUMBER_9" , XINE_EVENT_INPUT_NUMBER_9 }, { "XINE_EVENT_INPUT_NUMBER_10_ADD" , XINE_EVENT_INPUT_NUMBER_10_ADD }, { "XINE_EVENT_SET_V4L2" , XINE_EVENT_SET_V4L2 }, { "XINE_EVENT_PVR_SAVE" , XINE_EVENT_PVR_SAVE }, { "XINE_EVENT_PVR_REPORT_NAME" , XINE_EVENT_PVR_REPORT_NAME }, { "XINE_EVENT_PVR_REALTIME" , XINE_EVENT_PVR_REALTIME }, { "XINE_EVENT_PVR_PAUSE" , XINE_EVENT_PVR_PAUSE }, { "XINE_EVENT_SET_MPEG_DATA" , XINE_EVENT_SET_MPEG_DATA }, { NULL , 0 } }; static struct stream_infos_s { char *name; int type; } stream_infos[] = { { "XINE_STREAM_INFO_BITRATE" , XINE_STREAM_INFO_BITRATE }, { "XINE_STREAM_INFO_SEEKABLE" , XINE_STREAM_INFO_SEEKABLE }, { "XINE_STREAM_INFO_VIDEO_WIDTH" , XINE_STREAM_INFO_VIDEO_WIDTH }, { "XINE_STREAM_INFO_VIDEO_HEIGHT" , XINE_STREAM_INFO_VIDEO_HEIGHT }, { "XINE_STREAM_INFO_VIDEO_RATIO" , XINE_STREAM_INFO_VIDEO_RATIO }, { "XINE_STREAM_INFO_VIDEO_CHANNELS" , XINE_STREAM_INFO_VIDEO_CHANNELS }, { "XINE_STREAM_INFO_VIDEO_STREAMS" , XINE_STREAM_INFO_VIDEO_STREAMS }, { "XINE_STREAM_INFO_VIDEO_BITRATE" , XINE_STREAM_INFO_VIDEO_BITRATE }, { "XINE_STREAM_INFO_VIDEO_FOURCC" , XINE_STREAM_INFO_VIDEO_FOURCC }, { "XINE_STREAM_INFO_VIDEO_HANDLED" , XINE_STREAM_INFO_VIDEO_HANDLED }, { "XINE_STREAM_INFO_FRAME_DURATION" , XINE_STREAM_INFO_FRAME_DURATION }, { "XINE_STREAM_INFO_AUDIO_CHANNELS" , XINE_STREAM_INFO_AUDIO_CHANNELS }, { "XINE_STREAM_INFO_AUDIO_BITS" , XINE_STREAM_INFO_AUDIO_BITS }, { "XINE_STREAM_INFO_AUDIO_SAMPLERATE" , XINE_STREAM_INFO_AUDIO_SAMPLERATE }, { "XINE_STREAM_INFO_AUDIO_BITRATE" , XINE_STREAM_INFO_AUDIO_BITRATE }, { "XINE_STREAM_INFO_AUDIO_FOURCC" , XINE_STREAM_INFO_AUDIO_FOURCC }, { "XINE_STREAM_INFO_AUDIO_HANDLED" , XINE_STREAM_INFO_AUDIO_HANDLED }, { "XINE_STREAM_INFO_HAS_CHAPTERS" , XINE_STREAM_INFO_HAS_CHAPTERS }, { "XINE_STREAM_INFO_HAS_VIDEO" , XINE_STREAM_INFO_HAS_VIDEO }, { "XINE_STREAM_INFO_HAS_AUDIO" , XINE_STREAM_INFO_HAS_AUDIO }, { "XINE_STREAM_INFO_IGNORE_VIDEO" , XINE_STREAM_INFO_IGNORE_VIDEO }, { "XINE_STREAM_INFO_IGNORE_AUDIO" , XINE_STREAM_INFO_IGNORE_AUDIO }, { "XINE_STREAM_INFO_IGNORE_SPU" , XINE_STREAM_INFO_IGNORE_SPU }, { "XINE_STREAM_INFO_VIDEO_HAS_STILL" , XINE_STREAM_INFO_VIDEO_HAS_STILL }, { "XINE_STREAM_INFO_MAX_AUDIO_CHANNEL", XINE_STREAM_INFO_MAX_AUDIO_CHANNEL }, { "XINE_STREAM_INFO_MAX_SPU_CHANNEL" , XINE_STREAM_INFO_MAX_SPU_CHANNEL }, { NULL , 0 } }; static struct meta_infos_s { char *name; int type; } meta_infos[] = { { "XINE_META_INFO_TITLE" , XINE_META_INFO_TITLE }, { "XINE_META_INFO_COMMENT" , XINE_META_INFO_COMMENT }, { "XINE_META_INFO_ARTIST" , XINE_META_INFO_ARTIST }, { "XINE_META_INFO_GENRE" , XINE_META_INFO_GENRE }, { "XINE_META_INFO_ALBUM" , XINE_META_INFO_ALBUM }, { "XINE_META_INFO_YEAR" , XINE_META_INFO_YEAR }, { "XINE_META_INFO_VIDEOCODEC" , XINE_META_INFO_VIDEOCODEC }, { "XINE_META_INFO_AUDIOCODEC" , XINE_META_INFO_AUDIOCODEC }, { "XINE_META_INFO_SYSTEMLAYER" , XINE_META_INFO_SYSTEMLAYER }, { "XINE_META_INFO_INPUT_PLUGIN" , XINE_META_INFO_INPUT_PLUGIN }, { NULL , 0 } }; static struct xine_params_s { char *name; int param; } xine_params[] = { { "XINE_PARAM_SPEED" , XINE_PARAM_SPEED }, { "XINE_PARAM_AV_OFFSET" , XINE_PARAM_AV_OFFSET }, { "XINE_PARAM_AUDIO_CHANNEL_LOGICAL", XINE_PARAM_AUDIO_CHANNEL_LOGICAL }, { "XINE_PARAM_SPU_CHANNEL" , XINE_PARAM_SPU_CHANNEL }, { "XINE_PARAM_VIDEO_CHANNEL" , XINE_PARAM_VIDEO_CHANNEL }, { "XINE_PARAM_AUDIO_VOLUME" , XINE_PARAM_AUDIO_VOLUME }, { "XINE_PARAM_AUDIO_MUTE" , XINE_PARAM_AUDIO_MUTE }, { "XINE_PARAM_AUDIO_COMPR_LEVEL" , XINE_PARAM_AUDIO_COMPR_LEVEL }, { "XINE_PARAM_AUDIO_AMP_LEVEL" , XINE_PARAM_AUDIO_AMP_LEVEL }, { "XINE_PARAM_AUDIO_REPORT_LEVEL" , XINE_PARAM_AUDIO_REPORT_LEVEL }, { "XINE_PARAM_VERBOSITY" , XINE_PARAM_VERBOSITY }, { "XINE_PARAM_SPU_OFFSET" , XINE_PARAM_SPU_OFFSET }, { "XINE_PARAM_VO_DEINTERLACE" , XINE_PARAM_VO_DEINTERLACE }, { "XINE_PARAM_VO_ASPECT_RATIO" , XINE_PARAM_VO_ASPECT_RATIO }, { "XINE_PARAM_VO_HUE" , XINE_PARAM_VO_HUE }, { "XINE_PARAM_VO_SATURATION" , XINE_PARAM_VO_SATURATION }, { "XINE_PARAM_VO_CONTRAST" , XINE_PARAM_VO_CONTRAST }, { "XINE_PARAM_VO_BRIGHTNESS" , XINE_PARAM_VO_BRIGHTNESS }, { "XINE_PARAM_VO_ZOOM_X" , XINE_PARAM_VO_ZOOM_X }, { "XINE_PARAM_VO_ZOOM_Y" , XINE_PARAM_VO_ZOOM_Y }, { "XINE_PARAM_VO_PAN_SCAN" , XINE_PARAM_VO_PAN_SCAN }, { "XINE_PARAM_VO_TVMODE" , XINE_PARAM_VO_TVMODE }, { NULL , 0 } }; static struct xine_speeds_s { char *name; int speed; } xine_speeds[] = { { "XINE_SPEED_PAUSE" , XINE_SPEED_PAUSE }, { "XINE_SPEED_SLOW_4", XINE_SPEED_SLOW_4 }, { "XINE_SPEED_SLOW_2", XINE_SPEED_SLOW_2 }, { "XINE_SPEED_NORMAL", XINE_SPEED_NORMAL }, { "XINE_SPEED_FAST_2", XINE_SPEED_FAST_2 }, { "XINE_SPEED_FAST_4", XINE_SPEED_FAST_4 }, { NULL , 0 } }; static struct xine_tricks_s { char *name; int mode; } xine_tricks[] = { { "XINE_TRICK_MODE_OFF" , XINE_TRICK_MODE_OFF }, { "XINE_TRICK_MODE_SEEK_TO_POSITION", XINE_TRICK_MODE_SEEK_TO_POSITION }, { "XINE_TRICK_MODE_SEEK_TO_TIME" , XINE_TRICK_MODE_SEEK_TO_TIME }, { "XINE_TRICK_MODE_FAST_FORWARD" , XINE_TRICK_MODE_FAST_FORWARD }, { "XINE_TRICK_MODE_FAST_REWIND" , XINE_TRICK_MODE_FAST_REWIND }, { NULL , 0 } }; #if 0 static struct xine_vo_params_s { char *name; int param; } xine_vo_params[] = { /* XINE_PARAM_VIDEO VALUE */ { "XINE_PARAM_VO_DEINTERLACE" , XINE_PARAM_VO_DEINTERLACE }, { "XINE_PARAM_VO_ASPECT_RATIO" , XINE_PARAM_VO_ASPECT_RATIO }, { "XINE_PARAM_VO_HUE" , XINE_PARAM_VO_HUE }, { "XINE_PARAM_VO_SATURATION" , XINE_PARAM_VO_SATURATION }, { "XINE_PARAM_VO_CONTRAST" , XINE_PARAM_VO_CONTRAST }, { "XINE_PARAM_VO_BRIGHTNESS" , XINE_PARAM_VO_BRIGHTNESS }, { "XINE_PARAM_VO_ZOOM_X" , XINE_PARAM_VO_ZOOM_X }, { "XINE_PARAM_VO_ZOOM_Y" , XINE_PARAM_VO_ZOOM_Y }, { "XINE_PARAM_VO_PAN_SCAN" , XINE_PARAM_VO_PAN_SCAN }, { "XINE_PARAM_VO_TVMODE" , XINE_PARAM_VO_TVMODE }, { NULL , 0 } }; #endif #if 0 static struct xine_vo_zooms_s { char *name; int factor; } xine_vo_zooms[] = { { "XINE_VO_ZOOM_STEP", XINE_VO_ZOOM_STEP }, { "XINE_VO_ZOOM_MAX" , XINE_VO_ZOOM_MAX }, { "XINE_VO_ZOOM_MIN" , XINE_VO_ZOOM_MIN }, { NULL , 0 } }; #endif static struct xine_vo_aspects_s { char *name; int aspect; } xine_vo_aspects[] = { /* possible ratios for XINE_PARAM_VO_ASPECT_RATIO */ { "XINE_VO_ASPECT_AUTO" , XINE_VO_ASPECT_AUTO }, { "XINE_VO_ASPECT_SQUARE" , XINE_VO_ASPECT_SQUARE }, { "XINE_VO_ASPECT_4_3" , XINE_VO_ASPECT_4_3 }, { "XINE_VO_ASPECT_ANAMORPHIC", XINE_VO_ASPECT_ANAMORPHIC }, { "XINE_VO_ASPECT_DVB" , XINE_VO_ASPECT_DVB }, /* Don't use ;-) { "XINE_VO_ASPECT_NUM_RATIOS", XINE_VO_ASPECT_NUM_RATIOS },*/ { "XINE_VO_ASPECT_PAN_SCAN" , XINE_VO_ASPECT_PAN_SCAN }, { "XINE_VO_ASPECT_DONT_TOUCH", XINE_VO_ASPECT_DONT_TOUCH }, { NULL , 0 } }; static void toxine_handle_xine_errors(toxine_t *tox) { int err; return_if_no_stream(tox); err = xine_get_error(tox->stream); switch(err) { case XINE_ERROR_NONE: /* noop */ break; case XINE_ERROR_NO_INPUT_PLUGIN: perr("There is no input plugin available to handle '%s'.\n" "Maybe MRL syntax is wrong or file/stream source doesn't exist.", tox->current_mrl); break; case XINE_ERROR_NO_DEMUX_PLUGIN: perr("There is no demuxer plugin available " "to handle '%s'.\nUsually this means that the file format was not recognized.", tox->current_mrl); break; case XINE_ERROR_DEMUX_FAILED: perr("Demuxer failed. Maybe '%s' is a broken file?\n", tox->current_mrl); break; case XINE_ERROR_MALFORMED_MRL: perr("MRL '%s' is malformed\n", tox->current_mrl); break; case XINE_ERROR_INPUT_FAILED: perr("Input plugin failed to open '%s'\n", tox->current_mrl); break; default: perr("!! Unhandled error !!\n"); break; } } void toxine_dump_config_entry(toxine_t *tox, _cfg_entry_t *entry) { pinfo("%s:\n", entry->key); pinfo(" entry->description: '%s'\n", (entry->description) ? entry->description : "none"); pinfo(" entry->help: '%s'\n", (entry->help) ? entry->help : "none"); switch (entry->type) { case XINE_CONFIG_TYPE_STRING: pinfo(" entry->type: XINE_CONFIG_TYPE_STRING\n"); pinfo(" entry->str_value: '%s'\n", entry->str_value); pinfo(" entry->str_default: '%s'\n", entry->str_default); // if(tox) // toxine_set_last_char_result(tox, entry->str_value); break; case XINE_CONFIG_TYPE_RANGE: pinfo(" entry->type: XINE_CONFIG_TYPE_RANGE\n"); pinfo(" entry->num_value: '%d'\n", entry->num_value); pinfo(" entry->num_default: '%d'\n", entry->num_default); pinfo(" entry->range_min: '%d'\n", entry->range_min); pinfo(" entry->range_max: '%d'\n", entry->range_max); // if(tox) // toxine_set_last_int_result(tox, entry->num_value); break; case XINE_CONFIG_TYPE_ENUM: pinfo(" entry->type: XINE_CONFIG_TYPE_ENUM\n"); pinfo(" entry->num_value: '%d'\n", entry->num_value); pinfo(" entry->num_default: '%d'\n", entry->num_default); if(entry->enum_values) { int i; pinfo(" entry->enum_values: "); // if(tox) // toxine_set_last_achar_result(tox, (const char* const*)entry->enum_values); for(i = 0; entry->enum_values[i]; i++) pout("'%s' ", entry->enum_values[i]); pinfo("\n"); } break; case XINE_CONFIG_TYPE_NUM: pinfo(" entry->type: XINE_CONFIG_TYPE_NUM\n"); pinfo(" entry->num_value: '%d'\n", entry->num_value); pinfo(" entry->num_default: '%d'\n", entry->num_default); // if(tox) // toxine_set_last_int_result(tox, entry->num_value); break; case XINE_CONFIG_TYPE_BOOL: pinfo(" entry->type: XINE_CONFIG_TYPE_BOOL\n"); pinfo(" entry->num_value: '%d'\n", entry->num_value); pinfo(" entry->num_default: '%d'\n", entry->num_default); // if(tox) // toxine_set_last_int_result(tox, entry->num_value); break; case XINE_CONFIG_TYPE_UNKNOWN: pinfo(" entry->type: XINE_CONFIG_TYPE_UNKNOWN\n"); pinfo(" entry->str_value: '%s'\n", entry->str_value); pinfo(" entry->str_default: '%s'\n", entry->str_default); if(entry->enum_values) { int i; pinfo(" entry->enum_values: "); for(i = 0; entry->enum_values[i]; i++) pout("'%s' ", entry->enum_values[i]); pinfo("\n"); } else { pinfo(" entry->enum_values: NULL\n"); } pinfo(" entry->num_value: '%d'\n", entry->num_value); pinfo(" entry->num_default: '%d'\n", entry->num_default); pinfo(" entry->range_min: '%d'\n", entry->range_min); pinfo(" entry->range_max: '%d'\n", entry->range_max); break; } pinfo(".\n"); } /* * */ void _xine_new(commands_t *command, toxine_t *tox, void *data) { toxine_unset_last_result(tox); if(tox->xine) { pinfo("Exiting old xine instance\n"); _xine_exit(NULL, tox, NULL); } pinfo("xine_new():\n"); tox->xine = xine_new(); pinfo(".\n"); tox->xine_state |= XINE_NEW; toxine_set_last_int_result(tox, (int)tox->xine); _xine_config_load(NULL, tox, NULL); } void _xine_stream_new(commands_t *command, toxine_t *tox, void *data) { return_if_no_init(tox); if(tox->video.port == NULL) { perr("Choose and initialise a video driver first\n"); return; } if(tox->xine_state & XINE_STREAM) { perr("Stream is already created, use xine_dispose() in order to create a new one\n"); return; } pinfo("xine_stream_new():\n"); tox->stream = xine_stream_new(tox->xine, tox->audio.port, tox->video.port); pinfo(".\n"); if(tox->stream) { tox->xine_state |= XINE_STREAM; toxine_set_last_int_result(tox, (int)tox->stream); } else perr("Wow, xine_stream_new() failed.\n"); tox->event_queue = xine_event_new_queue(tox->stream); xine_event_create_listener_thread(tox->event_queue, toxine_event_listener, (void *) tox); } /* * */ void _xine_init(commands_t *command, toxine_t *tox, void *data) { toxine_unset_last_result(tox); if(tox->xine_state & XINE_INIT) { perr("xine engine already initialized.\n"); return; } if(!(tox->xine_state & XINE_NEW)) _xine_new(NULL, tox, NULL); pinfo("xine_init():\n"); xine_init(tox->xine); pinfo(".\n"); tox->xine_state |= XINE_INIT; pthread_mutex_init(&tox->event.mutex, NULL); if(!toxine_video_out_init(tox)) { perr("unable to initialize video out plugin.\n"); _xine_exit(NULL, tox, NULL); return; } if(!toxine_audio_out_init(tox)) { perr("unable to initialize audio driver, audio output disabled.\n"); _xine_exit(NULL, tox, NULL); return; } toxine_set_last_int_result(tox, (int)tox->xine); } /* * */ void _xine_open(commands_t *command, toxine_t *tox, void *data) { const char *mrl; return_if_no_stream(tox); mrl = toxine_get_arg(tox, 1); if(mrl) { int result; toxine_unset_last_result(tox); toxine_set_current_mrl(tox, mrl); pinfo("xine_open(%s):\n", tox->current_mrl); result = xine_open(tox->stream, tox->current_mrl); toxine_set_last_int_result(tox, result); pinfo("-- returned %d\n", result); tox->xine_state |= XINE_OPEN; pinfo(".\n"); } } /* * */ void _xine_play(commands_t *command, toxine_t *tox, void *data) { char *expanded_mrl = NULL; const char *mrl = NULL; int start = 0, time = 0; int ignore_args = 0; int nargs; int need_open = 1; int result; toxine_unset_last_result(tox); return_if_no_stream(tox); /* Don't take care about arguments */ if(data) ignore_args = (int) data; if(tox->ignore_finished) tox->ignore_finished = 0; nargs = toxine_is_args(tox); if((!nargs) || (ignore_args == NO_ARGS)) { if(!tox->current_mrl) { perr("You should set/specify an MRL.\n"); return; } else { mrl = tox->current_mrl; if(tox->playlist.cur >= 0) { time = tox->playlist.mmk[tox->playlist.cur]->start; if((tox->playlist.mmk[tox->playlist.cur]->end != -1) && (tox->playlist.mmk[tox->playlist.cur]->start < tox->playlist.mmk[tox->playlist.cur]->end)) { pthread_attr_t pth_attrs; struct sched_param pth_params; void *v; if(tox->playlist.thread_num > 0) pthread_join(tox->playlist.end_thread, &v); pthread_attr_init(&pth_attrs); pthread_attr_getschedparam(&pth_attrs, &pth_params); pth_params.sched_priority = sched_get_priority_min(SCHED_OTHER); pthread_attr_setschedparam(&pth_attrs, &pth_params); pthread_create(&tox->playlist.end_thread, &pth_attrs, toxine_end_thread,(void *)tox); } } } } else { /* xine_play mrl <#> xine_play start <0> xine_play time <0> */ if(nargs == 2) { if(toxine_is_arg_contain(tox, 1, "mrl")) { expanded_mrl = tilde_expand(((char *) toxine_get_arg(tox, 2))); mrl = (const char *)expanded_mrl; if(!tox->current_mrl) tox->current_mrl = strdup(mrl); else { if(!strcmp(tox->current_mrl, mrl)) need_open = 0; else { free(tox->current_mrl); tox->current_mrl = strdup(mrl); } } } else if(toxine_is_arg_contain(tox, 1, "start")) start = atoi((toxine_get_arg(tox, 2))); else if(toxine_is_arg_contain(tox, 1, "time")) time = atoi((toxine_get_arg(tox, 2))); else { perr("Unhandled argument '%s'\n", (toxine_get_arg(tox, 1))); return; } if(!mrl) { if(tox->current_mrl) mrl = (const char *)tox->current_mrl; else { perr("You should set/specify an MRL.\n"); return; } } } else if(nargs == 4) { /* xine_play mrl start <0> xine_play mrl time <0> */ if(toxine_is_arg_contain(tox, 1,"mrl")) { expanded_mrl = tilde_expand(((char *) toxine_get_arg(tox, 2))); mrl = (const char *)expanded_mrl; if(!tox->current_mrl) tox->current_mrl = strdup(mrl); else { if(!strcmp(tox->current_mrl, mrl)) need_open = 0; else { free(tox->current_mrl); tox->current_mrl = strdup(mrl); } } if(toxine_is_arg_contain(tox, 3, "start")) start = atoi((toxine_get_arg(tox, 4))); else if(toxine_is_arg_contain(tox, 3, "time")) time = atoi((toxine_get_arg(tox, 4))); else { perr("Unhandled argument '%s'\n", toxine_get_arg(tox, 3)); return; } } else { perr("Unhandled argument '%s'\n", toxine_get_arg(tox, 1)); return; } } else { printf("wrong command syntax, try 'syntax xine_play'\n"); return; } } if(!tox->current_mrl && mrl) tox->current_mrl = strdup(mrl); if(time) time *= 1000; if(need_open) { pinfo("xine_open(%s) && xine_play(%d, %d):\n", mrl, start, time); if((!(result = xine_open(tox->stream, mrl))) || (!(result = xine_play(tox->stream, start, time)))) toxine_handle_xine_errors(tox); else tox->xine_state |= XINE_OPEN; } else { pinfo("xine_play(%d, %d):\n", start, time); if(!(result = xine_play(tox->stream, start, time))) toxine_handle_xine_errors(tox); } pinfo(".\n"); toxine_set_last_int_result(tox, result); if(expanded_mrl) free(expanded_mrl); } /* * */ void _xine_trick_mode(commands_t *command, toxine_t *tox, void *data) { int nargs; toxine_unset_last_result(tox); return_if_no_stream(tox); if((nargs = toxine_is_args(tox)) == 2) { int i, trick_mode = -1; const char *trick = toxine_get_arg(tox, 1); for(i = 0; xine_tricks[i].name != NULL; i++) { if(!strncasecmp(trick, xine_tricks[i].name, strlen(trick))) { trick_mode = xine_tricks[i].mode; break; } } if(trick_mode >= 0) { int value, result; value = atoi(((char *)toxine_get_arg(tox, 2))); pinfo("xine_trick_mode(%s, %d):\n", xine_tricks[i].name, value); result = xine_trick_mode(tox->stream, trick_mode, value); toxine_set_last_int_result(tox, result); pinfo("--returned %d\n", result); } else perr("invalid trick mode: %s.\n", trick); pinfo(".\n"); } } /* * ************* */ void _xine_get_stream_info(commands_t *command, toxine_t *tox, void *data) { int nargs; toxine_unset_last_result(tox); return_if_no_stream(tox); nargs = toxine_is_args(tox); if(nargs) { char *info_name = (char *)toxine_get_arg(tox, 1); int i, found = -1; for(i = 0; stream_infos[i].name != NULL; i++) { if(!strncasecmp(info_name, stream_infos[i].name, strlen(info_name))) { found = i; break; } } if(found >= 0) { uint32_t stream_info; pinfo("xine_get_stream_info(%s):\n", stream_infos[i].name); stream_info = xine_get_stream_info(tox->stream, stream_infos[i].type); toxine_set_last_int_result(tox, stream_info); toxine_show_stream_info(stream_infos[i].type, stream_info); pinfo(".\n"); } } } void _xine_get_meta_info(commands_t *command, toxine_t *tox, void *data) { int nargs; toxine_unset_last_result(tox); return_if_no_stream(tox); nargs = toxine_is_args(tox); if(nargs) { char *info_name = (char *)toxine_get_arg(tox, 1); int i, found = -1; for(i = 0; meta_infos[i].name != NULL; i++) { if(!strncasecmp(info_name, meta_infos[i].name, strlen(info_name))) { found = i; break; } } if(found >= 0) { const char *meta_info; pinfo("xine_get_meta_info(%s):\n", meta_infos[i].name); meta_info = xine_get_meta_info(tox->stream, stream_infos[i].type); toxine_set_last_char_result(tox, meta_info); switch(meta_infos[i].type) { case XINE_META_INFO_TITLE: case XINE_META_INFO_COMMENT: case XINE_META_INFO_ARTIST: case XINE_META_INFO_GENRE: case XINE_META_INFO_ALBUM: case XINE_META_INFO_YEAR: case XINE_META_INFO_VIDEOCODEC: case XINE_META_INFO_AUDIOCODEC: case XINE_META_INFO_SYSTEMLAYER: case XINE_META_INFO_INPUT_PLUGIN: pinfo("%s\n", (meta_info) ? (char *) meta_info : "Unavailable"); break; } pinfo(".\n"); } } } /* * */ void _xine_stop(commands_t *command, toxine_t *tox, void *data) { toxine_unset_last_result(tox); return_if_no_stream(tox); tox->ignore_finished = 1; pinfo("xine_stop():\n"); xine_stop(tox->stream); pinfo(".\n"); } /* * */ void _xine_eject(commands_t *command, toxine_t *tox, void *data) { int retval; toxine_unset_last_result(tox); return_if_no_stream(tox); pinfo("xine_eject():\n"); retval = xine_eject(tox->stream); toxine_set_last_int_result(tox, retval); pinfo("returned %d.\n", retval); pinfo(".\n"); } /* * */ void _xine_exit(commands_t *command, toxine_t *tox, void *data) { toxine_unset_last_result(tox); return_if_no_new(tox); toxine_config_save(tox); if(tox->xine_state & XINE_STREAM) { _xine_close(NULL, tox, NULL); _xine_dispose(NULL, tox, NULL); } if(tox->xine_state & XINE_INIT) { if(tox->event_queue) { pinfo("xine_event_dispose_queue():\n"); xine_event_dispose_queue(tox->event_queue); pinfo(".\n"); tox->event_queue = NULL; } } if(tox->video.cur_plugin && tox->video.cur_plugin->video_out_deinit) { tox->video.running = 0; if(tox->video.loop_thread) pthread_join(tox->video.loop_thread, NULL); tox->video.cur_plugin->video_out_deinit(tox); } tox->video.cur_plugin = NULL; if(tox->audio.port) { xine_close_audio_driver(tox->xine, tox->audio.port); tox->audio.port = NULL; } pinfo("xine_exit():\n"); xine_exit(tox->xine); pinfo(".\n"); tox->xine = NULL; tox->xine_state = 0; pthread_mutex_destroy(&tox->event.mutex); } /* * */ void _xine_get_error(commands_t *command, toxine_t *tox, void *data) { int xine_errno; char buffer[2048]; toxine_unset_last_result(tox); return_if_no_stream(tox); pinfo("xine_get_error():\n"); xine_errno = xine_get_error(tox->stream); toxine_set_last_int_result(tox, xine_errno); sprintf(buffer, "returned %d (", xine_errno); switch(xine_errno) { case XINE_ERROR_NONE: sprintf(buffer, "%s XINE_ERROR_NONE)\n", buffer); break; case XINE_ERROR_NO_INPUT_PLUGIN: sprintf(buffer, "%s XINE_ERROR_NO_INPUT_PLUGIN)\n", buffer); break; case XINE_ERROR_NO_DEMUX_PLUGIN: sprintf(buffer, "%s XINE_ERROR_NO_DEMUXER_PLUGIN)\n", buffer); break; case XINE_ERROR_DEMUX_FAILED: sprintf(buffer, "%s XINE_ERROR_DEMUXER_FAILED)\n", buffer); break; case XINE_ERROR_MALFORMED_MRL: sprintf(buffer, "%s XINE_ERROR_MALFORMED_MRL)\n", buffer); break; } pinfo(buffer); pinfo(".\n"); } /* * */ void _xine_get_status(commands_t *command, toxine_t *tox, void *data) { int i, found = 0, status; toxine_unset_last_result(tox); return_if_no_stream(tox); pinfo("xine_get_status():\n"); status = xine_get_status(tox->stream); toxine_set_last_int_result(tox, status); for(i = 0; xine_status[i].name != NULL; i++) { if(status == xine_status[i].status) { found = i; break; } } pinfo("Current status of xine engine is %d (%s)\n", status, xine_status[found].name); pinfo(".\n"); } /* * */ void _xine_set_param(commands_t *command, toxine_t *tox, void *data) { toxine_unset_last_result(tox); return_if_no_stream(tox); if((toxine_is_args(tox)) >= 2) { const char *param; const char *svalue; int value; int i, found = -1; char buffer[2048]; int value_found = -1; param = toxine_get_arg(tox, 1); svalue = toxine_get_arg(tox, 2); value = atoi(((char *)svalue)); memset(&buffer, 0, sizeof(buffer)); for(i = 0; xine_params[i].name != NULL; i++) { if(!strncasecmp(param, xine_params[i].name, strlen(param))) { found = i; break; } } if(found >= 0) { sprintf(buffer, "xine_set_param(%s", xine_params[found].name); switch(xine_params[i].param) { case XINE_PARAM_SPEED: for(i = 0; xine_speeds[i].name != NULL; i++) { if(!strncasecmp(svalue, xine_speeds[i].name, strlen(svalue))) { value = xine_speeds[i].speed; value_found = 1; sprintf(buffer, "%s, %s)\n", buffer, xine_speeds[i].name); break; } } break; case XINE_PARAM_VO_ASPECT_RATIO: for(i = 0; xine_vo_aspects[i].name != NULL; i++) { if(!strncasecmp(svalue, xine_vo_aspects[i].name, strlen(svalue))) { value = xine_vo_aspects[i].aspect; value_found = 1; sprintf(buffer, "%s, %s)\n", buffer, xine_vo_aspects[i].name); break; } } break; case XINE_PARAM_AV_OFFSET: case XINE_PARAM_AUDIO_CHANNEL_LOGICAL: case XINE_PARAM_SPU_CHANNEL: case XINE_PARAM_VIDEO_CHANNEL: case XINE_PARAM_AUDIO_VOLUME: case XINE_PARAM_AUDIO_MUTE: case XINE_PARAM_AUDIO_COMPR_LEVEL: case XINE_PARAM_AUDIO_AMP_LEVEL: case XINE_PARAM_AUDIO_REPORT_LEVEL: case XINE_PARAM_VERBOSITY: case XINE_PARAM_SPU_OFFSET: case XINE_PARAM_VO_DEINTERLACE: case XINE_PARAM_VO_HUE: case XINE_PARAM_VO_SATURATION: case XINE_PARAM_VO_CONTRAST: case XINE_PARAM_VO_BRIGHTNESS: case XINE_PARAM_VO_ZOOM_X: case XINE_PARAM_VO_ZOOM_Y: case XINE_PARAM_VO_PAN_SCAN: case XINE_PARAM_VO_TVMODE: sprintf(buffer, "%s, %d)\n", buffer, value); value_found = 1; break; } if(value_found == -1) sprintf(buffer, "%s, UNKNOWN[%d])\n", buffer, value); pinfo(buffer); xine_set_param(tox->stream, xine_params[found].param, value); pinfo(".\n"); } else perr("Unknown xine parameter: '%s'\n", param); } else perr("Argument(s) missing.\n"); } /* * */ void _xine_get_param(commands_t *command, toxine_t *tox, void *data) { const char *param; int i, found = -1; toxine_unset_last_result(tox); return_if_no_stream(tox); param = toxine_get_arg(tox, 1); for(i = 0; xine_params[i].name != NULL; i++) { if(!strncasecmp(param, xine_params[i].name, strlen(param))) { found = i; break; } } if(found >= 0) { int result; pinfo("xine_get_param(%s):\n", xine_params[i].name); result = xine_get_param(tox->stream, xine_params[i].param); toxine_set_last_int_result(tox, result); pinfo("returned [%d]:\n", result); switch(xine_params[i].param) { case XINE_PARAM_SPEED: for(i = 0; xine_speeds[i].name != NULL; i++) { if(result == xine_speeds[i].speed) { pinfo("%s\n", xine_speeds[i].name); break; } } break; case XINE_PARAM_AV_OFFSET: pinfo("offset: %d (* 1/90000 s)\n", result); break; case XINE_PARAM_AUDIO_CHANNEL_LOGICAL: pinfo("logical audio channel: %d\n", result); break; case XINE_PARAM_SPU_CHANNEL: pinfo("spu channel: %d\n", result); break; case XINE_PARAM_VIDEO_CHANNEL: pinfo("video channel: %d\n", result); break; case XINE_PARAM_AUDIO_VOLUME: toxine_draw_bar("audio volume", 0, 255, result); break; case XINE_PARAM_AUDIO_MUTE: pinfo("mute: %s\n", (result) ? "yes" : "no"); break; case XINE_PARAM_AUDIO_COMPR_LEVEL: toxine_draw_bar("compression level", 0, 255, result); break; case XINE_PARAM_AUDIO_AMP_LEVEL: toxine_draw_bar("amplification level", 0, 100, result); break; case XINE_PARAM_AUDIO_REPORT_LEVEL: pinfo("report level: %s", (result) ? "yes" : "no"); break; case XINE_PARAM_VERBOSITY: pinfo("verbosity: %d", result); break; case XINE_PARAM_SPU_OFFSET: pinfo("spu offset: %d (u: 1/90000 sec)", result); break; case XINE_PARAM_VO_DEINTERLACE: pinfo("video out deinterlace: %s", (result) ? "yes" : "no"); break; case XINE_PARAM_VO_ASPECT_RATIO: for(i = 0; xine_vo_aspects[i].name != NULL; i++) { if(result == xine_vo_aspects[i].aspect) { pinfo("%s\n", xine_vo_aspects[i].name); break; } } break; case XINE_PARAM_VO_HUE: toxine_draw_bar("video output hue", 0, 65535, result); break; case XINE_PARAM_VO_SATURATION: toxine_draw_bar("video output saturation", 0, 65535, result); break; case XINE_PARAM_VO_CONTRAST: toxine_draw_bar("video output hue", 0, 65535, result); break; case XINE_PARAM_VO_BRIGHTNESS: toxine_draw_bar("video output brightness", 0, 65535, result); break; case XINE_PARAM_VO_ZOOM_X: toxine_draw_bar("video output zoom X", 0, 100, result); break; case XINE_PARAM_VO_ZOOM_Y: toxine_draw_bar("video output zoom Y", 0, 100, result); break; case XINE_PARAM_VO_PAN_SCAN: pinfo("video out pan and scan: %s", (result) ? "yes" : "no"); break; case XINE_PARAM_VO_TVMODE: pinfo("video out TV mode: %d", result); break; } } else perr("Unknown xine parameter: '%s'\n", param); pinfo(".\n"); } /* * */ void _xine_get_audio_lang(commands_t *command, toxine_t *tox, void *data) { char lang[20]; int channel; int ret; toxine_unset_last_result(tox); return_if_no_stream(tox); if(toxine_is_args(tox)) channel = atoi(((char *)toxine_get_arg(tox, 1))); else channel = tox->audio.channel; pinfo("xine_get_audio_lang(%d):\n", channel); ret = xine_get_audio_lang(tox->stream, channel, &lang[0]); toxine_set_last_int_result(tox, ret); poutalign(); pout("'%s'\n", lang); pinfo(".\n"); } /* * */ void _xine_get_spu_lang(commands_t *command, toxine_t *tox, void *data) { char lang[20]; int channel; int ret; toxine_unset_last_result(tox); return_if_no_stream(tox); if(toxine_is_args(tox)) channel = atoi(((char *)toxine_get_arg(tox, 1))); else channel = tox->video.spu_channel; pinfo("xine_get_spu_lang(%d):\n", channel); ret = xine_get_spu_lang(tox->stream, channel, &lang[0]); toxine_set_last_int_result(tox, ret); poutalign(); pout("'%s'\n", lang); pinfo(".\n"); } /* * */ void _xine_get_pos_length(commands_t *command, toxine_t *tox, void *data) { int result, stream, time, length; int stime, slength; toxine_unset_last_result(tox); return_if_no_stream(tox); pinfo("xine_get_pos_length():\n"); result = xine_get_pos_length (tox->stream, &stream, &time, &length); toxine_set_last_int_result(tox, result); stime = time / 1000; slength = length / 1000; toxine_draw_bar("", 0, length, time); pinfo("position:\n"); pinfo("Stream %d (0...65535), " "time %02d:%02d:%02d (%dms).\n", stream, stime / (60 * 60), (stime / 60) % 60, stime % 60, time); pinfo("Total time: %02d:%02d:%02d (%dms)\n", slength / (60 * 60), (slength / 60) % 60, slength % 60, length); pinfo(".\n"); } /* * */ void _xine_get_log(commands_t *command, toxine_t *tox, void *data) { int buftype = -1; const char *const *logs; const char *log = NULL, *bufname; const char *const *log_names; toxine_unset_last_result(tox); return_if_no_init(tox); bufname = toxine_get_arg(tox, 1); log_names = xine_get_log_names(tox->xine); toxine_set_last_achar_result(tox, log_names); if(log_names) { int i; for(i = 0, log = *log_names++; log; log = *log_names++, i++) { if(!strncasecmp(bufname, log, strlen(bufname))) { buftype = i; break; } } } if(buftype == -1) { buftype = atoi(((char *)bufname)); if(buftype >= xine_get_log_section_count(tox->xine)) { perr("buffer number %d is out of bounds\n", buftype); return; } pinfo("xine_get_log(%d):\n", buftype); } else pinfo("xine_get_log(%s):\n", log); logs = xine_get_log(tox->xine, buftype); toxine_set_last_achar_result(tox, logs); if(logs) { char buffer[2048]; for(log = *logs++; log; log = *logs++) { memset(&buffer, 0, sizeof(buffer)); sprintf(buffer, "%s%c", log, '\n'); pinfo("%s", buffer); } } else pinfo("No log entry available.\n"); pinfo(".\n"); } /* * */ void _xine_get_log_names(commands_t *command, toxine_t *tox, void *data) { const char *const *log_names; const char *log; char buffer[2048]; toxine_unset_last_result(tox); return_if_no_init(tox); memset(&buffer, 0, sizeof(buffer)); pinfo("xine_get_log_names():\n"); log_names = xine_get_log_names(tox->xine); toxine_set_last_achar_result(tox, log_names); if(log_names) { for(log = *log_names++; log; log = *log_names++) { if(strlen(buffer)) sprintf(buffer, "%s, %s", buffer, log); else sprintf(buffer, "%s", log); } sprintf(buffer, "%s.\n", buffer); pinfo(buffer); pinfo(".\n"); } } /* * */ void _xine_get_log_section_count(commands_t *command, toxine_t *tox, void *data) { int count; toxine_unset_last_result(tox); return_if_no_init(tox); pinfo("xine_get_log_section_count():\n"); count = xine_get_log_section_count(tox->xine); toxine_set_last_int_result(tox, count); pinfo("returned %d\n", count); pinfo(".\n"); } /* * */ void _xine_log(commands_t *command, toxine_t *tox, void *data) { int buftype = -1; const char *msg, *log = NULL, *bufname; const char *const *log_names; toxine_unset_last_result(tox); return_if_no_init(tox); bufname = toxine_get_arg(tox, 1); log_names = xine_get_log_names(tox->xine); if(log_names) { int i; for(i = 0, log = *log_names++; log; log = *log_names++, i++) { if(!strncasecmp(bufname, log, strlen(bufname))) { buftype = i; break; } } } msg = toxine_get_arg(tox, 2); if(buftype == -1) { buftype = atoi(((char *)bufname)); if(buftype >= xine_get_log_section_count(tox->xine)) { perr("buffer number %d is out of bounds\n", buftype); return; } pinfo("xine_log(%d, '%s')\n", buftype, msg); } else pinfo("xine_log(%s, '%s')\n", log, msg); xine_log(tox->xine, buftype, msg); pinfo(".\n"); } /* * */ void _xine_get_browsable_input_plugin_ids(commands_t *command, toxine_t *tox, void *data) { const char *const *inpp; toxine_unset_last_result(tox); return_if_no_init(tox); pinfo("xine_get_browsable_input_plugin_ids():\n"); inpp = xine_get_browsable_input_plugin_ids(tox->xine); toxine_set_last_achar_result(tox, inpp); if(inpp) { char buffer[4096]; const char *ipid; memset(&buffer, 0, sizeof(buffer)); pinfo("Available identifier of browsable input plugins are:\n"); for(ipid = *inpp++; ipid; ipid = *inpp++) { if(strlen(buffer)) sprintf(buffer, "%s, %s", buffer, ipid); else sprintf(buffer, "%s", ipid); } sprintf(buffer, "%s.\n", buffer); pinfo(buffer); } else pinfo("there is no browsable input plugin installed.\n"); pinfo(".\n"); } /* * */ void _xine_get_browse_mrls(commands_t *command, toxine_t *tox, void *data) { int nargs; toxine_unset_last_result(tox); return_if_no_init(tox); if((nargs = toxine_is_args(tox))) { xine_mrl_t **bmrls; const char *pname; const char *smrl = NULL; int mrls, i; char buffer[4096]; if(nargs >= 1) { pname = toxine_get_arg(tox, 1); if(nargs >= 2) smrl = toxine_get_arg(tox, 2); pinfo("xine_get_browse_mrls(%s,%s):\n", pname, smrl); bmrls = xine_get_browse_mrls(tox->xine, pname, smrl, &mrls); { char *p[mrls + 1]; for(i = 0; i < mrls; i++) { p[i] = bmrls[i]->mrl; } p[i] = NULL; toxine_set_last_achar_result(tox, (const char *const *)p); } if(bmrls) { for(i = 0; i < mrls; i++) { const xine_mrl_t *mrl = bmrls[i]; memset(&buffer, 0, sizeof(buffer)); sprintf(buffer, "%4d - '%s'", i, mrl->mrl); if(mrl->type & XINE_MRL_TYPE_file_symlink) sprintf(buffer, "%s@ -> '%s'", buffer, mrl->link); sprintf(buffer, "%s [ ", buffer); if(mrl->type & XINE_MRL_TYPE_unknown) sprintf(buffer, "%sunknown ", buffer); if(mrl->type & XINE_MRL_TYPE_dvd) sprintf(buffer, "%sdvd ", buffer); if(mrl->type & XINE_MRL_TYPE_vcd) sprintf(buffer, "%svcd ", buffer); if(mrl->type & XINE_MRL_TYPE_net) sprintf(buffer, "%snet ", buffer); if(mrl->type & XINE_MRL_TYPE_rtp) sprintf(buffer, "%srtp ", buffer); if(mrl->type & XINE_MRL_TYPE_stdin) sprintf(buffer, "%sstdin ", buffer); if(mrl->type & XINE_MRL_TYPE_file) sprintf(buffer, "%sfile ", buffer); if(mrl->type & XINE_MRL_TYPE_file_fifo) sprintf(buffer, "%sfifo ", buffer); if(mrl->type & XINE_MRL_TYPE_file_chardev) sprintf(buffer, "%schardev ", buffer); if(mrl->type & XINE_MRL_TYPE_file_directory) sprintf(buffer, "%sdirectory ", buffer); if(mrl->type & XINE_MRL_TYPE_file_blockdev) sprintf(buffer, "%sblockdev ", buffer); if(mrl->type & XINE_MRL_TYPE_file_normal) sprintf(buffer, "%snormal ", buffer); if(mrl->type & XINE_MRL_TYPE_file_sock) sprintf(buffer, "%ssock ", buffer); if(mrl->type & XINE_MRL_TYPE_file_exec) sprintf(buffer, "%sexec ", buffer); if(mrl->type & XINE_MRL_TYPE_file_backup) sprintf(buffer, "%sbackup ", buffer); if(mrl->type & XINE_MRL_TYPE_file_hidden) sprintf(buffer, "%shidden ", buffer); sprintf(buffer, "%s] (%Ld byte%s)\n", buffer, mrl->size, (mrl->size > 0) ?"s":""); pinfo(buffer); } pinfo(".\n"); } else pinfo("there is no available mrls from %s plugin.\n", pname); } } } /* * */ void _xine_get_autoplay_input_plugin_ids(commands_t *command, toxine_t *tox, void *data) { const char *const *inpp; toxine_unset_last_result(tox); return_if_no_init(tox); pinfo("xine_get_autoplay_input_plugin_ids():\n"); inpp = xine_get_autoplay_input_plugin_ids(tox->xine); toxine_set_last_achar_result(tox, inpp); if(inpp) { char buffer[4096]; const char *ipid; memset(&buffer, 0, sizeof(buffer)); pinfo("Available identifier of autoplay featured input plugins are:\n"); for(ipid = *inpp++; ipid; ipid = *inpp++) { if(strlen(buffer)) sprintf(buffer, "%s, %s", buffer, ipid); else sprintf(buffer, "%s", ipid); } sprintf(buffer, "%s.\n", buffer); pinfo(buffer); } else pinfo("there is no autoplay featured input plugin installed.\n"); pinfo(".\n"); } /* * */ void _xine_get_autoplay_mrls(commands_t *command, toxine_t *tox, void *data) { toxine_unset_last_result(tox); return_if_no_init(tox); if(toxine_is_args(tox)) { const char *pname; char **ap; int mrls, i; pname = toxine_get_arg(tox, 1); pinfo("xine_get_autoplay_mrls(%s):\n", pname); ap = xine_get_autoplay_mrls(tox->xine, pname, &mrls); toxine_set_last_achar_result(tox, (const char *const *)ap); if(ap) { for(i = 0; i < mrls; i++) pinfo("%s\n", ap[i]); pinfo(".\n"); } else pinfo("there is no available autoplay mrls from '%s' plugin.\n", pname); } } /* * */ void _xine_get_input_plugin_description(commands_t *command, toxine_t *tox, void *data) { toxine_unset_last_result(tox); return_if_no_init(tox); if(toxine_is_args(tox)) { const char *ipd; const char *pname; pname = toxine_get_arg(tox, 1); pinfo("xine_get_input_plugin_description(%s):\n", pname); ipd = xine_get_input_plugin_description(tox->xine, pname); toxine_set_last_char_result(tox, ipd); if(ipd) { pinfo("description of '%s' plugin id is:\n", pname); pinfo("%s\n", ipd); pinfo(".\n"); } else pinfo("there is no description for '%s' plugin.\n", pname); } } /* * */ void _xine_list_audio_output_plugins(commands_t *command, toxine_t *tox, void *data) { const char *const *aop; char buffer[4096]; toxine_unset_last_result(tox); return_if_no_init(tox); pinfo("xine_list_audio_output_plugins():\n"); aop = xine_list_audio_output_plugins(tox->xine); toxine_set_last_achar_result(tox, aop); if(aop) { const char *aopn; pinfo("Available audio output plugins are:\n"); memset(&buffer, 0, sizeof(buffer)); for(aopn = *aop++; aopn; aopn = *aop++) { if(strlen(buffer)) sprintf(buffer, "%s, %s", buffer, aopn); else sprintf(buffer, "%s", aopn); } sprintf(buffer, "%s.\n", buffer); pinfo(buffer); pinfo(".\n"); } else pinfo("there is no audio output plugin installed.\n"); } /* * */ void _xine_list_video_output_plugins(commands_t *command, toxine_t *tox, void *data) { const char *const *vop; char buffer[4096]; toxine_unset_last_result(tox); return_if_no_init(tox); pinfo("xine_list_video_output_plugins():\n"); vop = xine_list_video_output_plugins(tox->xine); toxine_set_last_achar_result(tox, vop); if(vop) { const char *vopn; pinfo("Available video output plugins are:\n"); memset(&buffer, 0, sizeof(buffer)); for(vopn = *vop++; vopn; vopn = *vop++) { if(strlen(buffer)) sprintf(buffer, "%s, %s", buffer, vopn); else sprintf(buffer, "%s", vopn); } sprintf(buffer, "%s.\n", buffer); pinfo(buffer); pinfo(".\n"); } else pinfo("there is no video output plugin installed.\n"); } /* * */ void _xine_event_send(commands_t *command, toxine_t *tox, void *data) { int alias_event = (int) data; toxine_unset_last_result(tox); return_if_no_stream(tox); if((toxine_is_args(tox)) || (alias_event > 0)) { const char *event_name = NULL; int event_type = alias_event; int i; if(alias_event == 0) { event_name = toxine_get_arg(tox, 1); for(i = 0; event_types[i].name != NULL; i++) { if(!strncasecmp(event_name, event_types[i].name, strlen(event_name))) { event_type = event_types[i].type; break; } } } if(event_type > 0) { xine_event_t xine_event; xine_event.type = event_type; xine_event.data_length = 0; xine_event.data = NULL; xine_event.stream = tox->stream; gettimeofday(&xine_event.tv, NULL); pinfo("xine_event_send(%d):\n", event_type); xine_event_send(tox->stream, &xine_event); pinfo(".\n"); } else { if(alias_event == 0) pinfo("there is no event type named '%s'.\n", event_name); else pinfo("there is no event type # %d.\n", alias_event); } } } /* * ****** CONFIG ****** */ void _xine_config_get_first_entry(commands_t *command, toxine_t *tox, void *data) { _cfg_entry_t cfg_entry; toxine_unset_last_result(tox); return_if_no_init(tox); pinfo("xine_config_get_first_entry():\n"); if((xine_config_get_first_entry(tox->xine, &cfg_entry))) toxine_dump_config_entry(tox, &cfg_entry); else perr("xine_config_get_first_entry() returned NULL\n"); pinfo(".\n"); } void _xine_config_get_next_entry(commands_t *command, toxine_t *tox, void *data) { _cfg_entry_t cfg_entry; toxine_unset_last_result(tox); return_if_no_init(tox); pinfo("xine_config_get_next_entry():\n"); if((xine_config_get_next_entry(tox->xine, &cfg_entry))) toxine_dump_config_entry(tox, &cfg_entry); else perr("xine_config_get_next_entry() returned NULL\n"); pinfo(".\n"); } void _xine_config_lookup_entry(commands_t *command, toxine_t *tox, void *data) { const char *key; _cfg_entry_t cfg_entry; toxine_unset_last_result(tox); return_if_no_init(tox); key = toxine_get_arg(tox, 1); pinfo("xine_config_lookup_entry(%s):\n", key); if((xine_config_lookup_entry(tox->xine, key, &cfg_entry))) toxine_dump_config_entry(tox, &cfg_entry); else perr("Entry '%s' doesn't exist.\n", key); pinfo(".\n"); } void _xine_config_update_entry(commands_t *command, toxine_t *tox, void *data) { const char *key; int value; _cfg_entry_t cfg_entry; toxine_unset_last_result(tox); return_if_no_init(tox); if(toxine_is_args(tox) >= 2) { const char *svalue; int valid_entry = 0; key = toxine_get_arg(tox, 1); svalue = toxine_get_arg(tox, 2); value = atoi(((char *) svalue)); pinfo("xine_config_lookup_entry(%s):\n", key); if((xine_config_lookup_entry(tox->xine, key, &cfg_entry))) { switch(cfg_entry.type) { case XINE_CONFIG_TYPE_STRING: cfg_entry.str_value = (char *)svalue; valid_entry = 1; break; case XINE_CONFIG_TYPE_RANGE: case XINE_CONFIG_TYPE_ENUM: case XINE_CONFIG_TYPE_NUM: cfg_entry.num_value = value; valid_entry = 1; break; case XINE_CONFIG_TYPE_BOOL: cfg_entry.num_value = (value) ? 1 : 0; valid_entry = 1; break; case XINE_CONFIG_TYPE_UNKNOWN: perr("Entry not registered\n"); break; } if(valid_entry) { pinfo("xine_config_update_entry(%s):\n", key); xine_config_update_entry(tox->xine, &cfg_entry); pinfo(".\n"); } } else perr("Entry '%s' doesn't exist.\n", key); pinfo(".\n"); } else perr("Argument(s) missing.\n"); } void _xine_config_load(commands_t *command, toxine_t *tox, void *data) { const char *filename = NULL; return_if_no_new(tox); if(toxine_is_args(tox)) { filename = toxine_get_arg(tox, 1); if(tox->configfile) free((char *)tox->configfile); tox->configfile = strdup(filename); } pinfo("xine_config_load(%s):\n", tox->configfile); xine_config_load(tox->xine, tox->configfile); pinfo(".\n"); } void _xine_config_save(commands_t *command, toxine_t *tox, void *data) { const char *filename = NULL; toxine_unset_last_result(tox); return_if_no_init(tox); if(toxine_is_args(tox)) filename = toxine_get_arg(tox, 1); pinfo("xine_config_save(%s):\n", (filename) ? filename : tox->configfile); xine_config_save(tox->xine, ((filename) ? filename : tox->configfile)); pinfo(".\n"); } void _xine_config_reset(commands_t *command, toxine_t *tox, void *data) { toxine_unset_last_result(tox); return_if_no_init(tox); pinfo("xine_config_reset():\n"); xine_config_reset(tox->xine); pinfo(".\n"); } /* * ****** END CONFIG ****** */ /* * */ void _xine_get_version(commands_t *command, toxine_t *tox, void *data) { int major, minor, sub; char buffer[32]; toxine_unset_last_result(tox); pinfo("xine_get_version():\n"); xine_get_version(&major, &minor, &sub); sprintf(buffer, "%d.%d.%d", major, minor, sub); toxine_set_last_char_result(tox, buffer); poutalign(); pout("'%d.%d.%d'\n", major, minor, sub); pinfo(".\n"); } /* * */ void _xine_get_version_string(commands_t *command, toxine_t *tox, void *data) { const char *result; toxine_unset_last_result(tox); pinfo("xine_get_version_string():\n"); result = xine_get_version_string(); toxine_set_last_char_result(tox, result); poutalign(); pout("'%s'\n", result); pinfo(".\n"); } /* * */ void _xine_check_version(commands_t *command, toxine_t *tox, void *data) { int major, minor, sub, retval; toxine_unset_last_result(tox); if(toxine_is_args(tox) >= 1) { if((sscanf((toxine_get_arg(tox, 1)), "%d.%d.%d", &major, &minor, &sub)) == 3) { pinfo("xine_check_version(%d,%d,%d):\n", major, minor, sub); retval = xine_check_version(major, minor, sub); toxine_set_last_int_result(tox, retval); pinfo("returned %d.\n", retval); pinfo(".\n"); } } } void _xine_close(commands_t *command, toxine_t *tox, void *data) { toxine_unset_last_result(tox); return_if_no_stream(tox); pinfo("xine_close():\n"); xine_close(tox->stream); pinfo(".\n"); tox->xine_state &= ~XINE_OPEN; } void _xine_dispose(commands_t *command, toxine_t *tox, void *data) { toxine_unset_last_result(tox); return_if_no_stream(tox); if(tox->event_queue) { pinfo("xine_event_dispose_queue():\n"); xine_event_dispose_queue(tox->event_queue); pinfo(".\n"); tox->event_queue = NULL; } pinfo("xine_dispose():\n"); xine_dispose(tox->stream); tox->stream = NULL; tox->xine_state &= ~(XINE_OPEN | XINE_STREAM); pinfo(".\n"); } void _xine_get_file_extensions(commands_t *command, toxine_t *tox, void *data) { char *exts; toxine_unset_last_result(tox); return_if_no_init(tox); pinfo("xine_get_file_extensions():\n"); exts = xine_get_file_extensions(tox->xine); toxine_set_last_char_result(tox, exts); pinfo("returned: '%s'\n", (exts) ? exts : "NONE"); pinfo(".\n"); toxine_free(exts); } void _xine_get_mime_types(commands_t *command, toxine_t *tox, void *data) { char *mimes; toxine_unset_last_result(tox); return_if_no_init(tox); pinfo("xine_get_mime_types():\n"); mimes = xine_get_mime_types(tox->xine); toxine_set_last_char_result(tox, mimes); pinfo("returned: '%s'\n", (mimes) ? mimes : "NONE"); pinfo(".\n"); toxine_free(mimes); } void _xine_get_current_frame(commands_t *command, toxine_t *tox, void *data) { char buffer[_PATH_MAX + _NAME_MAX + 1]; char *filename = NULL; FILE *fd; int width; int height; int ratio_code; int format; uint8_t *frame = NULL; int result; toxine_unset_last_result(tox); return_if_no_stream(tox); if(toxine_is_args(tox)) filename = (char *) toxine_get_arg(tox, 1); else { sprintf(buffer, "xine_frame-%d.frm", (unsigned int)(time(NULL))); filename = buffer; } width = xine_get_stream_info(tox->stream,XINE_STREAM_INFO_VIDEO_WIDTH); height = xine_get_stream_info(tox->stream,XINE_STREAM_INFO_VIDEO_HEIGHT); if((!width) || (!height)) perr("Wrong frame size: %dx%d\n", width, height); else { int size = (width * height) * 2; frame = (uint8_t *) xine_xmalloc(sizeof(uint8_t) * size); pinfo("xine_get_current_frame():\n"); if((result = xine_get_current_frame(tox->stream, &width, &height, &ratio_code, &format, frame))) { toxine_set_last_int_result(tox, result); pinfo("get frame: %dx%d, ratio %d, format %d\n", width, height, ratio_code, format); if((fd = fopen(filename, "w+b")) != NULL) { fwrite(frame, size, 1, fd); fflush(fd); fclose(fd); pinfo("File '%s' saved\n", filename); } else perr("Unable to open file '%s' in write mode\n", filename); } else perr("unable to get current frame\n"); pinfo(".\n"); toxine_free(frame); } } /* * xine-utils */ void _xine_usec_sleep(commands_t *command, toxine_t *tox, void *data) { unsigned usecs; toxine_unset_last_result(tox); usecs = (unsigned) atoi((toxine_get_arg(tox, 1))); pinfo("xine_usec_sleep(%u):\n", usecs); xine_usec_sleep(usecs); pinfo(".\n"); } void _NAPI_xine_dumpstream(toxine_t *tox) { const char *minfo; uint32_t iinfo; int i; toxine_unset_last_result(tox); return_if_no_stream(tox); return_if_no_open(tox); pinfo("Meta info:\n"); for(i = 0; meta_infos[i].name != NULL; i++) { minfo = xine_get_meta_info(tox->stream, meta_infos[i].type); toxine_set_last_char_result(tox, minfo); pinfo("%s: %s\n", meta_infos[i].name, (minfo) ? (char *) minfo : "Unavailable"); } pinfo("\n"); pinfo("Stream info:\n"); for(i = 0; stream_infos[i].name != NULL; i++) { iinfo = xine_get_stream_info(tox->stream, stream_infos[i].type); toxine_set_last_int_result(tox, iinfo); pinfo("%s: ", stream_infos[i].name); toxine_show_stream_info(stream_infos[i].type, iinfo); } pinfo(".\n"); }