[MPlayer-dev-eng] [PATCH] demux_lavf: add urlprefix suboption.

Nicolas George nicolas.george at normalesup.org
Sun Apr 7 19:07:52 CEST 2013


Setting it to an empty string may be necessary when using
special formats that use the given URL or file name as a
base path for other files.

Change the option parser to accept empty strings if
M_OPT_MIN is set and min = 0.
---
 DOCS/man/en/mplayer.1   |    5 +++++
 libmpdemux/demux_lavf.c |    5 +++++
 m_option.c              |    2 ++
 3 files changed, 12 insertions(+)

diff --git a/DOCS/man/en/mplayer.1 b/DOCS/man/en/mplayer.1
index d424589..c59c784 100644
--- a/DOCS/man/en/mplayer.1
+++ b/DOCS/man/en/mplayer.1
@@ -11753,6 +11753,11 @@ of TS packets to scan.
 Encryption key the demuxer should use.
 This is the raw binary data of the key converted to a hexadecimal string.
 .
+.TP
+.B urlprefix=string
+Prefix prepended to URL passed to libavformat.
+The default is "mp:".
+.
 .
 .SS FFmpeg libavformat muxers (\-lavfopts) (also see \-of lavf)
 .
diff --git a/libmpdemux/demux_lavf.c b/libmpdemux/demux_lavf.c
index 7ce3f32..ef623e8 100644
--- a/libmpdemux/demux_lavf.c
+++ b/libmpdemux/demux_lavf.c
@@ -54,12 +54,14 @@ static unsigned int opt_analyzeduration = 0;
 static char *opt_format;
 static char *opt_cryptokey;
 static char *opt_avopt = NULL;
+static char *opt_urlprefix;
 
 const m_option_t lavfdopts_conf[] = {
 	{"probesize", &(opt_probesize), CONF_TYPE_INT, CONF_RANGE, 32, INT_MAX, NULL},
 	{"format",    &(opt_format),    CONF_TYPE_STRING,       0,  0,       0, NULL},
 	{"analyzeduration",    &(opt_analyzeduration),    CONF_TYPE_INT,       CONF_RANGE,  0,       INT_MAX, NULL},
 	{"cryptokey", &(opt_cryptokey), CONF_TYPE_STRING,       0,  0,       0, NULL},
+	{"urlprefix", &(opt_urlprefix), CONF_TYPE_STRING, M_OPT_MIN,0,       0, NULL},
         {"o",                  &opt_avopt,                CONF_TYPE_STRING,    0,           0,             0, NULL},
 	{NULL, NULL, 0, 0, 0, 0, NULL}
 };
@@ -511,6 +513,9 @@ static demuxer_t* demux_open_lavf(demuxer_t *demuxer){
     int i;
     char mp_filename[256]="mp:";
 
+    if (opt_urlprefix)
+        av_strlcpy(mp_filename, opt_urlprefix, sizeof(mp_filename));
+
     stream_seek(demuxer->stream, 0);
 
     avfc = avformat_alloc_context();
diff --git a/m_option.c b/m_option.c
index 6814579..2335cb2 100644
--- a/m_option.c
+++ b/m_option.c
@@ -386,6 +386,8 @@ const m_option_type_t m_option_type_position = {
 static int parse_str(const m_option_t* opt,const char *name, const char *param, void* dst, int src) {
 
 
+  if (param == NULL && (opt->flags & M_OPT_MIN) && opt->min == 0)
+      param = "";
   if (param == NULL)
       return M_OPT_MISSING_PARAM;
 
-- 
1.7.10.4



More information about the MPlayer-dev-eng mailing list