summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--stream/stream.c2
-rw-r--r--stream/stream_dvdnav.c52
2 files changed, 54 insertions, 0 deletions
diff --git a/stream/stream.c b/stream/stream.c
index ae4335c8b7..6a231713fb 100644
--- a/stream/stream.c
+++ b/stream/stream.c
@@ -65,6 +65,7 @@ extern const stream_info_t stream_info_ffmpeg_unsafe;
extern const stream_info_t stream_info_avdevice;
extern const stream_info_t stream_info_file;
extern const stream_info_t stream_info_ifo;
+extern const stream_info_t stream_info_ifo_dvdnav;
extern const stream_info_t stream_info_dvd;
extern const stream_info_t stream_info_dvdnav;
extern const stream_info_t stream_info_bluray;
@@ -97,6 +98,7 @@ static const stream_info_t *const stream_list[] = {
&stream_info_dvd,
#endif
#if HAVE_DVDNAV
+ &stream_info_ifo_dvdnav,
&stream_info_dvdnav,
#endif
#if HAVE_LIBBLURAY
diff --git a/stream/stream_dvdnav.c b/stream/stream_dvdnav.c
index 2d9658bc78..67436aa5e6 100644
--- a/stream/stream_dvdnav.c
+++ b/stream/stream_dvdnav.c
@@ -23,15 +23,19 @@
#include <stdio.h>
#include <unistd.h>
#include <string.h>
+#include <strings.h>
#include <errno.h>
#include <assert.h>
#include <dvdnav/dvdnav.h>
+#include "osdep/io.h"
+
#include "options/options.h"
#include "common/msg.h"
#include "input/input.h"
#include "options/m_option.h"
+#include "options/path.h"
#include "osdep/timer.h"
#include "stream.h"
#include "demux/demux.h"
@@ -753,3 +757,51 @@ const stream_info_t stream_info_dvdnav = {
NULL
},
};
+
+static bool check_ifo(const char *path)
+{
+ if (strcasecmp(mp_basename(path), "video_ts.ifo"))
+ return false;
+
+ return dvd_probe(path, ".ifo", "DVDVIDEO-VMG");
+}
+
+static int ifo_dvdnav_stream_open(stream_t *stream)
+{
+ struct priv *priv = talloc_ptrtype(stream, priv);
+ stream->priv = priv;
+ *priv = stream_priv_dflts;
+
+ char *path = mp_file_get_path(priv, bstr0(stream->url));
+ if (!path)
+ goto unsupported;
+
+ // We allow the path to point to a directory containing VIDEO_TS/, a
+ // directory containing VIDEO_TS.IFO, or that file itself.
+ if (!check_ifo(path)) {
+ // On UNIX, just assume the filename is always uppercase.
+ char *npath = mp_path_join(priv, bstr0(path), bstr0("VIDEO_TS.IFO"));
+ if (!check_ifo(npath)) {
+ npath = mp_path_join(priv, bstr0(path), bstr0("VIDEO_TS/VIDEO_TS.IFO"));
+ if (!check_ifo(npath))
+ goto unsupported;
+ }
+ path = npath;
+ }
+
+ priv->device = bstrto0(priv, mp_dirname(path));
+
+ MP_INFO(stream, ".IFO detected. Redirecting to dvd://\n");
+ return open_s(stream);
+
+unsupported:
+ talloc_free(priv);
+ stream->priv = NULL;
+ return STREAM_UNSUPPORTED;
+}
+
+const stream_info_t stream_info_ifo_dvdnav = {
+ .name = "ifo/dvdnav",
+ .open = ifo_dvdnav_stream_open,
+ .protocols = (const char*const[]){ "file", "", NULL },
+};