summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoralbeu <albeu@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-01-17 20:24:28 +0000
committeralbeu <albeu@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-01-17 20:24:28 +0000
commit61185827265fe4f611b443c402da61749b37ef82 (patch)
tree8e0124d187c15b146c439811461ee851d8e838e0
parent9870d682a4140bb918c92ebd9359f2d8df987a65 (diff)
downloadmpv-61185827265fe4f611b443c402da61749b37ef82.tar.bz2
mpv-61185827265fe4f611b443c402da61749b37ef82.tar.xz
Fixed a few bugs and added support for VCD/DVD/TV in playlist using virtual url
like dvd://1 vcd://2 tv://5 git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@4221 b3059339-0415-0410-9bf9-f77b7e298cf2
-rw-r--r--cfg-common.h3
-rw-r--r--cfgparser.c4
-rw-r--r--playtree.c126
-rw-r--r--playtree.h7
4 files changed, 114 insertions, 26 deletions
diff --git a/cfg-common.h b/cfg-common.h
index 44057325d8..a204ad9b73 100644
--- a/cfg-common.h
+++ b/cfg-common.h
@@ -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_bytesperblock;
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},
diff --git a/cfgparser.c b/cfgparser.c
index 69b87b777e..4ea1edb299 100644
--- a/cfgparser.c
+++ b/cfgparser.c
@@ -300,7 +300,7 @@ static int config_read_option(m_config_t *config,config_t** conf_list, char *opt
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 @@ static int config_read_option(m_config_t *config,config_t** conf_list, char *opt
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);
diff --git a/playtree.c b/playtree.c
index 119f5374e8..a07e6f829c 100644
--- a/playtree.c
+++ b/playtree.c
@@ -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 @@ play_tree_set_child(play_tree_t* pt, play_tree_t* child) {
#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 @@ play_tree_set_parent(play_tree_t* pt, play_tree_t* parent) {
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 @@ play_tree_add_file(play_tree_t* pt,char* file) {
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 @@ play_tree_add_file(play_tree_t* pt,char* file) {
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 @@ play_tree_remove_file(play_tree_t* pt,char* file) {
#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 @@ play_tree_iter_push_params(play_tree_iter_t* iter) {
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 @@ play_tree_iter_pop_params(play_tree_iter_t* iter) {
if(iter->tree->params == NULL)
return;
- //printf("Poping params\n");
+ iter->entry_pushed = 0;
m_config_pop(iter->config);
}
@@ -457,12 +481,10 @@ play_tree_iter_step(play_tree_iter_t* iter, int d,int with_nodes) {
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 @@ play_tree_iter_step(play_tree_iter_t* iter, int d,int with_nodes) {
#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 @@ play_tree_is_valid(play_tree_t* pt) {
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 @@ play_tree_iter_up_step(play_tree_iter_t* iter, int d,int with_nodes) {
//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 @@ play_tree_iter_down_step(play_tree_iter_t* iter, int d,int with_nodes) {
//printf("PT : Go DOWN\n");
#endif
- iter->file = 0;
+ iter->file = -1;
// Push subtree params
if(iter->config)
@@ -617,7 +644,7 @@ play_tree_iter_down_step(play_tree_iter_t* iter, int d,int with_nodes) {
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 @@ play_tree_iter_get_file(play_tree_iter_t* iter, int d) {
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 @@ play_tree_iter_new_copy(play_tree_iter_t* old) {
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);
+
+}
+
diff --git a/playtree.h b/playtree.h
index f6636a27af..c1475a9877 100644
--- a/playtree.h
+++ b/playtree.h
@@ -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 @@ struct play_tree {
play_tree_param_t* params;
int loop;
char** files;
+ int entry_type;
};
struct play_tree_iter {