diff options
author | Guenter Bartsch <guenter@users.sourceforge.net> | 2001-06-16 18:03:21 +0000 |
---|---|---|
committer | Guenter Bartsch <guenter@users.sourceforge.net> | 2001-06-16 18:03:21 +0000 |
commit | aa6c019ffeaae2109b383f2a142bf2dab7c2f7b3 (patch) | |
tree | 21ca974b3613cb0d03c0bb42eb96dcacba8ffd59 /src/demuxers | |
parent | 528a7fbfe28ea118599df54bdb17b4c5f4850704 (diff) | |
download | xine-lib-aa6c019ffeaae2109b383f2a142bf2dab7c2f7b3.tar.gz xine-lib-aa6c019ffeaae2109b383f2a142bf2dab7c2f7b3.tar.bz2 |
xine engine cleanups and new callbacks for seamless branching
CVS patchset: 192
CVS date: 2001/06/16 18:03:21
Diffstat (limited to 'src/demuxers')
-rw-r--r-- | src/demuxers/demux.h | 11 | ||||
-rw-r--r-- | src/demuxers/demux_avi.c | 38 | ||||
-rw-r--r-- | src/demuxers/demux_elem.c | 52 | ||||
-rw-r--r-- | src/demuxers/demux_mpeg.c | 36 | ||||
-rw-r--r-- | src/demuxers/demux_mpeg_block.c | 72 | ||||
-rw-r--r-- | src/demuxers/demux_mpgaudio.c | 37 |
6 files changed, 171 insertions, 75 deletions
diff --git a/src/demuxers/demux.h b/src/demuxers/demux.h index 8db15c542..247425ea7 100644 --- a/src/demuxers/demux.h +++ b/src/demuxers/demux.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: demux.h,v 1.4 2001/04/27 10:47:41 f1rmb Exp $ + * $Id: demux.h,v 1.5 2001/06/16 18:03:22 guenter Exp $ */ #ifndef HAVE_DEMUX_H @@ -47,6 +47,12 @@ #define STAGE_BY_CONTENT 1 #define STAGE_BY_EXTENSION 2 +/* called when xine tries to branch seamlessly to the next mrl */ +typedef char* (*gui_get_next_mrl_cb_t) (void); + +/* called when xine branched successfully to the next mrl */ +typedef void (*gui_branched_cb_t) (void); + /* * a demux plugin (no matter if it's staically built into xine * or dynamically loaded at run-time) must implement these functions @@ -80,7 +86,8 @@ struct demux_plugin_s void (*start) (demux_plugin_t *this, fifo_buffer_t *video_fifo, fifo_buffer_t *audio_fifo, fifo_buffer_t *spu_fifo, - off_t pos) ; + off_t pos, gui_get_next_mrl_cb_t next_mrl_cb, + gui_branched_cb_t branched_cb) ; /* * stop & kill demux thread, free resources associated with current diff --git a/src/demuxers/demux_avi.c b/src/demuxers/demux_avi.c index 1c1bfe23d..30294f434 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.18 2001/06/16 14:34:48 guenter Exp $ + * $Id: demux_avi.c,v 1.19 2001/06/16 18:03:22 guenter Exp $ * * demultiplexer for avi streams * @@ -117,6 +117,8 @@ typedef struct demux_avi_s { uint32_t video_step; uint32_t AVI_errno; + + int send_end_buffers; } demux_avi_t ; #define AVI_ERR_SIZELIM 1 /* The write of the data would exceed @@ -821,20 +823,26 @@ static void *demux_avi_loop (void *this_gen) { buf_element_t *buf = NULL; demux_avi_t *this = (demux_avi_t *) this_gen; + this->send_end_buffers = 1; + do { if (!demux_avi_next(this)) this->status = DEMUX_FINISHED; } while (this->status == DEMUX_OK) ; - buf = this->video_fifo->buffer_pool_alloc (this->video_fifo); - buf->type = BUF_CONTROL_END; - this->video_fifo->put (this->video_fifo, buf); - - if(this->audio_fifo) { - buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); - buf->type = BUF_CONTROL_END; - this->audio_fifo->put (this->audio_fifo, buf); + if (this->send_end_buffers) { + buf = this->video_fifo->buffer_pool_alloc (this->video_fifo); + buf->type = BUF_CONTROL_END; + buf->decoder_info[0] = 0; /* stream finished */ + this->video_fifo->put (this->video_fifo, buf); + + if(this->audio_fifo) { + buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); + buf->type = BUF_CONTROL_END; + buf->decoder_info[0] = 0; /* stream finished */ + this->audio_fifo->put (this->audio_fifo, buf); + } } xprintf (VERBOSE|DEMUX, "demux_avi: demux loop finished.\n"); @@ -849,6 +857,7 @@ static void demux_avi_stop (demux_plugin_t *this_gen) { demux_avi_t *this = (demux_avi_t *) this_gen; buf_element_t *buf; + this->send_end_buffers = 0; this->status = DEMUX_FINISHED; pthread_join (this->thread, &p); @@ -856,17 +865,18 @@ static void demux_avi_stop (demux_plugin_t *this_gen) { AVI_close (this->avi); this->avi = NULL; - this->video_fifo->clear(this->video_fifo); this->audio_fifo->clear(this->audio_fifo); buf = this->video_fifo->buffer_pool_alloc (this->video_fifo); - buf->type = BUF_CONTROL_END; + buf->type = BUF_CONTROL_END; + buf->decoder_info[0] = 1; /* forced */ this->video_fifo->put (this->video_fifo, buf); if(this->audio_fifo) { buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); - buf->type = BUF_CONTROL_END; + buf->type = BUF_CONTROL_END; + buf->decoder_info[0] = 1; /* forced */ this->audio_fifo->put (this->audio_fifo, buf); } @@ -886,7 +896,9 @@ static void demux_avi_start (demux_plugin_t *this_gen, fifo_buffer_t *video_fifo, fifo_buffer_t *audio_fifo, fifo_buffer_t *spu_fifo, - off_t pos) + off_t pos, + gui_get_next_mrl_cb_t next_mrl_cb, + gui_branched_cb_t branched_cb) { buf_element_t *buf; demux_avi_t *this = (demux_avi_t *) this_gen; diff --git a/src/demuxers/demux_elem.c b/src/demuxers/demux_elem.c index e342b482c..5c2b58487 100644 --- a/src/demuxers/demux_elem.c +++ b/src/demuxers/demux_elem.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_elem.c,v 1.9 2001/05/30 02:09:24 f1rmb Exp $ + * $Id: demux_elem.c,v 1.10 2001/06/16 18:03:22 guenter Exp $ * * demultiplexer for elementary mpeg streams * @@ -52,6 +52,8 @@ typedef struct { int blocksize; int status; + + int send_end_buffers; } demux_mpeg_elem_t ; @@ -88,6 +90,8 @@ static void *demux_mpeg_elem_loop (void *this_gen) { buf_element_t *buf = NULL; demux_mpeg_elem_t *this = (demux_mpeg_elem_t *) this_gen; + this->send_end_buffers = 1; + do { if (!demux_mpeg_elem_next(this)) @@ -99,14 +103,18 @@ static void *demux_mpeg_elem_loop (void *this_gen) { this->status = DEMUX_FINISHED; - buf = this->video_fifo->buffer_pool_alloc (this->video_fifo); - buf->type = BUF_CONTROL_END; - this->video_fifo->put (this->video_fifo, buf); - - if(this->audio_fifo) { - buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); - buf->type = BUF_CONTROL_END; - this->audio_fifo->put (this->audio_fifo, buf); + if (this->send_end_buffers) { + buf = this->video_fifo->buffer_pool_alloc (this->video_fifo); + buf->type = BUF_CONTROL_END; + buf->decoder_info[0] = 0; /* stream finished */ + this->video_fifo->put (this->video_fifo, buf); + + if(this->audio_fifo) { + buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); + buf->type = BUF_CONTROL_END; + buf->decoder_info[0] = 0; /* stream finished */ + this->audio_fifo->put (this->audio_fifo, buf); + } } pthread_exit(NULL); @@ -116,12 +124,32 @@ static void *demux_mpeg_elem_loop (void *this_gen) { * */ static void demux_mpeg_elem_stop (demux_plugin_t *this_gen) { + demux_mpeg_elem_t *this = (demux_mpeg_elem_t *) this_gen; - void *p; + void *p; + buf_element_t *buf = NULL; + + this->send_end_buffers = 0; this->status = DEMUX_FINISHED; pthread_join (this->thread, &p); + + this->video_fifo->clear(this->video_fifo); + this->audio_fifo->clear(this->audio_fifo); + + buf = this->video_fifo->buffer_pool_alloc (this->video_fifo); + buf->type = BUF_CONTROL_END; + buf->decoder_info[0] = 1; /* forced */ + + this->video_fifo->put (this->video_fifo, buf); + + if(this->audio_fifo) { + buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); + buf->type = BUF_CONTROL_END; + buf->decoder_info[0] = 1; /* forced */ + this->audio_fifo->put (this->audio_fifo, buf); + } } /* @@ -140,7 +168,9 @@ static void demux_mpeg_elem_start (demux_plugin_t *this_gen, fifo_buffer_t *video_fifo, fifo_buffer_t *audio_fifo, fifo_buffer_t *spu_fifo, - off_t pos) { + off_t pos, + gui_get_next_mrl_cb_t next_mrl_cb, + gui_branched_cb_t branched_cb) { demux_mpeg_elem_t *this = (demux_mpeg_elem_t *) this_gen; buf_element_t *buf; diff --git a/src/demuxers/demux_mpeg.c b/src/demuxers/demux_mpeg.c index ab2353431..b80c8f7ca 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.18 2001/06/16 14:34:48 guenter Exp $ + * $Id: demux_mpeg.c,v 1.19 2001/06/16 18:03:22 guenter Exp $ * * demultiplexer for mpeg 1/2 program streams * reads streams of variable blocksizes @@ -61,6 +61,8 @@ typedef struct demux_mpeg_s { int status; int preview_mode; + + int send_end_buffers; } demux_mpeg_t ; static uint32_t read_bytes (demux_mpeg_t *this, int n) { @@ -511,6 +513,7 @@ static void *demux_mpeg_loop (void *this_gen) { uint32_t w; this->status = DEMUX_OK; + this->send_end_buffers = 1; do { w = parse_pack (this); @@ -520,16 +523,19 @@ static void *demux_mpeg_loop (void *this_gen) { } while (this->status == DEMUX_OK) ; - buf = this->video_fifo->buffer_pool_alloc (this->video_fifo); - buf->type = BUF_CONTROL_END; - this->video_fifo->put (this->video_fifo, buf); + if (this->send_end_buffers) { + buf = this->video_fifo->buffer_pool_alloc (this->video_fifo); + buf->type = BUF_CONTROL_END; + buf->decoder_info[0] = 0; /* stream finished */ + this->video_fifo->put (this->video_fifo, buf); - if(this->audio_fifo) { - buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); - buf->type = BUF_CONTROL_END; - this->audio_fifo->put (this->audio_fifo, buf); + if(this->audio_fifo) { + buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); + buf->type = BUF_CONTROL_END; + buf->decoder_info[0] = 0; /* stream finished */ + this->audio_fifo->put (this->audio_fifo, buf); + } } - xprintf (VERBOSE|DEMUX, "demux loop finished (status: %d, buf:%x)\n", this->status, w); printf ("demux loop finished (status: %d, buf:%x)\n", @@ -545,6 +551,7 @@ static void demux_mpeg_stop (demux_plugin_t *this_gen) { demux_mpeg_t *this = (demux_mpeg_t *) this_gen; buf_element_t *buf; + this->send_end_buffers = 0; this->status = DEMUX_FINISHED; pthread_join (this->thread, &p); @@ -553,15 +560,16 @@ static void demux_mpeg_stop (demux_plugin_t *this_gen) { this->audio_fifo->clear(this->audio_fifo); buf = this->video_fifo->buffer_pool_alloc (this->video_fifo); - buf->type = BUF_CONTROL_END; + buf->type = BUF_CONTROL_END; + buf->decoder_info[0] = 1; /* forced */ this->video_fifo->put (this->video_fifo, buf); if(this->audio_fifo) { buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); - buf->type = BUF_CONTROL_END; + buf->type = BUF_CONTROL_END; + buf->decoder_info[0] = 1; /* forced */ this->audio_fifo->put (this->audio_fifo, buf); } - } static int demux_mpeg_get_status (demux_plugin_t *this_gen) { @@ -573,7 +581,9 @@ static void demux_mpeg_start (demux_plugin_t *this_gen, fifo_buffer_t *video_fifo, fifo_buffer_t *audio_fifo, fifo_buffer_t *spu_fifo, - off_t pos) + off_t pos, + gui_get_next_mrl_cb_t next_mrl_cb, + gui_branched_cb_t branched_cb) { demux_mpeg_t *this = (demux_mpeg_t *) this_gen; buf_element_t *buf; diff --git a/src/demuxers/demux_mpeg_block.c b/src/demuxers/demux_mpeg_block.c index b3e7e422f..b90949820 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.15 2001/06/16 14:34:48 guenter Exp $ + * $Id: demux_mpeg_block.c,v 1.16 2001/06/16 18:03:22 guenter Exp $ * * demultiplexer for mpeg 1/2 program streams * @@ -43,19 +43,24 @@ static uint32_t xine_debug; typedef struct demux_mpeg_block_s { - demux_plugin_t demux_plugin; + demux_plugin_t demux_plugin; - fifo_buffer_t *audio_fifo; - fifo_buffer_t *video_fifo; - fifo_buffer_t *spu_fifo; + fifo_buffer_t *audio_fifo; + fifo_buffer_t *video_fifo; + fifo_buffer_t *spu_fifo; - input_plugin_t *input; + input_plugin_t *input; - pthread_t thread; + pthread_t thread; - int status; + int status; - int blocksize; + int blocksize; + + int send_end_buffers; + + gui_get_next_mrl_cb_t next_mrl_cb; + gui_branched_cb_t branched_cb; } demux_mpeg_block_t ; @@ -74,6 +79,7 @@ static void demux_mpeg_block_parse_pack (demux_mpeg_block_t *this, int preview_m buf = this->input->read_block (this->input, this->video_fifo, this->blocksize); if (buf==NULL) { + printf ("demux_mpeg_block: read_block failed\n"); this->status = DEMUX_FINISHED; return ; } @@ -333,25 +339,33 @@ static void *demux_mpeg_block_loop (void *this_gen) { buf_element_t *buf = NULL; demux_mpeg_block_t *this = (demux_mpeg_block_t *) this_gen; + printf ("demux_mpeg_block: demux loop starting...\n"); + + this->send_end_buffers = 1; + do { demux_mpeg_block_parse_pack(this, 0); } while (this->status == DEMUX_OK) ; - xprintf (VERBOSE|DEMUX, "demux loop finished (status: %d)\n", - this->status); + printf ("demux_mpeg_block: demux loop finished (status: %d)\n", + this->status); this->status = DEMUX_FINISHED; - buf = this->video_fifo->buffer_pool_alloc (this->video_fifo); - buf->type = BUF_CONTROL_END; - this->video_fifo->put (this->video_fifo, buf); - - if(this->audio_fifo) { - buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); - buf->type = BUF_CONTROL_END; - this->audio_fifo->put (this->audio_fifo, buf); + if (this->send_end_buffers) { + buf = this->video_fifo->buffer_pool_alloc (this->video_fifo); + buf->type = BUF_CONTROL_END; + buf->decoder_info[0] = 0; /* stream finished */ + this->video_fifo->put (this->video_fifo, buf); + + if(this->audio_fifo) { + buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); + buf->type = BUF_CONTROL_END; + buf->decoder_info[0] = 0; /* stream finished */ + this->audio_fifo->put (this->audio_fifo, buf); + } } pthread_exit(NULL); @@ -365,6 +379,9 @@ static void demux_mpeg_block_stop (demux_plugin_t *this_gen) { void *p; buf_element_t *buf; + printf ("demux_mpeg_block: stop(...)\n"); + + this->send_end_buffers = 0; this->status = DEMUX_FINISHED; pthread_join (this->thread, &p); @@ -373,12 +390,15 @@ static void demux_mpeg_block_stop (demux_plugin_t *this_gen) { this->audio_fifo->clear(this->audio_fifo); buf = this->video_fifo->buffer_pool_alloc (this->video_fifo); - buf->type = BUF_CONTROL_END; + buf->type = BUF_CONTROL_END; + buf->decoder_info[0] = 1; /* forced */ + this->video_fifo->put (this->video_fifo, buf); if(this->audio_fifo) { buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); - buf->type = BUF_CONTROL_END; + buf->type = BUF_CONTROL_END; + buf->decoder_info[0] = 1; /* forced */ this->audio_fifo->put (this->audio_fifo, buf); } @@ -394,7 +414,9 @@ static void demux_mpeg_block_start (demux_plugin_t *this_gen, fifo_buffer_t *video_fifo, fifo_buffer_t *audio_fifo, fifo_buffer_t *spu_fifo, - off_t pos) + off_t pos, + gui_get_next_mrl_cb_t next_mrl_cb, + gui_branched_cb_t branched_cb) { demux_mpeg_block_t *this = (demux_mpeg_block_t *) this_gen; @@ -403,8 +425,8 @@ static void demux_mpeg_block_start (demux_plugin_t *this_gen, this->video_fifo = video_fifo; this->audio_fifo = audio_fifo; this->spu_fifo = spu_fifo; - - this->status = DEMUX_OK; + this->next_mrl_cb = next_mrl_cb; + this->branched_cb = branched_cb; pos /= (off_t) this->blocksize; pos *= (off_t) this->blocksize; @@ -444,6 +466,8 @@ static void demux_mpeg_block_start (demux_plugin_t *this_gen, * now start demuxing */ + this->status = DEMUX_OK ; + pthread_create (&this->thread, NULL, demux_mpeg_block_loop, this) ; } diff --git a/src/demuxers/demux_mpgaudio.c b/src/demuxers/demux_mpgaudio.c index f99c77ffc..550ffee7d 100644 --- a/src/demuxers/demux_mpgaudio.c +++ b/src/demuxers/demux_mpgaudio.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_mpgaudio.c,v 1.11 2001/06/16 14:34:48 guenter Exp $ + * $Id: demux_mpgaudio.c,v 1.12 2001/06/16 18:03:22 guenter Exp $ * * demultiplexer for mpeg audio (i.e. mp3) streams * @@ -52,6 +52,8 @@ typedef struct { pthread_t thread; int status; + + int send_end_buffers; } demux_mpgaudio_t ; static uint32_t xine_debug; @@ -106,6 +108,8 @@ static void *demux_mpgaudio_loop (void *this_gen) { buf_element_t *buf; demux_mpgaudio_t *this = (demux_mpgaudio_t *) this_gen; + this->send_end_buffers = 1; + do { if (!demux_mpgaudio_next(this)) @@ -117,14 +121,18 @@ static void *demux_mpgaudio_loop (void *this_gen) { this->status = DEMUX_FINISHED; - buf = this->video_fifo->buffer_pool_alloc (this->video_fifo); - buf->type = BUF_CONTROL_END; - this->video_fifo->put (this->video_fifo, buf); - - if(this->audio_fifo) { - buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); - buf->type = BUF_CONTROL_END; - this->audio_fifo->put (this->audio_fifo, buf); + if (this->send_end_buffers) { + buf = this->video_fifo->buffer_pool_alloc (this->video_fifo); + buf->type = BUF_CONTROL_END; + buf->decoder_info[0] = 0; /* stream finished */ + this->video_fifo->put (this->video_fifo, buf); + + if(this->audio_fifo) { + buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); + buf->type = BUF_CONTROL_END; + buf->decoder_info[0] = 0; /* stream finished */ + this->audio_fifo->put (this->audio_fifo, buf); + } } pthread_exit(NULL); @@ -135,6 +143,7 @@ static void demux_mpgaudio_stop (demux_plugin_t *this_gen) { void *p; buf_element_t *buf; + this->send_end_buffers = 0; this->status = DEMUX_FINISHED; pthread_join (this->thread, &p); @@ -143,12 +152,14 @@ static void demux_mpgaudio_stop (demux_plugin_t *this_gen) { this->audio_fifo->clear(this->audio_fifo); buf = this->video_fifo->buffer_pool_alloc (this->video_fifo); - buf->type = BUF_CONTROL_END; + buf->type = BUF_CONTROL_END; + buf->decoder_info[0] = 1; /* forced */ this->video_fifo->put (this->video_fifo, buf); if(this->audio_fifo) { buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo); - buf->type = BUF_CONTROL_END; + buf->type = BUF_CONTROL_END; + buf->decoder_info[0] = 1; /* forced */ this->audio_fifo->put (this->audio_fifo, buf); } } @@ -163,7 +174,9 @@ static void demux_mpgaudio_start (demux_plugin_t *this_gen, fifo_buffer_t *video_fifo, fifo_buffer_t *audio_fifo, fifo_buffer_t *spu_fifo, - off_t pos) { + off_t pos, + gui_get_next_mrl_cb_t next_mrl_cb, + gui_branched_cb_t branched_cb) { demux_mpgaudio_t *this = (demux_mpgaudio_t *) this_gen; buf_element_t *buf; |