summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/demuxers/Makefile.am2
-rw-r--r--src/demuxers/demux_vox.c295
-rw-r--r--src/demuxers/group_audio.c4
3 files changed, 299 insertions, 2 deletions
diff --git a/src/demuxers/Makefile.am b/src/demuxers/Makefile.am
index 35d8b763c..7a7a34df8 100644
--- a/src/demuxers/Makefile.am
+++ b/src/demuxers/Makefile.am
@@ -109,7 +109,7 @@ xineplug_dmx_games_la_LDFLAGS = -avoid-version -module @XINE_PLUGIN_MIN_SYMS@
xineplug_dmx_audio_la_SOURCES = group_audio.c demux_aud.c demux_aiff.c \
demux_cdda.c demux_mpgaudio.c demux_realaudio.c \
- demux_snd.c demux_voc.c demux_wav.c
+ demux_snd.c demux_voc.c demux_vox.c demux_wav.c
xineplug_dmx_audio_la_LIBADD = $(XINELIB)
xineplug_dmx_audio_la_LDFLAGS = -avoid-version -module @XINE_PLUGIN_MIN_SYMS@
diff --git a/src/demuxers/demux_vox.c b/src/demuxers/demux_vox.c
new file mode 100644
index 000000000..91659516b
--- /dev/null
+++ b/src/demuxers/demux_vox.c
@@ -0,0 +1,295 @@
+/*
+ * Copyright (C) 2001-2003 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
+ *
+ * VOX Demuxer by Mike Melanson (melanson@pcisys.net)
+ * This a demuxer for .vox files containing raw Dialogic ADPCM data.
+ *
+ * $Id: demux_vox.c,v 1.1 2003/01/07 06:29:16 tmmm Exp $
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h>
+#include <fcntl.h>
+#include <unistd.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 DIALOGIC_SAMPLERATE 8000
+
+typedef struct {
+
+ demux_plugin_t demux_plugin;
+
+ xine_stream_t *stream;
+
+ config_values_t *config;
+
+ fifo_buffer_t *video_fifo;
+ fifo_buffer_t *audio_fifo;
+
+ input_plugin_t *input;
+
+ int status;
+
+ char last_mrl[1024];
+} demux_vox_t;
+
+typedef struct {
+
+ demux_class_t demux_class;
+
+ /* class-wide, global variables here */
+
+ xine_t *xine;
+ config_values_t *config;
+} demux_vox_class_t;
+
+static int demux_vox_send_chunk (demux_plugin_t *this_gen) {
+
+ demux_vox_t *this = (demux_vox_t *) this_gen;
+ buf_element_t *buf = NULL;
+ off_t current_file_pos;
+ int64_t audio_pts;
+ int bytes_read;
+
+ current_file_pos = this->input->get_current_pos(this->input);
+ audio_pts = current_file_pos;
+ /* each byte is 2 samples */
+ audio_pts *= 2 * 90000;
+ audio_pts /= DIALOGIC_SAMPLERATE;
+
+ /* read a buffer-sized block from the stream; if there is less than a
+ * buffer of data, send whatever there is; if there are no bytes returned,
+ * demux is finished */
+ buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo);
+ buf->type = BUF_AUDIO_DIALOGIC_IMA;
+ bytes_read = this->input->read(this->input, buf->content, buf->max_size);
+ if (bytes_read == 0) {
+ buf->free_buffer(buf);
+ this->status = DEMUX_FINISHED;
+ return this->status;
+ } else if (bytes_read < buf->max_size)
+ buf->size = bytes_read;
+ else
+ buf->size = buf->max_size;
+
+ buf->extra_info->input_pos = current_file_pos;
+ buf->extra_info->input_length = this->input->get_length(this->input);
+ buf->extra_info->input_time = audio_pts / 90000;
+ buf->pts = audio_pts;
+ buf->decoder_flags |= BUF_FLAG_FRAME_END;
+
+ this->audio_fifo->put (this->audio_fifo, buf);
+
+ return this->status;
+}
+
+static void demux_vox_send_headers(demux_plugin_t *this_gen) {
+
+ demux_vox_t *this = (demux_vox_t *) this_gen;
+ buf_element_t *buf;
+
+ this->video_fifo = this->stream->video_fifo;
+ this->audio_fifo = this->stream->audio_fifo;
+
+ this->status = DEMUX_OK;
+
+ /* load stream information */
+ this->stream->stream_info[XINE_STREAM_INFO_HAS_VIDEO] = 0;
+ this->stream->stream_info[XINE_STREAM_INFO_HAS_AUDIO] = 1;
+ this->stream->stream_info[XINE_STREAM_INFO_AUDIO_CHANNELS] = 1;
+ this->stream->stream_info[XINE_STREAM_INFO_AUDIO_SAMPLERATE] = DIALOGIC_SAMPLERATE;
+ this->stream->stream_info[XINE_STREAM_INFO_AUDIO_BITS] = 16;
+
+ /* send start buffers */
+ xine_demux_control_start(this->stream);
+
+ /* send init info to decoders */
+ if (this->audio_fifo) {
+ buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo);
+ buf->type = BUF_AUDIO_DIALOGIC_IMA;
+ buf->decoder_flags = BUF_FLAG_HEADER;
+ buf->decoder_info[0] = 0;
+ buf->decoder_info[1] = DIALOGIC_SAMPLERATE;
+ buf->decoder_info[2] = 16;
+ buf->decoder_info[3] = 1;
+ buf->size = 0;
+ this->audio_fifo->put (this->audio_fifo, buf);
+ }
+}
+
+static int demux_vox_seek (demux_plugin_t *this_gen,
+ off_t start_pos, int start_time) {
+
+ demux_vox_t *this = (demux_vox_t *) this_gen;
+
+ /* if thread is not running, initialize demuxer */
+ if( !this->stream->demux_thread_running ) {
+
+ /* send new pts */
+ xine_demux_control_newpts(this->stream, 0, 0);
+
+ this->status = DEMUX_OK;
+
+ /* start at the beginning of the file */
+ this->input->seek(this->input, 0, SEEK_SET);
+ }
+
+ return this->status;
+}
+
+static void demux_vox_dispose (demux_plugin_t *this_gen) {
+ demux_vox_t *this = (demux_vox_t *) this_gen;
+
+ free(this);
+}
+
+static int demux_vox_get_status (demux_plugin_t *this_gen) {
+ demux_vox_t *this = (demux_vox_t *) this_gen;
+
+ return this->status;
+}
+
+/* return the approximate length in seconds */
+static int demux_vox_get_stream_length (demux_plugin_t *this_gen) {
+
+ demux_vox_t *this = (demux_vox_t *) this_gen;
+
+ return this->input->get_length(this->input) * 2 / DIALOGIC_SAMPLERATE;
+}
+
+static uint32_t demux_vox_get_capabilities(demux_plugin_t *this_gen) {
+ return DEMUX_CAP_NOCAP;
+}
+
+static int demux_vox_get_optional_data(demux_plugin_t *this_gen,
+ void *data, int data_type) {
+ return DEMUX_OPTIONAL_UNSUPPORTED;
+}
+
+static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *stream,
+ input_plugin_t *input_gen) {
+
+ input_plugin_t *input = (input_plugin_t *) input_gen;
+ demux_vox_t *this;
+
+ this = xine_xmalloc (sizeof (demux_vox_t));
+ this->stream = stream;
+ this->input = input;
+
+ this->demux_plugin.send_headers = demux_vox_send_headers;
+ this->demux_plugin.send_chunk = demux_vox_send_chunk;
+ this->demux_plugin.seek = demux_vox_seek;
+ this->demux_plugin.dispose = demux_vox_dispose;
+ this->demux_plugin.get_status = demux_vox_get_status;
+ this->demux_plugin.get_stream_length = demux_vox_get_stream_length;
+ this->demux_plugin.get_video_frame = NULL;
+ this->demux_plugin.got_video_frame_cb= NULL;
+ this->demux_plugin.get_capabilities = demux_vox_get_capabilities;
+ this->demux_plugin.get_optional_data = demux_vox_get_optional_data;
+ this->demux_plugin.demux_class = class_gen;
+
+ this->status = DEMUX_FINISHED;
+
+ switch (stream->content_detection_method) {
+
+ case METHOD_BY_CONTENT:
+ case METHOD_EXPLICIT:
+ case METHOD_BY_EXTENSION: {
+ char *ending, *mrl;
+
+ mrl = input->get_mrl (input);
+
+ ending = strrchr(mrl, '.');
+
+ if (!ending) {
+ free (this);
+ return NULL;
+ }
+
+ if (strncasecmp (ending, ".vox", 4)) {
+ free (this);
+ return NULL;
+ }
+
+ }
+ break;
+
+ default:
+ free (this);
+ return NULL;
+ }
+
+ strncpy (this->last_mrl, input->get_mrl (input), 1024);
+
+ return &this->demux_plugin;
+}
+
+static char *get_description (demux_class_t *this_gen) {
+ return "Dialogic VOX file demux plugin";
+}
+
+static char *get_identifier (demux_class_t *this_gen) {
+ return "VOX";
+}
+
+static char *get_extensions (demux_class_t *this_gen) {
+ return "vox";
+}
+
+static char *get_mimetypes (demux_class_t *this_gen) {
+ return NULL;
+}
+
+static void class_dispose (demux_class_t *this_gen) {
+
+ demux_vox_class_t *this = (demux_vox_class_t *) this_gen;
+
+ free (this);
+}
+
+void *demux_vox_init_plugin (xine_t *xine, void *data) {
+
+ demux_vox_class_t *this;
+
+ this = xine_xmalloc (sizeof (demux_vox_class_t));
+ this->config = xine->config;
+ this->xine = xine;
+
+ this->demux_class.open_plugin = open_plugin;
+ this->demux_class.get_description = get_description;
+ this->demux_class.get_identifier = get_identifier;
+ this->demux_class.get_mimetypes = get_mimetypes;
+ this->demux_class.get_extensions = get_extensions;
+ this->demux_class.dispose = class_dispose;
+
+ return this;
+}
+
diff --git a/src/demuxers/group_audio.c b/src/demuxers/group_audio.c
index 8e93e2a9e..4622e9a03 100644
--- a/src/demuxers/group_audio.c
+++ b/src/demuxers/group_audio.c
@@ -19,7 +19,7 @@
*
* This file contains plugin entries for several demuxers used in games
*
- * $Id: group_audio.c,v 1.2 2003/01/05 14:30:14 miguelfreitas Exp $
+ * $Id: group_audio.c,v 1.3 2003/01/07 06:29:16 tmmm Exp $
*/
#ifdef HAVE_CONFIG_H
@@ -37,6 +37,7 @@ void *demux_mpgaudio_init_class (xine_t *xine, void *data);
void *demux_realaudio_init_plugin (xine_t *xine, void *data);
void *demux_snd_init_plugin (xine_t *xine, void *data);
void *demux_voc_init_plugin (xine_t *xine, void *data);
+void *demux_vox_init_plugin (xine_t *xine, void *data);
void *demux_wav_init_plugin (xine_t *xine, void *data);
/*
@@ -52,6 +53,7 @@ plugin_info_t xine_plugin_info[] = {
{ PLUGIN_DEMUX, 20, "realaudio", XINE_VERSION_CODE, NULL, demux_realaudio_init_plugin },
{ PLUGIN_DEMUX, 20, "snd", XINE_VERSION_CODE, NULL, demux_snd_init_plugin },
{ PLUGIN_DEMUX, 20, "voc", XINE_VERSION_CODE, NULL, demux_voc_init_plugin },
+ { PLUGIN_DEMUX, 20, "vox", XINE_VERSION_CODE, NULL, demux_vox_init_plugin },
{ PLUGIN_DEMUX, 20, "wav", XINE_VERSION_CODE, NULL, demux_wav_init_plugin },
{ PLUGIN_NONE, 0, "", 0, NULL, NULL }
};