path: root/stream/stream_file.c
diff options
authorwm4 <wm4@nowhere>2014-09-25 23:38:23 +0200
committerwm4 <wm4@nowhere>2014-09-25 23:54:18 +0200
commitd191de856486174faec188ad142ef3ff1b347bd4 (patch)
tree0bf66226ecea6a704b9d204cf465b35a7b9c318b /stream/stream_file.c
parentd8f993705c8403c527990cce961073c91143d1e7 (diff)
stream_dvd: better .ifo probing
stream_dvd.c includes a pseudo-protocol that recognizes .IFO files, and plays them using libdvdread. This was relatively lazy, and could perhaps easily trigger with files that just had the .ifo extension. Make the checks stricter, and even probe the file header. Apparently the first bytes in an .ifo file are always "DVDVIDEO-VTS", so check for this. Refuse to load the main "video_ts.ifo". The plan is to use stream_dvdnav for it. This also removes at least 1 memory leak.
Diffstat (limited to 'stream/stream_file.c')
1 files changed, 11 insertions, 0 deletions
diff --git a/stream/stream_file.c b/stream/stream_file.c
index 6a10114832..eef0dcc5cc 100644
--- a/stream/stream_file.c
+++ b/stream/stream_file.c
@@ -126,6 +126,17 @@ char *mp_file_url_to_filename(void *talloc_ctx, bstr url)
return filename;
+// Return talloc_strdup's filesystem path if local, otherwise NULL.
+// Unlike mp_file_url_to_filename(), doesn't return NULL if already local.
+char *mp_file_get_path(void *talloc_ctx, bstr url)
+ if (mp_split_proto(url, &(bstr){0}).len) {
+ return mp_file_url_to_filename(talloc_ctx, url);
+ } else {
+ return bstrto0(talloc_ctx, url);
+ }
static bool check_stream_network(stream_t *stream)