[vlc-commits] playlist: parse Windows Media Server metafile separately
Rémi Denis-Courmont
git at videolan.org
Sun Mar 31 16:37:06 CEST 2019
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Mar 31 17:31:49 2019 +0300| [4114d93cfdae7e69b6b33d0dae60343af3951a33] | committer: Rémi Denis-Courmont
playlist: parse Windows Media Server metafile separately
This format has nothing to do with the PLS file, except for the fact
that they both use INI syntax.
Also fix a harmless off-by-one in probing: the [Reference] magic is 11
bytes, not 10.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=4114d93cfdae7e69b6b33d0dae60343af3951a33
---
modules/demux/Makefile.am | 1 +
modules/demux/playlist/playlist.c | 4 ++
modules/demux/playlist/playlist.h | 2 +
modules/demux/playlist/wms.c | 86 +++++++++++++++++++++++++++++++++++++++
4 files changed, 93 insertions(+)
diff --git a/modules/demux/Makefile.am b/modules/demux/Makefile.am
index 2ae21f99d0..85d4b3fba9 100644
--- a/modules/demux/Makefile.am
+++ b/modules/demux/Makefile.am
@@ -240,6 +240,7 @@ libplaylist_plugin_la_SOURCES = \
demux/playlist/qtl.c \
demux/playlist/ram.c \
demux/playlist/sgimb.c \
+ demux/playlist/wms.c \
demux/playlist/wpl.c \
demux/playlist/xspf.c \
demux/playlist/playlist.c demux/playlist/playlist.h
diff --git a/modules/demux/playlist/playlist.c b/modules/demux/playlist/playlist.c
index 55f412a191..30dcfa4733 100644
--- a/modules/demux/playlist/playlist.c
+++ b/modules/demux/playlist/playlist.c
@@ -121,6 +121,10 @@ vlc_module_begin ()
add_shortcut( "itml" )
set_capability( "stream_filter", 310 )
set_callbacks( Import_iTML, NULL )
+ add_submodule()
+ set_description(N_("Windows Media Server metafile import") )
+ set_capability("stream_filter", 310)
+ set_callbacks(Import_WMS, NULL)
add_submodule ()
set_description( N_("WPL playlist import") )
add_shortcut( "wpl" )
diff --git a/modules/demux/playlist/playlist.h b/modules/demux/playlist/playlist.h
index 6a74680510..10a9135bbf 100644
--- a/modules/demux/playlist/playlist.h
+++ b/modules/demux/playlist/playlist.h
@@ -56,6 +56,8 @@ void Close_BDMV ( vlc_object_t * );
int Import_iTML ( vlc_object_t * );
+int Import_WMS(vlc_object_t *);
+
int Import_WPL ( vlc_object_t * );
void Close_WPL ( vlc_object_t * );
diff --git a/modules/demux/playlist/wms.c b/modules/demux/playlist/wms.c
new file mode 100644
index 0000000000..08768e33be
--- /dev/null
+++ b/modules/demux/playlist/wms.c
@@ -0,0 +1,86 @@
+/*****************************************************************************
+ * wms.c : Windows Media Server metafile format
+ *****************************************************************************
+ * Copyright (C) 2004-2019 VLC authors and VideoLAN
+ *
+ * Authors: Clément Stenac <zorglub at videolan.org>
+ * Authors: Sigmund Augdal Helberg <dnumgis at videolan.org>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <vlc_common.h>
+#include <vlc_access.h>
+#include <vlc_charset.h>
+
+#include "playlist.h"
+
+static int ReadDir(stream_t *demux, input_item_node_t *subitems)
+{
+ char *line;
+
+ while ((line = vlc_stream_ReadLine(demux->s)) != NULL)
+ {
+ if (!IsUTF8(line))
+ goto skip;
+ if (!strcmp(line, "[Reference]"))
+ goto skip;
+
+ const char *key = line;
+ char *value = strchr(line, '=');
+ if (value == NULL) {
+ msg_Warn(demux, "unexpected entry \"%s\"", line);
+ goto skip;
+ }
+ *(value++) = '\0';
+
+ unsigned id;
+ if (sscanf(key, "Ref%u", &id) != 1) {
+ msg_Warn(demux, "unexpected entry key \"%s\"", key);
+ goto skip;
+ }
+
+ if (!strncasecmp(value, "http://", 7))
+ memcpy(value, "mmsh", 4); /* Force MMSH access/demux */
+
+ input_item_t *item = input_item_New(value, value);
+ input_item_node_AppendItem(subitems, item);
+ input_item_Release(item);
+skip:
+ free(line);
+ }
+ return VLC_SUCCESS;
+}
+
+int Import_WMS(vlc_object_t *obj)
+{
+ stream_t *demux = (stream_t *)obj;
+ const uint8_t *peek;
+
+ CHECK_FILE(demux);
+
+ if (vlc_stream_Peek(demux->s, &peek, 10) < 10
+ || strncmp((const char *)peek, "[Reference]", 11))
+ return VLC_EGENERIC;
+
+ msg_Dbg(demux, "found WMS metafile");
+ demux->pf_readdir = ReadDir;
+ demux->pf_control = access_vaDirectoryControlHelper;
+ return VLC_SUCCESS;
+}
More information about the vlc-commits
mailing list