summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/libmpeg2/decode.c4
-rw-r--r--src/xine-engine/Makefile.am17
-rw-r--r--src/xine-engine/audio_decoder.h66
-rw-r--r--src/xine-engine/video_decoder.c160
-rw-r--r--src/xine-engine/video_decoder.h73
-rw-r--r--src/xine-engine/xine.c49
-rw-r--r--src/xine-engine/xine_internal.h108
7 files changed, 179 insertions, 298 deletions
diff --git a/src/libmpeg2/decode.c b/src/libmpeg2/decode.c
index e8c22551b..010eed0f5 100644
--- a/src/libmpeg2/decode.c
+++ b/src/libmpeg2/decode.c
@@ -28,9 +28,7 @@
/* Xine specific */
#include "buffer.h"
-#include "video_decoder.h"
-/* */
-
+#include "xine_internal.h"
#include "video_out.h"
#include "mpeg2.h"
diff --git a/src/xine-engine/Makefile.am b/src/xine-engine/Makefile.am
index 8608b16b5..c253a8ff6 100644
--- a/src/xine-engine/Makefile.am
+++ b/src/xine-engine/Makefile.am
@@ -9,7 +9,7 @@ lib_LTLIBRARIES = libxine.la
##libxine_la_SOURCES = xine.c buffer.c metronom.c configfile.c \
## monitor.c utils.c audio_decoder.c video_decoder.c load_plugins.c
libxine_la_SOURCES = metronom.c configfile.c monitor.c utils.c cpu_accel.c \
- load_plugins.c
+ load_plugins.c video_decoder.c audio_decoder.c
libxine_la_DEPENDENCIES = libsdeps
libxine_la_LIBADD = \
$(top_srcdir)/src/libmpeg2/libmpeg2.la \
@@ -18,16 +18,17 @@ libxine_la_LIBADD = \
## $(top_srcdir)/src/libspudec/libspudec.la \
$(THREAD_LIBS) \
$(DYNAMIC_LD_LIBS)
- -lXext -lm
+ -lm
libxine_la_LDFLAGS = -version-info 5:0:5
-include_HEADERS = buffer.h metronom.h configfile.h \
- monitor.h cpu_accel.h attributes.h utils.h audio_decoder.h \
- video_decoder.h
-noinst_HEADERS = xine_internal.h
+#include_HEADERS = buffer.h metronom.h configfile.h \
+# monitor.h cpu_accel.h attributes.h utils.h audio_decoder.h
-cpu_accel.lo:
- $(CC) -DHAVE_CONFIG_H $(INCLUDES) -pipe `echo "@DEBUG_CFLAGS@" | sed -e 's/\-DDEBUG//' -e 's/\-g//'` -fomit-frame-pointer -Wall -Wp,-MD,.deps/cpu_accel.P -c $(basename $@).c -o $@
+noinst_HEADERS = xine_internal.h buffer.h metronom.h configfile.h \
+ monitor.h cpu_accel.h attributes.h utils.h audio_decoder.h
+
+#cpu_accel.lo:
+# $(CC) -DHAVE_CONFIG_H $(INCLUDES) -pipe `echo "@DEBUG_CFLAGS@" | sed -e 's/\-DDEBUG//' -e 's/\-g//'` -fomit-frame-pointer -Wall -Wp,-MD,.deps/cpu_accel.P -c $(basename $@).c -o $@
# echo timestamp > $(basename $@).o
diff --git a/src/xine-engine/audio_decoder.h b/src/xine-engine/audio_decoder.h
deleted file mode 100644
index b7d6e4243..000000000
--- a/src/xine-engine/audio_decoder.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (C) 2000-2001 the xine project
- *
- * This file is part of xine, a unix video player.
- *
- * xine 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.
- *
- * xine 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
- *
- * $Id: audio_decoder.h,v 1.1 2001/04/18 22:36:05 f1rmb Exp $
- *
- *
- * functions that implement audio decoding
- */
-
-#ifndef HAVE_VIDEO_DECODER_H
-#define VIDEO_DECODER_H
-
-#include "buffer.h"
-
-/*
- * generic xine audio decoder plugin interface
- */
-
-typedef struct audio_decoder_s
-{
-
- /* get interface version */
- int (*get_version) (void);
-
- int (*can_handle) (int buf_type);
-
- void (*init) (ao_instance_t *audio_out);
-
- void (*decode_data) (buf_element_t *buf);
-
- void (*close) (void);
-
-} audio_decoder_t;
-
-/*
- * init audio decoders, allocate audio fifo,
- * start audio decoder thread
- */
-
-fifo_buffer_t *audio_decoder_init (ao_instance_t *audio_out,
- pthread_mutex_t xine_lock) ;
-
-/*
- * quit audio thread
- */
-
-void audio_decoder_shutdown ();
-
-
-#endif
diff --git a/src/xine-engine/video_decoder.c b/src/xine-engine/video_decoder.c
index d7d69f846..e668942de 100644
--- a/src/xine-engine/video_decoder.c
+++ b/src/xine-engine/video_decoder.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: video_decoder.c,v 1.2 2001/04/19 09:46:57 f1rmb Exp $
+ * $Id: video_decoder.c,v 1.3 2001/04/22 00:31:44 guenter Exp $
*
*/
@@ -26,154 +26,118 @@
#endif
#include "xine_internal.h"
-#include "video_out/video_out.h"
-#include "video_decoder.h"
-#define MAX_NUM_DECODERS 10
+void *video_decoder_loop (void *this_gen) {
-typedef struct vd_globals_s {
+ buf_element_t *buf;
+ xine_t *this = (xine_t *) this_gen;
+ int running = 1;
+ video_decoder_t *decoder;
- pthread_t mVideoThread;
+ while (running) {
- fifo_buffer_t *mBufVideo;
+ buf = this->video_fifo->get (this->video_fifo);
- video_decoder_t *mDecoders[MAX_NUM_DECODERS];
- video_decoder_t *mCurDecoder;
+ /* gVD.mnCurInputPos = pBuf->nInputPos; */
- uint32_t mnCurInputPos;
-
- vo_instance_t *mVideoOut;
-
- gui_status_callback_func_t gui_status_callback;
-
- int mbStreamFinished;
-
- pthread_mutex_t mXineLock;
-
-} vd_globals_t;
-
-static vd_globals_t gVD;
-
-void *video_decoder_loop () {
-
- buf_element_t *pBuf;
- int bRunning = 1;
-
- while (bRunning) {
-
- pBuf = gVD.mBufVideo->fifo_buffer_get (gVD.mBufVideo);
-
- gVD.mnCurInputPos = pBuf->nInputPos;
-
- switch (pBuf->nType) {
- case BUF_STREAMSTART:
- if (gVD.mCurDecoder) {
- gVD.mCurDecoder->close ();
- gVD.mCurDecoder = NULL;
+ switch (buf->type) {
+ case BUF_CONTROL_START:
+ if (this->video_cur_decoder) {
+ this->video_cur_decoder->close ();
+ this->video_cur_decoder = NULL;
}
- pthread_mutex_lock (&gVD.mXineLock);
- gVD.mbStreamFinished = 0;
- pthread_mutex_unlock (&gVD.mXineLock);
+ pthread_mutex_lock (&this->xine_lock);
+ this->video_finished = 0;
+ pthread_mutex_unlock (&this->xine_lock);
break;
- case BUF_MPEGVIDEO:
- case BUF_AVIVIDEO:
+ case BUF_VIDEO_MPEG:
+ case BUF_VIDEO_AVI:
- decoder = gVD.mDecoders [pBuf->nType];
+ decoder = this->video_decoders [(buf->type>>16) & 0xFF];
if (decoder) {
- if (gVD.mCurDecoder != decoder) {
+ if (this->video_cur_decoder != decoder) {
- if (gVD.mCurDecoder)
- gVD.mCurDecoder->close ();
+ if (this->video_cur_decoder)
+ this->video_cur_decoder->close ();
- gVD.mCurDecoder = decoder;
- gVD.mCurDecoder->init (gVD.mVideoOut);
+ this->video_cur_decoder = decoder;
+ this->video_cur_decoder->init (this->video_out);
}
- decoder->decode_data (pBuf);
+ decoder->decode_data (buf);
}
break;
- case BUF_STREAMEND:
- if (gVD.mCurDecoder) {
- gVD.mCurDecoder->close ();
- gVD.mCurDecoder = NULL;
+ case BUF_CONTROL_END:
+ if (this->video_cur_decoder) {
+ this->video_cur_decoder->close ();
+ this->video_cur_decoder = NULL;
}
- gVD.mbStreamFinished = 1;
-
- pthread_mutex_lock (&gVD.mXineLock);
+ pthread_mutex_lock (&this->xine_lock);
- gVD.mbVideoFinished = 1;
+ this->video_finished = 1;
- if (audio_decoder_is_stream_finished ()) {
- pthread_mutex_unlock (&gVD.mXineLock);
- xine_notify_stream_finished ();
+ if (this->audio_finished) {
+ pthread_mutex_unlock (&this->xine_lock);
+ xine_notify_stream_finished (this);
} else
- pthread_mutex_unlock (&gVD.mXineLock);
+ pthread_mutex_unlock (&this->xine_lock);
break;
- case BUF_QUIT:
- if (gVD.mCurDecoder) {
- gVD.mCurDecoder->close ();
- gVD.mCurDecoder = NULL;
+ case BUF_CONTROL_QUIT:
+ if (this->video_cur_decoder) {
+ this->video_cur_decoder->close ();
+ this->video_cur_decoder = NULL;
}
- bRunning = 0;
+ running = 0;
break;
}
- pBuf->free_buffer (pBuf);
+ buf->free_buffer (buf);
}
return NULL;
}
-int video_decoder_is_stream_finished () {
- return gVD.mbStreamFinished ;
-}
+void video_decoder_init (xine_t *this) {
-uint32_t video_decoder_get_pos () {
- return gVD.mnCurPos;
-}
+ int i;
+
+ this->video_cur_decoder = NULL;
+ for (i=0; i<DECODER_PLUGIN_MAX; i++)
+ this->video_decoders[i] = NULL;
-fifo_buffer_t *video_decoder_init (vo_instance_t *video_out,
- pthread_mutex_t xine_lock) {
+ /* FIXME: load video decoder plugins
+ this->video_decoders[0x00] = init_video_decoder_mpeg2dec ();
+ this->video_decoders[0x03] = init_video_decoder_avi ();
+ */
- gVD.mVideoOut = video_out;
- gVD.mXineLock = xine_lock;
+ this->video_fifo = fifo_buffer_new ();
- gVD.mCurDecoder = NULL;
- for (i=0; i<MAX_NUM_DECODERS; i++)
- gVD.mDecoders[i] = NULL;
-
- gVD.mDecoders[BUF_MPEGVIDEO] = init_video_decoder_mpeg2dec ();
- gVD.mDecoders[BUF_AVIVIDEO] = init_video_decoder_avi ();
-
- gVD.mBufVideo = fifo_buffer_new ();
-
- pthread_create (&gVD.mVideoThread, NULL, video_decoder_loop, NULL) ;
+ pthread_create (&this->video_thread, NULL, video_decoder_loop, this) ;
printf ("video_decoder_init: video thread created\n");
-
- return gVD.mBufVideo;
}
-void video_decoder_shutdown () {
+void video_decoder_shutdown (xine_t *this) {
- buf_element_t *pBuf;
+ buf_element_t *buf;
+ void *p;
- gVD.mBufVideo->fifo_buffer_clear(gVD.mBufVideo);
+ this->video_fifo->clear(this->video_fifo);
- pBuf = gVD.mBufVideo->buffer_pool_alloc ();
- pBuf->nType = BUF_QUIT;
- gVD.mBufVideo->fifo_buffer_put (gVD.mBufVideo, pBuf);
+ buf = this->video_fifo->buffer_pool_alloc ();
+ buf->type = BUF_CONTROL_QUIT;
+ this->video_fifo->put (this->video_fifo, buf);
- pthread_join (gVD.mVideoThread, &p);
+ pthread_join (this->video_thread, &p);
}
diff --git a/src/xine-engine/video_decoder.h b/src/xine-engine/video_decoder.h
deleted file mode 100644
index ee9abfe33..000000000
--- a/src/xine-engine/video_decoder.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (C) 2000-2001 the xine project
- *
- * This file is part of xine, a unix video player.
- *
- * xine 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.
- *
- * xine 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
- *
- * $Id: video_decoder.h,v 1.1 2001/04/18 22:36:09 f1rmb Exp $
- *
- *
- * functions that implement video decoding
- */
-
-#ifndef HAVE_VIDEO_DECODER_H
-#define VIDEO_DECODER_H
-
-#include <pthread.h>
-#include "buffer.h"
-#include "video_out.h"
-
-/*
- * generic xine video decoder plugin interface
- */
-
-typedef struct video_decoder_s
-{
-
- /* get interface version */
- int (*get_version) (void);
-
- int (*can_handle) (int buf_type);
-
- void (*init) (vo_instance_t *video_out);
-
- void (*decode_data) (buf_element_t *buf);
-
- void (*release_img_buffers) (void);
-
- void (*close) (void);
-
-} video_decoder_t;
-
-/*
- * init video decoders, allocate video fifo,
- * start video decoder thread
- */
-
-fifo_buffer_t *video_decoder_init (vo_instance_t *video_out,
- pthread_mutex_t xine_lock) ;
-
-/*
- * quit video thread
- */
-
-void video_decoder_shutdown ();
-
-uint32_t video_decoder_get_pos ();
-
-int video_decoder_is_stream_finished ();
-
-#endif
diff --git a/src/xine-engine/xine.c b/src/xine-engine/xine.c
index 17cec6014..6e6b25496 100644
--- a/src/xine-engine/xine.c
+++ b/src/xine-engine/xine.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: xine.c,v 1.3 2001/04/21 00:14:41 f1rmb Exp $
+ * $Id: xine.c,v 1.4 2001/04/22 00:31:44 guenter Exp $
*
* top-level xine functions
*
@@ -54,7 +54,6 @@
#include "metronom.h"
#include "configfile.h"
#include "monitor.h"
-#include "video_decoder.h"
#include "audio_decoder.h"
/* debugging purposes only */
@@ -82,35 +81,6 @@ void xine_notify_stream_finished (xine_t *this) {
/*
*
*/
-void *xine_spu_loop (xine_t *this, void *dummy) {
-
- buf_element_t *pBuf;
- int bRunning = 1;
-
- while (bRunning) {
-
- pBuf = this->fifo_funcs->fifo_buffer_get (this->spu_fifo);
-
- switch (pBuf->nType) {
- case BUF_QUIT:
- bRunning = 0;
- break;
- case BUF_RESET:
- spudec_reset ();
- break;
- case BUF_SPU:
- spudec_decode(pBuf->pContent, pBuf->nSize, pBuf->nPTS);
- break;
- }
- this->fifo_funcs->buffer_pool_free (pBuf);
- }
-
- return NULL;
-}
-
-/*
- *
- */
void xine_stop (xine_t *this) {
pthread_mutex_lock (&this->xine_lock);
@@ -468,8 +438,7 @@ xine_t *xine_init (vo_instance_t *vo,
* Init buffers
*/
- this->fifo_funcs = buffer_pool_init (2000, 4096);
- this->spu_fifo = this->fifo_funcs->fifo_buffer_new ();
+ buffer_pool_init (2000, 4096);
/*
* init demuxer
@@ -487,24 +456,16 @@ xine_t *xine_init (vo_instance_t *vo,
* init and start decoder threads
*/
- this->mBufVideo = video_decoder_init (vo);
-
+ video_decoder_init (this);
this->mBufAudio = audio_decoder_init (ao);
/*
- * init SPU decoder, start SPU thread
+ * init SPU decoder
*/
+ this->spu_fifo = fifo_buffer_new ();
spudec_init(NULL);
- if((err = pthread_create (&this->spu_thread, NULL,
- xine_spu_loop, NULL)) != 0) {
- fprintf(stderr, "pthread_create failed: return code %d.\n", err);
- exit(1);
- }
- else
- printf ("xine_init: SPU thread created\n");
-
/*
* load input plugins
*/
diff --git a/src/xine-engine/xine_internal.h b/src/xine-engine/xine_internal.h
index 6df6a99e8..b02948bb0 100644
--- a/src/xine-engine/xine_internal.h
+++ b/src/xine-engine/xine_internal.h
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: xine_internal.h,v 1.4 2001/04/21 00:14:41 f1rmb Exp $
+ * $Id: xine_internal.h,v 1.5 2001/04/22 00:31:44 guenter Exp $
*
*/
@@ -33,14 +33,62 @@
#define INPUT_PLUGIN_MAX 50
#define DEMUXER_PLUGIN_MAX 50
+#define DECODER_PLUGIN_MAX 50
#define CODEC_PLUGIN_IFACE_VERSION 1
#define CODEC_PLUGIN_MAX 50
#define AUDIO_OUT_PLUGIN_IFACE_VERSION 1
#define AUDIO_OUT_PLUGIN_MAX 50
-#define VIDEO_OUT_PLUGIN_IFACE_VERSIO 1
+#define VIDEO_OUT_PLUGIN_IFACE_VERSION 1
#define VIDEO_OUT_PLUGIN_MAX 50
-/* nStatus : current xine status */
+
+/*
+ * generic xine video decoder plugin interface
+ */
+
+typedef struct video_decoder_s video_decoder_t;
+
+struct video_decoder_s {
+
+ int interface_version;
+
+ int (*can_handle) (video_decoder_t *this, int buf_type);
+
+ void (*init) (video_decoder_t *this, vo_instance_t *video_out);
+
+ void (*decode_data) (video_decoder_t *this, buf_element_t *buf);
+
+ void (*release_img_buffers) (video_decoder_t *this);
+
+ void (*close) (void);
+
+};
+
+/*
+ * generic xine audio decoder plugin interface
+ */
+
+typedef struct audio_decoder_s audio_decoder_t;
+
+struct audio_decoder_s {
+
+ int interface_version;
+
+ int (*can_handle) (audio_decoder_t *this, int buf_type);
+
+ void (*init) (audio_decoder_t *this, ao_functions_t *audio_out);
+
+ void (*decode_data) (audio_decoder_t *this, buf_element_t *buf);
+
+ void (*close) (audio_decoder_t *this);
+
+};
+
+/*
+ * gui callback function - called by xine engine on stream end
+ *
+ * nStatus : current xine status
+ */
typedef void (*gui_status_callback_func_t)(int nStatus);
/*
@@ -76,7 +124,16 @@ typedef struct xine_s {
int audio_channel;
int spu_channel;
- gui_status_callback_func_t status_callback;
+ vo_instance_t *video_out;
+ fifo_buffer_t *video_fifo;
+ pthread_t video_thread;
+ video_decoder_t *video_decoders[DECODER_PLUGIN_MAX];
+ video_decoder_t *video_cur_decoder;
+ int video_finished;
+
+ int audio_finished;
+
+ gui_status_callback_func_t gui_status_callback;
/* Lock for xine player functions */
pthread_mutex_t xine_lock;
@@ -208,6 +265,42 @@ char **xine_get_autoplay_input_plugin_ids (xine_t *this) ;
*/
char **xine_get_autoplay_mrls (xine_t *this, char *plugin_id);
+/*
+ * internal use only
+ */
+
+void xine_notify_stream_finished (xine_t *this);
+
+/*
+ * video decoder stuff
+ */
+
+/*
+ * init video decoders, allocate video fifo,
+ * start video decoder thread
+ */
+
+void video_decoder_init (xine_t *this);
+
+/*
+ * quit video thread
+ */
+
+void video_decoder_shutdown (xine_t *this);
+
+/*
+ * init audio decoders, allocate audio fifo,
+ * start audio decoder thread
+ */
+
+void audio_decoder_init (xine_t *this);
+
+/*
+ * quit audio thread
+ */
+
+void audio_decoder_shutdown (xine_t *this);
+
/*
* Load input/demux/audio_out/video_out plugins
@@ -225,8 +318,11 @@ char **xine_get_autoplay_mrls (xine_t *this, char *plugin_id);
#define XINE_AUDIO_OUT_PLUGIN_PREFIXNAME "xineplug_ao_out_"
#define XINE_AUDIO_OUT_PLUGIN_PREFIXNAME_LENGTH 16
-#define XINE_CODEC_PLUGIN_PREFIXNAME "xineplug_codec_"
-#define XINE_CODEC_PLUGIN_PREFIXNAME_LENGTH 15
+#define XINE_AUDIO_DECODER_PLUGIN_PREFIXNAME "xineplug_ao_dec_"
+#define XINE_AUDIO_DECODER_PLUGIN_PREFIXNAME_LENGTH 16
+
+#define XINE_VIDEO_DECODER_PLUGIN_PREFIXNAME "xineplug_vo_dec_"
+#define XINE_VIDEO_DECODER_PLUGIN_PREFIXNAME_LENGTH 16
/* prototypes of load_plugins.c functions. */
void load_demux_plugins (xine_t *this,