summaryrefslogtreecommitdiffstats
path: root/player/loadfile.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-02-08 21:18:35 +0100
committerwm4 <wm4@nowhere>2016-02-08 21:18:35 +0100
commit3d9e1ad363e9b992bae59773c08bfb7bd3b1c796 (patch)
tree641254fc1e090245a789687f64664b2bdec582d1 /player/loadfile.c
parent09d61032cac27ce12e1b858b531150ac89efe424 (diff)
downloadmpv-3d9e1ad363e9b992bae59773c08bfb7bd3b1c796.tar.bz2
mpv-3d9e1ad363e9b992bae59773c08bfb7bd3b1c796.tar.xz
player: add --external-file option
Mostly intended for use with --lavfi-complex.
Diffstat (limited to 'player/loadfile.c')
-rw-r--r--player/loadfile.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/player/loadfile.c b/player/loadfile.c
index 7ed4cb6201..14ea719e62 100644
--- a/player/loadfile.c
+++ b/player/loadfile.c
@@ -696,6 +696,8 @@ bool mp_remove_track(struct MPContext *mpctx, struct track *track)
return true;
}
+// Add the given file as additional track. Only tracks of type "filter" are
+// included; pass STREAM_TYPE_COUNT to disable filtering.
struct track *mp_add_external_file(struct MPContext *mpctx, char *filename,
enum stream_type filter)
{
@@ -729,12 +731,14 @@ struct track *mp_add_external_file(struct MPContext *mpctx, char *filename,
struct track *first = NULL;
for (int n = 0; n < demux_get_num_stream(demuxer); n++) {
struct sh_stream *sh = demux_get_stream(demuxer, n);
- if (sh->type == filter) {
+ if (filter == STREAM_TYPE_COUNT || sh->type == filter) {
struct track *t = add_stream_track(mpctx, demuxer, sh, false);
t->is_external = true;
t->title = talloc_strdup(t, mp_basename(disp_filename));
t->external_filename = talloc_strdup(t, filename);
first = t;
+ // --external-file special semantics
+ t->no_default = filter == STREAM_TYPE_COUNT;
}
}
if (!first) {
@@ -753,18 +757,11 @@ err_out:
return false;
}
-static void open_audiofiles_from_options(struct MPContext *mpctx)
+static void open_external_files(struct MPContext *mpctx, char **files,
+ enum stream_type filter)
{
- struct MPOpts *opts = mpctx->opts;
- for (int n = 0; opts->audio_files && opts->audio_files[n]; n++)
- mp_add_external_file(mpctx, opts->audio_files[n], STREAM_AUDIO);
-}
-
-static void open_subtitles_from_options(struct MPContext *mpctx)
-{
- struct MPOpts *opts = mpctx->opts;
- for (int i = 0; opts->sub_name && opts->sub_name[i] != NULL; i++)
- mp_add_external_file(mpctx, opts->sub_name[i], STREAM_SUB);
+ for (int n = 0; files && files[n]; n++)
+ mp_add_external_file(mpctx, files[n], filter);
}
void autoload_external_files(struct MPContext *mpctx)
@@ -1247,8 +1244,9 @@ reopen_file:
mpctx->timeline_part = mpctx->num_timeline_parts;
timeline_switch_to_time(mpctx, 0);
- open_subtitles_from_options(mpctx);
- open_audiofiles_from_options(mpctx);
+ open_external_files(mpctx, opts->audio_files, STREAM_AUDIO);
+ open_external_files(mpctx, opts->sub_name, STREAM_SUB);
+ open_external_files(mpctx, opts->external_files, STREAM_TYPE_COUNT);
autoload_external_files(mpctx);
check_previous_track_selection(mpctx);