diff options
author | wm4 <wm4@nowhere> | 2014-09-25 23:54:58 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2014-09-26 00:30:21 +0200 |
commit | c3f77731380579323d3cf74bb739aace0a9d6717 (patch) | |
tree | 00d7dceb8127461c305ea14529c2837dcf15748a /stream/stream_dvdnav.c | |
parent | d191de856486174faec188ad142ef3ff1b347bd4 (diff) | |
download | mpv-c3f77731380579323d3cf74bb739aace0a9d6717.tar.bz2 mpv-c3f77731380579323d3cf74bb739aace0a9d6717.tar.xz |
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.
Diffstat (limited to 'stream/stream_dvdnav.c')
-rw-r--r-- | stream/stream_dvdnav.c | 52 |
1 files changed, 52 insertions, 0 deletions
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 }, +}; |