summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Melanson <mike@multimedia.cx>2002-07-07 01:24:40 +0000
committerMike Melanson <mike@multimedia.cx>2002-07-07 01:24:40 +0000
commit30b0d0c267b5f91b10c54146aff86208a04f6962 (patch)
treebb9e5ade018510117080c43c6936cad5751eef9e
parent4bd4bf63abc9fb679c7f84bf83ae5275561ed09c (diff)
downloadxine-lib-30b0d0c267b5f91b10c54146aff86208a04f6962.tar.gz
xine-lib-30b0d0c267b5f91b10c54146aff86208a04f6962.tar.bz2
initial commit for WAV, SMJPEG, FLI, and Id CIN file demuxers
CVS patchset: 2225 CVS date: 2002/07/07 01:24:40
-rw-r--r--AUTHORS4
-rw-r--r--ChangeLog4
-rw-r--r--src/demuxers/Makefile.am20
-rw-r--r--src/demuxers/demux_fli.c461
-rw-r--r--src/demuxers/demux_idcin.c437
-rw-r--r--src/demuxers/demux_smjpeg.c563
-rw-r--r--src/demuxers/demux_wav.c500
7 files changed, 1986 insertions, 3 deletions
diff --git a/AUTHORS b/AUTHORS
index 4a956236a..7952af635 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -230,8 +230,8 @@ Contributions
C version for linear blend deinterlacer
Mike Melanson <melanson@pcisys.net>
- QT, FILM and RoQ file demuxers, RoQ audio decoder, various ADPCM
- audio decoders
+ QT, FILM, RoQ, WAV, FLI, SMJPEG, and Id CIN file demuxers, RoQ audio
+ decoder, various ADPCM audio decoders
Tim Ferguson <timf@mail.csse.monash.edu.au>
CYUV and RoQ video decoders
diff --git a/ChangeLog b/ChangeLog
index 3b009df5d..86ffb1908 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,10 @@ xine-lib (0.9.13) unstable; urgency=low
* native wmv7 decoder using ffmpeg
* enable ffmpeg's native msmpeg4 v1/v2 decoder
* correct highlight placement for anamorphic and pan&scan menus with DXR3
+ * WAV file demuxer
+ * FLI file demuxer
+ * SMJPEG file demuxer
+ * Id CIN file demuxer
xine-lib (0.9.12) unstable; urgency=low
diff --git a/src/demuxers/Makefile.am b/src/demuxers/Makefile.am
index c25e97d09..4be5299a5 100644
--- a/src/demuxers/Makefile.am
+++ b/src/demuxers/Makefile.am
@@ -27,7 +27,9 @@ lib_LTLIBRARIES = $(ogg_module) $(qt_modules) $(asf_module) xineplug_dmx_avi.la
xineplug_dmx_mpeg_elem.la xineplug_dmx_mpeg_audio.la \
xineplug_dmx_mpeg_pes.la xineplug_dmx_mpeg_ts.la \
xineplug_dmx_cda.la xineplug_dmx_film.la \
- xineplug_dmx_roq.la
+ xineplug_dmx_roq.la xineplug_dmx_fli.la \
+ xineplug_dmx_smjpeg.la xineplug_dmx_wav.la \
+ xineplug_dmx_idcin.la
xineplug_dmx_ogg_la_SOURCES = demux_ogg.c
xineplug_dmx_ogg_la_LIBADD = $(OGG_LIBS) \
@@ -82,6 +84,22 @@ xineplug_dmx_roq_la_SOURCES = demux_roq.c
xineplug_dmx_roq_la_LIBADD = $(top_builddir)/src/xine-engine/libxine.la
xineplug_dmx_roq_la_LDFLAGS = -avoid-version -module
+xineplug_dmx_fli_la_SOURCES = demux_fli.c
+xineplug_dmx_fli_la_LIBADD = $(top_builddir)/src/xine-engine/libxine.la
+xineplug_dmx_fli_la_LDFLAGS = -avoid-version -module
+
+xineplug_dmx_smjpeg_la_SOURCES = demux_smjpeg.c
+xineplug_dmx_smjpeg_la_LIBADD = $(top_builddir)/src/xine-engine/libxine.la
+xineplug_dmx_smjpeg_la_LDFLAGS = -avoid-version -module
+
+xineplug_dmx_wav_la_SOURCES = demux_wav.c
+xineplug_dmx_wav_la_LIBADD = $(top_builddir)/src/xine-engine/libxine.la
+xineplug_dmx_wav_la_LDFLAGS = -avoid-version -module
+
+xineplug_dmx_idcin_la_SOURCES = demux_idcin.c
+xineplug_dmx_idcin_la_LIBADD = $(top_builddir)/src/xine-engine/libxine.la
+xineplug_dmx_idcin_la_LDFLAGS = -avoid-version -module
+
include_HEADERS = demux.h
##
diff --git a/src/demuxers/demux_fli.c b/src/demuxers/demux_fli.c
new file mode 100644
index 000000000..ffc6f11e8
--- /dev/null
+++ b/src/demuxers/demux_fli.c
@@ -0,0 +1,461 @@
+/*
+ * Copyright (C) 2000-2002 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
+ *
+ * FLI File Demuxer by Mike Melanson (melanson@pcisys.net)
+ * For information on the FLI format, as well as various traps to
+ * avoid while programming a FLI decoder, visit:
+ * http://www.pcisys.net/~melanson/codecs/
+ *
+ * $Id: demux_fli.c,v 1.1 2002/07/07 01:24:40 tmmm Exp $
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <pthread.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include "xine_internal.h"
+#include "xineutils.h"
+#include "compat.h"
+#include "demux.h"
+#include "bswap.h"
+
+#define LE_16(x) (le2me_16(*(unsigned short *)(x)))
+#define LE_32(x) (le2me_32(*(unsigned int *)(x)))
+
+#define VALID_ENDS "fli,flc"
+
+#define FLI_HEADER_SIZE 128
+#define FLI_FILE_MAGIC_1 0xAF11
+#define FLI_FILE_MAGIC_2 0xAF12
+#define FLI_CHUNK_MAGIC_1 0xF1FA
+#define FLI_CHUNK_MAGIC_2 0xF5FA
+
+typedef struct {
+
+ demux_plugin_t demux_plugin;
+
+ xine_t *xine;
+
+ config_values_t *config;
+
+ fifo_buffer_t *video_fifo;
+ fifo_buffer_t *audio_fifo;
+
+ input_plugin_t *input;
+
+ pthread_t thread;
+ int thread_running;
+ pthread_mutex_t mutex;
+ int send_end_buffers;
+
+ off_t start;
+ int status;
+
+ /* video information */
+ unsigned int width;
+ unsigned int height;
+
+ /* playback info */
+ unsigned int magic_number;
+ unsigned int speed;
+ unsigned int frame_pts_inc;
+ unsigned int frame_count;
+} demux_fli_t;
+
+static void *demux_fli_loop (void *this_gen) {
+
+ demux_fli_t *this = (demux_fli_t *) this_gen;
+ buf_element_t *buf = NULL;
+ int i = 0;
+ unsigned char fli_buf[6];
+ unsigned int chunk_size;
+ unsigned int chunk_magic;
+ int64_t pts_counter = 0;
+ off_t current_file_pos;
+
+ /* make sure to start just after the header */
+ this->input->seek(this->input, FLI_HEADER_SIZE, SEEK_SET);
+
+ /* do-while needed to seek after demux finished */
+ do {
+ /* main demuxer loop */
+ while (this->status == DEMUX_OK) {
+
+//printf ("loading chunk #%d\n", i);
+ /* check if all the frames have been sent */
+ if (i >= this->frame_count) {
+ this->status = DEMUX_FINISHED;
+ break;
+ }
+
+ current_file_pos = this->input->get_current_pos(this->input);
+
+ /* get the chunk size nd magic number */
+ if (this->input->read(this->input, fli_buf, 6) != 6) {
+ this->status = DEMUX_FINISHED;
+ break;
+ }
+ chunk_size = LE_32(&fli_buf[0]);
+ chunk_magic = LE_16(&fli_buf[4]);
+
+ /* rewind over the size and packetize the chunk */
+ this->input->seek(this->input, -6, SEEK_CUR);
+
+//printf (" chunk magic = %X\n", chunk_magic);
+ if ((chunk_magic = FLI_CHUNK_MAGIC_1) ||
+ (chunk_magic = FLI_CHUNK_MAGIC_2)) {
+ while (chunk_size) {
+//printf ("check 1\n");
+ buf = this->video_fifo->buffer_pool_alloc (this->video_fifo);
+ buf->content = buf->mem;
+ buf->type = BUF_VIDEO_FLI;
+ buf->input_pos = current_file_pos;
+ buf->pts = pts_counter;
+//printf ("check 2\n");
+
+ if (chunk_size > buf->max_size)
+ buf->size = buf->max_size;
+ else
+ buf->size = chunk_size;
+ chunk_size -= buf->size;
+
+//printf ("check 3\n");
+ if (this->input->read(this->input, buf->content, buf->size) !=
+ buf->size) {
+//printf ("check 4\n");
+ this->status = DEMUX_FINISHED;
+ break;
+ }
+//printf ("check 5\n");
+
+ if (!chunk_size)
+ buf->decoder_flags |= BUF_FLAG_FRAME_END;
+//printf ("check 6\n");
+ this->video_fifo->put(this->video_fifo, buf);
+//printf ("check 7\n");
+ }
+ pts_counter += this->frame_pts_inc;
+ }
+
+ i++;
+
+ /* someone may want to interrupt us */
+ pthread_mutex_unlock( &this->mutex );
+ pthread_mutex_lock( &this->mutex );
+ }
+
+ /* wait before sending end buffers: user might want to do a new seek */
+ while(this->send_end_buffers && this->video_fifo->size(this->video_fifo) &&
+ this->status != DEMUX_OK){
+ pthread_mutex_unlock( &this->mutex );
+ xine_usec_sleep(100000);
+ pthread_mutex_lock( &this->mutex );
+ }
+ } while (this->status == DEMUX_OK);
+
+ this->status = DEMUX_FINISHED;
+
+ if (this->send_end_buffers) {
+ xine_demux_control_end(this->xine, BUF_FLAG_END_STREAM);
+ }
+
+ this->thread_running = 0;
+ pthread_mutex_unlock( &this->mutex );
+
+ return NULL;
+}
+
+static int demux_fli_open(demux_plugin_t *this_gen, input_plugin_t *input,
+ int stage) {
+
+ demux_fli_t *this = (demux_fli_t *) this_gen;
+ char sig[2];
+ unsigned int magic_number;
+
+ this->input = input;
+
+ switch(stage) {
+ case STAGE_BY_CONTENT: {
+ if ((input->get_capabilities(input) & INPUT_CAP_SEEKABLE) == 0)
+ return DEMUX_CANNOT_HANDLE;
+
+ input->seek(input, 4, SEEK_SET);
+ if (input->read(input, sig, 2) != 2) {
+ return DEMUX_CANNOT_HANDLE;
+ }
+ magic_number = LE_16(&sig[0]);
+ if ((magic_number == FLI_FILE_MAGIC_1) ||
+ (magic_number == FLI_FILE_MAGIC_2))
+ return DEMUX_CAN_HANDLE;
+
+ return DEMUX_CANNOT_HANDLE;
+ }
+ break;
+
+ case STAGE_BY_EXTENSION: {
+ char *suffix;
+ char *MRL;
+ char *m, *valid_ends;
+
+ MRL = input->get_mrl (input);
+
+ suffix = strrchr(MRL, '.');
+
+ if(!suffix)
+ return DEMUX_CANNOT_HANDLE;
+
+ xine_strdupa(valid_ends, (this->config->register_string(this->config,
+ "mrl.ends_fli", VALID_ENDS,
+ "valid mrls ending for fli demuxer",
+ NULL, NULL, NULL)));
+ while((m = xine_strsep(&valid_ends, ",")) != NULL) {
+
+ while(*m == ' ' || *m == '\t') m++;
+
+ if(!strcasecmp((suffix + 1), m)) {
+ this->input = input;
+ return DEMUX_CAN_HANDLE;
+ }
+ }
+ return DEMUX_CANNOT_HANDLE;
+ }
+ break;
+
+ default:
+ return DEMUX_CANNOT_HANDLE;
+ break;
+
+ }
+
+ return DEMUX_CANNOT_HANDLE;
+}
+
+static int demux_fli_start (demux_plugin_t *this_gen,
+ fifo_buffer_t *video_fifo,
+ fifo_buffer_t *audio_fifo,
+ off_t start_pos, int start_time) {
+
+ demux_fli_t *this = (demux_fli_t *) this_gen;
+ buf_element_t *buf;
+ int err;
+ unsigned char fli_header[FLI_HEADER_SIZE];
+
+ pthread_mutex_lock(&this->mutex);
+
+ /* if thread is not running, initialize demuxer */
+ if (!this->thread_running) {
+ this->video_fifo = video_fifo;
+ this->audio_fifo = audio_fifo;
+
+ /* read the whole header */
+ this->input->seek(this->input, 0, SEEK_SET);
+ if (this->input->read(this->input, fli_header, FLI_HEADER_SIZE) !=
+ FLI_HEADER_SIZE) {
+ return DEMUX_FINISHED;
+ }
+
+ this->magic_number = LE_16(&fli_header[4]);
+ this->frame_count = LE_16(&fli_header[6]);
+ this->width = LE_16(&fli_header[8]);
+ this->height = LE_16(&fli_header[10]);
+ this->speed = LE_32(&fli_header[16]);
+ if (this->magic_number == 0xAF11) {
+ /*
+ * in this case, the speed (n) is number of 1/70s ticks between frames:
+ *
+ * xine pts n * frame #
+ * -------- = ----------- => xine pts = n * (90000/70) * frame #
+ * 90000 70
+ *
+ * therefore, the frame pts increment = n * 1285.7
+ */
+ this->frame_pts_inc = this->speed * 1285.7;
+ } else {
+ /*
+ * in this case, the speed (n) is number of milliseconds between frames:
+ *
+ * xine pts n * frame #
+ * -------- = ----------- => xine pts = n * 90 * frame #
+ * 90000 1000
+ *
+ * therefore, the frame pts increment = n * 90
+ */
+ this->frame_pts_inc = this->speed * 90;
+ }
+
+ /* print vital stats */
+ xine_log (this->xine, XINE_LOG_FORMAT,
+ _("demux_fli: FLI type: %04X, speed: %d/%d\n"),
+ this->magic_number, this->speed,
+ (this->magic_number == FLI_FILE_MAGIC_1) ? 70 : 1000);
+ xine_log (this->xine, XINE_LOG_FORMAT,
+ _("demux_fli: %d frames, %dx%d\n"),
+ this->frame_count, this->width, this->height);
+
+ /* send start buffers */
+ xine_demux_control_start(this->xine);
+
+ /* send new pts */
+ xine_demux_control_newpts(this->xine, 0, 0);
+
+#if 0
+ /* send start buffers */
+ buf = this->video_fifo->buffer_pool_alloc(this->video_fifo);
+ buf->type = BUF_CONTROL_START;
+ this->video_fifo->put(this->video_fifo, buf);
+ if (audio_fifo) {
+ buf = audio_fifo->buffer_pool_alloc(audio_fifo);
+ buf->type = BUF_CONTROL_START;
+ audio_fifo->put(audio_fifo, buf);
+ }
+
+ /* send new pts */
+ buf = this->video_fifo->buffer_pool_alloc (this->video_fifo);
+ buf->type = BUF_CONTROL_NEWPTS;
+ buf->disc_off = 0;
+ this->video_fifo->put (this->video_fifo, buf);
+
+ /* notify the engine that there will be no audio */
+ if (audio_fifo) {
+ buf = audio_fifo->buffer_pool_alloc (audio_fifo);
+ buf->type = BUF_CONTROL_NOP;
+ buf->disc_off = 0;
+ audio_fifo->put (audio_fifo, buf);
+ }
+#endif
+
+ /* send init info to FLI decoder */
+ buf = this->video_fifo->buffer_pool_alloc (this->video_fifo);
+ buf->content = buf->mem;
+ buf->decoder_flags = BUF_FLAG_HEADER;
+ buf->decoder_info[0] = 0;
+ buf->decoder_info[1] = this->frame_pts_inc; /* initial video_step */
+ /* be a rebel and send the FLI header instead of the bih */
+ memcpy(buf->content, fli_header, FLI_HEADER_SIZE);
+ buf->size = FLI_HEADER_SIZE;
+ buf->type = BUF_VIDEO_FLI;
+ this->video_fifo->put (this->video_fifo, buf);
+
+ this->status = DEMUX_OK;
+ this->send_end_buffers = 1;
+ this->thread_running = 1;
+
+ /* kick off the demux thread */
+ if ((err = pthread_create (&this->thread, NULL, demux_fli_loop, this)) != 0) {
+ printf ("demux_fli: can't create new thread (%s)\n", strerror(err));
+ abort();
+ }
+ }
+
+ pthread_mutex_unlock(&this->mutex);
+
+ return this->status;
+}
+
+static int demux_fli_seek (demux_plugin_t *this_gen,
+ off_t start_pos, int start_time) {
+ demux_fli_t *this = (demux_fli_t *) this_gen;
+
+ /* FLI files are not meant to be seekable */
+
+ return this->status;
+}
+
+static void demux_fli_stop (demux_plugin_t *this_gen) {
+
+ demux_fli_t *this = (demux_fli_t *) this_gen;
+ void *p;
+
+ pthread_mutex_lock( &this->mutex );
+
+ if (!this->thread_running) {
+ pthread_mutex_unlock( &this->mutex );
+ return;
+ }
+
+ this->send_end_buffers = 0;
+ this->status = DEMUX_FINISHED;
+
+ pthread_mutex_unlock( &this->mutex );
+ pthread_join (this->thread, &p);
+
+ xine_demux_flush_engine(this->xine);
+
+ xine_demux_control_end(this->xine, BUF_FLAG_END_USER);
+}
+
+static void demux_fli_close (demux_plugin_t *this) {
+ free(this);
+}
+
+static int demux_fli_get_status (demux_plugin_t *this_gen) {
+ demux_fli_t *this = (demux_fli_t *) this_gen;
+
+ return this->status;
+}
+
+static char *demux_fli_get_id(void) {
+ return "FLI";
+}
+
+static int demux_fli_get_stream_length (demux_plugin_t *this_gen) {
+
+ return 0;
+}
+
+static char *demux_fli_get_mimetypes(void) {
+ return NULL;
+}
+
+demux_plugin_t *init_demuxer_plugin(int iface, xine_t *xine) {
+ demux_fli_t *this;
+
+ if (iface != 10) {
+ printf ("demux_fli: plugin doesn't support plugin API version %d.\n"
+ " this means there's a version mismatch between xine and this "
+ " demuxer plugin. Installing current demux plugins should help.\n",
+ iface);
+ return NULL;
+ }
+
+ this = (demux_fli_t *) xine_xmalloc(sizeof(demux_fli_t));
+ this->config = xine->config;
+ this->xine = xine;
+
+ this->demux_plugin.interface_version = DEMUXER_PLUGIN_IFACE_VERSION;
+ this->demux_plugin.open = demux_fli_open;
+ this->demux_plugin.start = demux_fli_start;
+ this->demux_plugin.seek = demux_fli_seek;
+ this->demux_plugin.stop = demux_fli_stop;
+ this->demux_plugin.close = demux_fli_close;
+ this->demux_plugin.get_status = demux_fli_get_status;
+ this->demux_plugin.get_identifier = demux_fli_get_id;
+ this->demux_plugin.get_stream_length = demux_fli_get_stream_length;
+ this->demux_plugin.get_mimetypes = demux_fli_get_mimetypes;
+
+ return &this->demux_plugin;
+}
+
diff --git a/src/demuxers/demux_idcin.c b/src/demuxers/demux_idcin.c
new file mode 100644
index 000000000..269b74d04
--- /dev/null
+++ b/src/demuxers/demux_idcin.c
@@ -0,0 +1,437 @@
+/*
+ * Copyright (C) 2000-2002 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
+ *
+ * CIN File Demuxer by Mike Melanson (melanson@pcisys.net)
+ * For more information regarding the Id CIN file format, visit:
+ * http://www.csse.monash.edu.au/~timf/
+ *
+ * $Id: demux_idcin.c,v 1.1 2002/07/07 01:24:40 tmmm Exp $
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <pthread.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include "xine_internal.h"
+#include "xineutils.h"
+#include "compat.h"
+#include "demux.h"
+#include "bswap.h"
+
+#define LE_16(x) (le2me_16(*(unsigned short *)(x)))
+#define LE_32(x) (le2me_32(*(unsigned int *)(x)))
+
+#define VALID_ENDS "cin"
+#define IDCIN_HEADER_SIZE 20
+#define HUFFMAN_TABLE_SIZE 65536
+#define IDCIN_FRAME_PTS_INC (90000 / 14)
+
+typedef struct {
+
+ demux_plugin_t demux_plugin;
+
+ xine_t *xine;
+
+ config_values_t *config;
+
+ fifo_buffer_t *video_fifo;
+ fifo_buffer_t *audio_fifo;
+
+ input_plugin_t *input;
+
+ pthread_t thread;
+ int thread_running;
+ pthread_mutex_t mutex;
+ int send_end_buffers;
+
+ off_t start;
+ int status;
+
+ unsigned int video_width;
+ unsigned int video_height;
+ unsigned int audio_sample_rate;
+ unsigned int audio_bytes_per_sample;
+ unsigned int audio_channels;
+
+ unsigned char huffman_table[HUFFMAN_TABLE_SIZE];
+
+} demux_idcin_t;
+
+static void *demux_idcin_loop (void *this_gen) {
+
+ demux_idcin_t *this = (demux_idcin_t *) this_gen;
+ buf_element_t *buf = NULL;
+ unsigned int command;
+ off_t current_file_pos;
+
+ pthread_mutex_lock( &this->mutex );
+
+ /* do-while needed to seek after demux finished */
+ do {
+ /* main demuxer loop */
+ while (this->status == DEMUX_OK) {
+
+ current_file_pos = this->input->get_current_pos(this->input);
+
+ /* figure out what the next data is */
+ if (this->input->read(this->input, (unsigned char *)&command, 4) != 4) {
+ this->status = DEMUX_FINISHED;
+ pthread_mutex_unlock(&this->mutex);
+ break;
+ }
+
+ command = le2me_32(command);
+ }
+
+ /* wait before sending end buffers: user might want to do a new seek */
+ while(this->send_end_buffers && this->video_fifo->size(this->video_fifo) &&
+ this->status != DEMUX_OK){
+ pthread_mutex_unlock( &this->mutex );
+ xine_usec_sleep(100000);
+ pthread_mutex_lock( &this->mutex );
+ }
+
+ } while (this->status == DEMUX_OK);
+
+ printf ("demux_idcin: demux loop finished (status: %d)\n",
+ this->status);
+
+ this->status = DEMUX_FINISHED;
+
+ if (this->send_end_buffers) {
+ xine_demux_control_end(this->xine, BUF_FLAG_END_STREAM);
+ }
+
+ this->thread_running = 0;
+ pthread_mutex_unlock(&this->mutex);
+ return NULL;
+}
+
+static int demux_idcin_open(demux_plugin_t *this_gen,
+ input_plugin_t *input, int stage) {
+
+ demux_idcin_t *this = (demux_idcin_t *) this_gen;
+ char header[IDCIN_HEADER_SIZE];
+ unsigned int current_value;
+
+ this->input = input;
+
+ switch(stage) {
+ case STAGE_BY_CONTENT: {
+ if ((input->get_capabilities(input) & INPUT_CAP_SEEKABLE) == 0)
+ return DEMUX_CANNOT_HANDLE;
+
+ input->seek(input, 0, SEEK_SET);
+ if (input->read(input, header, IDCIN_HEADER_SIZE) != IDCIN_HEADER_SIZE)
+ return DEMUX_CANNOT_HANDLE;
+
+ /*
+ * This is what you could call a "probabilistic" file check: Id CIN
+ * files don't have a definite file signature. In lieu of such a marker,
+ * perform sanity checks on the 5 header fields:
+ * width, height: greater than 0, less than or equal to 1024
+ * audio sample rate: greater than or equal to 8000, less than or
+ * equal to 48000, or 0 for no audio
+ * audio sample width (bytes/sample): 0 for no audio, or 1 or 2
+ * audio channels: 0 for no audio, or 1 or 2
+ */
+
+ /* check the width */
+ current_value = LE_32(&header[0]);
+ if ((current_value == 0) || (current_value > 1024))
+ return DEMUX_CANNOT_HANDLE;
+
+ /* check the height */
+ current_value = LE_32(&header[4]);
+ if ((current_value == 0) || (current_value > 1024))
+ return DEMUX_CANNOT_HANDLE;
+
+ /* check the audio sample rate */
+ current_value = LE_32(&header[8]);
+ if ((current_value < 8000) || (current_value > 48000))
+ return DEMUX_CANNOT_HANDLE;
+
+ /* check the audio bytes/sample */
+ current_value = LE_32(&header[12]);
+ if (current_value > 2)
+ return DEMUX_CANNOT_HANDLE;
+
+ /* check the audio channels */
+ current_value = LE_32(&header[16]);
+ if (current_value > 2)
+ return DEMUX_CANNOT_HANDLE;
+
+ /* if execution got this far, qualify it as a valid Id CIN file */
+ return DEMUX_CAN_HANDLE;
+ }
+ break;
+
+ case STAGE_BY_EXTENSION: {
+ char *suffix;
+ char *MRL;
+ char *m, *valid_ends;
+
+ MRL = input->get_mrl (input);
+
+ suffix = strrchr(MRL, '.');
+
+ if(!suffix)
+ return DEMUX_CANNOT_HANDLE;
+
+ xine_strdupa(valid_ends, (this->config->register_string(this->config,
+ "mrl.ends_idcin", VALID_ENDS,
+ _("valid mrls ending for idcin demuxer"),
+ NULL, NULL, NULL))); while((m = xine_strsep(&valid_ends, ",")) != NULL) {
+
+ while(*m == ' ' || *m == '\t') m++;
+
+ if(!strcasecmp((suffix + 1), m)) {
+ this->input = input;
+ return DEMUX_CAN_HANDLE;
+ }
+ }
+ return DEMUX_CANNOT_HANDLE;
+ }
+ break;
+
+ default:
+ return DEMUX_CANNOT_HANDLE;
+ break;
+ }
+
+ return DEMUX_CANNOT_HANDLE;
+}
+
+static int demux_idcin_start (demux_plugin_t *this_gen,
+ fifo_buffer_t *video_fifo,
+ fifo_buffer_t *audio_fifo,
+ off_t start_pos, int start_time) {
+
+ demux_idcin_t *this = (demux_idcin_t *) this_gen;
+ buf_element_t *buf;
+ int err;
+ char header[IDCIN_HEADER_SIZE];
+
+ pthread_mutex_lock(&this->mutex);
+
+ /* if thread is not running, initialize demuxer */
+ if (!this->thread_running) {
+ this->video_fifo = video_fifo;
+ this->audio_fifo = audio_fifo;
+
+ this->input->seek(this->input, 0, SEEK_SET);
+ if (this->input->read(this->input, header, IDCIN_HEADER_SIZE) !=
+ IDCIN_HEADER_SIZE) {
+ this->status = DEMUX_FINISHED;
+ pthread_mutex_unlock(&this->mutex);
+ return DEMUX_FINISHED;
+ }
+
+ this->video_width = LE_32(&header[0]);
+ this->video_height = LE_32(&header[4]);
+ this->audio_sample_rate = LE_32(&header[8]);
+ this->audio_bytes_per_sample = LE_32(&header[12]);
+ this->audio_channels = LE_32(&header[16]);
+
+ /* read the Huffman table */
+ if (this->input->read(this->input, this->huffman_table,
+ HUFFMAN_TABLE_SIZE) != HUFFMAN_TABLE_SIZE) {
+ this->status = DEMUX_FINISHED;
+ pthread_mutex_unlock(&this->mutex);
+ return DEMUX_FINISHED;
+ }
+
+ /* print vital stats */
+ xine_log (this->xine, XINE_LOG_FORMAT,
+ _("demux_idcin: Id CIN file, video is %dx%d, 14 frames/sec\n"),
+ this->video_width,
+ this->video_height);
+ if (this->audio_channels)
+ xine_log (this->xine, XINE_LOG_FORMAT,
+ _("demux_idcin: %d-bit, %d Hz %s PCM audio\n"),
+ this->audio_bytes_per_sample * 8,
+ this->audio_sample_rate,
+ (this->audio_channels == 1) ? "monaural" : "stereo");
+
+
+pthread_mutex_unlock(&this->mutex);
+return DEMUX_FINISHED;
+
+
+ /* send start buffers */
+ xine_demux_control_start(this->xine);
+
+ /* send new pts */
+ xine_demux_control_newpts(this->xine, 0, 0);
+
+ /* send init info to decoders */
+ buf = this->video_fifo->buffer_pool_alloc (this->video_fifo);
+ buf->content = buf->mem;
+ buf->decoder_flags = BUF_FLAG_HEADER;
+ buf->decoder_info[0] = 0;
+ buf->decoder_info[1] = IDCIN_FRAME_PTS_INC; /* initial video_step */
+ /* really be a rebel: No structure at all, just put the video width
+ * and height straight into the buffer, BE_16 format */
+ buf->content[0] = (this->video_width >> 8) & 0xFF;
+ buf->content[1] = (this->video_width >> 0) & 0xFF;
+ buf->content[2] = (this->video_height >> 8) & 0xFF;
+ buf->content[3] = (this->video_height >> 0) & 0xFF;
+ buf->size = 4;
+ buf->type = BUF_VIDEO_IDCIN;
+ this->video_fifo->put (this->video_fifo, buf);
+
+ /* send the Huffman table */
+ buf = this->video_fifo->buffer_pool_alloc (this->video_fifo);
+ buf->content = buf->mem;
+ buf->decoder_flags = BUF_FLAG_SPECIAL;
+ buf->decoder_info[1] = BUF_SPECIAL_IDCIN_HUFFMAN_TABLE;
+ buf->decoder_info[2] = (unsigned int)&this->huffman_table;
+ buf->size = 0;
+ buf->type = BUF_VIDEO_IDCIN;
+ this->video_fifo->put (this->video_fifo, buf);
+
+ if (this->audio_fifo && this->audio_channels) {
+ buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo);
+ buf->content = buf->mem;
+ buf->type = BUF_AUDIO_LPCM_LE;
+ buf->decoder_flags = BUF_FLAG_HEADER;
+ buf->decoder_info[0] = 0;
+ buf->decoder_info[1] = this->audio_sample_rate;
+ buf->decoder_info[2] = this->audio_bytes_per_sample * 8;
+ buf->decoder_info[3] = this->audio_channels;
+ this->audio_fifo->put (this->audio_fifo, buf);
+ }
+
+ this->status = DEMUX_OK;
+ this->send_end_buffers = 1;
+ this->thread_running = 1;
+
+ if ((err = pthread_create (&this->thread, NULL, demux_idcin_loop, this)) != 0) {
+ printf ("demux_idcin: can't create new thread (%s)\n", strerror(err));
+ abort();
+ }
+
+ this->status = DEMUX_OK;
+ }
+
+ pthread_mutex_unlock(&this->mutex);
+
+ return this->status;
+}
+
+static int demux_idcin_seek (demux_plugin_t *this_gen,
+ off_t start_pos, int start_time) {
+
+ /* Id CIN files are not meant to be seekable; don't even bother */
+
+ return 0;
+}
+
+static void demux_idcin_stop (demux_plugin_t *this_gen) {
+
+ demux_idcin_t *this = (demux_idcin_t *) this_gen;
+ void *p;
+
+ pthread_mutex_lock( &this->mutex );
+
+ if (!this->thread_running) {
+ pthread_mutex_unlock( &this->mutex );
+ return;
+ }
+
+ /* seek to the start of the data in case there's another start command */
+ this->input->seek(this->input, IDCIN_HEADER_SIZE + HUFFMAN_TABLE_SIZE,
+ SEEK_SET);
+
+ this->send_end_buffers = 0;
+ this->status = DEMUX_FINISHED;
+
+ pthread_mutex_unlock( &this->mutex );
+ pthread_join (this->thread, &p);
+
+ xine_demux_flush_engine(this->xine);
+
+ xine_demux_control_end(this->xine, BUF_FLAG_END_USER);
+}
+
+static void demux_idcin_close (demux_plugin_t *this) {
+ free(this);
+}
+
+static int demux_idcin_get_status (demux_plugin_t *this_gen) {
+ demux_idcin_t *this = (demux_idcin_t *) this_gen;
+
+ return this->status;
+}
+
+static char *demux_idcin_get_id(void) {
+ return "Id CIN";
+}
+
+static int demux_idcin_get_stream_length (demux_plugin_t *this_gen) {
+
+ return 0;
+}
+
+static char *demux_idcin_get_mimetypes(void) {
+ return NULL;
+}
+
+demux_plugin_t *init_demuxer_plugin(int iface, xine_t *xine) {
+ demux_idcin_t *this;
+
+ if (iface != 10) {
+ printf (_("demux_idcin: plugin doesn't support plugin API version %d.\n"
+ " this means there's a version mismatch between xine and this "
+ " demuxer plugin.\nInstalling current demux plugins should help.\n"),
+ iface);
+ return NULL;
+ }
+
+ this = (demux_idcin_t *) xine_xmalloc(sizeof(demux_idcin_t));
+ this->config = xine->config;
+ this->xine = xine;
+
+ (void *) this->config->register_string(this->config,
+ "mrl.ends_idcin", VALID_ENDS,
+ _("valid mrls ending for idcin demuxer"), NULL, NULL, NULL);
+
+ this->demux_plugin.interface_version = DEMUXER_PLUGIN_IFACE_VERSION;
+ this->demux_plugin.open = demux_idcin_open;
+ this->demux_plugin.start = demux_idcin_start;
+ this->demux_plugin.seek = demux_idcin_seek;
+ this->demux_plugin.stop = demux_idcin_stop;
+ this->demux_plugin.close = demux_idcin_close;
+ this->demux_plugin.get_status = demux_idcin_get_status;
+ this->demux_plugin.get_identifier = demux_idcin_get_id;
+ this->demux_plugin.get_stream_length = demux_idcin_get_stream_length;
+ this->demux_plugin.get_mimetypes = demux_idcin_get_mimetypes;
+
+ this->status = DEMUX_FINISHED;
+ pthread_mutex_init(&this->mutex, NULL);
+
+ return &this->demux_plugin;
+}
diff --git a/src/demuxers/demux_smjpeg.c b/src/demuxers/demux_smjpeg.c
new file mode 100644
index 000000000..860cf48a2
--- /dev/null
+++ b/src/demuxers/demux_smjpeg.c
@@ -0,0 +1,563 @@
+/*
+ * Copyright (C) 2000-2002 the xine project
+ *
+ * This file is part of xine, a free 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
+ *
+ * SMJPEG File Demuxer by Mike Melanson (melanson@pcisys.net)
+ * For more information on the SMJPEG file format, visit:
+ * http://www.lokigames.com/development/smjpeg.php3
+ *
+ * $Id: demux_smjpeg.c,v 1.1 2002/07/07 01:24:40 tmmm Exp $
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <pthread.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include "xine_internal.h"
+#include "xineutils.h"
+#include "compat.h"
+#include "demux.h"
+#include "bswap.h"
+
+#define BE_16(x) (be2me_16(*(unsigned short *)(x)))
+#define BE_32(x) (be2me_32(*(unsigned int *)(x)))
+
+#define FOURCC_TAG( ch0, ch1, ch2, ch3 ) \
+ ( (long)(unsigned char)(ch3) | ( (long)(unsigned char)(ch2) << 8 ) | \
+ ( (long)(unsigned char)(ch1) << 16 ) | ( (long)(unsigned char)(ch0) << 24 ) )
+
+#define _TXT_TAG FOURCC_TAG('_', 'T', 'X', 'T')
+#define _SND_TAG FOURCC_TAG('_', 'S', 'N', 'D')
+#define _VID_TAG FOURCC_TAG('_', 'V', 'I', 'D')
+#define HEND_TAG FOURCC_TAG('H', 'E', 'N', 'D')
+#define sndD_TAG FOURCC_TAG('s', 'n', 'd', 'D')
+#define vidD_TAG FOURCC_TAG('v', 'i', 'd', 'D')
+
+#define VALID_ENDS "mjpg"
+
+#define SMJPEG_SIGNATURE_SIZE 8
+/* 16 is the max size of a header chunk (the video header) */
+#define SMJPEG_VIDEO_HEADER_SIZE 16
+#define SMJPEG_AUDIO_HEADER_SIZE 12
+#define SMJPEG_HEADER_CHUNK_MAX_SIZE SMJPEG_VIDEO_HEADER_SIZE
+#define SMJPEG_CHUNK_PREAMBLE_SIZE 12
+
+typedef struct {
+
+ demux_plugin_t demux_plugin;
+
+ xine_t *xine;
+
+ config_values_t *config;
+
+ fifo_buffer_t *video_fifo;
+ fifo_buffer_t *audio_fifo;
+
+ input_plugin_t *input;
+
+ pthread_t thread;
+ int thread_running;
+ pthread_mutex_t mutex;
+ int send_end_buffers;
+
+ off_t input_length;
+ int status;
+
+ /* when this flag is set, demuxer only dispatches audio samples until it
+ * encounters a video keyframe, then it starts sending every frame again */
+ int waiting_for_keyframe;
+
+ /* video information */
+ unsigned int video_type;
+ xine_bmiheader bih;
+
+ /* audio information */
+ unsigned int audio_codec;
+ unsigned int audio_type;
+ unsigned int audio_sample_rate;
+ unsigned int audio_bits;
+ unsigned int audio_channels;
+
+ /* playback information */
+ unsigned int duration; /* duration in milliseconds */
+} demux_smjpeg_t;
+
+static void *demux_smjpeg_loop (void *this_gen) {
+
+ demux_smjpeg_t *this = (demux_smjpeg_t *) this_gen;
+ buf_element_t *buf = NULL;
+ unsigned int chunk_tag;
+ int64_t pts;
+ unsigned int remaining_sample_bytes;
+ unsigned char preamble[SMJPEG_CHUNK_PREAMBLE_SIZE];
+ off_t current_file_pos;
+
+ pthread_mutex_lock( &this->mutex );
+
+ /* do-while needed to seek after demux finished */
+ do {
+ /* main demuxer loop */
+ while (this->status == DEMUX_OK) {
+
+ /* someone may want to interrupt us */
+ pthread_mutex_unlock( &this->mutex );
+ pthread_mutex_lock( &this->mutex );
+
+ /* load the next sample */
+ current_file_pos = this->input->get_current_pos(this->input);
+ if (this->input->read(this->input, preamble,
+ SMJPEG_CHUNK_PREAMBLE_SIZE) != SMJPEG_CHUNK_PREAMBLE_SIZE) {
+ this->status = DEMUX_FINISHED;
+ return NULL;
+ }
+
+ chunk_tag = BE_32(&preamble[0]);
+ remaining_sample_bytes = BE_32(&preamble[8]);
+
+ /*
+ * Each sample has an absolute timestamp in millisecond units:
+ *
+ * xine pts timestamp (ms)
+ * -------- = --------------
+ * 90000 1000
+ *
+ * therefore, xine pts = timestamp * 90000 / 1000 => timestamp * 90
+ */
+ pts = BE_32(&preamble[4]);
+ pts *= 90;
+
+ /* break up the data into packets and dispatch them */
+ if (((chunk_tag == sndD_TAG) && this->audio_fifo && this->audio_type) ||
+ (chunk_tag == vidD_TAG)) {
+
+ while (remaining_sample_bytes) {
+ if (chunk_tag == sndD_TAG) {
+ buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo);
+ buf->type = this->audio_type;
+ buf->decoder_info[1] = this->audio_sample_rate;
+ buf->decoder_info[2] = this->audio_bits;
+ buf->decoder_info[3] = this->audio_channels;
+ } else {
+ buf = this->video_fifo->buffer_pool_alloc (this->video_fifo);
+ buf->type = this->video_type;
+ }
+
+ buf->content = buf->mem;
+ buf->input_pos = current_file_pos;
+ buf->input_length = this->input_length;
+ buf->input_time = pts / 90000;
+ buf->pts = pts;
+ buf->decoder_flags = 0;
+
+ if (remaining_sample_bytes > buf->max_size)
+ buf->size = buf->max_size;
+ else
+ buf->size = remaining_sample_bytes;
+ remaining_sample_bytes -= buf->size;
+
+ if (this->input->read(this->input, buf->content, buf->size) !=
+ buf->size) {
+ this->status = DEMUX_FINISHED;
+ break;
+ }
+
+ if (!remaining_sample_bytes)
+ buf->decoder_flags |= BUF_FLAG_FRAME_END;
+
+ if (chunk_tag == sndD_TAG)
+ this->audio_fifo->put(this->audio_fifo, buf);
+ else
+ this->video_fifo->put(this->video_fifo, buf);
+ }
+
+ } else {
+
+ /* skip the chunk if it can't be handled */
+ this->input->seek(this->input, remaining_sample_bytes, SEEK_CUR);
+
+ }
+
+ }
+
+#if 1
+ /* wait before sending end buffers: user might want to do a new seek */
+ while(this->send_end_buffers && this->video_fifo->size(this->video_fifo) &&
+ this->status != DEMUX_OK){
+ pthread_mutex_unlock( &this->mutex );
+ xine_usec_sleep(100000);
+ pthread_mutex_lock( &this->mutex );
+ }
+#endif
+
+ } while (this->status == DEMUX_OK);
+
+ printf ("demux_smjpeg: demux loop finished (status: %d)\n",
+ this->status);
+
+ this->status = DEMUX_FINISHED;
+
+ if (this->send_end_buffers) {
+ xine_demux_control_end(this->xine, BUF_FLAG_END_STREAM);
+ }
+
+ this->thread_running = 0;
+ pthread_mutex_unlock(&this->mutex);
+ return NULL;
+}
+
+static int demux_smjpeg_open(demux_plugin_t *this_gen, input_plugin_t *input,
+ int stage) {
+ demux_smjpeg_t *this = (demux_smjpeg_t *) this_gen;
+ char signature[8];
+
+ this->input = input;
+
+ switch(stage) {
+ case STAGE_BY_CONTENT: {
+ if ((input->get_capabilities(input) & INPUT_CAP_SEEKABLE) == 0)
+ return DEMUX_CANNOT_HANDLE;
+
+ input->seek(input, 0, SEEK_SET);
+ if (input->read(input, signature, SMJPEG_SIGNATURE_SIZE) !=
+ SMJPEG_SIGNATURE_SIZE)
+ return DEMUX_CANNOT_HANDLE;
+
+ /* check for the SMJPEG signature */
+ if ((signature[0] == 0x00) &&
+ (signature[1] == 0x0A) &&
+ (signature[2] == 'S') &&
+ (signature[3] == 'M') &&
+ (signature[4] == 'J') &&
+ (signature[5] == 'P') &&
+ (signature[6] == 'E') &&
+ (signature[7] == 'G'))
+ return DEMUX_CAN_HANDLE;
+
+ return DEMUX_CANNOT_HANDLE;
+ }
+ break;
+
+ case STAGE_BY_EXTENSION: {
+ char *suffix;
+ char *MRL;
+ char *m, *valid_ends;
+
+ MRL = input->get_mrl (input);
+
+ suffix = strrchr(MRL, '.');
+
+ if(!suffix)
+ return DEMUX_CANNOT_HANDLE;
+
+ xine_strdupa(valid_ends, (this->config->register_string(this->config,
+ "mrl.ends_smjpeg", VALID_ENDS,
+ _("valid mrls ending for smjpeg demuxer"),
+ NULL, NULL, NULL)));
+ while((m = xine_strsep(&valid_ends, ",")) != NULL) {
+
+ while(*m == ' ' || *m == '\t') m++;
+
+ if(!strcasecmp((suffix + 1), m)) {
+ this->input = input;
+ return DEMUX_CAN_HANDLE;
+ }
+ }
+ return DEMUX_CANNOT_HANDLE;
+ }
+ break;
+
+ default:
+ return DEMUX_CANNOT_HANDLE;
+ break;
+
+ }
+
+ return DEMUX_CANNOT_HANDLE;
+}
+
+static int demux_smjpeg_start (demux_plugin_t *this_gen,
+ fifo_buffer_t *video_fifo,
+ fifo_buffer_t *audio_fifo,
+ off_t start_pos, int start_time) {
+
+ demux_smjpeg_t *this = (demux_smjpeg_t *) this_gen;
+ unsigned int chunk_tag;
+ unsigned char header_chunk[SMJPEG_HEADER_CHUNK_MAX_SIZE];
+ buf_element_t *buf;
+ int err;
+
+ pthread_mutex_lock(&this->mutex);
+
+ /* if thread is not running, initialize demuxer */
+ if (!this->thread_running) {
+ this->video_fifo = video_fifo;
+ this->audio_fifo = audio_fifo;
+
+ /* initial state: no video and no audio (until headers found) */
+ this->video_type = this->audio_type = 0;
+ this->input_length = this->input->get_length (this->input);
+
+ /* jump over the signature and version to the duration */
+ this->input->seek(this->input, 12, SEEK_SET);
+ if (this->input->read(this->input, header_chunk, 4) != 4) {
+ this->status = DEMUX_FINISHED;
+ return this->status;
+ }
+ this->duration = BE_32(&header_chunk[0]);
+
+ /* traverse the header chunks until the HEND tag is found */
+ chunk_tag = 0;
+ while (chunk_tag != HEND_TAG) {
+
+ if (this->input->read(this->input, header_chunk, 4) != 4) {
+ this->status = DEMUX_FINISHED;
+ return this->status;
+ }
+ chunk_tag = BE_32(&header_chunk[0]);
+
+ switch(chunk_tag) {
+
+ case HEND_TAG:
+ /* this indicates the end of the header; do nothing and fall
+ * out of the loop on the next iteration */
+ break;
+
+ case _VID_TAG:
+ if (this->input->read(this->input, header_chunk,
+ SMJPEG_VIDEO_HEADER_SIZE) != SMJPEG_VIDEO_HEADER_SIZE) {
+ this->status = DEMUX_FINISHED;
+ return this->status;
+ }
+
+ this->bih.biWidth = BE_16(&header_chunk[8]);
+ this->bih.biHeight = BE_16(&header_chunk[10]);
+ this->bih.biCompression = *(uint32_t *)&header_chunk[12];
+ this->video_type = fourcc_to_buf_video(this->bih.biCompression);
+ break;
+
+ case _SND_TAG:
+ if (this->input->read(this->input, header_chunk,
+ SMJPEG_AUDIO_HEADER_SIZE) != SMJPEG_AUDIO_HEADER_SIZE) {
+ this->status = DEMUX_FINISHED;
+ return this->status;
+ }
+
+ this->audio_sample_rate = BE_16(&header_chunk[4]);
+ this->audio_bits = header_chunk[6];
+ this->audio_channels = header_chunk[7];
+ this->audio_codec = *(uint32_t *)&header_chunk[8];
+ this->audio_type = formattag_to_buf_audio(this->audio_codec);
+ break;
+
+ default:
+ /* for all other chunk types, read the length and skip the rest
+ * of the chunk */
+ if (this->input->read(this->input, header_chunk, 4) != 4) {
+ this->status = DEMUX_FINISHED;
+ return this->status;
+ }
+ this->input->seek(this->input, BE_32(&header_chunk[0]), SEEK_CUR);
+ break;
+ }
+
+ }
+
+this->video_type = BUF_VIDEO_JPEG;
+ if(!this->video_type)
+ xine_report_codec(this->xine, XINE_CODEC_VIDEO,
+ this->bih.biCompression, 0, 0);
+
+ if(!this->audio_type && this->audio_codec)
+ xine_report_codec( this->xine, XINE_CODEC_AUDIO,
+ this->audio_codec, 0, 0);
+
+ /* print vital stats */
+ xine_log (this->xine, XINE_LOG_FORMAT,
+ _("demux_smjpeg: SMJPEG file, running time: %d min, %d sec\n"),
+ this->duration / 1000 / 60,
+ this->duration / 1000 % 60);
+ if (this->video_type)
+ xine_log (this->xine, XINE_LOG_FORMAT,
+ _("demux_smjpeg: %c%c%c%c video @ %dx%d\n"),
+ *((char *)&this->bih.biCompression + 0),
+ *((char *)&this->bih.biCompression + 1),
+ *((char *)&this->bih.biCompression + 2),
+ *((char *)&this->bih.biCompression + 3),
+ this->bih.biWidth,
+ this->bih.biHeight);
+ if (this->audio_type)
+ xine_log (this->xine, XINE_LOG_FORMAT,
+ _("demux_smjpeg: '%c%c%c%c' audio @ %d Hz, %d bits, %d channel%c\n"),
+ *((char *)&this->audio_codec + 0),
+ *((char *)&this->audio_codec + 1),
+ *((char *)&this->audio_codec + 2),
+ *((char *)&this->audio_codec + 3),
+ this->audio_sample_rate,
+ this->audio_bits,
+ this->audio_channels,
+ (this->audio_channels == 1) ? 0 : 's');
+
+ /* send start buffers */
+ xine_demux_control_start(this->xine);
+
+ /* send init info to decoders */
+ buf = this->video_fifo->buffer_pool_alloc (this->video_fifo);
+ buf->content = buf->mem;
+ buf->decoder_flags = BUF_FLAG_HEADER;
+ buf->decoder_info[0] = 0;
+ buf->decoder_info[1] = 3000; /* initial video_step */
+ memcpy(buf->content, &this->bih, sizeof(this->bih));
+ buf->size = sizeof(this->bih);
+ buf->type = this->video_type;
+ this->video_fifo->put (this->video_fifo, buf);
+
+ if (this->audio_fifo && this->audio_type) {
+ buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo);
+ buf->content = buf->mem;
+ buf->type = this->audio_type;
+ buf->decoder_flags = BUF_FLAG_HEADER;
+ buf->decoder_info[0] = 0;
+ buf->decoder_info[1] = this->audio_sample_rate;
+ buf->decoder_info[2] = this->audio_bits;
+ buf->decoder_info[3] = this->audio_channels;
+ this->audio_fifo->put (this->audio_fifo, buf);
+ }
+
+ this->status = DEMUX_OK;
+ this->send_end_buffers = 1;
+ this->thread_running = 1;
+
+ if ((err = pthread_create (&this->thread, NULL, demux_smjpeg_loop, this)) != 0) {
+ printf ("demux_qt: can't create new thread (%s)\n", strerror(err));
+ abort();
+ }
+
+
+ }
+
+ pthread_mutex_unlock(&this->mutex);
+
+ return this->status;
+}
+
+static int demux_smjpeg_seek (demux_plugin_t *this_gen,
+ off_t start_pos, int start_time) {
+
+ /* SMJPEG files consist of a series of keyframes, but there is no
+ * master index; in order to effectively seek, an index would have to be
+ * built by traversing the file in advance. Therefore, don't bother
+ * implementing the seek function. */
+
+ return 0;
+}
+
+static void demux_smjpeg_stop (demux_plugin_t *this_gen) {
+
+ demux_smjpeg_t *this = (demux_smjpeg_t *) this_gen;
+ void *p;
+
+ pthread_mutex_lock( &this->mutex );
+
+ if (!this->thread_running) {
+ pthread_mutex_unlock( &this->mutex );
+ return;
+ }
+
+ this->send_end_buffers = 0;
+ this->status = DEMUX_FINISHED;
+
+ pthread_mutex_unlock( &this->mutex );
+ pthread_join (this->thread, &p);
+
+ xine_demux_flush_engine(this->xine);
+
+ xine_demux_control_end(this->xine, BUF_FLAG_END_USER);
+}
+
+static void demux_smjpeg_close (demux_plugin_t *this_gen) {
+ demux_smjpeg_t *this = (demux_smjpeg_t *) this_gen;
+
+ pthread_mutex_destroy (&this->mutex);
+ free(this);
+}
+
+static int demux_smjpeg_get_status (demux_plugin_t *this_gen) {
+ demux_smjpeg_t *this = (demux_smjpeg_t *) this_gen;
+
+ return this->status;
+}
+
+static char *demux_smjpeg_get_id(void) {
+ return "SMJPEG";
+}
+
+static int demux_smjpeg_get_stream_length (demux_plugin_t *this_gen) {
+ demux_smjpeg_t *this = (demux_smjpeg_t *) this_gen;
+
+ /* return total running time in seconds */
+ return this->duration / 1000;
+}
+
+static char *demux_smjpeg_get_mimetypes(void) {
+ return NULL;
+}
+
+demux_plugin_t *init_demuxer_plugin(int iface, xine_t *xine) {
+ demux_smjpeg_t *this;
+
+ if (iface != 10) {
+ printf (_("demux_smjpeg: plugin doesn't support plugin API version %d.\n"
+ " this means there's a version mismatch between xine and this "
+ " demuxer plugin. Installing current demux plugins should help.\n"),
+ iface);
+ return NULL;
+ }
+
+ this = (demux_smjpeg_t *) xine_xmalloc(sizeof(demux_smjpeg_t));
+ this->config = xine->config;
+ this->xine = xine;
+
+ (void *) this->config->register_string(this->config,
+ "mrl.ends_film", VALID_ENDS,
+ _("valid mrls ending for film demuxer"),
+ NULL, NULL, NULL);
+
+ this->demux_plugin.interface_version = DEMUXER_PLUGIN_IFACE_VERSION;
+ this->demux_plugin.open = demux_smjpeg_open;
+ this->demux_plugin.start = demux_smjpeg_start;
+ this->demux_plugin.seek = demux_smjpeg_seek;
+ this->demux_plugin.stop = demux_smjpeg_stop;
+ this->demux_plugin.close = demux_smjpeg_close;
+ this->demux_plugin.get_status = demux_smjpeg_get_status;
+ this->demux_plugin.get_identifier = demux_smjpeg_get_id;
+ this->demux_plugin.get_stream_length = demux_smjpeg_get_stream_length;
+ this->demux_plugin.get_mimetypes = demux_smjpeg_get_mimetypes;
+
+ this->status = DEMUX_FINISHED;
+ pthread_mutex_init(&this->mutex, NULL);
+
+ return &this->demux_plugin;
+}
+
diff --git a/src/demuxers/demux_wav.c b/src/demuxers/demux_wav.c
new file mode 100644
index 000000000..91919b9c2
--- /dev/null
+++ b/src/demuxers/demux_wav.c
@@ -0,0 +1,500 @@
+/*
+ * Copyright (C) 2001-2002 the xine project
+ *
+ * This file is part of xine, a free 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
+ *
+ * MS WAV File Demuxer by Mike Melanson (melanson@pcisys.net)
+ * based on WAV specs that are available far and wide
+ *
+ * $Id: demux_wav.c,v 1.1 2002/07/07 01:24:40 tmmm Exp $
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <pthread.h>
+#include <string.h>
+#include <stdlib.h>
+#include <ctype.h>
+
+#include "xine_internal.h"
+#include "xineutils.h"
+#include "demux.h"
+#include "buffer.h"
+#include "bswap.h"
+
+#define LE_16(x) (le2me_16(*(uint16_t *)(x)))
+#define LE_32(x) (le2me_32(*(uint32_t *)(x)))
+
+#define VALID_ENDS "wav"
+#define WAV_SIGNATURE_SIZE 16
+#define WAV_HEADER_MAX_SIZE 0x14
+/* this is the hex value for 'data' */
+#define data_TAG 0x61746164
+#define PCM_BLOCK_ALIGN 1024
+
+typedef struct {
+
+ demux_plugin_t demux_plugin;
+
+ xine_t *xine;
+
+ config_values_t *config;
+
+ fifo_buffer_t *video_fifo;
+ fifo_buffer_t *audio_fifo;
+
+ input_plugin_t *input;
+
+ pthread_t thread;
+ int thread_running;
+ pthread_mutex_t mutex;
+ int send_end_buffers;
+ int status;
+
+ xine_waveformatex wave;
+ unsigned int audio_type;
+
+ off_t data_start;
+ off_t data_size;
+ off_t data_end;
+
+ int seek_flag; /* this is set when a seek just occurred */
+} demux_wav_t;
+
+static void *demux_wav_loop (void *this_gen) {
+
+ demux_wav_t *this = (demux_wav_t *) this_gen;
+ buf_element_t *buf = NULL;
+ unsigned int remaining_sample_bytes;
+ off_t current_file_pos;
+ int64_t current_pts;
+
+ pthread_mutex_lock( &this->mutex );
+ this->seek_flag = 1;
+
+ /* do-while needed to seek after demux finished */
+ do {
+ /* main demuxer loop */
+ while (this->status == DEMUX_OK) {
+
+ /* someone may want to interrupt us */
+ pthread_mutex_unlock( &this->mutex );
+ pthread_mutex_lock( &this->mutex );
+
+ /* just load data chunks from wherever the stream happens to be
+ * pointing; issue a DEMUX_FINISHED status is EOF is reached */
+ remaining_sample_bytes = this->wave.nBlockAlign;
+ current_file_pos = this->input->get_current_pos(this->input);
+
+ current_pts = current_file_pos;
+ current_pts -= this->data_start;
+ current_pts *= 90000;
+ current_pts /= this->wave.nAvgBytesPerSec;
+
+ if (this->seek_flag) {
+ xine_demux_control_newpts(this->xine, current_pts, 0);
+ this->seek_flag = 0;
+ }
+
+ while (remaining_sample_bytes) {
+ buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo);
+ buf->content = buf->mem;
+ buf->type = this->audio_type;
+ buf->input_pos = current_file_pos;
+ buf->input_length = this->data_end;
+ buf->input_time = current_pts / 90000;
+ buf->pts = current_pts;
+ buf->decoder_flags = 0;
+
+ if (remaining_sample_bytes > buf->max_size)
+ buf->size = buf->max_size;
+ else
+ buf->size = remaining_sample_bytes;
+ remaining_sample_bytes -= buf->size;
+
+ if (this->input->read(this->input, buf->content, buf->size) !=
+ buf->size) {
+ this->status = DEMUX_FINISHED;
+ break;
+ }
+
+ if (!remaining_sample_bytes)
+ buf->decoder_flags |= BUF_FLAG_FRAME_END;
+
+ buf->decoder_info[1] = this->wave.nSamplesPerSec;
+ buf->decoder_info[2] = this->wave.wBitsPerSample;
+ buf->decoder_info[3] = this->wave.nChannels;
+ this->audio_fifo->put (this->audio_fifo, buf);
+ }
+ }
+
+ /* wait before sending end buffers: user might want to do a new seek */
+ while(this->send_end_buffers && this->video_fifo->size(this->video_fifo) &&
+ this->status != DEMUX_OK){
+ pthread_mutex_unlock( &this->mutex );
+ xine_usec_sleep(100000);
+ pthread_mutex_lock( &this->mutex );
+ }
+
+ } while (this->status == DEMUX_OK);
+
+ printf ("demux_wav: demux loop finished (status: %d)\n",
+ this->status);
+
+ this->status = DEMUX_FINISHED;
+
+ if (this->send_end_buffers) {
+ xine_demux_control_end(this->xine, BUF_FLAG_END_STREAM);
+ }
+
+ this->thread_running = 0;
+ pthread_mutex_unlock(&this->mutex);
+ return NULL;
+}
+
+static int demux_wav_open(demux_plugin_t *this_gen,
+ input_plugin_t *input, int stage) {
+
+ demux_wav_t *this = (demux_wav_t *) this_gen;
+ unsigned char signature[WAV_SIGNATURE_SIZE];
+
+ this->input = input;
+
+ switch(stage) {
+ case STAGE_BY_CONTENT: {
+ if ((input->get_capabilities(input) & INPUT_CAP_SEEKABLE) == 0)
+ return DEMUX_CANNOT_HANDLE;
+
+ input->seek(input, 0, SEEK_SET);
+ if (input->read(input, signature, WAV_SIGNATURE_SIZE) !=
+ WAV_SIGNATURE_SIZE)
+ return DEMUX_CANNOT_HANDLE;
+
+ /* check the signature */
+ if ((signature[0] == 'R') &&
+ (signature[1] == 'I') &&
+ (signature[2] == 'F') &&
+ (signature[3] == 'F') &&
+ (signature[8] == 'W') &&
+ (signature[9] == 'A') &&
+ (signature[10] == 'V') &&
+ (signature[11] == 'E') &&
+ (signature[12] == 'f') &&
+ (signature[13] == 'm') &&
+ (signature[14] == 't') &&
+ (signature[15] == ' '))
+ return DEMUX_CAN_HANDLE;
+
+ return DEMUX_CANNOT_HANDLE;
+ }
+ break;
+
+ case STAGE_BY_EXTENSION: {
+ char *suffix;
+ char *MRL;
+ char *m, *valid_ends;
+
+ MRL = input->get_mrl (input);
+
+ suffix = strrchr(MRL, '.');
+
+ if(!suffix)
+ return DEMUX_CANNOT_HANDLE;
+
+ xine_strdupa(valid_ends, (this->config->register_string(this->config,
+ "mrl.ends_wav", VALID_ENDS,
+ _("valid mrls ending for wav demuxer"),
+ NULL, NULL, NULL))); while((m = xine_strsep(&valid_ends, ",")) != NULL) {
+
+ while(*m == ' ' || *m == '\t') m++;
+
+ if(!strcasecmp((suffix + 1), m)) {
+ this->input = input;
+ return DEMUX_CAN_HANDLE;
+ }
+ }
+ return DEMUX_CANNOT_HANDLE;
+ }
+ break;
+
+ default:
+ return DEMUX_CANNOT_HANDLE;
+ break;
+ }
+
+ return DEMUX_CANNOT_HANDLE;
+}
+
+static int demux_wav_start (demux_plugin_t *this_gen,
+ fifo_buffer_t *video_fifo,
+ fifo_buffer_t *audio_fifo,
+ off_t start_pos, int start_time) {
+
+ demux_wav_t *this = (demux_wav_t *) this_gen;
+ buf_element_t *buf;
+ int err;
+ unsigned int chunk_tag;
+ unsigned int chunk_size;
+ unsigned char chunk_preamble[8];
+ unsigned int wav_header_size;
+ unsigned char wav_header[WAV_HEADER_MAX_SIZE];
+
+ pthread_mutex_lock(&this->mutex);
+
+ /* if thread is not running, initialize demuxer */
+ if (!this->thread_running) {
+ this->video_fifo = video_fifo;
+ this->audio_fifo = audio_fifo;
+
+ /* go straight for the format structure */
+ this->input->seek(this->input, WAV_SIGNATURE_SIZE, SEEK_SET);
+ if (this->input->read(this->input,
+ (unsigned char *)&wav_header_size, 4) != 4) {
+ this->status = DEMUX_FINISHED;
+ pthread_mutex_unlock(&this->mutex);
+ return this->status;
+ }
+ wav_header_size = le2me_32(wav_header_size);
+ if (this->input->read(this->input, wav_header, wav_header_size) !=
+ wav_header_size) {
+ this->status = DEMUX_FINISHED;
+ pthread_mutex_unlock(&this->mutex);
+ return this->status;
+ }
+ memcpy(&this->wave, wav_header, sizeof(this->wave));
+ xine_waveformatex_le2me(&this->wave);
+ this->audio_type = formattag_to_buf_audio(this->wave.wFormatTag);
+ if(!this->audio_type) {
+ xine_report_codec( this->xine, XINE_CODEC_AUDIO, this->audio_type, 0, 0);
+ this->status = DEMUX_FINISHED;
+ pthread_mutex_unlock(&this->mutex);
+ return this->status;
+ }
+
+ /* traverse through the chunks to find the 'data' chunk */
+ this->data_start = this->data_size = this->data_end = 0;
+ while (this->data_start == 0) {
+
+ if (this->input->read(this->input, chunk_preamble, 8) != 8) {
+ this->status = DEMUX_FINISHED;
+ pthread_mutex_unlock(&this->mutex);
+ return this->status;
+ }
+ chunk_tag = LE_32(&chunk_preamble[0]);
+ chunk_size = LE_32(&chunk_preamble[4]);
+
+ if (chunk_tag == data_TAG) {
+ this->data_start = this->input->get_current_pos(this->input);
+ this->data_size = chunk_size;
+ this->data_end = this->data_start + chunk_size;
+ } else {
+ this->input->seek(this->input, chunk_size, SEEK_CUR);
+ }
+ }
+
+ /* print vital stats */
+ xine_log(this->xine, XINE_LOG_FORMAT,
+ _("demux_wav: format 0x%X audio, %d Hz, %d bits/sample, %d channel%c\n"),
+ this->wave.wFormatTag,
+ this->wave.nSamplesPerSec,
+ this->wave.wBitsPerSample,
+ this->wave.nChannels,
+ (this->wave.nChannels == 1) ? ' ' : 's');
+ xine_log(this->xine, XINE_LOG_FORMAT,
+ _("demux_wav: running time = %d min, %d sec\n"),
+ this->data_size / this->wave.nAvgBytesPerSec / 60,
+ this->data_size / this->wave.nAvgBytesPerSec % 60);
+ xine_log(this->xine, XINE_LOG_FORMAT,
+ _("demux_wav: average bytes/sec = %d, block alignment = %d\n"),
+ this->wave.nAvgBytesPerSec,
+ this->wave.nBlockAlign);
+
+ /* special block alignment hack so that the demuxer doesn't send
+ * packets with individual PCM samples */
+ if ((this->wave.nAvgBytesPerSec / this->wave.nBlockAlign) ==
+ this->wave.nSamplesPerSec)
+ this->wave.nBlockAlign = PCM_BLOCK_ALIGN;
+
+ /* send start buffers */
+ xine_demux_control_start(this->xine);
+
+ /* send init info to decoders */
+ if (this->audio_fifo && this->audio_type) {
+ buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo);
+ buf->content = buf->mem;
+ buf->type = this->audio_type;
+ buf->decoder_flags = BUF_FLAG_HEADER;
+ buf->decoder_info[0] = 0;
+ buf->decoder_info[1] = this->wave.nSamplesPerSec;
+ buf->decoder_info[2] = this->wave.wBitsPerSample;
+ buf->decoder_info[3] = this->wave.nChannels;
+ memcpy(buf->content, &this->wave, sizeof(this->wave));
+ buf->size = sizeof(this->wave);
+ this->audio_fifo->put (this->audio_fifo, buf);
+ }
+
+ this->status = DEMUX_OK;
+ this->send_end_buffers = 1;
+ this->thread_running = 1;
+
+ if ((err = pthread_create (&this->thread, NULL, demux_wav_loop, this)) != 0) {
+ printf ("demux_wav: can't create new thread (%s)\n", strerror(err));
+ abort();
+ }
+ }
+
+ pthread_mutex_unlock(&this->mutex);
+
+ return this->status;
+}
+
+static int demux_wav_seek (demux_plugin_t *this_gen,
+ off_t start_pos, int start_time) {
+
+ demux_wav_t *this = (demux_wav_t *) this_gen;
+ int status;
+ off_t data_offset;
+
+ pthread_mutex_lock(&this->mutex);
+
+ /* check the boundary offsets */
+ if (start_pos < this->data_start)
+ this->input->seek(this->input, this->data_start, SEEK_SET);
+ else if (start_pos >= this->data_end) {
+ this->status = DEMUX_FINISHED;
+ status = this->status;
+ pthread_mutex_unlock(&this->mutex);
+ return status;
+ } else {
+ /* This function must seek along the block alignment. Determine how
+ * far into the data the requested offset lies, divide the diff
+ * by the block alignment integer-wise, and multiply that by the
+ * block alignment to get the new aligned offset. */
+ data_offset = start_pos - this->data_start;
+ data_offset /= this->wave.nBlockAlign;
+ data_offset *= this->wave.nBlockAlign;
+ data_offset += this->data_start;
+
+ this->input->seek(this->input, data_offset, SEEK_SET);
+ }
+
+ this->seek_flag = 1;
+ status = this->status = DEMUX_OK;
+ pthread_mutex_unlock(&this->mutex);
+
+ return status;
+}
+
+static void demux_wav_stop (demux_plugin_t *this_gen) {
+
+ demux_wav_t *this = (demux_wav_t *) this_gen;
+ void *p;
+
+ pthread_mutex_lock( &this->mutex );
+
+ if (!this->thread_running) {
+ pthread_mutex_unlock( &this->mutex );
+ return;
+ }
+
+ /* seek back to the beginning of the data in preparation for another
+ * start */
+ this->input->seek(this->input, this->data_start, SEEK_SET);
+
+ this->send_end_buffers = 0;
+ this->status = DEMUX_FINISHED;
+
+ pthread_mutex_unlock( &this->mutex );
+ pthread_join (this->thread, &p);
+
+ xine_demux_flush_engine(this->xine);
+
+ xine_demux_control_end(this->xine, BUF_FLAG_END_USER);
+}
+
+static void demux_wav_close (demux_plugin_t *this_gen) {
+ demux_wav_t *this = (demux_wav_t *) this_gen;
+
+ pthread_mutex_destroy (&this->mutex);
+ free(this);
+}
+
+static int demux_wav_get_status (demux_plugin_t *this_gen) {
+ demux_wav_t *this = (demux_wav_t *) this_gen;
+
+ return this->status;
+}
+
+static char *demux_wav_get_id(void) {
+ return "WAV";
+}
+
+static char *demux_wav_get_mimetypes(void) {
+ return NULL;
+}
+
+/* return the approximate length in seconds */
+static int demux_wav_get_stream_length (demux_plugin_t *this_gen) {
+
+ demux_wav_t *this = (demux_wav_t *) this_gen;
+
+ return (int)(this->data_size / this->wave.nAvgBytesPerSec);
+}
+
+demux_plugin_t *init_demuxer_plugin(int iface, xine_t *xine) {
+
+ demux_wav_t *this;
+
+ if (iface != 10) {
+ printf (_("demux_wav: plugin doesn't support plugin API version %d.\n"
+ " this means there's a version mismatch between xine and this "
+ " demuxer plugin.\nInstalling current demux plugins should help.\n"),
+ iface);
+ return NULL;
+ }
+
+ this = xine_xmalloc (sizeof (demux_wav_t));
+ this->config = xine->config;
+ this->xine = xine;
+
+ (void*) this->config->register_string(this->config,
+ "mrl.ends_wav", VALID_ENDS,
+ _("valid mrls ending for wav demuxer"),
+ NULL, NULL, NULL);
+
+ this->demux_plugin.interface_version = DEMUXER_PLUGIN_IFACE_VERSION;
+ this->demux_plugin.open = demux_wav_open;
+ this->demux_plugin.start = demux_wav_start;
+ this->demux_plugin.seek = demux_wav_seek;
+ this->demux_plugin.stop = demux_wav_stop;
+ this->demux_plugin.close = demux_wav_close;
+ this->demux_plugin.get_status = demux_wav_get_status;
+ this->demux_plugin.get_identifier = demux_wav_get_id;
+ this->demux_plugin.get_stream_length = demux_wav_get_stream_length;
+ this->demux_plugin.get_mimetypes = demux_wav_get_mimetypes;
+
+ this->status = DEMUX_FINISHED;
+ pthread_mutex_init( &this->mutex, NULL );
+
+ return (demux_plugin_t *) this;
+}