From c3f77731380579323d3cf74bb739aace0a9d6717 Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 25 Sep 2014 23:54:58 +0200 Subject: stream_dvdnav: allow opening DVD directories directly Same hack as with stream_dvd.c. VIDEO_TS.IFO files are now opened via stream_dvdnav.c. Directories containing a VIDEO_TS.IFO or VIDEO_TS/VIDEO_TS.IFO file are also opened with it. --- stream/stream.c | 2 ++ stream/stream_dvdnav.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) 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 #include #include +#include #include #include #include +#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 }, +}; -- cgit v1.2.3