summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Zuehlke <andruil@users.sourceforge.net>2003-07-03 00:58:51 +0000
committerMarco Zuehlke <andruil@users.sourceforge.net>2003-07-03 00:58:51 +0000
commit47c9d902db7454b476ed48f90b7743dffe64281c (patch)
tree6ae7215333ff0e55a2493aa841668014e78b37a3
parent2bec19f4ff74d64f11f3e5655047122d7b4823a9 (diff)
downloadxine-lib-47c9d902db7454b476ed48f90b7743dffe64281c.tar.gz
xine-lib-47c9d902db7454b476ed48f90b7743dffe64281c.tar.bz2
cleaning up; removing unused stuff
CVS patchset: 5124 CVS date: 2003/07/03 00:58:51
-rw-r--r--src/demuxers/demux_4xm.c99
-rw-r--r--src/demuxers/demux_ac3.c79
-rw-r--r--src/demuxers/demux_aiff.c95
-rw-r--r--src/demuxers/demux_aud.c97
-rw-r--r--src/input/input_plugin.h9
5 files changed, 108 insertions, 271 deletions
diff --git a/src/demuxers/demux_4xm.c b/src/demuxers/demux_4xm.c
index d83df7771..60ff7dde2 100644
--- a/src/demuxers/demux_4xm.c
+++ b/src/demuxers/demux_4xm.c
@@ -16,12 +16,14 @@
* 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
- *
+ */
+
+/*
* 4X Technologies (.4xm) File Demuxer by Mike Melanson (melanson@pcisys.net)
* For more information on the 4xm file format, visit:
* http://www.pcisys.net/~melanson/codecs/
*
- * $Id: demux_4xm.c,v 1.2 2003/06/21 22:33:49 tmmm Exp $
+ * $Id: demux_4xm.c,v 1.3 2003/07/03 00:58:52 andruil Exp $
*/
#ifdef HAVE_CONFIG_H
@@ -34,6 +36,11 @@
#include <string.h>
#include <stdlib.h>
+/********** logging **********/
+#define LOG_MODULE "demux_4xm"
+/* #define LOG_VERBOSE */
+/* #define LOG */
+
#include "xine_internal.h"
#include "xineutils.h"
#include "compat.h"
@@ -73,21 +80,14 @@ typedef struct AudioTrack {
} audio_track_t;
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;
-
- off_t data_start;
- off_t data_size;
int status;
+
unsigned int filesize;
xine_bmiheader bih;
@@ -98,17 +98,10 @@ typedef struct {
int64_t pts;
int last_chunk_was_audio;
int last_audio_frame_count;
-
} demux_fourxm_t;
typedef struct {
-
demux_class_t demux_class;
-
- /* class-wide, global variables here */
-
- xine_t *xine;
- config_values_t *config;
} demux_fourxm_class_t;
/* Open a 4xm file
@@ -116,7 +109,7 @@ typedef struct {
* It returns 1 if 4xm file was opened successfully. */
static int open_fourxm_file(demux_fourxm_t *fourxm) {
- unsigned char preview[MAX_PREVIEW_SIZE];
+ unsigned char preview[12];
int header_size;
unsigned char *header;
int i;
@@ -124,33 +117,23 @@ static int open_fourxm_file(demux_fourxm_t *fourxm) {
unsigned int size;
unsigned int current_track;
- if (fourxm->input->get_capabilities(fourxm->input) & INPUT_CAP_SEEKABLE) {
- /* reset the file */
- fourxm->input->seek(fourxm->input, 0, SEEK_SET);
-
- /* the file signature will be in the first 12 bytes */
- if (fourxm->input->read(fourxm->input, preview, 12) != 12) {
- return 0;
- }
- } else {
- fourxm->input->get_optional_data(fourxm->input, preview,
- INPUT_OPTIONAL_DATA_PREVIEW);
- }
+ /* the file signature will be in the first 12 bytes */
+ if (xine_demux_read_header(fourxm->input, preview, 12) != 12)
+ return 0;
/* check for the signature tags */
if ((LE_32(&preview[0]) != RIFF_TAG) ||
(LE_32(&preview[8]) != _4XMV_TAG))
return 0;
- /* file is qualified; if the input was not seekable, skip over the header
- * bytes in the stream */
- if ((fourxm->input->get_capabilities(fourxm->input) & INPUT_CAP_SEEKABLE) == 0) {
- fourxm->input->seek(fourxm->input, 12, SEEK_SET);
- }
+ /* file is qualified; skip over the header bytes in the stream */
+ fourxm->input->seek(fourxm->input, 12, SEEK_SET);
+ /* seems to be unnecessary (see end of function)
fourxm->filesize = LE_32(&preview[8]);
if (fourxm->filesize == 0)
fourxm->filesize = 0xFFFFFFFF;
+ */
/* fetch the LIST-HEAD header */
if (fourxm->input->read(fourxm->input, preview, 12) != 12)
@@ -162,8 +145,10 @@ static int open_fourxm_file(demux_fourxm_t *fourxm) {
/* read the whole header */
header_size = LE_32(&preview[4]) - 4;
header = xine_xmalloc(header_size);
- if (fourxm->input->read(fourxm->input, header, header_size) != header_size)
+ if (fourxm->input->read(fourxm->input, header, header_size) != header_size) {
+ free(header);
return 0;
+ }
fourxm->bih.biWidth = 0;
fourxm->bih.biHeight = 0;
@@ -196,7 +181,7 @@ static int open_fourxm_file(demux_fourxm_t *fourxm) {
current_track = LE_32(&header[i + 8]);
if (current_track + 1 > fourxm->track_count) {
fourxm->track_count = current_track + 1;
- fourxm->tracks = realloc(fourxm->tracks,
+ fourxm->tracks = realloc(fourxm->tracks,
fourxm->track_count * sizeof(audio_track_t));
if (!fourxm->tracks) {
free(header);
@@ -207,7 +192,7 @@ static int open_fourxm_file(demux_fourxm_t *fourxm) {
fourxm->tracks[current_track].channels = LE_32(&header[i + 36]);
fourxm->tracks[current_track].sample_rate = LE_32(&header[i + 40]);
fourxm->tracks[current_track].bits = LE_32(&header[i + 44]);
- fourxm->tracks[current_track].audio_type =
+ fourxm->tracks[current_track].audio_type =
BUF_AUDIO_LPCM_LE + (current_track & 0x0000FFFF);
i += 8 + size;
}
@@ -308,8 +293,8 @@ static int demux_fourxm_send_chunk(demux_plugin_t *this_gen) {
size = LE_32(&header[4]);
if (current_track >= this->track_count) {
- printf ("bad audio track number (%d >= %d)\n", current_track,
- this->track_count);
+ lprintf ("bad audio track number (%d >= %d)\n",
+ current_track, this->track_count);
this->status = DEMUX_FINISHED;
return this->status;
}
@@ -452,9 +437,8 @@ static int demux_fourxm_get_optional_data(demux_plugin_t *this_gen,
}
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 = (input_plugin_t *) input_gen;
demux_fourxm_t *this;
this = xine_xmalloc (sizeof (demux_fourxm_t));
@@ -477,40 +461,27 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
switch (stream->content_detection_method) {
- case METHOD_BY_CONTENT:
- case METHOD_EXPLICIT:
-
- if (!open_fourxm_file(this)) {
- free (this);
- return NULL;
- }
-
- break;
-
case METHOD_BY_EXTENSION: {
- char *ending, *mrl;
+ char *extensions, *mrl;
mrl = input->get_mrl (input);
+ extensions = class_gen->get_extensions (class_gen);
- ending = strrchr(mrl, '.');
-
- if (!ending) {
+ if (!xine_demux_check_extension (mrl, extensions)) {
free (this);
return NULL;
}
+ }
+ /* falling through is intended */
- if (strncasecmp (ending, ".4xm", 4)) {
- free (this);
- return NULL;
- }
+ case METHOD_BY_CONTENT:
+ case METHOD_EXPLICIT:
if (!open_fourxm_file(this)) {
free (this);
return NULL;
}
- }
-
break;
default:
@@ -548,9 +519,7 @@ void *demux_fourxm_init_plugin (xine_t *xine, void *data) {
demux_fourxm_class_t *this;
- this = xine_xmalloc (sizeof (demux_fourxm_class_t));
- this->config = xine->config;
- this->xine = xine;
+ this = xine_xmalloc (sizeof (demux_fourxm_class_t));
this->demux_class.open_plugin = open_plugin;
this->demux_class.get_description = get_description;
diff --git a/src/demuxers/demux_ac3.c b/src/demuxers/demux_ac3.c
index 2e2945403..5bbbe17f7 100644
--- a/src/demuxers/demux_ac3.c
+++ b/src/demuxers/demux_ac3.c
@@ -16,13 +16,14 @@
* 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
- *
+ */
+
+/*
* AC3 File Demuxer by Mike Melanson (melanson@pcisys.net)
* This demuxer detects raw AC3 data in a file and shovels AC3 data
* directly to the AC3 decoder.
*
- * $Id: demux_ac3.c,v 1.7 2003/03/31 19:31:54 tmmm Exp $
- *
+ * $Id: demux_ac3.c,v 1.8 2003/07/03 00:58:52 andruil Exp $
*/
#ifdef HAVE_CONFIG_H
@@ -45,21 +46,15 @@
#define AC3_PREAMBLE_BYTES 5
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;
- int seek_flag;
+ int seek_flag;
int sample_rate;
int frame_size;
int running_time;
@@ -67,23 +62,14 @@ typedef struct {
/* This hack indicates that 2 bytes (0x0B77) have already been consumed
* from a non-seekable stream during the detection phase. */
int first_non_seekable_frame;
-
- char last_mrl[1024];
} demux_ac3_t;
typedef struct {
-
demux_class_t demux_class;
-
- /* class-wide, global variables here */
-
- xine_t *xine;
- config_values_t *config;
} demux_ac3_class_t;
/* borrow some knowledge from the AC3 decoder */
-struct frmsize_s
-{
+struct frmsize_s {
uint16_t bit_rate;
uint16_t frm_size[3];
};
@@ -134,33 +120,18 @@ static const struct frmsize_s frmsizecod_tbl[64] =
static int open_ac3_file(demux_ac3_t *this) {
unsigned char preamble[AC3_PREAMBLE_BYTES];
- unsigned char preview[MAX_PREVIEW_SIZE];
/* check if the sync mark matches up */
- if (this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE) {
- this->input->seek(this->input, 0, SEEK_SET);
- if (this->input->read(this->input, preamble, AC3_PREAMBLE_BYTES) !=
+ if (xine_demux_read_header(this->input, preamble, AC3_PREAMBLE_BYTES) !=
AC3_PREAMBLE_BYTES)
- return 0;
- } else {
- this->input->get_optional_data(this->input, preview,
- INPUT_OPTIONAL_DATA_PREVIEW);
-
- this->first_non_seekable_frame = 1;
-
- /* copy over the header bytes for processing */
- memcpy(preamble, preview, AC3_PREAMBLE_BYTES);
- }
+ return 0;
if ((preamble[0] != 0x0B) ||
(preamble[1] != 0x77))
return 0;
- /* file is qualified; if the input was not seekable, skip over the header
- * bytes in the stream */
- if ((this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE) == 0) {
- this->input->seek(this->input, AC3_PREAMBLE_BYTES, SEEK_SET);
- }
+ /* file is qualified; skip over the header bytes in the stream */
+ this->input->seek(this->input, AC3_PREAMBLE_BYTES, SEEK_SET);
this->sample_rate = preamble[4] >> 6;
if (this->sample_rate > 2)
@@ -182,6 +153,9 @@ static int open_ac3_file(demux_ac3_t *this) {
this->running_time *= (90000 / 1000) * (256 * 3);
this->running_time /= this->sample_rate;
+ if (!INPUT_IS_SEEKABLE(this->input))
+ this->first_non_seekable_frame = 1;
+
return 1;
}
@@ -284,7 +258,7 @@ static int demux_ac3_seek (demux_plugin_t *this_gen,
/* if input is non-seekable, do not proceed with the rest of this
* seek function */
- if ((this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE) == 0)
+ if (!INPUT_IS_SEEKABLE(this->input))
return this->status;
/* divide the requested offset integer-wise by the frame alignment and
@@ -326,9 +300,8 @@ static int demux_ac3_get_optional_data(demux_plugin_t *this_gen,
}
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 = (input_plugin_t *) input_gen;
demux_ac3_t *this;
this = xine_xmalloc (sizeof (demux_ac3_t));
@@ -352,25 +325,18 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
switch (stream->content_detection_method) {
case METHOD_BY_EXTENSION: {
- char *ending, *mrl;
+ char *extensions, *mrl;
mrl = input->get_mrl (input);
+ extensions = class_gen->get_extensions (class_gen);
- ending = strrchr(mrl, '.');
-
- if (!ending) {
+ if (!xine_demux_check_extension (mrl, extensions)) {
free (this);
return NULL;
}
-
- if (strncasecmp (ending, ".ac3", 4)) {
- free (this);
- return NULL;
- }
-
}
/* falling through is intended */
-
+
case METHOD_BY_CONTENT:
case METHOD_EXPLICIT:
@@ -381,14 +347,11 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
break;
-
default:
free (this);
return NULL;
}
- strncpy (this->last_mrl, input->get_mrl (input), 1024);
-
return &this->demux_plugin;
}
@@ -419,9 +382,7 @@ void *demux_ac3_init_plugin (xine_t *xine, void *data) {
demux_ac3_class_t *this;
- this = xine_xmalloc (sizeof (demux_ac3_class_t));
- this->config = xine->config;
- this->xine = xine;
+ this = xine_xmalloc (sizeof (demux_ac3_class_t));
this->demux_class.open_plugin = open_plugin;
this->demux_class.get_description = get_description;
diff --git a/src/demuxers/demux_aiff.c b/src/demuxers/demux_aiff.c
index ba235e758..9ede53241 100644
--- a/src/demuxers/demux_aiff.c
+++ b/src/demuxers/demux_aiff.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2001-2002 the xine project
+ * Copyright (C) 2001-2003 the xine project
*
* This file is part of xine, a free video player.
*
@@ -16,10 +16,12 @@
* 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
- *
+ */
+
+/*
* AIFF File Demuxer by Mike Melanson (melanson@pcisys.net)
*
- * $Id: demux_aiff.c,v 1.29 2003/03/31 19:31:54 tmmm Exp $
+ * $Id: demux_aiff.c,v 1.30 2003/07/03 00:58:52 andruil Exp $
*
*/
@@ -57,18 +59,12 @@
#define PCM_BLOCK_ALIGN 1024
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;
unsigned int audio_type;
@@ -85,18 +81,10 @@ typedef struct {
off_t data_size;
int seek_flag; /* this is set when a seek just occurred */
-
- char last_mrl[1024];
} demux_aiff_t;
typedef struct {
-
demux_class_t demux_class;
-
- /* class-wide, global variables here */
-
- xine_t *xine;
- config_values_t *config;
} demux_aiff_class_t;
/* returns 1 if the AIFF file was opened successfully, 0 otherwise */
@@ -107,31 +95,17 @@ static int open_aiff_file(demux_aiff_t *this) {
unsigned int chunk_type;
unsigned int chunk_size;
unsigned char buffer[100];
- unsigned char preview[MAX_PREVIEW_SIZE];
-
- if (this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE) {
- this->input->seek(this->input, 0, SEEK_SET);
- if (this->input->read(this->input, signature, AIFF_SIGNATURE_SIZE) !=
- AIFF_SIGNATURE_SIZE)
- return 0;
- } else {
- this->input->get_optional_data(this->input, preview,
- INPUT_OPTIONAL_DATA_PREVIEW);
- /* copy over the header bytes for processing */
- memcpy(signature, preview, AIFF_SIGNATURE_SIZE);
- }
+ if (xine_demux_read_header(this->input, signature, AIFF_SIGNATURE_SIZE) != AIFF_SIGNATURE_SIZE)
+ return 0;
/* check the signature */
if ((BE_32(&signature[0]) != FORM_TAG) ||
(BE_32(&signature[8]) != AIFF_TAG))
return 0;
- /* file is qualified; if the input was not seekable, skip over the header
- * bytes in the stream */
- if ((this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE) == 0) {
- this->input->seek(this->input, AIFF_SIGNATURE_SIZE, SEEK_SET);
- }
+ /* file is qualified; skip over the header bytes in the stream */
+ this->input->seek(this->input, AIFF_SIGNATURE_SIZE, SEEK_SET);
/* audio type is PCM unless proven otherwise */
this->audio_type = BUF_AUDIO_LPCM_BE;
@@ -141,13 +115,12 @@ static int open_aiff_file(demux_aiff_t *this) {
this->audio_sample_rate = 0;
this->audio_bytes_per_second = 0;
- /* skip past the file header and traverse the chunks */
- this->input->seek(this->input, 12, SEEK_SET);
+ /* traverse the chunks */
while (1) {
if (this->input->read(this->input, preamble, PREAMBLE_SIZE) !=
PREAMBLE_SIZE) {
this->status = DEMUX_FINISHED;
- return DEMUX_CANNOT_HANDLE;
+ return 0;
}
chunk_type = BE_32(&preamble[0]);
chunk_size = BE_32(&preamble[4]);
@@ -156,7 +129,7 @@ static int open_aiff_file(demux_aiff_t *this) {
if (this->input->read(this->input, buffer, chunk_size) !=
chunk_size) {
this->status = DEMUX_FINISHED;
- return DEMUX_CANNOT_HANDLE;
+ return 0;
}
this->audio_channels = BE_16(&buffer[0]);
@@ -166,7 +139,7 @@ static int open_aiff_file(demux_aiff_t *this) {
this->audio_bytes_per_second = this->audio_channels *
(this->audio_bits / 8) * this->audio_sample_rate;
- } else if ((chunk_type == SSND_TAG) ||
+ } else if ((chunk_type == SSND_TAG) ||
(chunk_type == APCM_TAG)) {
/* audio data has been located; proceed to demux loop after
@@ -175,7 +148,7 @@ static int open_aiff_file(demux_aiff_t *this) {
this->data_start = this->input->get_current_pos(this->input);
this->data_size = this->audio_frames * this->audio_channels *
(this->audio_bits / 8);
- this->running_time = this->audio_frames / this->audio_sample_rate;
+ this->running_time = (this->audio_frames / this->audio_sample_rate) * 1000;
this->audio_block_align = PCM_BLOCK_ALIGN;
@@ -306,7 +279,7 @@ static int demux_aiff_seek (demux_plugin_t *this_gen,
/* if input is non-seekable, do not proceed with the rest of this
* seek function */
- if ((this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE) == 0)
+ if (!INPUT_IS_SEEKABLE(this->input))
return this->status;
/* check the boundary offsets */
@@ -348,7 +321,7 @@ static int demux_aiff_get_stream_length (demux_plugin_t *this_gen) {
demux_aiff_t *this = (demux_aiff_t *) this_gen;
- return this->running_time * 1000;
+ return this->running_time;
}
static uint32_t demux_aiff_get_capabilities(demux_plugin_t *this_gen)
@@ -363,9 +336,8 @@ static int demux_aiff_get_optional_data(demux_plugin_t *this_gen,
}
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 = (input_plugin_t *) input_gen;
demux_aiff_t *this;
this = xine_xmalloc (sizeof (demux_aiff_t));
@@ -388,40 +360,27 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
switch (stream->content_detection_method) {
- case METHOD_BY_CONTENT:
- case METHOD_EXPLICIT:
-
- if (!open_aiff_file(this)) {
- free (this);
- return NULL;
- }
-
- break;
-
case METHOD_BY_EXTENSION: {
- char *ending, *mrl;
+ char *extensions, *mrl;
mrl = input->get_mrl (input);
+ extensions = class_gen->get_extensions (class_gen);
- ending = strrchr(mrl, '.');
- if (!ending) {
+ if (!xine_demux_check_extension (mrl, extensions)) {
free (this);
return NULL;
}
+ }
+ /* falling through is intended */
- if (strncasecmp (ending, ".aif", 4) &&
- strncasecmp (ending, ".aiff", 5)) {
- free (this);
- return NULL;
- }
+ case METHOD_BY_CONTENT:
+ case METHOD_EXPLICIT:
if (!open_aiff_file(this)) {
free (this);
return NULL;
}
- }
-
break;
default:
@@ -429,8 +388,6 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
return NULL;
}
- strncpy (this->last_mrl, input->get_mrl (input), 1024);
-
return &this->demux_plugin;
}
@@ -463,9 +420,7 @@ void *demux_aiff_init_plugin (xine_t *xine, void *data) {
demux_aiff_class_t *this;
- this = xine_xmalloc (sizeof (demux_aiff_class_t));
- this->config = xine->config;
- this->xine = xine;
+ this = xine_xmalloc (sizeof (demux_aiff_class_t));
this->demux_class.open_plugin = open_plugin;
this->demux_class.get_description = get_description;
diff --git a/src/demuxers/demux_aud.c b/src/demuxers/demux_aud.c
index 410051bbb..9411e8c40 100644
--- a/src/demuxers/demux_aud.c
+++ b/src/demuxers/demux_aud.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2000-2002 the xine project
+ * Copyright (C) 2000-2003 the xine project
*
* This file is part of xine, a free video player.
*
@@ -16,7 +16,9 @@
* 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
- *
+ */
+
+/*
* Westwood Studios AUD File Demuxer by Mike Melanson (melanson@pcisys.net)
* For more information regarding the AUD file format, refer to:
* http://www.geocities.com/SiliconValley/8682/aud3.txt
@@ -32,7 +34,7 @@
* data. This makes seeking conceptually impossible. Upshot: Random
* seeking is not supported.
*
- * $Id: demux_aud.c,v 1.8 2003/04/02 05:14:10 guenter Exp $
+ * $Id: demux_aud.c,v 1.9 2003/07/03 00:58:52 andruil Exp $
*/
#ifdef HAVE_CONFIG_H
@@ -55,42 +57,26 @@
#define AUD_CHUNK_PREAMBLE_SIZE 8
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 thread_running;
+ int status;
off_t data_start;
off_t data_size;
- int status;
int audio_samplerate;
int audio_channels;
int audio_bits;
int audio_type;
int64_t audio_frame_counter;
-
- char last_mrl[1024];
-
} demux_aud_t;
typedef struct {
-
demux_class_t demux_class;
-
- /* class-wide, global variables here */
-
- xine_t *xine;
- config_values_t *config;
} demux_aud_class_t;
@@ -98,27 +84,16 @@ typedef struct {
static int open_aud_file(demux_aud_t *this) {
unsigned char header[AUD_HEADER_SIZE];
- unsigned char preview[MAX_PREVIEW_SIZE];
-
- if (this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE) {
- this->input->seek(this->input, 0, SEEK_SET);
- if (this->input->read(this->input, header, AUD_HEADER_SIZE) !=
- AUD_HEADER_SIZE)
- return 0;
- } else {
- this->input->get_optional_data(this->input, preview,
- INPUT_OPTIONAL_DATA_PREVIEW);
-
- /* copy over the header bytes for processing */
- memcpy(header, preview, AUD_HEADER_SIZE);
- }
+
+ if (xine_demux_read_header(this->input, header, AUD_HEADER_SIZE) != AUD_HEADER_SIZE)
+ return 0;
/* Probabilistic content detection strategy: There is no file signature
* so perform sanity checks on various header parameters:
* 8000 <= sample rate (16 bits) <= 48000 ==> 40001 acceptable numbers
* compression type (8 bits) = 1 or 99 ==> 2 acceptable numbers
* There is a total of 24 bits. The number space contains 2^24 =
- * 16777216 numbers. There are 40001 * 2 = 80002 acceptable combinations
+ * 16777216 numbers. There are 40001 * 2 = 80002 acceptable combinations
* of numbers. There is a 80002/16777216 = 0.48% chance of a false
* positive.
*/
@@ -127,17 +102,14 @@ static int open_aud_file(demux_aud_t *this) {
return 0;
if (header[11] == 1)
- this->audio_type = BUF_AUDIO_WESTWOOD;
+ this->audio_type = BUF_AUDIO_WESTWOOD;
else if (header[11] == 99)
- this->audio_type = BUF_AUDIO_VQA_IMA;
+ this->audio_type = BUF_AUDIO_VQA_IMA;
else
return 0;
- /* file is qualified; if the input was not seekable, skip over the header
- * bytes in the stream */
- if ((this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE) == 0) {
- this->input->seek(this->input, AUD_HEADER_SIZE, SEEK_SET);
- }
+ /* file is qualified; skip over the header bytes in the stream */
+ this->input->seek(this->input, AUD_HEADER_SIZE, SEEK_SET);
/* flag 0 indicates stereo */
this->audio_channels = (header[10] & 0x1) + 1;
@@ -259,13 +231,10 @@ static int demux_aud_seek (demux_plugin_t *this_gen,
/* if input is non-seekable, do not proceed with the rest of this
* seek function */
- if ((this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE) == 0)
+ if (!INPUT_IS_SEEKABLE(this->input))
return this->status;
-
/* no seeking yet */
-
-
return this->status;
}
@@ -295,9 +264,8 @@ static int demux_aud_get_optional_data(demux_plugin_t *this_gen,
}
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 = (input_plugin_t *) input_gen;
demux_aud_t *this;
this = xine_xmalloc (sizeof (demux_aud_t));
@@ -320,39 +288,26 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
switch (stream->content_detection_method) {
- case METHOD_BY_CONTENT:
- case METHOD_EXPLICIT:
-
- if (!open_aud_file(this)) {
- free (this);
- return NULL;
- }
- break;
-
case METHOD_BY_EXTENSION: {
- char *ending, *mrl;
+ char *extensions, *mrl;
mrl = input->get_mrl (input);
+ extensions = class_gen->get_extensions (class_gen);
- ending = strrchr(mrl, '.');
-
- if (!ending) {
+ if (!xine_demux_check_extension (mrl, extensions)) {
free (this);
return NULL;
}
+ }
+ /* falling through is intended */
- if (strncasecmp (ending, ".aud", 4)) {
- free (this);
- return NULL;
- }
+ case METHOD_BY_CONTENT:
+ case METHOD_EXPLICIT:
if (!open_aud_file(this)) {
free (this);
return NULL;
}
-
- }
-
break;
default:
@@ -360,8 +315,6 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
return NULL;
}
- strncpy (this->last_mrl, input->get_mrl (input), 1024);
-
return &this->demux_plugin;
}
@@ -392,9 +345,7 @@ void *demux_aud_init_plugin (xine_t *xine, void *data) {
demux_aud_class_t *this;
- this = xine_xmalloc (sizeof (demux_aud_class_t));
- this->config = xine->config;
- this->xine = xine;
+ this = xine_xmalloc (sizeof (demux_aud_class_t));
this->demux_class.open_plugin = open_plugin;
this->demux_class.get_description = get_description;
diff --git a/src/input/input_plugin.h b/src/input/input_plugin.h
index 507c5e974..99fb1d738 100644
--- a/src/input/input_plugin.h
+++ b/src/input/input_plugin.h
@@ -1,5 +1,5 @@
-/*
- * Copyright (C) 2000-2002 the xine project
+/*
+ * Copyright (C) 2000-2003 the xine project
*
* This file is part of xine, a free video player.
*
@@ -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: input_plugin.h,v 1.49 2003/05/20 13:50:56 mroi Exp $
+ * $Id: input_plugin.h,v 1.50 2003/07/03 00:58:51 andruil Exp $
*/
#ifndef HAVE_INPUT_PLUGIN_H
@@ -48,7 +48,7 @@ struct input_class_s {
* return NULL if the plugin does'nt handle the given mrl
*/
input_plugin_t* (*get_instance) (input_class_t *this, xine_stream_t *stream, const char *mrl);
-
+
/*
* return short, human readable identifier for this plugin class
*/
@@ -265,6 +265,7 @@ struct input_plugin_s {
#define INPUT_CAP_CHAPTERS 0x00000080
+#define INPUT_IS_SEEKABLE(input) (((input)->get_capabilities(input) & INPUT_CAP_SEEKABLE) != 0)
#define INPUT_OPTIONAL_UNSUPPORTED 0
#define INPUT_OPTIONAL_SUCCESS 1