Mercurial > mplayer.hg
changeset 4220:fe2c20d52a25
Fixed a few bugs and added support for VCD/DVD/TV in playlist using virtual url
like dvd://1 vcd://2 tv://5
author | albeu |
---|---|
date | Thu, 17 Jan 2002 20:24:28 +0000 |
parents | 70888f501b4a |
children | 401149ba73fd |
files | cfg-common.h cfgparser.c playtree.c playtree.h |
diffstat | 4 files changed, 114 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/cfg-common.h Thu Jan 17 19:24:33 2002 +0000 +++ b/cfg-common.h Thu Jan 17 20:24:28 2002 +0000 @@ -8,10 +8,12 @@ #endif #ifdef HAVE_VCD {"vcd", &vcd_track, CONF_TYPE_INT, CONF_RANGE, 1, 99, NULL}, + {"cdrom-device", &cdrom_device, CONF_TYPE_STRING, 0, 0, 0, NULL}, #else {"vcd", "VCD support is NOT available on this system!\n", CONF_TYPE_PRINT, CONF_NOCFG, 0, 0, NULL}, #endif #ifdef USE_DVDREAD + {"dvd-device", &dvd_device, CONF_TYPE_STRING, 0, 0, 0, NULL}, {"dvd", &dvd_title, CONF_TYPE_INT, CONF_RANGE, 1, 99, NULL}, {"dvdangle", &dvd_angle, CONF_TYPE_INT, CONF_RANGE, 1, 99, NULL}, {"chapter", &dvd_chapter, CONF_TYPE_INT, CONF_RANGE, 1, 99, NULL}, @@ -115,6 +117,7 @@ extern int vivo_param_width; extern int vivo_param_height; extern int vivo_param_vformat; +extern char *dvd_device, *cdrom_device; struct config vivoopts_conf[]={ {"version", &vivo_param_version, CONF_TYPE_INT, 0, 0, 0, NULL},
--- a/cfgparser.c Thu Jan 17 19:24:33 2002 +0000 +++ b/cfgparser.c Thu Jan 17 20:24:28 2002 +0000 @@ -300,7 +300,7 @@ mp_msg(MSGT_CFGPARSER, MSGL_DBG3, "read_option: conf=%p opt='%s' param='%s'\n", conf, opt, param); - for(nconf = 0 ; conf_list&& conf_list[nconf] != NULL; nconf++) { + for(nconf = 0 ; conf_list[nconf] != NULL; nconf++) { conf = conf_list[nconf]; for (i = 0; conf[i].name != NULL; i++) { int namelength; @@ -563,7 +563,7 @@ break; } out: - if(config->global == 0 && ! (conf[i].flags & CONF_GLOBAL)) { + if(ret >= 0 && config->global == 0 && ! (conf[i].flags & CONF_GLOBAL)) { play_tree_t* dest = config->last_entry ? config->last_entry : config->last_parent; #ifdef MP_DEBUG assert(dest != NULL);
--- a/playtree.c Thu Jan 17 19:24:33 2002 +0000 +++ b/playtree.c Thu Jan 17 20:24:28 2002 +0000 @@ -4,6 +4,7 @@ #include <string.h> #include <stdio.h> #include <unistd.h> +#include <errno.h> #ifdef MP_DEBUG #include <assert.h> #endif @@ -13,11 +14,15 @@ static int play_tree_is_valid(play_tree_t* pt); +static void +play_tree_iter_set_param(play_tree_iter_t* iter,char* opt,char* val); + play_tree_t* play_tree_new(void) { play_tree_t* r = (play_tree_t*)calloc(1,sizeof(play_tree_t)); if(r == NULL) mp_msg(MSGT_PLAYTREE,MSGL_ERR,"Can't allocate %d bytes of memory\n",sizeof(play_tree_t)); + r->entry_type = PLAY_TREE_ENTRY_NODE; return r; } @@ -189,7 +194,7 @@ #ifdef MP_DEBUG assert(pt != NULL); - assert(pt->files == NULL); + assert(pt->entry_type == PLAY_TREE_ENTRY_NODE); #endif for(iter = pt->child ; iter != NULL ; iter = iter->next) @@ -234,6 +239,7 @@ void play_tree_add_file(play_tree_t* pt,char* file) { int n = 0; + char* e; #ifdef MP_DEBUG assert(pt != NULL); @@ -241,6 +247,10 @@ assert(file != NULL); #endif + if(pt->entry_type != PLAY_TREE_ENTRY_NODE && + pt->entry_type != PLAY_TREE_ENTRY_FILE) + return; + if(pt->files) { for(n = 0 ; pt->files[n] != NULL ; n++) /* NOTHING */; @@ -251,9 +261,21 @@ return; } - pt->files[n] = strdup(file); + e = pt->files[n] = strdup(file); pt->files[n+1] = NULL; + if(strncasecmp(e,"vcd://",6) == 0 && strlen(&e[6]) > 0) { + pt->entry_type = PLAY_TREE_ENTRY_VCD; + memmove(e,e + 6,strlen(&e[6])+1); + } else if(strncasecmp(e,"dvd://",6) == 0 && strlen(&e[6]) > 0) { + pt->entry_type = PLAY_TREE_ENTRY_DVD; + memmove(e,&e[6],strlen(&e[6])+1); + } else if(strncasecmp(e,"tv://",5) == 0 && strlen(&e[5]) > 0) { + pt->entry_type = PLAY_TREE_ENTRY_TV; + memmove(e,&e[5],strlen(&e[5])+1); + } else + pt->entry_type = PLAY_TREE_ENTRY_FILE; + } int @@ -263,7 +285,7 @@ #ifdef MP_DEBUG assert(pt != NULL); assert(file != NULL); - assert(pt->files != NULL); + assert(pt->entry_type != PLAY_TREE_ENTRY_NODE); #endif for(n=0 ; pt->files[n] != NULL ; n++) { @@ -383,7 +405,9 @@ pt->params[n].name,pt->params[n].value); } } - //printf("Param pushed\n"); + + if(!pt->child) + iter->entry_pushed = 1; return 1; } @@ -397,7 +421,7 @@ if(iter->tree->params == NULL) return; - //printf("Poping params\n"); + iter->entry_pushed = 0; m_config_pop(iter->config); } @@ -457,12 +481,10 @@ return play_tree_iter_step(iter,0,with_nodes); } - if(iter->config && iter->entry_pushed) { + if(iter->config && iter->entry_pushed) play_tree_iter_pop_params(iter); - iter->entry_pushed = 0; - } - iter->file = 0; + iter->file = -1; if( d > 0 ) pt = iter->tree->next; else if(d < 0) @@ -511,14 +533,15 @@ #ifdef MP_DEBUG assert(pt->files != NULL); #endif - + iter->tree = pt; + for(d = 0 ; iter->tree->files[d] != NULL ; d++) /* NOTHING */; iter->num_files = d; - + if(iter->config) - iter->entry_pushed = play_tree_iter_push_params(iter); + play_tree_iter_push_params(iter); return PLAY_TREE_ITER_ENTRY; @@ -532,8 +555,12 @@ assert(pt != NULL); #endif - if(pt->files != NULL) + if(pt->entry_type != PLAY_TREE_ENTRY_NODE) { +#ifdef MP_DEBUG + assert(pt->child == NULL); +#endif return 1; + } else if (pt->child != NULL) { for(iter = pt->child ; iter != NULL ; iter = iter->next) { if(play_tree_is_valid(iter)) @@ -552,7 +579,7 @@ //printf("PT : Go UP\n"); #endif - iter->file = 0; + iter->file = -1; if(iter->tree->parent == iter->root->parent) return PLAY_TREE_ITER_END; @@ -588,7 +615,7 @@ //printf("PT : Go DOWN\n"); #endif - iter->file = 0; + iter->file = -1; // Push subtree params if(iter->config) @@ -617,7 +644,7 @@ char* play_tree_iter_get_file(play_tree_iter_t* iter, int d) { - + char* entry; #ifdef MP_DEBUG assert(iter != NULL); assert(iter->tree->child == NULL); @@ -626,16 +653,43 @@ if(iter->tree->files == NULL) return NULL; +#ifdef MP_DEBUG + assert(iter->num_files > 0); +#endif + + if(iter->file >= iter->num_files-1 || iter->file < -1) + return NULL; + if(d > 0) { - if(iter->tree->files[iter->file] == NULL) - return NULL; - iter->file++; + if(iter->file >= iter->num_files - 1) + iter->file = 0; + else + iter->file++; } else if(d < 0) { - if(iter->file == 0) - return NULL; - iter->file--; - } - return iter->tree->files[iter->file-1]; + if(iter->file <= 0) + iter->file = iter->num_files - 1; + else + iter->file--; + } + entry = iter->tree->files[iter->file]; + + switch(iter->tree->entry_type) { + case PLAY_TREE_ENTRY_DVD : + play_tree_iter_set_param(iter,"dvd",entry); + break; + case PLAY_TREE_ENTRY_VCD : + play_tree_iter_set_param(iter,"vcd",entry); + break; + case PLAY_TREE_ENTRY_TV : + { + char* val = (char*)malloc(strlen(entry) + 11 + 1); + sprintf(val,"on:channel=%s",entry); + play_tree_iter_set_param(iter,"tv",val); + break; + } + } + + return entry; } play_tree_t* @@ -700,3 +754,27 @@ return iter; } + +static void +play_tree_iter_set_param(play_tree_iter_t* iter,char* opt,char* val) { + int push = 0; + play_tree_t* pt; +#ifdef MP_DEBUG + assert(iter != NULL); + assert(iter->tree != NULL); +#endif + + pt = iter->tree; + + if(iter->tree->params == NULL) + push = 1; + + play_tree_set_param(iter->tree,opt,val); + + if(push) + play_tree_iter_push_params(iter); + else if(iter->config) + m_config_set_option(iter->config,opt,val); + +} +
--- a/playtree.h Thu Jan 17 19:24:33 2002 +0000 +++ b/playtree.h Thu Jan 17 20:24:28 2002 +0000 @@ -10,6 +10,12 @@ #define PLAY_TREE_ITER_NODE 2 #define PLAY_TREE_ITER_END 3 +#define PLAY_TREE_ENTRY_NODE -1 +#define PLAY_TREE_ENTRY_DVD 0 +#define PLAY_TREE_ENTRY_VCD 1 +#define PLAY_TREE_ENTRY_TV 2 +#define PLAY_TREE_ENTRY_FILE 3 + typedef struct play_tree play_tree_t; typedef struct play_tree_iter play_tree_iter_t; typedef struct play_tree_param play_tree_param_t; @@ -44,6 +50,7 @@ play_tree_param_t* params; int loop; char** files; + int entry_type; }; struct play_tree_iter {