From 61d797672169a892c7b0d45e687fb9a76925c0cd Mon Sep 17 00:00:00 2001 From: arpi Date: Sun, 22 Dec 2002 21:01:01 +0000 Subject: XMMS Input plugin support based on patches by Balatoni Denes changes by me: glib dependency removed, files merged, code simplified, some bugfixes git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@8529 b3059339-0415-0410-9bf9-f77b7e298cf2 --- Makefile | 2 +- configure | 46 ++++++ libmpdemux/Makefile | 5 +- libmpdemux/demux_xmms.c | 336 +++++++++++++++++++++++++++++++++++++++++ libmpdemux/demux_xmms_plugin.h | 155 +++++++++++++++++++ libmpdemux/demuxer.c | 35 ++++- libmpdemux/demuxer.h | 1 + libmpdemux/open.c | 1 + 8 files changed, 578 insertions(+), 3 deletions(-) create mode 100644 libmpdemux/demux_xmms.c create mode 100644 libmpdemux/demux_xmms_plugin.h diff --git a/Makefile b/Makefile index 4a3163b66e..3224fe9f6a 100644 --- a/Makefile +++ b/Makefile @@ -35,7 +35,7 @@ OBJS_MPLAYER = $(SRCS_MPLAYER:.c=.o) VO_LIBS = $(AA_LIB) $(X_LIB) $(SDL_LIB) $(GGI_LIB) $(MP1E_LIB) $(MLIB_LIB) $(SVGA_LIB) $(DIRECTFB_LIB) $(GIF_LIB) AO_LIBS = $(ARTS_LIB) $(NAS_LIB) $(SGIAUDIO_LIB) -CODEC_LIBS = $(AV_LIB) $(FAME_LIB) $(MAD_LIB) $(VORBIS_LIB) $(FAAD_LIB) $(LIBLZO_LIB) $(XVID_LIB) $(DECORE_LIB) $(PNG_LIB) $(Z_LIB) $(JPEG_LIB) $(ALSA_LIB) +CODEC_LIBS = $(AV_LIB) $(FAME_LIB) $(MAD_LIB) $(VORBIS_LIB) $(FAAD_LIB) $(LIBLZO_LIB) $(XVID_LIB) $(DECORE_LIB) $(PNG_LIB) $(Z_LIB) $(JPEG_LIB) $(ALSA_LIB) $(XMMS_LIB) COMMON_LIBS = libmpcodecs/libmpcodecs.a mp3lib/libMP3.a liba52/liba52.a libmpeg2/libmpeg2.a $(W32_LIB) $(DS_LIB) libaf/libaf.a libmpdemux/libmpdemux.a input/libinput.a $(PP_LIB) postproc/libswscale.a linux/libosdep.a $(CSS_LIB) $(CODEC_LIBS) $(FREETYPE_LIB) $(TERMCAP_LIB) $(CDPARANOIA_LIB) $(STREAMING_LIB) $(WIN32_LIB) CFLAGS = $(OPTFLAGS) -Ilibmpdemux -Iloader -Ilibvo $(FREETYPE_INC) $(EXTRA_INC) $(CDPARANOIA_INC) $(SDL_INC) # -Wall diff --git a/configure b/configure index 449df6da92..925fc1d819 100755 --- a/configure +++ b/configure @@ -175,6 +175,7 @@ Codecs: --enable-faad build with FAAD2 (MP4/AAC) support [autodetect] --disable-libdv disable libdv 0.9.5 en/decoding support [autodetect] --disable-mad disable libmad (mpeg audio) support [autodetect] + --enable-xmms build with XMMS inputplugin support [disabled] Video output: --disable-vidix disable VIDIX stuff [enable on x86 *nix] @@ -268,6 +269,8 @@ Use these options if autodetection fails: --with-glib-config=PATH path to glib*-config (e.g. /opt/bin/glib-config) --with-dvdnav-config=PATH path to dvdnav-config --with-livelibdir=DIR path to LIVE.COM Streaming Media libraries + --with-xmmsplugindir=DIR path to xmms plugins + --with-xmmslibdir=DIR path to libxmms.so.1 EOF exit 0 @@ -976,6 +979,7 @@ _mad=auto _vorbis=auto _tremor=no _faad=auto +_xmms=no _css=auto _dvdnav=yes _dvdread=auto @@ -1116,6 +1120,7 @@ for ac_option do --disable-tremor) _tremor=no ;; --enable-faad) _faad=yes ;; --disable-faad) _faad=no ;; + --enable-xmms) _xmms=yes ;; --enable-css) _css=yes ;; --disable-css) _css=no ;; --enable-dvdread) _dvdread=yes ;; @@ -1259,6 +1264,14 @@ for ac_option do _mlib=yes ;; + --with-xmmslibdir=*) + _xmmslibdir=`echo $ac_option | cut -d '=' -f 2` + ;; + + --with-xmmsplugindir=*) + _xmmsplugindir=`echo $ac_option | cut -d '=' -f 2` + ;; + --disable-profile) _profile= ;; @@ -4346,6 +4359,33 @@ else fi echores "$_sortsub" + +echocheck "XMMS inputplugin support" +if test "$_xmms" = yes ; then + + if ( xmms-config --version ) >/dev/null 2>&1 ; then + if test -z "$_xmmsplugindir" ; then + _xmmsplugindir=`xmms-config --input-plugin-dir` + fi + if test -z "$_xmmslibdir" ; then + _xmmslibdir=`xmms-config --exec-prefix`/lib + fi + else + if test -z "$_xmmsplugindir" ; then + _xmmsplugindir=/usr/lib/xmms/Input + fi + if test -z "$_xmmslibdir" ; then + _xmmslibdir=/usr/lib + fi + fi + + _def_xmms='#define HAVE_XMMS 1' + _xmms_lib="${_xmmslibdir}/libxmms.so.1 -export-dynamic" +else + _def_xmms='#undef HAVE_XMMS' +fi +echores "$_xmms" + # --------------- GUI specific tests begin ------------------- echocheck "GUI" echo "$_gui" @@ -4695,6 +4735,8 @@ LIBLZO_LIB= $_ld_liblzo MAD_LIB = $_ld_mad VORBIS_LIB = $_ld_vorbis $_ld_libdv FAAD_LIB = $_ld_faad +XMMS_PLUGINS = $_xmms +XMMS_LIB = $_xmms_lib # --- Some stuff for autoconfigure ---- $_target_arch @@ -5101,6 +5143,10 @@ $_def_menu /* enables / disables subtitles sorting */ $_def_sortsub +/* XMMS input plugin support */ +$_def_xmms +#define XMMS_INPUT_PLUGIN_DIR "$_xmmsplugindir" + /* Extension defines */ $_def_3dnow // only define if you have 3DNOW (AMD k6-2, AMD Athlon, iDT WinChip, etc.) $_def_3dnowex // only define if you have 3DNOWEX (AMD Athlon, etc.) diff --git a/libmpdemux/Makefile b/libmpdemux/Makefile index 055a82a74b..1a45093a8c 100644 --- a/libmpdemux/Makefile +++ b/libmpdemux/Makefile @@ -4,6 +4,9 @@ LIBNAME = libmpdemux.a include ../config.mak SRCS = mp3_hdr.c video.c mpeg_hdr.c cache2.c asfheader.c aviheader.c aviprint.c aviwrite.c demux_asf.c demux_avi.c demux_mov.c parse_mp4.c demux_mpg.c demux_pva.c demux_viv.c demuxer.c dvdauth.c dvdnav_stream.c open.c parse_es.c stream.c tv.c tvi_dummy.c tvi_v4l.c tvi_bsdbt848.c frequencies.c demux_fli.c demux_real.c demux_y4m.c yuv4mpeg.c yuv4mpeg_ratio.c demux_nuv.c demux_film.c demux_roq.c mf.c demux_mf.c demux_audio.c demux_demuxers.c demux_ogg.c demux_bmp.c cdda.c demux_rawaudio.c cddb.c cdinfo.c demux_rawdv.c ai_alsa.c ai_oss.c audio_in.c demux_smjpeg.c +ifeq ($(XMMS_PLUGINS),yes) +SRCS += demux_xmms.c +endif ifeq ($(STREAMING),yes) SRCS += asf_streaming.c url.c http.c network.c asf_mmst_streaming.c ifeq ($(STREAMING_LIVE_DOT_COM),yes) @@ -20,7 +23,7 @@ endif OBJS = $(SRCS:.c=.o) OBJS += $(CPLUSPLUSSRCS:.cpp=.o) INCLUDE = -I../loader $(CSS_INC) $(EXTRA_INC) -CFLAGS = $(OPTFLAGS) $(INCLUDE) +CFLAGS = $(OPTFLAGS) $(INCLUDE) $(XMMS_CFLAGS) CPLUSPLUSFLAGS = $(CFLAGS) $(CPLUSPLUSINCLUDE) CPLUSPLUS = $(CC) diff --git a/libmpdemux/demux_xmms.c b/libmpdemux/demux_xmms.c new file mode 100644 index 0000000000..2a03a0be3c --- /dev/null +++ b/libmpdemux/demux_xmms.c @@ -0,0 +1,336 @@ +// This is not reentrant (because of global variables shared with demux_xmms_output.c) +// and the plugins are not reentrant either perhaps +#include "config.h" + +#include +#include +#include +#include +#include +#include +#include + +#include "../cfgparser.h" +#include "../libao2/afmt.h" +#include "stream.h" +#include "demuxer.h" +#include "stheader.h" + +#include +#include +#include +//#include + +#define XMMS_PACKETSIZE 65536 // some plugins won't play if this is too small + +#include "demux_xmms_plugin.h" +//#include "demux_xmms_pluginenum.h" +//#include "demux_xmms_input.h" + +//extern OutputPlugin xmms_output_plugin; + +static pthread_mutex_t xmms_mutex; +static int format = 0x1; // Raw PCM +static char xmms_audiobuffer[XMMS_PACKETSIZE]; +static uint32_t xmms_channels; +static uint32_t xmms_samplerate; +static uint32_t xmms_afmt; +static int xmms_length; +static char *xmms_title=NULL; +static uint32_t xmms_audiopos=0; + +static uint64_t written = 0; + +static void disk_close(void) {} +static void disk_flush(int time) {} +static void disk_pause(short p) {} +static void disk_init(void) {} + +static int disk_free(void) { // vqf plugin sends more than it should + return (XMMS_PACKETSIZE-xmms_audioposd_name)+4]; + void* handle; + sprintf(filename,XMMS_INPUT_PLUGIN_DIR "/%s",ent->d_name); + handle=dlopen(filename, RTLD_NOW); + if(handle){ + void *(*gpi) (void); + gpi=dlsym(handle, "get_iplugin_info"); + if(gpi){ + InputPlugin *p=gpi(); + printf("XMMS: found plugin: %s (%s)\n",ent->d_name,p->description); + p->handle = handle; + p->filename = strdup(filename); + p->get_vis_type = input_get_vis_type; + p->add_vis_pcm = input_add_vis_pcm; + p->set_info = input_set_info; + p->set_info_text = input_set_info_text; + if(p->init) p->init(); + input_plugins[no_plugins++]=p; + } else + dlclose(handle); + } + } + closedir(dir); +} + +static void cleanup_plugins(){ + while(no_plugins>0){ + --no_plugins; + printf("XMMS: Closing plugin %s\n",input_plugins[no_plugins]->filename); + if(input_plugins[no_plugins]->cleanup) + input_plugins[no_plugins]->cleanup(); + dlclose(input_plugins[no_plugins]->handle); + } +} + +extern void resync_audio_stream(sh_audio_t *sh_audio); + +int demux_xmms_open(demuxer_t* demuxer) { + InputPlugin* ip = NULL; + sh_audio_t* sh_audio; + WAVEFORMATEX* w; + xmms_priv_t *priv; + int i; + + init_plugins(); + for(i=0;iis_our_file(demuxer->stream->url)){ + ip=input_plugins[i]; break; + } + } + if(!ip) return 0; // no plugin to handle this... + + pthread_mutex_init(&xmms_mutex,NULL); + + priv=(xmms_priv_t *)malloc(sizeof(xmms_priv_t)); + memset(priv,0,sizeof(xmms_priv_t)); + priv->ip=ip; + + memset(xmms_audiobuffer,0,XMMS_PACKETSIZE); + + xmms_channels=0; + sh_audio = new_sh_audio(demuxer,0); + sh_audio->wf = w = (WAVEFORMATEX*)malloc(sizeof(WAVEFORMATEX)); + w->wFormatTag = sh_audio->format = format; + + demuxer->movi_start = 0; + demuxer->movi_end = 100; + demuxer->audio->id = 0; + demuxer->audio->sh = sh_audio; + demuxer->priv=priv; + sh_audio->ds = demuxer->audio; + + xmms_output_plugin.init(); + ip->get_song_info(demuxer->stream->url,&xmms_title,&xmms_length); + if (xmms_length<=0) demuxer->seekable=0; +// printf("XMMS song title='%s' length=%d\n",xmms_title,xmms_length); +// input_play(demuxer->stream->url); + ip->output = &xmms_output_plugin; + ip->play_file(demuxer->stream->url); + + mp_msg(MSGT_DEMUX,MSGL_INFO,"Waiting for the XMMS plugin to start playback of '%s'...\n",demuxer->stream->url); + while (xmms_channels==0) { + usleep(10000); + if(ip->get_time()<0) return 0; + } + sh_audio->sample_format= xmms_afmt; + switch (xmms_afmt) { + case AFMT_S16_LE: + case AFMT_S16_BE: + case AFMT_U16_LE: + case AFMT_U16_BE: + sh_audio->samplesize = 2; + break; + default: + sh_audio->samplesize = 1; + } + w->wBitsPerSample = sh_audio->samplesize*8; + w->nChannels = sh_audio->channels = xmms_channels; + w->nSamplesPerSec = sh_audio->samplerate = xmms_samplerate; + w->nAvgBytesPerSec = xmms_samplerate*sh_audio->channels*sh_audio->samplesize; + w->nBlockAlign = sh_audio->samplesize*sh_audio->channels; + w->cbSize = 0; + + return 1; +} + +int demux_xmms_fill_buffer(demuxer_t* demuxer, demux_stream_t *ds) { + sh_audio_t *sh_audio = demuxer->audio->sh; + xmms_priv_t *priv=demuxer->priv; + demux_packet_t* dp; + + while (xmms_audioposip->get_time()<0) return 0; + usleep(1000); + } + + pthread_mutex_lock(&xmms_mutex); + dp = new_demux_packet(XMMS_PACKETSIZE/2); + ds->pts = priv->spos / (float)(sh_audio->wf->nAvgBytesPerSec); + ds->pos = priv->spos; + priv->spos+=XMMS_PACKETSIZE/2; + memcpy(dp->buffer,xmms_audiobuffer,XMMS_PACKETSIZE/2); + memcpy(xmms_audiobuffer,&xmms_audiobuffer[XMMS_PACKETSIZE/2],xmms_audiopos-XMMS_PACKETSIZE/2); + xmms_audiopos-=XMMS_PACKETSIZE/2; + pthread_mutex_unlock(&xmms_mutex); + + ds_add_packet(ds,dp); + + return 1; +} + +void demux_xmms_seek(demuxer_t *demuxer,float rel_seek_secs,int flags){ + stream_t* s = demuxer->stream; + sh_audio_t* sh_audio = demuxer->audio->sh; + xmms_priv_t *priv=demuxer->priv; + float pos; + + if(priv->ip->get_time()<0) return; + + pos = (flags & 1) ? 0 : priv->spos / (float)(sh_audio->wf->nAvgBytesPerSec); + if (flags & 2) + pos+= rel_seek_secs*xmms_length; + else + pos+= rel_seek_secs; + + if (pos<0) pos=0; + if (pos>=xmms_length) pos=xmms_length-1; + + priv->ip->seek((pos<0)?0:(int)pos); + priv->spos=pos * (float)(sh_audio->wf->nAvgBytesPerSec);; +} + +int demux_close_xmms(demuxer_t* demuxer) { + xmms_priv_t *priv=demuxer->priv; + priv->ip->stop(); + free(priv); demuxer->priv=NULL; + cleanup_plugins(); + return 1; +} + +int demux_xmms_control(demuxer_t *demuxer,int cmd, void *arg){ + demux_stream_t *d_video=demuxer->video; + sh_audio_t *sh_audio=demuxer->audio->sh; + xmms_priv_t *priv=demuxer->priv; + + switch(cmd) { + case DEMUXER_CTRL_GET_TIME_LENGTH: + if (xmms_length<=0) return DEMUXER_CTRL_DONTKNOW; + *((unsigned long *)arg)=(unsigned long)xmms_length/1000; + return DEMUXER_CTRL_GUESS; + + case DEMUXER_CTRL_GET_PERCENT_POS: + if (xmms_length<=0) + return DEMUXER_CTRL_DONTKNOW; + *((int *)arg)=(int)( priv->spos / (float)(sh_audio->wf->nAvgBytesPerSec) / xmms_length ); + return DEMUXER_CTRL_OK; + + default: + return DEMUXER_CTRL_NOTIMPL; + } +} diff --git a/libmpdemux/demux_xmms_plugin.h b/libmpdemux/demux_xmms_plugin.h new file mode 100644 index 0000000000..dd3e7938e5 --- /dev/null +++ b/libmpdemux/demux_xmms_plugin.h @@ -0,0 +1,155 @@ +/* XMMS - Cross-platform multimedia player + * Copyright (C) 1998-2000 Peter Alm, Mikael Alm, Olle Hallnas, Thomas Nilsson and 4Front Technologies + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. 2. + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ +#ifndef PLUGIN_H +#define PLUGIN_H + +typedef enum +{ + FMT_U8, FMT_S8, FMT_U16_LE, FMT_U16_BE, FMT_U16_NE, FMT_S16_LE, FMT_S16_BE, FMT_S16_NE +} +AFormat; + +typedef struct +{ + void *handle; /* Filled in by xmms */ + char *filename; /* Filled in by xmms */ + char *description; /* The description that is shown in the preferences box */ + void (*init) (void); + void (*about) (void); /* Show the about box */ + void (*configure) (void); /* Show the configuration dialog */ + void (*get_volume) (int *l, int *r); + void (*set_volume) (int l, int r); /* Set the volume */ + int (*open_audio) (AFormat fmt, int rate, int nch); /* Open the device, if the device can't handle the given + parameters the plugin is responsible for downmixing + the data to the right format before outputting it */ + void (*write_audio) (void *ptr, int length); /* The input plugin calls this to write data to the output + buffer */ + void (*close_audio) (void); /* No comment... */ + void (*flush) (int time); /* Flush the buffer and set the plugins internal timers to time */ + void (*pause) (short paused); /* Pause or unpause the output */ + int (*buffer_free) (void); /* Return the amount of data that can be written to the buffer, + two calls to this without a call to write_audio should make + the plugin output audio directly */ + int (*buffer_playing) (void); /* Returns TRUE if the plugin currently is playing some audio, + otherwise return FALSE */ + int (*output_time) (void); /* Return the current playing time */ + int (*written_time) (void); /* Return the length of all the data that has been written to + the buffer */ +} +OutputPlugin; + +typedef struct +{ + void *handle; /* Filled in by xmms */ + char *filename; /* Filled in by xmms */ + char *description; /* The description that is shown in the preferences box */ + void (*init) (void); /* Called when the plugin is loaded */ + void (*cleanup) (void); /* Called when the plugin is unloaded */ + void (*about) (void); /* Show the about box */ + void (*configure) (void); /* Show the configure box */ + int (*mod_samples) (void *data, int length, AFormat fmt, int srate, int nch); /* Modify samples */ + void (*query_format) (AFormat *fmt,int *rate, int *nch); +} +EffectPlugin; + +typedef enum +{ + INPUT_VIS_ANALYZER, INPUT_VIS_SCOPE, INPUT_VIS_VU, INPUT_VIS_OFF +} +InputVisType; + +typedef struct +{ + void *handle; /* Filled in by xmms */ + char *filename; /* Filled in by xmms */ + char *description; /* The description that is shown in the preferences box */ + void (*init) (void); /* Called when the plugin is loaded */ + void (*about) (void); /* Show the about box */ + void (*configure) (void); + int (*is_our_file) (char *filename); /* Return 1 if the plugin can handle the file */ + void *(*scan_dir) (char *dirname); /* Look in Input/cdaudio/cdaudio.c to see how */ + /* to use this */ + void (*play_file) (char *filename); /* Guess what... */ + void (*stop) (void); /* Tricky one */ + void (*pause) (short paused); /* Pause or unpause */ + void (*seek) (int time); /* Seek to the specified time */ + void (*set_eq) (int on, float preamp, float *bands); /* Set the equalizer, most plugins won't be able to do this */ + int (*get_time) (void); /* Get the time, usually returns the output plugins output time */ + void (*get_volume) (int *l, int *r); /* Input-plugin specific volume functions, just provide a NULL if */ + void (*set_volume) (int l, int r); /* you want the output plugin to handle it */ + void (*cleanup) (void); /* Called when xmms exit */ + InputVisType (*get_vis_type) (void); /* OBSOLETE, DO NOT USE! */ + void (*add_vis_pcm) (int time, AFormat fmt, int nch, int length, void *ptr); /* Send data to the visualization plugins + Preferably 512 samples/block */ + void (*set_info) (char *title, int length, int rate, int freq, int nch); /* Fill in the stuff that is shown in the player window + set length to -1 if it's unknown. Filled in by xmms */ + void (*set_info_text) (char *text); /* Show some text in the song title box in the main window, + call it with NULL as argument to reset it to the song title. + Filled in by xmms */ + void (*get_song_info) (char *filename, char **title, int *length); /* Function to grab the title string */ + void (*file_info_box) (char *filename); /* Bring up an info window for the filename passed in */ + OutputPlugin *output; /* Handle to the current output plugin. Filled in by xmms */ +} +InputPlugin; + +/* So that input plugins can get the title formatting information */ +char *xmms_get_gentitle_format(void); + +/* So that output plugins can communicate with effect plugins */ +EffectPlugin *get_current_effect_plugin(void); +int effects_enabled(void); + +typedef struct +{ + void *handle; /* Filled in by xmms */ + char *filename; /* Filled in by xmms */ + int xmms_session; /* The session ID for attaching to the control socket */ + char *description; /* The description that is shown in the preferences box */ + void (*init) (void); /* Called when the plugin is enabled */ + void (*about) (void); /* Show the about box */ + void (*configure) (void); + void (*cleanup) (void); /* Called when the plugin is disabled or when xmms exits */ +} +GeneralPlugin; + +typedef struct _VisPlugin +{ + void *handle; /* Filled in by xmms */ + char *filename; /* Filled in by xmms */ + int xmms_session; /* The session ID for attaching to the control socket */ + char *description; /* The description that is shown in the preferences box */ + int num_pcm_chs_wanted; /* Numbers of PCM channels wanted in the call to render_pcm */ + int num_freq_chs_wanted; /* Numbers of freq channels wanted in the call to render_freq */ + void (*init)(void); /* Called when the plugin is enabled */ + void (*cleanup)(void); /* Called when the plugin is disabled */ + void (*about)(void); /* Show the about box */ + void (*configure)(void); /* Show the configure box */ + void (*disable_plugin)(struct _VisPlugin *); /* Call this with a pointer to your plugin to disable the plugin */ + void (*playback_start)(void); /* Called when playback starts */ + void (*playback_stop)(void); /* Called when playback stops */ + void (*render_pcm)(short pcm_data[2][512]); /* Render the PCM data, don't do anything time consuming in here */ + void (*render_freq)(short freq_data[2][256]); /* Render the freq data, don't do anything time consuming in here */ +} VisPlugin; + +#endif diff --git a/libmpdemux/demuxer.c b/libmpdemux/demuxer.c index 020571840c..0fc2780641 100644 --- a/libmpdemux/demuxer.c +++ b/libmpdemux/demuxer.c @@ -132,6 +132,7 @@ extern void demux_close_avi(demuxer_t *demuxer); extern void demux_close_rawdv(demuxer_t* demuxer); extern void demux_close_pva(demuxer_t* demuxer); extern void demux_close_smjpeg(demuxer_t* demuxer); +extern void demux_close_xmms(demuxer_t* demuxer); #ifdef USE_TV #include "tv.h" @@ -194,6 +195,11 @@ void free_demuxer(demuxer_t *demuxer){ case DEMUXER_TYPE_AVI_NI: case DEMUXER_TYPE_AVI_NINI: demux_close_avi(demuxer); return; +#ifdef HAVE_XMMS + case DEMUXER_TYPE_XMMS: + demux_close_xmms(demuxer); break; +#endif + } // free streams: for(i=0;i<256;i++){ @@ -269,6 +275,7 @@ int demux_rawdv_fill_buffer(demuxer_t *demuxer); int demux_y4m_fill_buffer(demuxer_t *demux); int demux_audio_fill_buffer(demux_stream_t *ds); int demux_pva_fill_buffer(demuxer_t *demux); +int demux_xmms_fill_buffer(demuxer_t *demux,demux_stream_t *ds); extern int demux_demuxers_fill_buffer(demuxer_t *demux,demux_stream_t *ds); extern int demux_ogg_fill_buffer(demuxer_t *d); @@ -303,6 +310,9 @@ int demux_fill_buffer(demuxer_t *demux,demux_stream_t *ds){ #endif case DEMUXER_TYPE_Y4M: return demux_y4m_fill_buffer(demux); case DEMUXER_TYPE_AUDIO: return demux_audio_fill_buffer(ds); +#ifdef HAVE_XMMS + case DEMUXER_TYPE_XMMS: return demux_xmms_fill_buffer(demux,ds); +#endif case DEMUXER_TYPE_DEMUXERS: return demux_demuxers_fill_buffer(demux,ds); #ifdef HAVE_OGGVORBIS case DEMUXER_TYPE_OGG: return demux_ogg_fill_buffer(demux); @@ -533,6 +543,7 @@ extern int demux_rawaudio_open(demuxer_t* demuxer); extern int smjpeg_check_file(demuxer_t *demuxer); extern int demux_open_smjpeg(demuxer_t* demuxer); extern int bmp_check_file(demuxer_t *demuxer); +extern int demux_xmms_open(demuxer_t* demuxer); extern demuxer_t* init_avi_with_ogg(demuxer_t* demuxer); @@ -850,6 +861,19 @@ if(file_format==DEMUXER_TYPE_UNKNOWN || file_format==DEMUXER_TYPE_AUDIO){ demuxer = NULL; } } +#ifdef HAVE_XMMS +//=============== Try to open as XMMS file: ================= +if(file_format==DEMUXER_TYPE_UNKNOWN){ + demuxer=new_demuxer(stream,DEMUXER_TYPE_XMMS,audio_id,video_id,dvdsub_id); + if(demux_xmms_open(demuxer)){ + mp_msg(MSGT_DEMUXER,MSGL_INFO,MSGTR_DetectedAudiofile); + file_format=DEMUXER_TYPE_XMMS; + } else { + free_demuxer(demuxer); + demuxer = NULL; + } +} +#endif //=============== Try to open as a RTP stream: =========== if(file_format==DEMUXER_TYPE_RTP) { demuxer=new_demuxer(stream,DEMUXER_TYPE_RTP,audio_id,video_id,dvdsub_id); @@ -1107,6 +1131,7 @@ extern void demux_audio_seek(demuxer_t *demuxer,float rel_seek_secs,int flags); extern void demux_demuxers_seek(demuxer_t *demuxer,float rel_seek_secs,int flags); extern void demux_ogg_seek(demuxer_t *demuxer,float rel_seek_secs,int flags); extern void demux_rawaudio_seek(demuxer_t *demuxer,float rel_seek_secs,int flags); +extern void demux_xmms_seek(demuxer_t *demuxer,float rel_seek_secs,int flags); int demux_seek(demuxer_t *demuxer,float rel_seek_secs,int flags){ demux_stream_t *d_audio=demuxer->audio; @@ -1188,6 +1213,10 @@ switch(demuxer->file_format){ #endif case DEMUXER_TYPE_RAWAUDIO: demux_rawaudio_seek(demuxer,rel_seek_secs,flags); break; +#ifdef HAVE_XMMS + case DEMUXER_TYPE_XMMS: + demux_xmms_seek(demuxer,rel_seek_secs,flags); break; +#endif } // switch(demuxer->file_format) @@ -1248,6 +1277,7 @@ char* demux_info_get(demuxer_t *demuxer, char *opt) { extern int demux_mpg_control(demuxer_t *demuxer, int cmd, void *arg); extern int demux_asf_control(demuxer_t *demuxer, int cmd, void *arg); extern int demux_avi_control(demuxer_t *demuxer, int cmd, void *arg); +extern int demux_xmms_control(demuxer_t *demuxer, int cmd, void *arg); int demux_control(demuxer_t *demuxer, int cmd, void *arg) { switch(demuxer->type) { @@ -1260,7 +1290,10 @@ int demux_control(demuxer_t *demuxer, int cmd, void *arg) { case DEMUXER_TYPE_AVI_NI: case DEMUXER_TYPE_AVI_NINI: return demux_avi_control(demuxer,cmd,arg); - +#ifdef HAVE_XMMS + case DEMUXER_TYPE_XMMS: + return demux_xmms_control(demuxer,cmd,arg); +#endif default: return DEMUXER_CTRL_NOTIMPL; } diff --git a/libmpdemux/demuxer.h b/libmpdemux/demuxer.h index 699843c7bb..a1489b896a 100644 --- a/libmpdemux/demuxer.h +++ b/libmpdemux/demuxer.h @@ -33,6 +33,7 @@ #define DEMUXER_TYPE_RAWDV 22 #define DEMUXER_TYPE_PVA 23 #define DEMUXER_TYPE_SMJPEG 24 +#define DEMUXER_TYPE_XMMS 25 // This should always match the higest demuxer type number. // Unless you want to disallow users to force the demuxer to some types diff --git a/libmpdemux/open.c b/libmpdemux/open.c index 72bf95543d..4bb1835a23 100644 --- a/libmpdemux/open.c +++ b/libmpdemux/open.c @@ -526,6 +526,7 @@ if(dvd_title){ stream=new_stream(f,STREAMTYPE_FILE); stream->end_pos=len; + stream->url=filename?strdup(filename):NULL; return stream; } -- cgit v1.2.3