/* ** 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. ** */ #ifndef __TOXINE_MAIN_H__ #define __TOXINE_MAIN_H__ #include #include #include #include #include #include #include typedef struct toxine_s toxine_t; #include "utils.h" #include "vo_plugin.h" #ifndef __GNUC__ #define __tox_func__ __func__ #else #define __tox_func__ __FUNCTION__ #endif #ifdef XINE_ORT #define _cfg_entry_t xine_config_entry_t #else #define _cfg_entry_t xine_cfg_entry_t #endif #define INFO_PREFIX " (I) " #define HELP_PREFIX " (?) " #define ECHO_PREFIX " (e) " #define ERROR_PREFIX " (!) " #define EMPTY_PREFIX " " #define PROMPT "toxine{%s}> " #define PLAYLIST_LOOP 0 #define PLAYLIST_MRL_LOOP 1 #define XINE_INIT 0x000000001 #define XINE_NEW 0x000000002 #define XINE_OPEN 0x000000004 #define XINE_STREAM 0x000000008 #define DUMP_XINE_STATE(x) \ do { \ if((x)->xine_state & XINE_INIT) pinfo("STATE & XINE_INIT\n"); \ else pinfo("! STATE & XINE_INIT\n"); \ if((x)->xine_state & XINE_INIT) pinfo("STATE & XINE_NEW\n"); \ else pinfo("! STATE & XINE_NEW\n"); \ if((x)->xine_state & XINE_INIT) pinfo("STATE & XINE_OPEN\n"); \ else pinfo("! STATE & XINE_OPEN\n"); \ if((x)->xine_state & XINE_INIT) pinfo("STATE & XINE_STREAM\n"); \ else pinfo("! STATE & XINE_STREAM\n"); \ } while(0) #define toxine_free(x) do { \ if((x)) { \ free((x)); \ x = NULL; \ } \ } while(0) #define poutalign() do { \ fprintf(stdout, "%s", EMPTY_PREFIX); \ fflush(stdout); \ } while(0) #define pout(FMT,ARGS...) do { \ fprintf(stdout, FMT, ##ARGS); \ fflush(stdout); \ } while(0) #define perr(FMT,ARGS...) do { \ fprintf(stdout, "%s", ERROR_PREFIX); \ fprintf(stdout, FMT, ##ARGS); \ fflush(stdout); \ } while(0) #define pinfo(FMT,ARGS...) do { \ fprintf(stdout, "%s", INFO_PREFIX); \ fprintf(stdout, FMT, ##ARGS); \ fflush(stdout); \ } while(0) #define phelp(FMT,ARGS...) do { \ fprintf(stdout, "%s", HELP_PREFIX); \ fprintf(stdout, FMT, ##ARGS); \ fflush(stdout); \ } while(0) #define pecho(FMT,ARGS...) do { \ fprintf(stdout, "%s", ECHO_PREFIX); \ fprintf(stdout, FMT, ##ARGS); \ fflush(stdout); \ } while(0) #define return_if_no_init(x) do { \ if(((x)->xine == NULL) || !((x)->xine_state & XINE_INIT)) { \ perr("%s(): xine engine uninitialized. Do it first.\n", \ __tox_func__); \ return; \ } \ } while(0) #define return_if_no_new(x) do { \ if(((x)->xine == NULL) || !((x)->xine_state & XINE_NEW)) { \ perr("%s(): xine instance not created. Do it first.\n", \ __tox_func__); \ return; \ } \ } while(0) #define return_if_no_open(x) do { \ if(((x)->xine == NULL) || !((x)->xine_state & XINE_OPEN)) { \ perr("%s(): mrl not opened. Do it first.\n", \ __tox_func__); \ return; \ } \ } while(0) #define return_if_no_stream(x) do { \ if(((x)->xine == NULL) || !((x)->xine_state & XINE_STREAM)) { \ perr("%s(): no stream created. Do it first.\n", \ __tox_func__); \ return; \ } \ } while(0) #ifndef NAME_MAX #define _NAME_MAX 256 #else #define _NAME_MAX NAME_MAX #endif #ifndef PATH_MAX #define _PATH_MAX 768 #else #define _PATH_MAX PATH_MAX #endif typedef struct { int xine_state; char *state; } prompt_state_t; typedef struct { char *ident; char *mrl; int start; /* 0..x (secs) */ int end; /* -1 == else (secs) */ } mediamark_t; struct toxine_s { xine_t *xine; xine_stream_t *stream; xine_event_queue_t *event_queue; int autoinit; int running; int display_events; char *last_result; char *configfile; uint32_t xine_state; /* bitfield, see XINE_* */ int ignore_finished; int msg_fd; int loop_mode; struct { xine_video_port_t *port; const char *name; int spu_channel; toxine_vo_plugin_t *plugins[TOXINE_VO_PLUGINS_MAX]; int plugins_num; toxine_vo_plugin_t *cur_plugin; toxine_vo_plugin_t *last_plugin; pthread_t loop_thread; int running; } video; struct { xine_audio_port_t *port; const char *name; int channel; struct { int enable; int caps; int volume_level; int mute; } mixer; } audio; struct { pthread_mutex_t mutex; xine_event_t last; } event; struct { int execute; char *remain; char *line; char *command; int num_args; char *args[256]; } command; char *current_mrl; struct { mediamark_t **mmk; int num; /* number of entries in playlist */ int cur; /* current entry in playlist */ int loop; pthread_t end_thread; int thread_num; } playlist; char prompt[32]; int interactive; struct { int in_use; char *filename; FILE *fd; char buf[256]; char *ln; } script; }; typedef struct commands_s commands_t; typedef void (*cmd_func_t)(commands_t *, toxine_t *, void *); struct commands_s { char *command; int argtype; cmd_func_t function; char *help; char *syntax; }; #endif