changeset 4343:b0c8eed7473c

Extended DVD chapter specification. Remove -last-chapter option.
author kmkaplan
date Thu, 24 Jan 2002 23:02:59 +0000
parents 4395c96c64cd
children 7d9b4c874f73
files cfg-common.h libmpdemux/open.c libmpdemux/stream.h mencoder.c
diffstat 4 files changed, 37 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/cfg-common.h	Thu Jan 24 21:46:57 2002 +0000
+++ b/cfg-common.h	Thu Jan 24 23:02:59 2002 +0000
@@ -16,8 +16,7 @@
 	{"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},
-	{"last-chapter", &dvd_last_chapter, CONF_TYPE_INT, CONF_RANGE, 1, 99, NULL},
+	{"chapter", dvd_parse_chapter_range, CONF_TYPE_FUNC_PARAM, 0, 0, 0, NULL},
 #else
 	{"dvd", "MPlayer was compiled WITHOUT libdvdread support!\n", CONF_TYPE_PRINT, CONF_NOCFG, 0, 0, NULL},
 #endif
--- a/libmpdemux/open.c	Thu Jan 24 21:46:57 2002 +0000
+++ b/libmpdemux/open.c	Thu Jan 24 23:02:59 2002 +0000
@@ -1,4 +1,5 @@
 
+#include <ctype.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -13,6 +14,7 @@
 #include <sys/cdrio.h>
 #endif
 
+#include "../cfgparser.h"
 #include "stream.h"
 #include "demuxer.h"
 
@@ -421,6 +423,38 @@
 
 }
 
+int dvd_parse_chapter_range(struct config *conf, const char *range){
+  char *s, *t;
+  dvd_chapter = 1;
+  dvd_last_chapter = 0;
+  if (*range && isdigit(*range)) {
+    dvd_chapter = strtol(range, &s, 10);
+    if (range == s) {
+      mp_msg(MSGT_OPEN, MSGL_ERR, "Invalid chapter range specification %s\n", range);
+      return -1;
+    }
+  }
+  if (*s == 0)
+    return 0;
+  else if (*s != '-') {
+    mp_msg(MSGT_OPEN, MSGL_ERR, "Invalid chapter range specification %s\n", range);
+    return -1;
+  }
+  ++s;
+  if (*s == 0)
+      return 0;
+  if (! isdigit(*s)) {
+    mp_msg(MSGT_OPEN, MSGL_ERR, "Invalid chapter range specification %s\n", range);
+    return -1;
+  }
+  dvd_last_chapter = strtol(s, &t, 10);
+  if (s == t || *t)  {
+    mp_msg(MSGT_OPEN, MSGL_ERR, "Invalid chapter range specification %s\n", range);
+    return -1;
+  }
+  return 0;
+}
+
 #ifdef USE_DVDREAD
 
 int dvd_aid_from_lang(stream_t *stream, unsigned char* lang){
--- a/libmpdemux/stream.h	Thu Jan 24 21:46:57 2002 +0000
+++ b/libmpdemux/stream.h	Thu Jan 24 23:02:59 2002 +0000
@@ -184,6 +184,7 @@
 extern int dvd_chapter;
 extern int dvd_last_chapter;
 extern int dvd_angle;
+int dvd_parse_chapter_range(struct config*, const char*);
 //#endif
 
 #ifdef USE_DVDREAD
--- a/mencoder.c	Thu Jan 24 21:46:57 2002 +0000
+++ b/mencoder.c	Thu Jan 24 23:02:59 2002 +0000
@@ -27,6 +27,7 @@
 #include "cpudetect.h"
 
 #include "codec-cfg.h"
+#include "cfgparser.h"
 
 #include "stream.h"
 #include "demuxer.h"
@@ -171,8 +172,6 @@
 static int vo_w=0, vo_h=0;
 //-------------------------- config stuff:
 
-#include "cfgparser.h"
-
 m_config_t* mconfig;
 
 static int cfg_inc_verbose(struct config *conf){ ++verbose; return 0;}