mirror of https://github.com/mpv-player/mpv
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.
This commit is contained in:
parent
d191de8564
commit
c3f7773138
|
@ -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
|
||||
|
|
|
@ -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 },
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue