summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwnoun <wnoun@outlook.com>2020-04-16 18:03:18 +0800
committerwm4 <1387750+wm4@users.noreply.github.com>2020-09-12 13:03:13 +0200
commit49f5c9b4820b082b8d25b753ff010562939a754f (patch)
treeece028bd81709a03ae5b914e3f4452dad484a919
parenteed8b6d47bf9c2437852cd99f53db18b3dff9ad7 (diff)
downloadmpv-49f5c9b4820b082b8d25b753ff010562939a754f.tar.bz2
mpv-49f5c9b4820b082b8d25b753ff010562939a754f.tar.xz
command: add property track-list/N/main-selection
-rw-r--r--DOCS/man/input.rst7
-rw-r--r--player/command.c11
2 files changed, 18 insertions, 0 deletions
diff --git a/DOCS/man/input.rst b/DOCS/man/input.rst
index 2b2ad76719..23725d97ec 100644
--- a/DOCS/man/input.rst
+++ b/DOCS/man/input.rst
@@ -2720,6 +2720,12 @@ Property list
``track-list/N/selected``
``yes`` if the track is currently decoded, ``no`` otherwise.
+ ``track-list/N/main-selection``
+ It indicates the selection order of tracks for the same type.
+ If a track is not selected, or is selected by the ``--lavfi-complex``,
+ it is not available. For subtitle tracks, ``0`` represents the ``sid``,
+ and ``1`` represents the ``secondary-sid``.
+
``track-list/N/ff-index``
The stream index as usually used by the FFmpeg utilities. Note that
this can be potentially wrong if a demuxer other than libavformat
@@ -2786,6 +2792,7 @@ Property list
"default" MPV_FORMAT_FLAG
"forced" MPV_FORMAT_FLAG
"selected" MPV_FORMAT_FLAG
+ "main-selection" MPV_FORMAT_INT64
"external" MPV_FORMAT_FLAG
"external-filename" MPV_FORMAT_STRING
"codec" MPV_FORMAT_STRING
diff --git a/player/command.c b/player/command.c
index 572d0874d0..b0753b690a 100644
--- a/player/command.c
+++ b/player/command.c
@@ -1919,6 +1919,16 @@ static int get_track_entry(int item, int action, void *arg, void *ctx)
if (p.par_h)
par = p.par_w / (double) p.par_h;
+ int order = -1;
+ if (track->selected) {
+ for (int i = 0; i < num_ptracks[track->type]; i++) {
+ if (mpctx->current_track[i][track->type] == track) {
+ order = i;
+ break;
+ }
+ }
+ }
+
struct m_sub_property props[] = {
{"id", SUB_PROP_INT(track->user_tid)},
{"type", SUB_PROP_STR(stream_type_name(track->type)),
@@ -1939,6 +1949,7 @@ static int get_track_entry(int item, int action, void *arg, void *ctx)
{"hearing-impaired", SUB_PROP_FLAG(track->hearing_impaired_track)},
{"external", SUB_PROP_FLAG(track->is_external)},
{"selected", SUB_PROP_FLAG(track->selected)},
+ {"main-selection", SUB_PROP_INT(order), .unavailable = order < 0},
{"external-filename", SUB_PROP_STR(track->external_filename),
.unavailable = !track->external_filename},
{"ff-index", SUB_PROP_INT(track->ff_index)},