diff options
Diffstat (limited to 'src/xine-engine')
-rw-r--r-- | src/xine-engine/audio_decoder.c | 5 | ||||
-rw-r--r-- | src/xine-engine/buffer.h | 5 | ||||
-rw-r--r-- | src/xine-engine/video_decoder.c | 6 | ||||
-rw-r--r-- | src/xine-engine/xine.c | 196 | ||||
-rw-r--r-- | src/xine-engine/xine_internal.h | 42 |
5 files changed, 102 insertions, 152 deletions
diff --git a/src/xine-engine/audio_decoder.c b/src/xine-engine/audio_decoder.c index 0a98a15d8..707160c58 100644 --- a/src/xine-engine/audio_decoder.c +++ b/src/xine-engine/audio_decoder.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: audio_decoder.c,v 1.31 2001/08/25 08:48:12 guenter Exp $ + * $Id: audio_decoder.c,v 1.32 2001/09/01 14:33:00 guenter Exp $ * * * functions that implement audio decoding @@ -54,6 +54,9 @@ void *audio_decoder_loop (void *this_gen) { if (buf->input_pos) this->cur_input_pos = buf->input_pos; + if (buf->input_time) + this->cur_input_time = buf->input_time; + /* * Call update status callback function if * there is no video decoder initialized, like diff --git a/src/xine-engine/buffer.h b/src/xine-engine/buffer.h index de98971f5..9cd17add0 100644 --- a/src/xine-engine/buffer.h +++ b/src/xine-engine/buffer.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: buffer.h,v 1.7 2001/08/31 17:57:54 jkeil Exp $ + * $Id: buffer.h,v 1.8 2001/09/01 14:33:00 guenter Exp $ * * * contents: @@ -109,8 +109,9 @@ struct buf_element_s { uint32_t size ; /* size of _content_ */ uint32_t max_size; uint32_t type; - uint32_t PTS, DTS; + uint32_t PTS; off_t input_pos; /* remember where this buf came from in the input source */ + int input_time;/* time offset in seconds from beginning of stream */ uint32_t decoder_info[4]; /* additional decoder flags and other dec-spec. stuff */ void (*free_buffer) (buf_element_t *buf); diff --git a/src/xine-engine/video_decoder.c b/src/xine-engine/video_decoder.c index 64d9748e4..83e716cae 100644 --- a/src/xine-engine/video_decoder.c +++ b/src/xine-engine/video_decoder.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: video_decoder.c,v 1.44 2001/08/28 19:16:20 guenter Exp $ + * $Id: video_decoder.c,v 1.45 2001/09/01 14:33:00 guenter Exp $ * */ @@ -66,6 +66,8 @@ void *video_decoder_loop (void *this_gen) { buf = this->video_fifo->get (this->video_fifo); if (buf->input_pos) this->cur_input_pos = buf->input_pos; + if (buf->input_time) + this->cur_input_time = buf->input_time; /* printf ("video_decoder: got buffer %d\n", buf->type); */ @@ -182,7 +184,7 @@ void *video_decoder_loop (void *this_gen) { decoder->get_identifier()); } - + decoder->decode_data (this->cur_video_decoder_plugin, buf); } } else diff --git a/src/xine-engine/xine.c b/src/xine-engine/xine.c index a4878d7b9..b2abd26a0 100644 --- a/src/xine-engine/xine.c +++ b/src/xine-engine/xine.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: xine.c,v 1.52 2001/08/29 11:14:12 guenter Exp $ + * $Id: xine.c,v 1.53 2001/09/01 14:33:00 guenter Exp $ * * top-level xine functions * @@ -75,11 +75,11 @@ void xine_stop (xine_t *this) { pthread_mutex_unlock (&this->xine_lock); return; } - else if(this->status == XINE_PAUSE) { - this->metronom->set_speed (this->metronom, SPEED_NORMAL); - this->paused = 0; - this->audio_mute = 0; - } + + + this->metronom->set_speed (this->metronom, SPEED_NORMAL); + this->speed = SPEED_NORMAL; + this->audio_mute = 0; this->status = XINE_STOP; printf ("xine_stop: stopping demuxer\n"); @@ -89,8 +89,6 @@ void xine_stop (xine_t *this) { this->cur_demuxer_plugin = NULL; } - printf ("xine_stop: closing input\n"); - if(this->cur_input_plugin) { this->cur_input_plugin->close(this->cur_input_plugin); /* @@ -174,20 +172,38 @@ static int find_demuxer(xine_t *this, const char *MRL) { return 0; } -static void xine_play_internal (xine_t *this, char *mrl, - int spos, off_t pos) { +void xine_play (xine_t *this, char *mrl, + int start_pos, int start_time) { double share ; - off_t len; + off_t pos, len; int i; - xprintf (VERBOSE|LOOP, "xine open %s, start pos = %d\n", mrl, spos); + xprintf (VERBOSE|LOOP, "xine open %s, start pos = %d\n", mrl, start_pos); - printf ("xine_play_internal: open %s, start pos = %d\n", mrl, spos); + pthread_mutex_lock (&this->xine_lock); - if (this->status != XINE_STOP) { - printf ("xine_play_internal: error: xine is not stopped\n"); - return; + printf ("xine_play: open %s, start pos = %d\n", mrl, start_pos); + + /* + * stop engine? + */ + + if (this->status == XINE_PLAY) { + + if(this->cur_demuxer_plugin) { + this->cur_demuxer_plugin->stop (this->cur_demuxer_plugin); + } + + if(this->cur_input_plugin) { + + if (strcmp (mrl, this->cur_mrl)) + this->cur_input_plugin->close(this->cur_input_plugin); + else + this->cur_input_plugin->stop(this->cur_input_plugin); + } + + this->status = XINE_STOP; } /* @@ -204,8 +220,9 @@ static void xine_play_internal (xine_t *this, char *mrl, } if (!this->cur_input_plugin) { - perror ("open input source"); + printf ("xine: cannot find input plugin for this MRL\n"); this->cur_demuxer_plugin = NULL; + pthread_mutex_unlock (&this->xine_lock); return; } @@ -224,6 +241,7 @@ static void xine_play_internal (xine_t *this, char *mrl, if(!find_demuxer(this, mrl)) { printf ("xine: couldn't find demuxer for >%s<\n", mrl); + pthread_mutex_unlock (&this->xine_lock); return; } @@ -234,94 +252,32 @@ static void xine_play_internal (xine_t *this, char *mrl, * start demuxer */ - if (spos) { + if (start_pos) { len = this->cur_input_plugin->get_length (this->cur_input_plugin); - share = (double) spos / 65535; + share = (double) start_pos / 65535; pos = (off_t) (share * len) ; - } + } else + pos = 0; this->cur_demuxer_plugin->start (this->cur_demuxer_plugin, this->video_fifo, this->audio_fifo, - pos, + pos, start_time, this->get_next_mrl_cb, this->branched_cb); this->status = XINE_PLAY; strncpy (this->cur_mrl, mrl, 1024); - printf ("xine: demuxer started\n"); - -} + this->metronom->set_speed (this->metronom, SPEED_NORMAL); + this->audio_mute = 0; + this->speed = SPEED_NORMAL; -void xine_play (xine_t *this, char *MRL, int spos) { - - pthread_mutex_lock (&this->xine_lock); - - if(this->status == XINE_PAUSE) { - - this->metronom->set_speed (this->metronom, SPEED_NORMAL); - this->paused = 0; - this->audio_mute = 0; - - if(this->cur_demuxer_plugin) { - this->cur_demuxer_plugin->stop (this->cur_demuxer_plugin); - this->cur_demuxer_plugin = NULL; - } - - printf ("xine_stop: closing input\n"); - - if(this->cur_input_plugin) { - this->cur_input_plugin->close(this->cur_input_plugin); - } - - this->status = XINE_STOP; - - } - else if (this->status != XINE_STOP) { - - this->metronom->set_speed (this->metronom, SPEED_NORMAL); - this->audio_mute = 0; - - pthread_mutex_unlock (&this->xine_lock); - return; - } - - xine_play_internal (this, MRL, spos, (off_t) 0); + printf ("xine_play: demuxer started\n"); pthread_mutex_unlock (&this->xine_lock); } -void xine_seek (xine_t *this, char *mrl, int pos) { - - pthread_mutex_lock (&this->xine_lock); - - printf ("xine_seek\n"); - - if (this->status == XINE_PLAY || this->status == XINE_PAUSE) { - - if(this->status == XINE_PAUSE) { - this->metronom->set_speed (this->metronom, SPEED_NORMAL); - this->paused = 0; - this->audio_mute = 0; - } - - if(this->cur_demuxer_plugin) { - this->cur_demuxer_plugin->stop (this->cur_demuxer_plugin); - } - - if(this->cur_input_plugin) { - this->cur_input_plugin->stop(this->cur_input_plugin); - } - - this->status = XINE_STOP; - } - - xine_play_internal (this, mrl, pos, (off_t)0); - - pthread_mutex_unlock (&this->xine_lock); -} - int xine_eject (xine_t *this) { if(this->cur_input_plugin == NULL) @@ -347,11 +303,9 @@ void xine_exit (xine_t *this) { pthread_mutex_lock (&this->xine_lock); - if(this->status == XINE_PAUSE) { - this->metronom->set_speed (this->metronom, SPEED_NORMAL); - this->paused = 0; - this->status = XINE_STOP; - } + this->metronom->set_speed (this->metronom, SPEED_NORMAL); + this->speed = SPEED_NORMAL; + this->status = XINE_STOP; /* * stop decoder threads @@ -391,37 +345,6 @@ void xine_exit (xine_t *this) { } -void xine_pause (xine_t *this) { - - pthread_mutex_lock (&this->xine_lock); - - printf ("xine_pause\n"); - - if (this->status != XINE_PLAY && this->status != XINE_PAUSE ) { - printf ("xine: error, pause called when not in playback mode\n"); - pthread_mutex_unlock (&this->xine_lock); - return; - } - - if (this->paused) { - - this->metronom->set_speed (this->metronom, SPEED_NORMAL); - this->audio_mute = 0; - this->paused = 0; - this->status = XINE_PLAY; - - } else { - - this->metronom->set_speed (this->metronom, SPEED_PAUSE); - this->paused = 1; - this->audio_mute = 2; - this->status = XINE_PAUSE; - - } - - pthread_mutex_unlock (&this->xine_lock); -} - static void event_handler(xine_t *xine, event_t *event, void *data) { /* Check Xine handle/current input plugin is not NULL */ if((xine == NULL) || (xine->cur_input_plugin == NULL)) { @@ -658,8 +581,11 @@ void xine_set_speed (xine_t *this, int speed) { this->metronom->set_speed (this->metronom, speed); - this->audio_mute = speed != SPEED_NORMAL; - this->paused = speed == SPEED_PAUSE; + if (speed == SPEED_PAUSE) + this->audio_mute = 2; + else + this->audio_mute = speed != SPEED_NORMAL; + this->speed = speed; pthread_mutex_unlock (&this->xine_lock); @@ -669,3 +595,21 @@ void xine_set_speed (xine_t *this, int speed) { int xine_get_speed (xine_t *this) { return this->speed; } + +/* + * time measurement / seek + */ + +int xine_get_current_time (xine_t *this) { + return this->cur_input_time; +} + +int xine_get_stream_length (xine_t *this) { + + if(this->cur_demuxer_plugin) + return this->cur_demuxer_plugin->get_stream_length (this->cur_demuxer_plugin); + + return 0; +} + + diff --git a/src/xine-engine/xine_internal.h b/src/xine-engine/xine_internal.h index 56290bb79..33af5169d 100644 --- a/src/xine-engine/xine_internal.h +++ b/src/xine-engine/xine_internal.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: xine_internal.h,v 1.42 2001/08/28 22:52:57 f1rmb Exp $ + * $Id: xine_internal.h,v 1.43 2001/09/01 14:33:00 guenter Exp $ * */ @@ -120,7 +120,6 @@ typedef void (*gui_stream_end_cb_t)(int nStatus); #define XINE_STOP 0 #define XINE_PLAY 1 #define XINE_QUIT 2 -#define XINE_PAUSE 3 typedef struct xine_s xine_t; @@ -146,6 +145,7 @@ struct xine_s { int status; int speed; off_t cur_input_pos; + int cur_input_time; char cur_mrl[1024]; spu_functions_t *spu_out; @@ -166,7 +166,6 @@ struct xine_s { video_decoder_t *video_decoder_plugins[DECODER_PLUGIN_MAX]; video_decoder_t *cur_video_decoder_plugin; int video_finished; - int paused; ao_instance_t *audio_out; fifo_buffer_t *audio_fifo; @@ -211,29 +210,18 @@ xine_t *xine_init (vo_driver_t *vo, gui_branched_cb_t branched_cb); /* - * open a stream and play it + * open a stream sekk to a given position and play it * - * name : mrl to open - * pos : start position 0..65535 + * name : mrl to open + * start_pos : position in input source (0..65535) + * start_time : position measured in seconds from stream start * - */ -void xine_play (xine_t *this, char *MRL, int pos); - - -/* - * seek the stream to pos, and play it - * - * name : mrl to open - * pos : start position 0..65535 + * if both parameters are !=0 start_pos will be used + * for non-seekable streams both values will be ignored * */ -void xine_seek (xine_t *this, char *MRL, int pos); - +void xine_play (xine_t *this, char *MRL, int start_pos, int start_time); -/* - * toggle pause mode - */ -void xine_pause (xine_t *this); /* * set/get playback speed @@ -280,6 +268,18 @@ int xine_get_status (xine_t *this); int xine_get_current_position (xine_t *this); /* + * get current position measured in seconds from + * the beginning of the stream + */ +int xine_get_current_time (xine_t *this); + +/* + * estimate length of input stream in seconds + * may return 0 if stream is not seekable + */ +int xine_get_stream_length (xine_t *this); + +/* * return the current audio channel */ int xine_get_audio_channel (xine_t *this); |