summaryrefslogtreecommitdiffstats
path: root/m_option.c
diff options
context:
space:
mode:
authorptt <ptt@b3059339-0415-0410-9bf9-f77b7e298cf2>2006-09-25 16:47:56 +0000
committerptt <ptt@b3059339-0415-0410-9bf9-f77b7e298cf2>2006-09-25 16:47:56 +0000
commit928da7a4484938cef38ae682837cf857999e853d (patch)
treef9da93bc2452fcccc35368d1bee9aa3b9631144f /m_option.c
parentc8c0aa686f8a4ac6ec7ffd3e748d8475cb2f8f97 (diff)
downloadmpv-928da7a4484938cef38ae682837cf857999e853d.tar.bz2
mpv-928da7a4484938cef38ae682837cf857999e853d.tar.xz
after a long time, finally i could add -endpos option to mplayer executable.
as oded told me on 1006 02 24, i applied it, blame me if some problem occurs, i hope not, since i tried it for a while.... git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@19979 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'm_option.c')
-rw-r--r--m_option.c72
1 files changed, 72 insertions, 0 deletions
diff --git a/m_option.c b/m_option.c
index 7d7e16926c..c5a718fe63 100644
--- a/m_option.c
+++ b/m_option.c
@@ -1175,6 +1175,78 @@ m_option_type_t m_option_type_afmt = {
};
+// Time or size (-endpos)
+
+static int parse_time_size(m_option_t* opt,char *name, char *param, void* dst, int src) {
+
+ if (dst == NULL)
+ return 0;
+
+ m_time_size_t* ts = dst;
+ ts->pos=0;
+
+ char unit[4];
+ int a,b;
+ float d;
+ double end_at;
+
+ if (param == NULL || strlen(param) == 0)
+ return M_OPT_MISSING_PARAM;
+
+ /* End at size parsing */
+ if(sscanf(param, "%lf%3s", &end_at, unit) == 2) {
+ ts->type = END_AT_SIZE;
+ if(!strcasecmp(unit, "b"))
+ ;
+ else if(!strcasecmp(unit, "kb"))
+ end_at *= 1024;
+ else if(!strcasecmp(unit, "mb"))
+ end_at *= 1024*1024;
+ else if(!strcasecmp(unit, "gb"))
+ end_at *= 1024*1024*1024;
+ else
+ ts->type = END_AT_NONE;
+
+ if (ts->type == END_AT_SIZE) {
+ ts->pos = end_at;
+ return 1;
+ }
+ }
+
+ /* End at time parsing. This has to be last because of
+ * sscanf("%f", ...) below */
+ if (sscanf(param, "%d:%d:%f", &a, &b, &d) == 3)
+ end_at = 3600*a + 60*b + d;
+ else if (sscanf(param, "%d:%f", &a, &d) == 2)
+ end_at = 60*a + d;
+ else if (sscanf(param, "%f", &d) == 1)
+ end_at = d;
+ else {
+ mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Option %s: invalid time or size: '%s'\n",
+ name,param);
+ return M_OPT_INVALID;
+ }
+
+ ts->type = END_AT_TIME;
+ ts->pos = end_at;
+
+ return 1;
+}
+
+m_option_type_t m_option_type_time_size = {
+ "Time or size",
+ "",
+ sizeof(m_time_size_t),
+ 0,
+ parse_time_size,
+ NULL,
+ copy_opt,
+ copy_opt,
+ NULL,
+ NULL
+};
+
+
//// Objects (i.e. filters, etc) settings
#include "m_struct.h"