summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuenter Bartsch <guenter@users.sourceforge.net>2001-04-24 17:42:26 +0000
committerGuenter Bartsch <guenter@users.sourceforge.net>2001-04-24 17:42:26 +0000
commit8f4426252dba8db47beaea9b9956c03668c1a640 (patch)
tree242ba9845819a00adb9178d22e80d2389851e53e
parent1cc52e26e9d712583e2c1ea23ee5bfbb87e25255 (diff)
downloadxine-lib-8f4426252dba8db47beaea9b9956c03668c1a640.tar.gz
xine-lib-8f4426252dba8db47beaea9b9956c03668c1a640.tar.bz2
fixed input and demux plugins to reflect new buffer api
CVS patchset: 20 CVS date: 2001/04/24 17:42:26
-rw-r--r--src/demuxers/demux_avi.c76
-rw-r--r--src/demuxers/demux_mpeg.c60
-rw-r--r--src/demuxers/demux_mpeg_block.c40
-rw-r--r--src/input/input_file.c138
-rw-r--r--src/input/input_plugin.h52
-rw-r--r--src/xine-engine/load_plugins.c6
6 files changed, 197 insertions, 175 deletions
diff --git a/src/demuxers/demux_avi.c b/src/demuxers/demux_avi.c
index 3469467ad..4fdf68d2e 100644
--- a/src/demuxers/demux_avi.c
+++ b/src/demuxers/demux_avi.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: demux_avi.c,v 1.3 2001/04/21 00:14:40 f1rmb Exp $
+ * $Id: demux_avi.c,v 1.4 2001/04/24 17:42:26 guenter Exp $
*
* demultiplexer for avi streams
*
@@ -260,7 +260,7 @@ static avi_t *AVI_init(demux_avi_t *this)
/* Read first 12 bytes and check that this is an AVI file */
- if( this->input->read(data,12) != 12 ) ERR_EXIT(AVI_ERR_READ) ;
+ if( this->input->read(this->input, data,12) != 12 ) ERR_EXIT(AVI_ERR_READ) ;
if( strncasecmp(data ,"RIFF",4) !=0 ||
strncasecmp(data+8,"AVI ",4) !=0 ) ERR_EXIT(AVI_ERR_NO_AVI) ;
@@ -271,29 +271,29 @@ static avi_t *AVI_init(demux_avi_t *this)
hdrl_data = 0;
while(1) {
- if (this->input->read(data,8) != 8 ) break; /* We assume it's EOF */
+ if (this->input->read(this->input, data,8) != 8 ) break; /* We assume it's EOF */
n = str2ulong(data+4);
n = PAD_EVEN(n);
if(strncasecmp(data,"LIST",4) == 0)
{
- if( this->input->read(data,4) != 4 ) ERR_EXIT(AVI_ERR_READ)
+ if( this->input->read(this->input, data,4) != 4 ) ERR_EXIT(AVI_ERR_READ)
n -= 4;
if(strncasecmp(data,"hdrl",4) == 0)
{
hdrl_len = n;
hdrl_data = (unsigned char *) xmalloc(n);
if(hdrl_data==0) ERR_EXIT(AVI_ERR_NO_MEM)
- if( this->input->read(hdrl_data,n) != n ) ERR_EXIT(AVI_ERR_READ)
+ if( this->input->read(this->input, hdrl_data,n) != n ) ERR_EXIT(AVI_ERR_READ)
}
else if(strncasecmp(data,"movi",4) == 0)
{
- AVI->movi_start = this->input->seek(0,SEEK_CUR);
- this->input->seek(n,SEEK_CUR);
+ AVI->movi_start = this->input->seek(this->input, 0,SEEK_CUR);
+ this->input->seek(this->input, n, SEEK_CUR);
}
else
- this->input->seek(n,SEEK_CUR);
+ this->input->seek(this->input, n, SEEK_CUR);
}
else if(strncasecmp(data,"idx1",4) == 0)
{
@@ -303,10 +303,10 @@ static avi_t *AVI_init(demux_avi_t *this)
AVI->n_idx = AVI->max_idx = n/16;
AVI->idx = (unsigned char((*)[16]) ) xmalloc(n);
if(AVI->idx==0) ERR_EXIT(AVI_ERR_NO_MEM)
- if( this->input->read((char *)AVI->idx,n) != n ) ERR_EXIT(AVI_ERR_READ)
+ if( this->input->read(this->input, (char *)AVI->idx, n) != n ) ERR_EXIT(AVI_ERR_READ)
}
else
- this->input->seek(n,SEEK_CUR);
+ this->input->seek(this->input, n, SEEK_CUR);
}
if(!hdrl_data) ERR_EXIT(AVI_ERR_NO_HDRL) ;
@@ -411,7 +411,7 @@ static avi_t *AVI_init(demux_avi_t *this)
AVI->audio_tag[2] = 'w';
AVI->audio_tag[3] = 'b';
- this->input->seek(AVI->movi_start,SEEK_SET);
+ this->input->seek(this->input, AVI->movi_start, SEEK_SET);
/* if the file has an idx1, check if this is relative
to the start of the file or to the start of the movi list */
@@ -432,16 +432,16 @@ static avi_t *AVI_init(demux_avi_t *this)
pos = str2ulong(AVI->idx[i]+ 8);
len = str2ulong(AVI->idx[i]+12);
- this->input->seek(pos,SEEK_SET);
- if(this->input->read(data,8)!=8) ERR_EXIT(AVI_ERR_READ) ;
+ this->input->seek(this->input, pos, SEEK_SET);
+ if(this->input->read(this->input, data, 8)!=8) ERR_EXIT(AVI_ERR_READ) ;
if( strncasecmp(data,AVI->idx[i],4)==0 && str2ulong(data+4)==len )
{
idx_type = 1; /* Index from start of file */
}
else
{
- this->input->seek(pos+AVI->movi_start-4,SEEK_SET);
- if(this->input->read(data,8)!=8) ERR_EXIT(AVI_ERR_READ) ;
+ this->input->seek(this->input, pos+AVI->movi_start-4, SEEK_SET);
+ if(this->input->read(this->input, data, 8)!=8) ERR_EXIT(AVI_ERR_READ) ;
if( strncasecmp(data,AVI->idx[i],4)==0 && str2ulong(data+4)==len )
{
idx_type = 2; /* Index from start of movi list */
@@ -454,20 +454,20 @@ static avi_t *AVI_init(demux_avi_t *this)
{
/* we must search through the file to get the index */
- this->input->seek( AVI->movi_start, SEEK_SET);
+ this->input->seek(this->input, AVI->movi_start, SEEK_SET);
AVI->n_idx = 0;
while(1)
{
- if( this->input->read(data,8) != 8 ) break;
+ if( this->input->read(this->input, data,8) != 8 ) break;
n = str2ulong(data+4);
/* The movi list may contain sub-lists, ignore them */
if(strncasecmp(data,"LIST",4)==0)
{
- this->input->seek(4,SEEK_CUR);
+ this->input->seek(this->input, 4,SEEK_CUR);
continue;
}
@@ -478,10 +478,10 @@ static avi_t *AVI_init(demux_avi_t *this)
|| ( (data[2]=='w' || data[2]=='W') &&
(data[3]=='b' || data[3]=='B') ) )
{
- avi_add_index_entry(AVI,data,0,this->input->seek(0,SEEK_CUR)-8,n);
+ avi_add_index_entry(AVI,data,0,this->input->seek(this->input, 0, SEEK_CUR)-8,n);
}
- this->input->seek(PAD_EVEN(n),SEEK_CUR);
+ this->input->seek(this->input, PAD_EVEN(n), SEEK_CUR);
}
idx_type = 1;
}
@@ -537,7 +537,7 @@ static avi_t *AVI_init(demux_avi_t *this)
/* Reposition the file */
- this->input->seek(AVI->movi_start,SEEK_SET);
+ this->input->seek(this->input, AVI->movi_start, SEEK_SET);
AVI->video_posf = 0;
AVI->video_posb = 0;
@@ -627,9 +627,9 @@ static long AVI_read_audio(demux_avi_t *this, avi_t *AVI, char *audbuf,
todo = left;
pos = AVI->audio_index[AVI->audio_posc].pos + AVI->audio_posb;
/* printf ("demux_avi: read audio from %d\n", pos); */
- if (this->input->seek (pos, SEEK_SET)<0)
+ if (this->input->seek (this->input, pos, SEEK_SET)<0)
return -1;
- if (this->input->read(audbuf+nr,todo) != todo)
+ if (this->input->read(this->input, audbuf+nr,todo) != todo)
{
AVI->AVI_errno = AVI_ERR_READ;
*bFrameDone = 0;
@@ -674,9 +674,9 @@ static long AVI_read_video(demux_avi_t *this, avi_t *AVI, char *vidbuf,
todo = left;
pos = AVI->video_index[AVI->video_posf].pos + AVI->video_posb;
/* printf ("demux_avi: read video from %d\n", pos); */
- if (this->input->seek (pos, SEEK_SET)<0)
+ if (this->input->seek (this->input, pos, SEEK_SET)<0)
return -1;
- if (this->input->read(vidbuf+nr,todo) != todo)
+ if (this->input->read(this->input, vidbuf+nr,todo) != todo)
{
AVI->AVI_errno = AVI_ERR_READ;
*bFrameDone = 0;
@@ -700,7 +700,7 @@ static int demux_avi_next (demux_avi_t *this) {
if (this->avi->video_frames <= this->avi->video_posf)
return 0;
- buf = this->audio_fifo->buffer_pool_alloc ();
+ buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo);
buf->content = buf->mem;
buf->DTS = 0 ; /* FIXME */
@@ -714,7 +714,7 @@ static int demux_avi_next (demux_avi_t *this) {
buf->size = AVI_read_audio (this, this->avi, buf->mem, 2048, &buf->frame_end);
buf->PTS = 0;
- buf->input_pos = this->input->seek (0, SEEK_CUR);
+ buf->input_pos = this->input->seek (this->input, 0, SEEK_CUR);
switch (this->avi->a_fmt) {
case 0x01:
@@ -767,10 +767,10 @@ static void *demux_avi_loop (void *this_gen) {
} while (this->status == DEMUX_OK) ;
- buf = this->video_fifo->buffer_pool_alloc ();
+ buf = this->video_fifo->buffer_pool_alloc (this->video_fifo);
buf->type = BUF_CONTROL_END;
this->video_fifo->put (this->video_fifo, buf);
- buf = this->audio_fifo->buffer_pool_alloc ();
+ buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo);
buf->type = BUF_CONTROL_END;
this->audio_fifo->put (this->audio_fifo, buf);
@@ -861,15 +861,15 @@ static void demux_avi_start (demux_plugin_t *this_gen,
* send start buffers
*/
- buf = this->video_fifo->buffer_pool_alloc ();
+ buf = this->video_fifo->buffer_pool_alloc (this->video_fifo);
buf->type = BUF_CONTROL_START;
this->video_fifo->put (this->video_fifo, buf);
- buf = this->audio_fifo->buffer_pool_alloc ();
+ buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo);
buf->type = BUF_CONTROL_START;
this->audio_fifo->put (this->audio_fifo, buf);
- buf = this->video_fifo->buffer_pool_alloc ();
+ buf = this->video_fifo->buffer_pool_alloc (this->video_fifo);
buf->content = buf->mem;
this->avi->bih.biSize = this->video_step; /* HACK */
memcpy (buf->content, &this->avi->bih, sizeof (this->avi->bih));
@@ -877,7 +877,7 @@ static void demux_avi_start (demux_plugin_t *this_gen,
buf->type = BUF_VIDEO_AVI;
this->video_fifo->put (this->video_fifo, buf);
- buf = this->audio_fifo->buffer_pool_alloc ();
+ buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo);
buf->content = buf->mem;
memcpy (buf->content, &this->avi->wavex,
sizeof (this->avi->wavex));
@@ -897,15 +897,15 @@ static int demux_avi_open(demux_plugin_t *this_gen, input_plugin_t *input, int s
case STAGE_BY_CONTENT: {
uint8_t buf[4096];
- if (input->get_blocksize())
+ if (input->get_blocksize(input))
return DEMUX_CANNOT_HANDLE;
- if (!(input->get_capabilities() & INPUT_CAP_SEEKABLE))
+ if (!(input->get_capabilities(input) & INPUT_CAP_SEEKABLE))
return DEMUX_CANNOT_HANDLE;
- input->seek(0, SEEK_SET);
+ input->seek(input, 0, SEEK_SET);
- if(input->read(buf, 4)) {
+ if(input->read(input, buf, 4)) {
if((buf[0] == 0x52)
&& (buf[1] == 0x49)
@@ -929,7 +929,7 @@ static int demux_avi_open(demux_plugin_t *this_gen, input_plugin_t *input, int s
case STAGE_BY_EXTENSION: {
char *ending, *mrl;
- mrl = this->input->get_mrl ();
+ mrl = this->input->get_mrl (this->input);
ending = strrchr(mrl, '.');
xprintf(VERBOSE|DEMUX, "demux_avi_can_handle: ending %s of %s\n",
diff --git a/src/demuxers/demux_mpeg.c b/src/demuxers/demux_mpeg.c
index 5cc08817c..ecdd17ef0 100644
--- a/src/demuxers/demux_mpeg.c
+++ b/src/demuxers/demux_mpeg.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: demux_mpeg.c,v 1.3 2001/04/21 00:14:40 f1rmb Exp $
+ * $Id: demux_mpeg.c,v 1.4 2001/04/24 17:42:26 guenter Exp $
*
* demultiplexer for mpeg 1/2 program streams
* reads streams of variable blocksizes
@@ -67,7 +67,7 @@ static uint32_t read_bytes (demux_mpeg_t *this, int n) {
buf[4]=0;
- i = this->input->read (buf, n);
+ i = this->input->read (this->input, buf, n);
if (i != n) {
this->status = DEMUX_FINISHED;
@@ -137,7 +137,7 @@ static void parse_mpeg2_packet (demux_mpeg_t *this, int nID) {
}
/* read rest of header */
- i = this->input->read (this->dummy_space, header_len+4);
+ i = this->input->read (this->input, this->dummy_space, header_len+4);
track = this->dummy_space[0] & 0x0F ;
@@ -145,12 +145,12 @@ static void parse_mpeg2_packet (demux_mpeg_t *this, int nID) {
/* contents */
- buf = this->input->read_block (this->audio_fifo, nLen-4);
+ buf = this->input->read_block (this->input, this->audio_fifo, nLen-4);
buf->type = BUF_AUDIO_AC3 + track;
buf->PTS = pts;
buf->DTS = 0 ; /* FIXME */
- buf->input_pos = this->input->get_current_pos ();
+ buf->input_pos = this->input->get_current_pos (this->input);
this->audio_fifo->put (this->audio_fifo, buf);
@@ -182,14 +182,14 @@ static void parse_mpeg2_packet (demux_mpeg_t *this, int nID) {
}
/* read rest of header */
- i = this->input->read (this->dummy_space, header_len);
+ i = this->input->read (this->input, this->dummy_space, header_len);
- buf = this->input->read_block (this->audio_fifo, nLen);
+ buf = this->input->read_block (this->input, this->audio_fifo, nLen);
buf->type = BUF_AUDIO_MPEG + track;
buf->PTS = pts;
buf->DTS = 0; /* FIXME */
- buf->input_pos = this->input->seek (0, SEEK_CUR);
+ buf->input_pos = this->input->seek (this->input, 0, SEEK_CUR);
this->audio_fifo->put (this->audio_fifo, buf);
@@ -220,11 +220,11 @@ static void parse_mpeg2_packet (demux_mpeg_t *this, int nID) {
}
/* read rest of header */
- i = this->input->read (this->dummy_space, header_len);
+ i = this->input->read (this->input, this->dummy_space, header_len);
/* contents */
- buf = this->input->read_block (this->audio_fifo, nLen);
+ buf = this->input->read_block (this->input, this->audio_fifo, nLen);
buf->type = BUF_VIDEO_MPEG;
buf->PTS = pts;
@@ -235,7 +235,7 @@ static void parse_mpeg2_packet (demux_mpeg_t *this, int nID) {
} else {
xprintf (VERBOSE|DEMUX, ",unknown stream - skipped");
- i = this->input->read (this->dummy_space, nLen);
+ i = this->input->read (this->input, this->dummy_space, nLen);
/* (*this->input->seek) (nLen,SEEK_CUR); */
}
@@ -332,12 +332,12 @@ static void parse_mpeg1_packet (demux_mpeg_t *this, int nID)
xprintf (VERBOSE|DEMUX|AUDIO, ", audio #%d", track);
- buf = this->input->read_block (this->audio_fifo, nLen);
+ buf = this->input->read_block (this->input, this->audio_fifo, nLen);
buf->type = BUF_AUDIO_MPEG + track ;
buf->PTS = pts;
buf->DTS = 0; /* FIXME */
- buf->input_pos = this->input->seek (0, SEEK_CUR);
+ buf->input_pos = this->input->seek (this->input, 0, SEEK_CUR);
this->audio_fifo->put (this->audio_fifo, buf);
@@ -345,7 +345,7 @@ static void parse_mpeg1_packet (demux_mpeg_t *this, int nID)
xprintf (VERBOSE|DEMUX|VIDEO, ", video #%d", nID & 0x0f);
- buf = this->input->read_block (this->video_fifo, nLen);
+ buf = this->input->read_block (this->input, this->video_fifo, nLen);
buf->type = BUF_VIDEO_MPEG;
buf->PTS = pts;
@@ -355,10 +355,10 @@ static void parse_mpeg1_packet (demux_mpeg_t *this, int nID)
} else if (nID == 0xbd) {
xprintf (VERBOSE|DEMUX|AC3, ", ac3");
- i = this->input->read (this->dummy_space, nLen);
+ i = this->input->read (this->input, this->dummy_space, nLen);
} else {
xprintf (VERBOSE|DEMUX, ", unknown (nID = %d)",nID);
- this->input->read (this->dummy_space, nLen);
+ this->input->read (this->input, this->dummy_space, nLen);
}
xprintf (VERBOSE|DEMUX, ")\n");
@@ -404,7 +404,7 @@ static uint32_t parse_pack(demux_mpeg_t *this)
buf = read_bytes (this, 2);
xprintf (VERBOSE|DEMUX, " system_header (%d +6 bytes)\n",buf);
- this->input->read (scratch,buf);
+ this->input->read (this->input, scratch, buf);
buf = read_bytes (this, 4) ;
}
@@ -454,10 +454,10 @@ static void *demux_mpeg_loop (void *this_gen) {
} while (this->status == DEMUX_OK) ;
- buf = this->video_fifo->buffer_pool_alloc ();
+ buf = this->video_fifo->buffer_pool_alloc (this->video_fifo);
buf->type = BUF_CONTROL_END;
this->video_fifo->put (this->video_fifo, buf);
- buf = this->audio_fifo->buffer_pool_alloc ();
+ buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo);
buf->type = BUF_CONTROL_END;
this->audio_fifo->put (this->audio_fifo, buf);
@@ -495,15 +495,15 @@ static void demux_mpeg_start (demux_plugin_t *this_gen,
this->status = DEMUX_OK;
- if ((this->input->get_capabilities () & INPUT_CAP_SEEKABLE) != 0 ) {
+ if ((this->input->get_capabilities (this->input) & INPUT_CAP_SEEKABLE) != 0 ) {
xprintf (VERBOSE|DEMUX, "=>seek to %Ld\n",pos);
- this->input->seek (pos+4, SEEK_SET);
+ this->input->seek (this->input, pos+4, SEEK_SET);
}
- buf = this->video_fifo->buffer_pool_alloc ();
+ buf = this->video_fifo->buffer_pool_alloc (this->video_fifo);
buf->type = BUF_CONTROL_START;
this->video_fifo->put (this->video_fifo, buf);
- buf = this->audio_fifo->buffer_pool_alloc ();
+ buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo);
buf->type = BUF_CONTROL_START;
this->audio_fifo->put (this->audio_fifo, buf);
@@ -521,13 +521,13 @@ static int demux_mpeg_open(demux_plugin_t *this_gen, input_plugin_t *ip, int sta
case STAGE_BY_CONTENT: {
uint8_t buf[4096];
- if((ip->get_capabilities() & INPUT_CAP_SEEKABLE) != 0) {
- ip->seek(0, SEEK_SET);
+ if((ip->get_capabilities(ip) & INPUT_CAP_SEEKABLE) != 0) {
+ ip->seek(ip, 0, SEEK_SET);
- if(ip->get_blocksize())
+ if(ip->get_blocksize(ip))
return DEMUX_CANNOT_HANDLE;
- if(ip->read(buf, 6)) {
+ if(ip->read(ip, buf, 6)) {
if(buf[0] || buf[1] || (buf[2] != 0x01))
return DEMUX_CANNOT_HANDLE;
@@ -554,7 +554,7 @@ static int demux_mpeg_open(demux_plugin_t *this_gen, input_plugin_t *ip, int sta
case STAGE_BY_EXTENSION: {
char *media;
char *ending;
- char *MRL = ip->get_mrl();
+ char *MRL = ip->get_mrl(ip);
media = strstr(MRL, "://");
if(media) {
@@ -612,10 +612,12 @@ demux_plugin_t *init_demux_plugin(int iface, config_values_t *config) {
demux_mpeg_t *this = xmalloc (sizeof (demux_mpeg_t));
+ xine_debug = config->lookup_int (config, "xine_debug", 0);
+
switch (iface) {
case 1:
- // FIXME xine_debug = xd;
+
this->demux_plugin.interface_version = DEMUXER_PLUGIN_IFACE_VERSION;
this->demux_plugin.open = demux_mpeg_open;
this->demux_plugin.start = demux_mpeg_start;
diff --git a/src/demuxers/demux_mpeg_block.c b/src/demuxers/demux_mpeg_block.c
index bcdd003f6..1ee29506f 100644
--- a/src/demuxers/demux_mpeg_block.c
+++ b/src/demuxers/demux_mpeg_block.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: demux_mpeg_block.c,v 1.3 2001/04/21 00:14:40 f1rmb Exp $
+ * $Id: demux_mpeg_block.c,v 1.4 2001/04/24 17:42:26 guenter Exp $
*
* demultiplexer for mpeg 1/2 program streams
*
@@ -69,7 +69,7 @@ static void demux_mpeg_block_parse_pack (demux_mpeg_block_t *this) {
uint32_t nStreamID;
- buf = this->input->read_block (this->video_fifo, this->blocksize);
+ buf = this->input->read_block (this->input, this->video_fifo, this->blocksize);
if (buf==NULL) {
this->status = DEMUX_FINISHED;
@@ -223,7 +223,7 @@ static void demux_mpeg_block_parse_pack (demux_mpeg_block_t *this) {
buf->type = BUF_SPU_PACKAGE + nSPUID;
buf->PTS = nPTS;
buf->DTS = nDTS ;
- buf->input_pos = this->input->seek (0, SEEK_CUR);
+ buf->input_pos = this->input->seek (this->input, 0, SEEK_CUR);
this->spu_fifo->put (this->spu_fifo, buf);
@@ -240,7 +240,7 @@ static void demux_mpeg_block_parse_pack (demux_mpeg_block_t *this) {
buf->type = BUF_AUDIO_AC3 + nTrack;
buf->PTS = nPTS;
buf->DTS = nDTS ;
- buf->input_pos = this->input->seek (0, SEEK_CUR);
+ buf->input_pos = this->input->seek (this->input, 0, SEEK_CUR);
this->audio_fifo->put (this->audio_fifo, buf);
@@ -263,7 +263,7 @@ static void demux_mpeg_block_parse_pack (demux_mpeg_block_t *this) {
buf->type = BUF_AUDIO_LPCM + nTrack;
buf->PTS = nPTS;
buf->DTS = nDTS ;
- buf->input_pos = this->input->seek (0, SEEK_CUR);
+ buf->input_pos = this->input->seek (this->input, 0, SEEK_CUR);
this->audio_fifo->put (this->audio_fifo, buf);
@@ -279,7 +279,7 @@ static void demux_mpeg_block_parse_pack (demux_mpeg_block_t *this) {
buf->type = BUF_VIDEO_MPEG;
buf->PTS = nPTS;
buf->DTS = nDTS;
- buf->input_pos = this->input->seek (0, SEEK_CUR);
+ buf->input_pos = this->input->seek (this->input, 0, SEEK_CUR);
this->video_fifo->put (this->video_fifo, buf);
@@ -297,7 +297,7 @@ static void demux_mpeg_block_parse_pack (demux_mpeg_block_t *this) {
buf->type = BUF_AUDIO_MPEG + nTrack;
buf->PTS = nPTS;
buf->DTS = nDTS;
- buf->input_pos = this->input->seek (0, SEEK_CUR);
+ buf->input_pos = this->input->seek (this->input, 0, SEEK_CUR);
this->audio_fifo->put (this->audio_fifo, buf);
@@ -329,11 +329,11 @@ static void *demux_mpeg_block_loop (void *this_gen) {
this->status = DEMUX_FINISHED;
- buf = this->video_fifo->buffer_pool_alloc ();
+ buf = this->video_fifo->buffer_pool_alloc (this->video_fifo);
buf->type = BUF_CONTROL_END;
this->video_fifo->put (this->video_fifo, buf);
- buf = this->audio_fifo->buffer_pool_alloc ();
+ buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo);
buf->type = BUF_CONTROL_END;
this->audio_fifo->put (this->audio_fifo, buf);
@@ -375,19 +375,19 @@ static void demux_mpeg_block_start (demux_plugin_t *this_gen,
pos /= (off_t) this->blocksize;
pos *= (off_t) this->blocksize;
- if((this->input->get_capabilities() & INPUT_CAP_SEEKABLE) != 0) {
+ if((this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE) != 0) {
xprintf (VERBOSE|DEMUX, "=>seek to %Ld\n",pos);
- this->input->seek (pos, SEEK_SET);
+ this->input->seek (this->input, pos, SEEK_SET);
}
/*
* send start buffer
*/
- buf = this->video_fifo->buffer_pool_alloc ();
+ buf = this->video_fifo->buffer_pool_alloc (this->video_fifo);
buf->type = BUF_CONTROL_START;
this->video_fifo->put (this->video_fifo, buf);
- buf = this->audio_fifo->buffer_pool_alloc ();
+ buf = this->audio_fifo->buffer_pool_alloc (this->video_fifo);
buf->type = BUF_CONTROL_START;
this->audio_fifo->put (this->audio_fifo, buf);
@@ -410,15 +410,15 @@ static int demux_mpeg_block_open(demux_plugin_t *this_gen,
case STAGE_BY_CONTENT: {
uint8_t buf[4096];
- if((input->get_capabilities() & INPUT_CAP_SEEKABLE) != 0) {
- input->seek(0, SEEK_SET);
+ if((input->get_capabilities(input) & INPUT_CAP_SEEKABLE) != 0) {
+ input->seek(input, 0, SEEK_SET);
- this->blocksize = input->get_blocksize();
+ this->blocksize = input->get_blocksize(input);
if (!this->blocksize)
return DEMUX_CANNOT_HANDLE;
- if (input->read(buf, this->blocksize)) {
+ if (input->read(input, buf, this->blocksize)) {
if(buf[0] || buf[1] || (buf[2] != 0x01))
return DEMUX_CANNOT_HANDLE;
@@ -449,7 +449,7 @@ static int demux_mpeg_block_open(demux_plugin_t *this_gen,
char *ending;
char *MRL;
- MRL = input->get_mrl ();
+ MRL = input->get_mrl (input);
media = strstr(MRL, "://");
if(media) {
@@ -506,10 +506,12 @@ demux_plugin_t *init_demux_mpeg_block(int iface, config_values_t *config) {
demux_mpeg_block_t *this = xmalloc (sizeof (demux_mpeg_block_t));
+ xine_debug = config->lookup_int (config, "xine_debug", 0);
+
switch (iface) {
case 1:
- // FIXME xine_debug = xd;
+
this->demux_plugin.interface_version = DEMUXER_PLUGIN_IFACE_VERSION;
this->demux_plugin.open = demux_mpeg_block_open;
this->demux_plugin.start = demux_mpeg_block_start;
diff --git a/src/input/input_file.c b/src/input/input_file.c
index 782127961..5c1f76083 100644
--- a/src/input/input_file.c
+++ b/src/input/input_file.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: input_file.c,v 1.3 2001/04/21 00:14:40 f1rmb Exp $
+ * $Id: input_file.c,v 1.4 2001/04/24 17:42:27 guenter Exp $
*/
#ifdef HAVE_CONFIG_H
@@ -34,20 +34,26 @@
#include "monitor.h"
#include "input_plugin.h"
-
static uint32_t xine_debug;
-static int input_file_handle;
-static char *input_file_mrl;
-static uint32_t file_plugin_get_capabilities () {
+typedef struct file_input_plugin_s {
+ input_plugin_t input_plugin;
+
+ int fh;
+ char *mrl;
+ config_values_t *config;
+} file_input_plugin_t;
+
+static uint32_t file_plugin_get_capabilities (input_plugin_t *this_gen) {
return INPUT_CAP_SEEKABLE;
}
-static int file_plugin_open (char *mrl) {
+static int file_plugin_open (input_plugin_t *this_gen, char *mrl) {
- char *filename;
+ char *filename;
+ file_input_plugin_t *this = (file_input_plugin_t *) this_gen;
- input_file_mrl = mrl;
+ this->mrl = mrl;
if (!strncasecmp (mrl, "file:",5))
filename = &mrl[5];
@@ -56,9 +62,9 @@ static int file_plugin_open (char *mrl) {
xprintf (VERBOSE|INPUT, "Opening >%s<\n",filename);
- input_file_handle = open (filename, O_RDONLY);
+ this->fh = open (filename, O_RDONLY);
- if (input_file_handle == -1) {
+ if (this->fh == -1) {
return 0;
}
@@ -66,20 +72,22 @@ static int file_plugin_open (char *mrl) {
}
-static off_t file_plugin_read (char *buf, off_t len) {
- return read (input_file_handle, buf, len);
+static off_t file_plugin_read (input_plugin_t *this_gen, char *buf, off_t len) {
+ file_input_plugin_t *this = (file_input_plugin_t *) this_gen;
+ return read (this->fh, buf, len);
}
-static buf_element_t *file_plugin_read_block (fifo_buffer_t *fifo, off_t todo) {
+static buf_element_t *file_plugin_read_block (input_plugin_t *this_gen, fifo_buffer_t *fifo, off_t todo) {
- off_t num_bytes, total_bytes;
- buf_element_t *buf = fifo->buffer_pool_alloc ();
+ off_t num_bytes, total_bytes;
+ file_input_plugin_t *this = (file_input_plugin_t *) this_gen;
+ buf_element_t *buf = fifo->buffer_pool_alloc (fifo);
buf->content = buf->mem;
total_bytes = 0;
while (total_bytes < todo) {
- num_bytes = read (input_file_handle, buf->mem + total_bytes, todo-total_bytes);
+ num_bytes = read (this->fh, buf->mem + total_bytes, todo-total_bytes);
total_bytes += num_bytes;
if (!num_bytes) {
buf->free_buffer (buf);
@@ -91,31 +99,37 @@ static buf_element_t *file_plugin_read_block (fifo_buffer_t *fifo, off_t todo) {
}
-static off_t file_plugin_seek (off_t offset, int origin) {
- return lseek (input_file_handle, offset, origin);
+static off_t file_plugin_seek (input_plugin_t *this_gen, off_t offset, int origin) {
+ file_input_plugin_t *this = (file_input_plugin_t *) this_gen;
+
+ return lseek (this->fh, offset, origin);
}
-static off_t file_plugin_get_current_pos (){
- return lseek (input_file_handle, 0, SEEK_CUR);
+static off_t file_plugin_get_current_pos (input_plugin_t *this_gen){
+ file_input_plugin_t *this = (file_input_plugin_t *) this_gen;
+
+ return lseek (this->fh, 0, SEEK_CUR);
}
-static off_t file_plugin_get_length (void) {
- struct stat buf ;
+static off_t file_plugin_get_length (input_plugin_t *this_gen) {
+
+ struct stat buf ;
+ file_input_plugin_t *this = (file_input_plugin_t *) this_gen;
- if (fstat (input_file_handle, &buf) == 0) {
+ if (fstat (this->fh, &buf) == 0) {
return buf.st_size;
} else
perror ("system call fstat");
return 0;
}
-static uint32_t file_plugin_get_blocksize () {
+static uint32_t file_plugin_get_blocksize (input_plugin_t *this_gen) {
return 0;
}
-static char **file_plugin_get_dir (char *filename, int *nFiles) {
+static char **file_plugin_get_dir (input_plugin_t *this_gen, char *filename, int *nFiles) {
/* not yet implemented */
printf ("input_file : get_dir () not implemented yet!\n");
@@ -123,61 +137,68 @@ static char **file_plugin_get_dir (char *filename, int *nFiles) {
return NULL;
}
-static int file_plugin_eject_media () {
+static int file_plugin_eject_media (input_plugin_t *this_gen) {
return 1; /* doesn't make sense */
}
-static char* file_plugin_get_mrl () {
- return input_file_mrl;
+static char* file_plugin_get_mrl (input_plugin_t *this_gen) {
+ file_input_plugin_t *this = (file_input_plugin_t *) this_gen;
+
+ return this->mrl;
}
-static void file_plugin_close (void) {
+static void file_plugin_close (input_plugin_t *this_gen) {
+ file_input_plugin_t *this = (file_input_plugin_t *) this_gen;
+
xprintf (VERBOSE|INPUT, "closing input\n");
- close(input_file_handle);
- input_file_handle = -1;
+ close(this->fh);
+ this->fh = -1;
}
-static char *file_plugin_get_description (void) {
+static char *file_plugin_get_description (input_plugin_t *this_gen) {
return "plain file input plugin as shipped with xine";
}
-static char *file_plugin_get_identifier (void) {
+static char *file_plugin_get_identifier (input_plugin_t *this_gen) {
return "file";
}
-
-static input_plugin_t plugin_info = {
- INPUT_PLUGIN_IFACE_VERSION,
- file_plugin_get_capabilities,
- file_plugin_open,
- file_plugin_read,
- file_plugin_read_block,
- file_plugin_seek,
- file_plugin_get_current_pos,
- file_plugin_get_length,
- file_plugin_get_blocksize,
- file_plugin_get_dir,
- file_plugin_eject_media,
- file_plugin_get_mrl,
- file_plugin_close,
- file_plugin_get_description,
- file_plugin_get_identifier,
- NULL, /* autoplay */
- NULL /* clut */
-};
-
-
input_plugin_t *get_input_plugin (int iface, config_values_t *config) {
- /* FIXME: set debug level (from config?) */
+ file_input_plugin_t *this;
+
+ xine_debug = config->lookup_int (config, "xine_debug", 0);
switch (iface) {
case 1:
- input_file_handle = -1;
- return &plugin_info;
+ this = (file_input_plugin_t *) malloc (sizeof (file_input_plugin_t));
+
+ this->input_plugin.interface_version = INPUT_PLUGIN_IFACE_VERSION;
+ this->input_plugin.get_capabilities = file_plugin_get_capabilities;
+ this->input_plugin.open = file_plugin_open;
+ this->input_plugin.read = file_plugin_read;
+ this->input_plugin.read_block = file_plugin_read_block;
+ this->input_plugin.seek = file_plugin_seek;
+ this->input_plugin.get_current_pos = file_plugin_get_current_pos;
+ this->input_plugin.get_length = file_plugin_get_length;
+ this->input_plugin.get_blocksize = file_plugin_get_blocksize;
+ this->input_plugin.get_dir = file_plugin_get_dir;
+ this->input_plugin.eject_media = file_plugin_eject_media;
+ this->input_plugin.get_mrl = file_plugin_get_mrl;
+ this->input_plugin.close = file_plugin_close;
+ this->input_plugin.get_description = file_plugin_get_description;
+ this->input_plugin.get_identifier = file_plugin_get_identifier;
+ this->input_plugin.get_autoplay_list = NULL;
+ this->input_plugin.get_clut = NULL;
+
+ this->fh = -1;
+ this->mrl = NULL;
+ this->config = config;
+
+ return (input_plugin_t *) this;
break;
default:
fprintf(stderr,
@@ -189,3 +210,4 @@ input_plugin_t *get_input_plugin (int iface, config_values_t *config) {
return NULL;
}
}
+
diff --git a/src/input/input_plugin.h b/src/input/input_plugin.h
index 718fe6226..6117dd8c2 100644
--- a/src/input/input_plugin.h
+++ b/src/input/input_plugin.h
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: input_plugin.h,v 1.2 2001/04/21 00:14:41 f1rmb Exp $
+ * $Id: input_plugin.h,v 1.3 2001/04/24 17:42:27 guenter Exp $
*/
#ifndef HAVE_INPUT_PLUGIN_H
@@ -40,7 +40,9 @@ typedef struct { /* CLUT == Color LookUp Table */
} __attribute__ ((packed)) clut_t;
#endif
-typedef struct input_plugin_s
+typedef struct input_plugin_s input_plugin_t;
+
+struct input_plugin_s
{
/*
@@ -52,18 +54,18 @@ typedef struct input_plugin_s
* return capabilities of input source
*/
- uint32_t (*get_capabilities) (void);
+ uint32_t (*get_capabilities) (input_plugin_t *this);
/*
* open input MRL - return 1 if succ
*/
- int (*open) (char *mrl);
+ int (*open) (input_plugin_t *this, char *mrl);
/*
* read nlen bytes, return number of bytes read
*/
- off_t (*read) (char *buf, off_t nlen);
+ off_t (*read) (input_plugin_t *this, char *buf, off_t nlen);
/*
@@ -71,7 +73,7 @@ typedef struct input_plugin_s
* for blocked input sources len must be == blocksize
* the fifo parameter is only used to get access to the buffer_pool_alloc function
*/
- buf_element_t *(*read_block)(fifo_buffer_t *fifo, off_t len);
+ buf_element_t *(*read_block)(input_plugin_t *this, fifo_buffer_t *fifo, off_t len);
/*
@@ -79,34 +81,34 @@ typedef struct input_plugin_s
*
* if seeking failed, -1 is returned
*/
- off_t (*seek) (off_t offset, int origin);
+ off_t (*seek) (input_plugin_t *this, off_t offset, int origin);
/*
* get current position in stream.
*
*/
- off_t (*get_current_pos) (void);
+ off_t (*get_current_pos) (input_plugin_t *this);
/*
* return length of input (-1 => unlimited, e.g. stream)
*/
- off_t (*get_length) (void);
+ off_t (*get_length) (input_plugin_t *this);
/*
* return block size of input source (if supported, 0 otherwise)
*/
- uint32_t (*get_blocksize) (void);
+ uint32_t (*get_blocksize) (input_plugin_t *this);
/*
* ls function
* return value: NULL => filename is a file, **char=> filename is a dir
*/
- char** (*get_dir) (char *filename, int *nFiles);
+ char** (*get_dir) (input_plugin_t *this, char *filename, int *nFiles);
/*
@@ -114,25 +116,25 @@ typedef struct input_plugin_s
*
* returns 0 for temporary failures
*/
- int (*eject_media) (void);
+ int (*eject_media) (input_plugin_t *this);
/*
* return current MRL
*/
- char * (*get_mrl) (void);
+ char * (*get_mrl) (input_plugin_t *this);
/*
* close input source
*/
- void (*close) (void);
+ void (*close) (input_plugin_t *this);
/*
* return human readable (verbose = 1 line) description for this plugin
*/
- char* (*get_description) (void);
+ char* (*get_description) (input_plugin_t *this);
/*
@@ -140,35 +142,29 @@ typedef struct input_plugin_s
* this is used for GUI buttons, The identifier must have max. 4 characters
* characters (max. 5 including terminating \0)
*/
- char* (*get_identifier) (void);
+ char* (*get_identifier) (input_plugin_t *this);
/*
* generate autoplay list
* return value: list of MRLs
*/
- char** (*get_autoplay_list) (int *nFiles);
+ char** (*get_autoplay_list) (input_plugin_t *this, int *nFiles);
/*
* gets the subtitle/menu palette
*/
- clut_t* (*get_clut) (void);
-
+ clut_t* (*get_clut) (input_plugin_t *this);
+};
-} input_plugin_t;
+/*
+ * possible capabilites an input plugin can have:
+ */
#define INPUT_CAP_SEEKABLE 1
#define INPUT_CAP_BLOCK 2
#define INPUT_CAP_AUTOPLAY 4
#define INPUT_CAP_CLUT 8
-
-/*
- * init/get plugin structure
- *
- * try to initialize the plugin with given interface version
- * and configuration options
- */
-
#endif
diff --git a/src/xine-engine/load_plugins.c b/src/xine-engine/load_plugins.c
index 3321fb4c4..b80f1e929 100644
--- a/src/xine-engine/load_plugins.c
+++ b/src/xine-engine/load_plugins.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: load_plugins.c,v 1.5 2001/04/24 15:47:32 guenter Exp $
+ * $Id: load_plugins.c,v 1.6 2001/04/24 17:42:27 guenter Exp $
*
*
* Load input/demux/audio_out/video_out/codec plugins
@@ -156,7 +156,7 @@ void load_input_plugins (xine_t *this,
else {
void *(*initplug) (int, config_values_t *);
- if((initplug = dlsym(plugin, "init_demuxer_plugin")) != NULL) {
+ if((initplug = dlsym(plugin, "init_input_plugin")) != NULL) {
input_plugin_t *ip;
ip = (input_plugin_t *) initplug(iface_version, config);
@@ -164,7 +164,7 @@ void load_input_plugins (xine_t *this,
printf("input plugin found : %s(ID: %s, iface: %d)\n",
str,
- this->input_plugins[this->num_input_plugins]->get_identifier(),
+ this->input_plugins[this->num_input_plugins]->get_identifier(this->input_plugins[this->num_input_plugins]),
this->input_plugins[this->num_input_plugins]->interface_version);
this->num_input_plugins++;