summaryrefslogtreecommitdiffstats
path: root/player
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2019-12-20 09:41:42 +0100
committerwm4 <wm4@nowhere>2019-12-20 13:00:39 +0100
commit1cb9e7efb8b7420e80d31f45c508b05bae96685e (patch)
treea66b841575b7a15e5b0d65517ea58929dbed041b /player
parent572c32abbedd3860718f099743dfa973b4f58bbc (diff)
downloadmpv-1cb9e7efb8b7420e80d31f45c508b05bae96685e.tar.bz2
mpv-1cb9e7efb8b7420e80d31f45c508b05bae96685e.tar.xz
stream, demux: redo origin policy thing
mpv has a very weak and very annoying policy that determines whether a playlist should be used or not. For example, if you play a remote playlist, you usually don't want it to be able to read local filesystem entries. (Although for a media player the impact is small I guess.) It's weak and annoying as in that it does not prevent certain cases which could be interpreted as bad in some cases, such as allowing playlists on the local filesystem to reference remote URLs. It probably barely makes sense, but we just want to exclude some other "definitely not a good idea" things, all while playlists generally just work, so whatever. The policy is: - from the command line anything is played - local playlists can reference anything except "unsafe" streams ("unsafe" means special stream inputs like libavfilter graphs) - remote playlists can reference only remote URLs - things like "memory://" and archives are "transparent" to this This commit does... something. It replaces the weird stream flags with a slightly clearer "origin" value, which is now consequently passed down and used everywhere. It fixes some deviations from the described policy. I wanted to force archives to reference only content within them, but this would probably have been more complicated (or required different abstractions), and I'm too lazy to figure it out, so archives are now "transparent" (playlists within archives behave the same outside). There may be a lot of bugs in this. This is unfortunately a very noisy commit because: - every stream open call now needs to pass the origin - so does every demuxer open call (=> params param. gets mandatory) - most stream were changed to provide the "origin" value - the origin value needed to be passed along in a lot of places - I was too lazy to split the commit Fixes: #7274
Diffstat (limited to 'player')
-rw-r--r--player/loadfile.c14
-rw-r--r--player/misc.c4
2 files changed, 6 insertions, 12 deletions
diff --git a/player/loadfile.c b/player/loadfile.c
index 2535e75617..462355f60e 100644
--- a/player/loadfile.c
+++ b/player/loadfile.c
@@ -746,6 +746,7 @@ int mp_add_external_file(struct MPContext *mpctx, char *filename,
struct demuxer_params params = {
.is_top_level = true,
+ .stream_flags = STREAM_ORIGIN_DIRECT,
};
switch (filter) {
@@ -949,7 +950,8 @@ static void load_chapters(struct MPContext *mpctx)
if (chapter_file && chapter_file[0]) {
chapter_file = talloc_strdup(NULL, chapter_file);
mp_core_unlock(mpctx);
- struct demuxer *demux = demux_open_url(chapter_file, NULL,
+ struct demuxer_params p = {.stream_flags = STREAM_ORIGIN_DIRECT};
+ struct demuxer *demux = demux_open_url(chapter_file, &p,
mpctx->playback_abort,
mpctx->global);
mp_core_lock(mpctx);
@@ -1065,8 +1067,6 @@ static void start_open(struct MPContext *mpctx, char *url, int url_flags,
mpctx->open_format = talloc_strdup(NULL, mpctx->opts->demuxer_name);
mpctx->open_url_flags = url_flags;
mpctx->open_for_prefetch = for_prefetch && mpctx->opts->demuxer_thread;
- if (mpctx->opts->load_unsafe_playlists)
- mpctx->open_url_flags = 0;
if (pthread_create(&mpctx->open_thread, NULL, open_demux_thread, mpctx)) {
cancel_open(mpctx);
@@ -1473,14 +1473,6 @@ static void play_current_file(struct MPContext *mpctx)
if (mpctx->demuxer->playlist) {
struct playlist *pl = mpctx->demuxer->playlist;
- int entry_stream_flags = 0;
- if (!pl->disable_safety && !mpctx->opts->load_unsafe_playlists) {
- entry_stream_flags = STREAM_SAFE_ONLY;
- if (mpctx->demuxer->is_network)
- entry_stream_flags |= STREAM_NETWORK_ONLY;
- }
- for (struct playlist_entry *e = pl->first; e; e = e->next)
- e->stream_flags |= entry_stream_flags;
transfer_playlist(mpctx, pl);
mp_notify_property(mpctx, "playlist");
mpctx->error_playing = 2;
diff --git a/player/misc.c b/player/misc.c
index ae4550fec5..5a96d6cc25 100644
--- a/player/misc.c
+++ b/player/misc.c
@@ -238,7 +238,9 @@ void error_on_track(struct MPContext *mpctx, struct track *track)
int stream_dump(struct MPContext *mpctx, const char *source_filename)
{
struct MPOpts *opts = mpctx->opts;
- stream_t *stream = stream_open(source_filename, mpctx->global);
+ stream_t *stream = stream_create(source_filename,
+ STREAM_ORIGIN_DIRECT | STREAM_READ,
+ mpctx->playback_abort, mpctx->global);
if (!stream)
return -1;