diff options
-rw-r--r-- | src/demuxers/demux_mpeg_block.c | 33 | ||||
-rw-r--r-- | src/input/input_cdda.c | 4 | ||||
-rw-r--r-- | src/input/input_dvb.c | 2 | ||||
-rw-r--r-- | src/input/input_dvd.c | 19 | ||||
-rw-r--r-- | src/input/input_file.c | 4 | ||||
-rw-r--r-- | src/input/input_gnome_vfs.c | 4 | ||||
-rw-r--r-- | src/input/input_http.c | 4 | ||||
-rw-r--r-- | src/input/input_mms.c | 4 | ||||
-rw-r--r-- | src/input/input_net.c | 4 | ||||
-rw-r--r-- | src/input/input_plugin.h | 24 | ||||
-rw-r--r-- | src/input/input_pnm.c | 2 | ||||
-rw-r--r-- | src/input/input_pvr.c | 4 | ||||
-rw-r--r-- | src/input/input_rtp.c | 4 | ||||
-rw-r--r-- | src/input/input_rtsp.c | 2 | ||||
-rw-r--r-- | src/input/input_smb.c | 4 | ||||
-rw-r--r-- | src/input/input_stdin_fifo.c | 4 | ||||
-rw-r--r-- | src/input/input_v4l.c | 4 | ||||
-rw-r--r-- | src/input/input_vcd.c | 4 | ||||
-rw-r--r-- | src/input/libdvdnav/dvdnav.h | 4 | ||||
-rw-r--r-- | src/input/libdvdnav/searching.c | 90 | ||||
-rw-r--r-- | src/input/vcd/xineplug_inp_vcd.c | 4 | ||||
-rw-r--r-- | src/xine-engine/input_cache.c | 28 |
22 files changed, 200 insertions, 56 deletions
diff --git a/src/demuxers/demux_mpeg_block.c b/src/demuxers/demux_mpeg_block.c index 4a2f7b6e8..e59910cad 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.211 2005/02/06 15:26:16 tmattern Exp $ + * $Id: demux_mpeg_block.c,v 1.212 2005/10/14 21:02:16 miguelfreitas Exp $ * * demultiplexer for mpeg 1/2 program streams * used with fixed blocksize devices (like dvd/vcd) @@ -1268,7 +1268,6 @@ static int demux_mpeg_block_seek (demux_plugin_t *this_gen, demux_mpeg_block_t *this = (demux_mpeg_block_t *) this_gen; start_pos = (off_t) ( (double) start_pos / 65535 * this->input->get_length (this->input) ); - start_time /= 1000; if((this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE) != 0) { @@ -1279,20 +1278,26 @@ static int demux_mpeg_block_seek (demux_plugin_t *this_gen, this->input->seek (this->input, start_pos, SEEK_SET); } else if (start_time) { - if (this->last_cell_time) { - start_pos = start_time - (this->last_cell_time + this->last_begin_time)/1000; - start_pos *= this->rate; - start_pos *= 50; - start_pos += this->last_cell_pos; + if( this->input->seek_time ) { + this->input->seek_time (this->input, start_time, SEEK_SET); } else { - start_pos = start_time; - start_pos *= this->rate; - start_pos *= 50; + start_time /= 1000; + + if (this->last_cell_time) { + start_pos = start_time - (this->last_cell_time + this->last_begin_time)/1000; + start_pos *= this->rate; + start_pos *= 50; + start_pos += this->last_cell_pos; + } else { + start_pos = start_time; + start_pos *= this->rate; + start_pos *= 50; + } + start_pos /= (off_t) this->blocksize; + start_pos *= (off_t) this->blocksize; + + this->input->seek (this->input, start_pos, SEEK_SET); } - start_pos /= (off_t) this->blocksize; - start_pos *= (off_t) this->blocksize; - - this->input->seek (this->input, start_pos, SEEK_SET); } else this->input->seek (this->input, 0, SEEK_SET); } diff --git a/src/input/input_cdda.c b/src/input/input_cdda.c index c9c47ad7a..2018fcad9 100644 --- a/src/input/input_cdda.c +++ b/src/input/input_cdda.c @@ -20,7 +20,7 @@ * Compact Disc Digital Audio (CDDA) Input Plugin * by Mike Melanson (melanson@pcisys.net) * - * $Id: input_cdda.c,v 1.78 2005/10/08 11:26:23 mroi Exp $ + * $Id: input_cdda.c,v 1.79 2005/10/14 21:02:16 miguelfreitas Exp $ */ #ifdef HAVE_CONFIG_H @@ -2664,7 +2664,7 @@ static void *init_plugin (xine_t *xine, void *data) { plugin_info_t xine_plugin_info[] = { /* type, API, "name", version, special_info, init_function */ - { PLUGIN_INPUT | PLUGIN_MUST_PRELOAD, 16, "CD", XINE_VERSION_CODE, NULL, init_plugin }, + { PLUGIN_INPUT | PLUGIN_MUST_PRELOAD, 17, "CD", XINE_VERSION_CODE, NULL, init_plugin }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; diff --git a/src/input/input_dvb.c b/src/input/input_dvb.c index f76207671..3b4fe73b3 100644 --- a/src/input/input_dvb.c +++ b/src/input/input_dvb.c @@ -3201,6 +3201,6 @@ static void *init_class (xine_t *xine, void *data) { plugin_info_t xine_plugin_info[] = { /* type, API, "name", version, special_info, init_function */ - { PLUGIN_INPUT | PLUGIN_MUST_PRELOAD, 16, "DVB", XINE_VERSION_CODE, NULL, init_class }, + { PLUGIN_INPUT | PLUGIN_MUST_PRELOAD, 17, "DVB", XINE_VERSION_CODE, NULL, init_class }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; diff --git a/src/input/input_dvd.c b/src/input/input_dvd.c index 0f281c91c..748f43489 100644 --- a/src/input/input_dvd.c +++ b/src/input/input_dvd.c @@ -18,7 +18,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_dvd.c,v 1.205 2005/09/12 17:44:37 tmattern Exp $ + * $Id: input_dvd.c,v 1.206 2005/10/14 21:02:16 miguelfreitas Exp $ * */ @@ -895,6 +895,20 @@ static off_t dvd_plugin_seek (input_plugin_t *this_gen, off_t offset, int origin return dvd_plugin_get_current_pos(this_gen); } +static off_t dvd_plugin_seek_time (input_plugin_t *this_gen, int time_offset, int origin) { + dvd_input_plugin_t *this = (dvd_input_plugin_t*)this_gen; + + trace_print("Called\n"); + + if(!this || !this->dvdnav || origin != SEEK_SET) { + return -1; + } + + dvdnav_time_search(this->dvdnav, time_offset * 90); + + return dvd_plugin_get_current_pos(this_gen); +} + static off_t dvd_plugin_get_length (input_plugin_t *this_gen) { dvd_input_plugin_t *this = (dvd_input_plugin_t*)this_gen; uint32_t pos=0; @@ -1627,6 +1641,7 @@ static input_plugin_t *dvd_class_get_instance (input_class_t *class_gen, xine_st this->input_plugin.read = dvd_plugin_read; this->input_plugin.read_block = dvd_plugin_read_block; this->input_plugin.seek = dvd_plugin_seek; + this->input_plugin.seek_time = dvd_plugin_seek_time; this->input_plugin.get_current_pos = dvd_plugin_get_current_pos; this->input_plugin.get_length = dvd_plugin_get_length; this->input_plugin.get_blocksize = dvd_plugin_get_blocksize; @@ -1893,6 +1908,6 @@ static void *init_class (xine_t *xine, void *data) { plugin_info_t xine_plugin_info[] = { /* type, API, "name", version, special_info, init_function */ - { PLUGIN_INPUT | PLUGIN_MUST_PRELOAD, 16, "DVD", XINE_VERSION_CODE, NULL, init_class }, + { PLUGIN_INPUT | PLUGIN_MUST_PRELOAD, 17, "DVD", XINE_VERSION_CODE, NULL, init_class }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; diff --git a/src/input/input_file.c b/src/input/input_file.c index cc8be66c0..33045ffc5 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.104 2005/09/02 22:39:43 tmattern Exp $ + * $Id: input_file.c,v 1.105 2005/10/14 21:02:16 miguelfreitas Exp $ */ #ifdef HAVE_CONFIG_H @@ -911,6 +911,6 @@ static void *init_plugin (xine_t *xine, void *data) { plugin_info_t xine_plugin_info[] = { /* type, API, "name", version, special_info, init_function */ - { PLUGIN_INPUT | PLUGIN_MUST_PRELOAD, 16, "FILE", XINE_VERSION_CODE, NULL, init_plugin }, + { PLUGIN_INPUT | PLUGIN_MUST_PRELOAD, 17, "FILE", XINE_VERSION_CODE, NULL, init_plugin }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; diff --git a/src/input/input_gnome_vfs.c b/src/input/input_gnome_vfs.c index 246e20023..67470c923 100644 --- a/src/input/input_gnome_vfs.c +++ b/src/input/input_gnome_vfs.c @@ -18,7 +18,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_gnome_vfs.c,v 1.27 2005/05/29 12:29:42 hadess Exp $ + * $Id: input_gnome_vfs.c,v 1.28 2005/10/14 21:02:16 miguelfreitas Exp $ */ @@ -390,7 +390,7 @@ static input_info_t input_info_gnomevfs = { }; plugin_info_t xine_plugin_info[] = { - { PLUGIN_INPUT | PLUGIN_NO_UNLOAD, 16, "gnomevfs", XINE_VERSION_CODE, + { PLUGIN_INPUT | PLUGIN_NO_UNLOAD, 17, "gnomevfs", XINE_VERSION_CODE, &input_info_gnomevfs, init_input_class }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; diff --git a/src/input/input_http.c b/src/input/input_http.c index a5d32d53d..eb20a0a07 100644 --- a/src/input/input_http.c +++ b/src/input/input_http.c @@ -19,7 +19,7 @@ * * input plugin for http network streams * - * $Id: input_http.c,v 1.110 2005/05/21 16:16:35 jstembridge Exp $ + * $Id: input_http.c,v 1.111 2005/10/14 21:02:16 miguelfreitas Exp $ */ #ifdef HAVE_CONFIG_H @@ -1059,6 +1059,6 @@ static void *init_class (xine_t *xine, void *data) { plugin_info_t xine_plugin_info[] = { /* type, API, "name", version, special_info, init_function */ - { PLUGIN_INPUT | PLUGIN_MUST_PRELOAD, 16, "http", XINE_VERSION_CODE, NULL, init_class }, + { PLUGIN_INPUT | PLUGIN_MUST_PRELOAD, 17, "http", XINE_VERSION_CODE, NULL, init_class }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; diff --git a/src/input/input_mms.c b/src/input/input_mms.c index 573618166..975c5c8ba 100644 --- a/src/input/input_mms.c +++ b/src/input/input_mms.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_mms.c,v 1.56 2005/02/07 23:58:58 tmattern Exp $ + * $Id: input_mms.c,v 1.57 2005/10/14 21:02:16 miguelfreitas Exp $ * * mms input plugin based on work from major mms */ @@ -477,6 +477,6 @@ static void *init_class (xine_t *xine, void *data) { plugin_info_t xine_plugin_info[] = { /* type, API, "name", version, special_info, init_function */ - { PLUGIN_INPUT | PLUGIN_MUST_PRELOAD, 16, "mms", XINE_VERSION_CODE, NULL, init_class }, + { PLUGIN_INPUT | PLUGIN_MUST_PRELOAD, 17, "mms", XINE_VERSION_CODE, NULL, init_class }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; diff --git a/src/input/input_net.c b/src/input/input_net.c index 68af7f610..6dd9c8be4 100644 --- a/src/input/input_net.c +++ b/src/input/input_net.c @@ -20,7 +20,7 @@ * Read from a tcp network stream over a lan (put a tweaked mp1e encoder the * other end and you can watch tv anywhere in the house ..) * - * $Id: input_net.c,v 1.63 2005/02/06 15:00:36 tmattern Exp $ + * $Id: input_net.c,v 1.64 2005/10/14 21:02:16 miguelfreitas Exp $ * * how to set up mp1e for use with this plugin: * @@ -545,7 +545,7 @@ static void *init_class (xine_t *xine, void *data) { plugin_info_t xine_plugin_info[] = { /* type, API, "name", version, special_info, init_function */ - { PLUGIN_INPUT, 16, "tcp", XINE_VERSION_CODE, NULL, init_class }, + { PLUGIN_INPUT, 17, "tcp", XINE_VERSION_CODE, NULL, init_class }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; diff --git a/src/input/input_plugin.h b/src/input/input_plugin.h index 6b72640dc..2e9f0dca6 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.59 2005/02/06 15:00:34 tmattern Exp $ + * $Id: input_plugin.h,v 1.60 2005/10/14 21:02:16 miguelfreitas Exp $ */ #ifndef HAVE_INPUT_PLUGIN_H @@ -37,7 +37,7 @@ # include <xine/configfile.h> #endif -#define INPUT_PLUGIN_IFACE_VERSION 16 +#define INPUT_PLUGIN_IFACE_VERSION 17 typedef struct input_class_s input_class_t ; typedef struct input_plugin_s input_plugin_t; @@ -136,11 +136,31 @@ struct input_plugin_s { /* + * seek to time position, return new position + * time_offset is given in miliseconds + * + * if seeking failed, -1 is returned + * + * note: only SEEK_SET (0) is currently supported as origin + * note: may be NULL is not supported + */ + off_t (*seek_time) (input_plugin_t *this, int time_offset, int origin); + + + /* * get current position in stream. * */ off_t (*get_current_pos) (input_plugin_t *this); + + /* + * get current time position in stream in miliseconds. + * + * note: may be NULL is not supported + */ + int (*get_current_time) (input_plugin_t *this); + /* * return number of bytes in the next playable entity or -1 if the diff --git a/src/input/input_pnm.c b/src/input/input_pnm.c index a8ae73af2..6e93cffad 100644 --- a/src/input/input_pnm.c +++ b/src/input/input_pnm.c @@ -301,7 +301,7 @@ static void *init_class (xine_t *xine, void *data) { plugin_info_t xine_plugin_info[] = { /* type, API, "name", version, special_info, init_function */ - { PLUGIN_INPUT, 16, "pnm", XINE_VERSION_CODE, NULL, init_class }, + { PLUGIN_INPUT, 17, "pnm", XINE_VERSION_CODE, NULL, init_class }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; diff --git a/src/input/input_pvr.c b/src/input/input_pvr.c index 545f23777..1445f8a6d 100644 --- a/src/input/input_pvr.c +++ b/src/input/input_pvr.c @@ -38,7 +38,7 @@ * usage: * xine pvr:/<prefix_to_tmp_files>\!<prefix_to_saved_files>\!<max_page_age> * - * $Id: input_pvr.c,v 1.55 2005/08/25 15:36:29 valtri Exp $ + * $Id: input_pvr.c,v 1.56 2005/10/14 21:02:16 miguelfreitas Exp $ */ /************************************************************************** @@ -1569,7 +1569,7 @@ static void *init_plugin (xine_t *xine, void *data) { plugin_info_t xine_plugin_info[] = { /* type, API, "name", version, special_info, init_function */ - { PLUGIN_INPUT | PLUGIN_MUST_PRELOAD, 16, "pvr", XINE_VERSION_CODE, NULL, init_plugin }, + { PLUGIN_INPUT | PLUGIN_MUST_PRELOAD, 17, "pvr", XINE_VERSION_CODE, NULL, init_plugin }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; diff --git a/src/input/input_rtp.c b/src/input/input_rtp.c index 9c8202d99..9500ab925 100644 --- a/src/input/input_rtp.c +++ b/src/input/input_rtp.c @@ -689,7 +689,7 @@ static input_plugin_t *rtp_class_get_instance (input_class_t *cls_gen, } } - this = (rtp_input_plugin_t *) malloc(sizeof(rtp_input_plugin_t)); + this = (rtp_input_plugin_t *) xine_xmalloc(sizeof(rtp_input_plugin_t)); this->stream = stream; this->mrl = mrl; this->filename = filename; @@ -779,7 +779,7 @@ static void *init_class (xine_t *xine, void *data) { plugin_info_t xine_plugin_info[] = { /* type, API, "name", version, special_info, init_function */ - { PLUGIN_INPUT, 16, "rtp", XINE_VERSION_CODE, NULL, init_class }, + { PLUGIN_INPUT, 17, "rtp", XINE_VERSION_CODE, NULL, init_class }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; diff --git a/src/input/input_rtsp.c b/src/input/input_rtsp.c index 9882697fc..47e8a9654 100644 --- a/src/input/input_rtsp.c +++ b/src/input/input_rtsp.c @@ -313,7 +313,7 @@ static void *init_class (xine_t *xine, void *data) { plugin_info_t xine_plugin_info[] = { /* type, API, "name", version, special_info, init_function */ - { PLUGIN_INPUT, 16, "rtsp", XINE_VERSION_CODE, NULL, init_class }, + { PLUGIN_INPUT, 17, "rtsp", XINE_VERSION_CODE, NULL, init_class }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; diff --git a/src/input/input_smb.c b/src/input/input_smb.c index 25c4e9466..20ad5cf79 100644 --- a/src/input/input_smb.c +++ b/src/input/input_smb.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_smb.c,v 1.4 2005/02/06 15:00:36 tmattern Exp $ + * $Id: input_smb.c,v 1.5 2005/10/14 21:02:16 miguelfreitas Exp $ */ @@ -258,7 +258,7 @@ static input_info_t input_info_smb = { }; plugin_info_t xine_plugin_info[] = { - { PLUGIN_INPUT, 16, "smb", XINE_VERSION_CODE, &input_info_smb, + { PLUGIN_INPUT, 17, "smb", XINE_VERSION_CODE, &input_info_smb, init_input_class }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; diff --git a/src/input/input_stdin_fifo.c b/src/input/input_stdin_fifo.c index cbfa0f510..87d38a6e1 100644 --- a/src/input/input_stdin_fifo.c +++ b/src/input/input_stdin_fifo.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_stdin_fifo.c,v 1.62 2005/02/06 15:00:36 tmattern Exp $ + * $Id: input_stdin_fifo.c,v 1.63 2005/10/14 21:02:16 miguelfreitas Exp $ */ #ifdef HAVE_CONFIG_H @@ -377,6 +377,6 @@ static void *init_class (xine_t *xine, void *data) { plugin_info_t xine_plugin_info[] = { /* type, API, "name", version, special_info, init_function */ - { PLUGIN_INPUT, 16, "stdin", XINE_VERSION_CODE, NULL, init_class }, + { PLUGIN_INPUT, 17, "stdin", XINE_VERSION_CODE, NULL, init_class }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; diff --git a/src/input/input_v4l.c b/src/input/input_v4l.c index 298367dd2..4d688207b 100644 --- a/src/input/input_v4l.c +++ b/src/input/input_v4l.c @@ -1947,8 +1947,8 @@ static void *init_radio_class (xine_t *xine, void *data) plugin_info_t xine_plugin_info[] = { /* type, API, "name", version, special_info, init_function */ - { PLUGIN_INPUT | PLUGIN_MUST_PRELOAD, 16, "v4l_radio", XINE_VERSION_CODE, NULL, init_radio_class }, - { PLUGIN_INPUT | PLUGIN_MUST_PRELOAD, 16, "v4l_tv", XINE_VERSION_CODE, NULL, init_video_class }, + { PLUGIN_INPUT | PLUGIN_MUST_PRELOAD, 17, "v4l_radio", XINE_VERSION_CODE, NULL, init_radio_class }, + { PLUGIN_INPUT | PLUGIN_MUST_PRELOAD, 17, "v4l_tv", XINE_VERSION_CODE, NULL, init_video_class }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; diff --git a/src/input/input_vcd.c b/src/input/input_vcd.c index e6fafe07b..014904969 100644 --- a/src/input/input_vcd.c +++ b/src/input/input_vcd.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_vcd.c,v 1.80 2005/09/02 22:39:43 tmattern Exp $ + * $Id: input_vcd.c,v 1.81 2005/10/14 21:02:16 miguelfreitas Exp $ * */ @@ -1115,6 +1115,6 @@ static void *init_class (xine_t *xine, void *data) { plugin_info_t xine_plugin_info[] = { /* type, API, "name", version, special_info, init_function */ - { PLUGIN_INPUT | PLUGIN_MUST_PRELOAD, 16, "VCDO", XINE_VERSION_CODE, NULL, init_class }, + { PLUGIN_INPUT | PLUGIN_MUST_PRELOAD, 17, "VCDO", XINE_VERSION_CODE, NULL, init_class }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; diff --git a/src/input/libdvdnav/dvdnav.h b/src/input/libdvdnav/dvdnav.h index 6910506b6..6942078da 100644 --- a/src/input/libdvdnav/dvdnav.h +++ b/src/input/libdvdnav/dvdnav.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: dvdnav.h,v 1.14 2003/07/19 13:04:03 mroi Exp $ + * $Id: dvdnav.h,v 1.15 2005/10/14 21:02:16 miguelfreitas Exp $ * */ @@ -114,6 +114,8 @@ dvdnav_status_t dvdnav_path(dvdnav_t *self, const char **path); */ const char* dvdnav_err_to_string(dvdnav_t *self); +/* converts a dvd_time_t to PTS ticks */ +int64_t dvdnav_convert_time(dvd_time_t *time); /********************************************************************* * changing and reading DVD player characteristics * diff --git a/src/input/libdvdnav/searching.c b/src/input/libdvdnav/searching.c index 2b4c534cc..1ff110783 100644 --- a/src/input/libdvdnav/searching.c +++ b/src/input/libdvdnav/searching.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: searching.c,v 1.18 2004/03/16 11:43:38 mroi Exp $ + * $Id: searching.c,v 1.19 2005/10/14 21:02:16 miguelfreitas Exp $ * */ @@ -27,6 +27,7 @@ #include <assert.h> #include "dvdnav_internal.h" +#include "dvdnav.h" /* #define LOG_DEBUG @@ -34,12 +35,6 @@ /* Searching API calls */ -dvdnav_status_t dvdnav_time_search(dvdnav_t *this, - uint64_t time) { - /* FIXME: Time search the current PGC based on the xxx table */ - return DVDNAV_STATUS_OK; -} - /* Scan the ADMAP for a particular block number. */ /* Return placed in vobu. */ /* Returns error status */ @@ -101,6 +96,87 @@ static dvdnav_status_t dvdnav_scan_admap(dvdnav_t *this, int32_t domain, uint32_ return DVDNAV_STATUS_ERR; } +dvdnav_status_t dvdnav_time_search(dvdnav_t *this, + uint64_t time) { + + uint64_t target = time; + uint64_t length = 0; + uint32_t first_cell_nr, last_cell_nr, cell_nr; + int32_t found; + cell_playback_t *cell; + dvd_state_t *state; + dvdnav_status_t result; + + if(this->position_current.still != 0) { + printerr("Cannot seek in a still frame."); + return DVDNAV_STATUS_ERR; + } + + pthread_mutex_lock(&this->vm_lock); + state = &(this->vm->state); + if(!state->pgc) { + printerr("No current PGC."); + pthread_mutex_unlock(&this->vm_lock); + return DVDNAV_STATUS_ERR; + } + + + if (this->pgc_based) { + first_cell_nr = 1; + last_cell_nr = state->pgc->nr_of_cells; + } else { + /* Find start cell of program. */ + first_cell_nr = state->pgc->program_map[state->pgN-1]; + /* Find end cell of program */ + if(state->pgN < state->pgc->nr_of_programs) + last_cell_nr = state->pgc->program_map[state->pgN] - 1; + else + last_cell_nr = state->pgc->nr_of_cells; + } + + found = 0; + for(cell_nr = first_cell_nr; (cell_nr <= last_cell_nr) && !found; cell_nr ++) { + cell = &(state->pgc->cell_playback[cell_nr-1]); + length = dvdnav_convert_time(&cell->playback_time); + if (target >= length) { + target -= length; + } else { + /* FIXME: there must be a better way than interpolation */ + target = target * (cell->last_sector - cell->first_sector + 1) / length; + target += cell->first_sector; + + found = 1; + break; + } + } + + if(found) { + int32_t vobu; +#ifdef LOG_DEBUG + fprintf(MSG_OUT, "libdvdnav: Seeking to cell %i from choice of %i to %i\n", + cell_nr, first_cell_nr, last_cell_nr); +#endif + if (dvdnav_scan_admap(this, state->domain, target, &vobu) == DVDNAV_STATUS_OK) { + int32_t start = state->pgc->cell_playback[cell_nr-1].first_sector; + + if (vm_jump_cell_block(this->vm, cell_nr, vobu - start)) { +#ifdef LOG_DEBUG + fprintf(MSG_OUT, "libdvdnav: After cellN=%u blockN=%u target=%x vobu=%x start=%x\n" , + state->cellN, state->blockN, target, vobu, start); +#endif + this->vm->hop_channel += HOP_SEEK; + pthread_mutex_unlock(&this->vm_lock); + return DVDNAV_STATUS_OK; + } + } + } + + fprintf(MSG_OUT, "libdvdnav: Error when seeking\n"); + printerr("Error when seeking."); + pthread_mutex_unlock(&this->vm_lock); + return DVDNAV_STATUS_ERR; +} + dvdnav_status_t dvdnav_sector_search(dvdnav_t *this, uint64_t offset, int32_t origin) { uint32_t target = 0; diff --git a/src/input/vcd/xineplug_inp_vcd.c b/src/input/vcd/xineplug_inp_vcd.c index 4c69f2505..697272f21 100644 --- a/src/input/vcd/xineplug_inp_vcd.c +++ b/src/input/vcd/xineplug_inp_vcd.c @@ -1,5 +1,5 @@ /* - $Id: xineplug_inp_vcd.c,v 1.44 2005/07/28 02:17:23 rockyb Exp $ + $Id: xineplug_inp_vcd.c,v 1.45 2005/10/14 21:02:16 miguelfreitas Exp $ Copyright (C) 2002, 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com> @@ -1984,7 +1984,7 @@ _("For tracking down bugs in the VCD plugin. Mask values are:\n" const plugin_info_t xine_plugin_info[] = { /* type, API, "name", version, special_info, init_function */ - { PLUGIN_INPUT | PLUGIN_MUST_PRELOAD, 16, (char *) SHORT_PLUGIN_NAME, + { PLUGIN_INPUT | PLUGIN_MUST_PRELOAD, 17, (char *) SHORT_PLUGIN_NAME, XINE_VERSION_CODE, NULL, vcd_init }, { PLUGIN_NONE, 0, (char *) "", 0, NULL, NULL } }; diff --git a/src/xine-engine/input_cache.c b/src/xine-engine/input_cache.c index 9c448f792..deec873d8 100644 --- a/src/xine-engine/input_cache.c +++ b/src/xine-engine/input_cache.c @@ -22,7 +22,7 @@ * The goal of this input plugin is to reduce * the number of calls to the real input plugin. * - * $Id: input_cache.c,v 1.7 2005/05/22 19:50:05 jstembridge Exp $ + * $Id: input_cache.c,v 1.8 2005/10/14 21:02:16 miguelfreitas Exp $ */ #ifdef HAVE_CONFIG_H @@ -254,6 +254,19 @@ static off_t cache_plugin_seek(input_plugin_t *this_gen, off_t offset, int origi return cur_pos; } +static off_t cache_plugin_seek_time(input_plugin_t *this_gen, int time_offset, int origin) { + cache_input_plugin_t *this = (cache_input_plugin_t *)this_gen; + off_t cur_pos; + + lprintf("time_offset: %ld, origin: %d\n", time_offset, origin); + this->seek_call++; + + cur_pos = this->main_input_plugin->seek_time(this->main_input_plugin, time_offset, origin); + this->buf_len = this->buf_pos = 0; + this->main_seek_call++; + return cur_pos; +} + static off_t cache_plugin_get_current_pos(input_plugin_t *this_gen) { cache_input_plugin_t *this = (cache_input_plugin_t *)this_gen; off_t cur_pos; @@ -269,6 +282,15 @@ static off_t cache_plugin_get_current_pos(input_plugin_t *this_gen) { return cur_pos; } +static int cache_plugin_get_current_time(input_plugin_t *this_gen) { + cache_input_plugin_t *this = (cache_input_plugin_t *)this_gen; + int cur_time; + + cur_time = this->main_input_plugin->get_current_time(this->main_input_plugin); + + return cur_time; +} + static off_t cache_plugin_get_length (input_plugin_t *this_gen) { cache_input_plugin_t *this = (cache_input_plugin_t *)this_gen; @@ -337,7 +359,11 @@ input_plugin_t *_x_cache_plugin_get_instance (xine_stream_t *stream, int readahe this->input_plugin.read = cache_plugin_read; this->input_plugin.read_block = cache_plugin_read_block; this->input_plugin.seek = cache_plugin_seek; + if(this->main_input_plugin->seek_time) + this->input_plugin.seek_time = cache_plugin_seek_time; this->input_plugin.get_current_pos = cache_plugin_get_current_pos; + if(this->main_input_plugin->get_current_time) + this->input_plugin.get_current_time = cache_plugin_get_current_time; this->input_plugin.get_length = cache_plugin_get_length; this->input_plugin.get_blocksize = cache_plugin_get_blocksize; this->input_plugin.get_mrl = cache_plugin_get_mrl; |