diff options
-rw-r--r-- | include/xine.h.tmpl.in | 34 | ||||
-rw-r--r-- | src/input/input_dvd.c | 20 | ||||
-rw-r--r-- | src/input/input_file.c | 54 | ||||
-rw-r--r-- | src/input/input_vcd.c | 14 | ||||
-rw-r--r-- | src/xine-engine/load_plugins.c | 33 | ||||
-rw-r--r-- | src/xine-engine/xine_internal.h | 6 |
6 files changed, 109 insertions, 52 deletions
diff --git a/include/xine.h.tmpl.in b/include/xine.h.tmpl.in index 70b077965..0d79fddb8 100644 --- a/include/xine.h.tmpl.in +++ b/include/xine.h.tmpl.in @@ -29,7 +29,7 @@ \endverbatim */ /* - * $Id: xine.h.tmpl.in,v 1.21 2001/06/16 18:03:21 guenter Exp $ + * $Id: xine.h.tmpl.in,v 1.22 2001/06/23 14:05:46 f1rmb Exp $ * */ @@ -446,9 +446,32 @@ void xine_select_spu_channel (xine_t *this, int channel); */ char **xine_get_browsable_input_plugin_ids (xine_t *this) ; -/** - * \fn char **xine_get_browse_mrls (xine_t *this, char *plugin_id, char *start_mrl) - * \brief Request available MRLs from plugins +/* Types of mrls returned by get_dir() */ +#define mrl_unknown 0x0 +#define mrl_dvd 0x1 +#define mrl_vcd 0x3 +#define mrl_net 0x4 +#define mrl_rtp 0x5 +#define mrl_stdin 0x6 +#define mrl_fifo 0x7 +#define mrl_chardev 0x8 +#define mrl_directory 0x9 +#define mrl_blockdev 0xA +#define mrl_normal 0xB +#define mrl_symbolic_link 0xC +#define mrl_sock 0xD +/* bit for exec file, should be combinated with mrl_normal type*/ +#define mrl_type_exec 0xFFFF8000 + +typedef struct { + char *mrl; /* <type>://<location */ + int type; /* match to mrl_type enum */ + off_t size; /* size of this source, may be 0 */ +} mrl_t; + +/** + * \fn mrl_t **xine_get_browse_mrls (xine_t *this, char *plugin_id, char *start_mrl) + * \brief Request available MRLs from plugins * \param this Current xine engine configuration ( #see xine_init() ) * \param plugin_id Plugin name ( #see xine_get_browsable_input_plugin_ids() ) * \param start_mrl MRL @@ -462,8 +485,7 @@ char **xine_get_browsable_input_plugin_ids (xine_t *this) ; * returns NULL if <start_mrl> is an invalid MRL, not even a directory. */ -char **xine_get_browse_mrls (xine_t *this, char *plugin_id, - char *start_mrl); +mrl_t **xine_get_browse_mrls (xine_t *this, char *plugin_id, char *start_mrl); /** @} end of browsegroup*/ diff --git a/src/input/input_dvd.c b/src/input/input_dvd.c index 3c49e5948..968af4ce2 100644 --- a/src/input/input_dvd.c +++ b/src/input/input_dvd.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_dvd.c,v 1.10 2001/06/21 17:34:23 guenter Exp $ + * $Id: input_dvd.c,v 1.11 2001/06/23 14:05:47 f1rmb Exp $ */ #ifdef HAVE_CONFIG_H @@ -428,14 +428,13 @@ static mrl_t **dvd_plugin_get_dir (input_plugin_t *this_gen, dvd_input_plugin_t *this = (dvd_input_plugin_t *) this_gen; int i, fd; - if (filename) { - *nEntries = 0; + *nEntries = 0; + + if (filename) return NULL; - } - + if((fd = open(DVD, O_RDONLY|O_NONBLOCK)) > -1) { - - int nFiles, nFiles2; + int nFiles, nFiles2; UDFListDir (fd, "/VIDEO_TS", MAX_DIR_ENTRIES, this->filelist, &nFiles); @@ -468,10 +467,11 @@ static mrl_t **dvd_plugin_get_dir (input_plugin_t *this_gen, close (fd); - } else { - *nEntries = 0; - return NULL; } + else + return NULL; + + this->mrls[*nEntries] = NULL; return this->mrls; } diff --git a/src/input/input_file.c b/src/input/input_file.c index 8b78365b0..eba41cbd1 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.12 2001/06/21 17:34:23 guenter Exp $ + * $Id: input_file.c,v 1.13 2001/06/23 14:05:47 f1rmb Exp $ */ #ifdef HAVE_CONFIG_H @@ -72,9 +72,9 @@ typedef struct { char *mrl; config_values_t *config; - mrl_t **mrls; int mrls_allocated_entries; - + mrl_t *mrls[1]; + } file_input_plugin_t; /* @@ -196,7 +196,7 @@ static mrl_t **file_plugin_get_dir (input_plugin_t *this_gen, struct dirent *pdirent; DIR *pdir; mode_t mode; - struct stat stat; + struct stat pstat; int num_files = 0; *nFiles = 0; @@ -223,7 +223,6 @@ static mrl_t **file_plugin_get_dir (input_plugin_t *this_gen, return NULL; } - while((pdirent = readdir(pdir)) != NULL) { /* * full pathname creation @@ -239,11 +238,11 @@ static mrl_t **file_plugin_get_dir (input_plugin_t *this_gen, } sprintf(fullpathname, "%s/%s", current_dir, pdirent->d_name); - + /* * stat the file */ - if(lstat(fullpathname, &stat) < 0) { + if(lstat(fullpathname, &pstat) < 0) { fprintf(stderr, "lstat() failed: %s\n", strerror(errno)); free(fullpathname); return NULL; @@ -253,26 +252,30 @@ static mrl_t **file_plugin_get_dir (input_plugin_t *this_gen, * alloc enought memory in private plugin structure to * store found mrls. */ - if(num_files > this->mrls_allocated_entries + if(num_files >= this->mrls_allocated_entries || this->mrls_allocated_entries == 0) { - this->mrls[num_files] = (mrl_t *) malloc(sizeof(mrl_t)); - - this->mrls[num_files]->mrl = (char *) - malloc(strlen(pdirent->d_name + 1)); + + if((this->mrls[num_files] = (mrl_t *) malloc(sizeof(mrl_t))) == NULL) { + fprintf(stderr, "malloc() failed: %s\n", strerror(errno)); + return NULL; + } + + this->mrls[num_files]->mrl = (char *) malloc(strlen(fullpathname) + 1); + } - else + else { this->mrls[num_files]->mrl = (char *) - realloc(this->mrls[num_files]->mrl, strlen(pdirent->d_name + 1)); + realloc(this->mrls[num_files]->mrl, strlen(fullpathname) + 1); + } - /* FIXME: store valid MRLs with valid path name */ - strcpy(this->mrls[num_files]->mrl, pdirent->d_name); + sprintf(this->mrls[num_files]->mrl, "%s", fullpathname); - this->mrls[num_files]->size = stat.st_size; + this->mrls[num_files]->size = pstat.st_size; /* * Ok, now check file type */ - mode = stat.st_mode; + mode = pstat.st_mode; if(S_ISLNK(mode)) { this->mrls[num_files]->type = mrl_symbolic_link; @@ -320,11 +323,14 @@ static mrl_t **file_plugin_get_dir (input_plugin_t *this_gen, closedir(pdir); *nFiles = num_files; - + if(num_files > this->mrls_allocated_entries) this->mrls_allocated_entries = num_files; - free(fullpathname); + if(fullpathname) + free(fullpathname); + + this->mrls[num_files] = NULL; return this->mrls; } @@ -384,7 +390,6 @@ static int file_plugin_get_optional_data (input_plugin_t *this_gen, * */ input_plugin_t *init_input_plugin (int iface, config_values_t *config) { - file_input_plugin_t *this; xine_debug = config->lookup_int (config, "xine_debug", 0); @@ -414,7 +419,10 @@ input_plugin_t *init_input_plugin (int iface, config_values_t *config) { this->fh = -1; this->mrl = NULL; this->config = config; - this->mrls_allocated_entries = 0; + + this->mrls[0] = (mrl_t *) malloc(sizeof(mrl_t)); + this->mrls[0]->mrl = (char *) malloc(sizeof(char *)); + this->mrls_allocated_entries = 1; return (input_plugin_t *) this; break; @@ -428,3 +436,5 @@ input_plugin_t *init_input_plugin (int iface, config_values_t *config) { return NULL; } } + + diff --git a/src/input/input_vcd.c b/src/input/input_vcd.c index 36a32bb19..00a63ecc5 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.10 2001/06/21 17:34:23 guenter Exp $ + * $Id: input_vcd.c,v 1.11 2001/06/23 14:05:47 f1rmb Exp $ */ #ifdef HAVE_CONFIG_H @@ -925,11 +925,11 @@ static mrl_t **vcd_plugin_get_dir (input_plugin_t *this_gen, vcd_input_plugin_t *this = (vcd_input_plugin_t *) this_gen; int i; - if (filename) { - *nEntries = 0; - return NULL; - } + *nEntries = 0; + if (filename) + return NULL; + this->fd = open (CDROM, O_RDONLY); if (this->fd == -1) { @@ -949,7 +949,7 @@ static mrl_t **vcd_plugin_get_dir (input_plugin_t *this_gen, close (this->fd); this->fd = -1; - *nEntries = this->total_tracks; + *nEntries = this->total_tracks - 1; /* printf ("%d tracks\n", this->total_tracks); */ @@ -962,6 +962,8 @@ static mrl_t **vcd_plugin_get_dir (input_plugin_t *this_gen, this->mrls[i-1]->size = vcd_plugin_get_length ((input_plugin_t *) this); } + this->mrls[*nEntries] = NULL; + return this->mrls; } diff --git a/src/xine-engine/load_plugins.c b/src/xine-engine/load_plugins.c index fedaf9d78..f9f485e36 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.25 2001/06/15 23:59:18 f1rmb Exp $ + * $Id: load_plugins.c,v 1.26 2001/06/23 14:05:47 f1rmb Exp $ * * * Load input/demux/audio_out/video_out/codec plugins @@ -702,9 +702,32 @@ char **xine_get_autoplay_mrls (xine_t *this, char *plugin_id) { /** *************************************************************** * Browse featured plugins section */ -char **xine_get_browse_mrls (xine_t *this, char *plugin_id, - char *start_mrl) { +mrl_t **xine_get_browse_mrls (xine_t *this, char *plugin_id, char *start_mrl) { + input_plugin_t *ip; + mrl_t **browse_mrls = NULL; + int i, n; + + if(!this || !plugin_id) + return NULL; + + if(!this->num_input_plugins) + return NULL; - printf("%s not implemented yet\n", __FUNCTION__); - return NULL; + for(i = 0; i < this->num_input_plugins; i++) { + + ip = this->input_plugins[i]; + + if(!strcasecmp((ip->get_identifier(ip)), plugin_id)) { + if(((ip->get_capabilities(ip)) & INPUT_CAP_GET_DIR)) { + + if(ip->get_dir) + browse_mrls = ip->get_dir(ip, start_mrl, &n); + + } + goto browse_mrls_done; + } + } + + browse_mrls_done: + return browse_mrls; } diff --git a/src/xine-engine/xine_internal.h b/src/xine-engine/xine_internal.h index 716377b04..9712196cf 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.25 2001/06/18 15:43:01 richwareham Exp $ + * $Id: xine_internal.h,v 1.26 2001/06/23 14:05:47 f1rmb Exp $ * */ @@ -261,8 +261,8 @@ char **xine_get_browsable_input_plugin_ids (xine_t *this) ; * returns NULL if start_mrl is an invalid MRL, not even a directory */ -char **xine_get_browse_mrls (xine_t *this, char *plugin_id, - char *start_mrl); +mrl_t **xine_get_browse_mrls (xine_t *this, char *plugin_id, + char *start_mrl); /* * autoplay support |