diff options
author | wm4 <wm4@mplayer2.org> | 2011-10-24 02:41:17 +0200 |
---|---|---|
committer | wm4 <wm4@mplayer2.org> | 2012-07-28 20:57:44 +0200 |
commit | 42c3a300082f5dfbbd09818d149331ff45fd5892 (patch) | |
tree | 58dd8ff6656c5ab1dfc836cb5da2a5781ecda4e8 | |
parent | af7a29424c889ea6993561262539586d7ac1dc40 (diff) | |
download | mpv-42c3a300082f5dfbbd09818d149331ff45fd5892.tar.bz2 mpv-42c3a300082f5dfbbd09818d149331ff45fd5892.tar.xz |
commands: add show_tracks_osd command to display audio and subtitle tracks on OSD
The command lists the audio and subtitle tracks in the current file on the
OSD. It also marks the currently active streams.
Video streams are not shown, as files with more than one video stream are
exceedingly rare.
-rw-r--r-- | DOCS/OUTDATED-tech/slave.txt | 3 | ||||
-rw-r--r-- | command.c | 82 | ||||
-rw-r--r-- | input/input.c | 1 | ||||
-rw-r--r-- | input/input.h | 1 |
4 files changed, 87 insertions, 0 deletions
diff --git a/DOCS/OUTDATED-tech/slave.txt b/DOCS/OUTDATED-tech/slave.txt index 4359aa1a29..d57a8aca46 100644 --- a/DOCS/OUTDATED-tech/slave.txt +++ b/DOCS/OUTDATED-tech/slave.txt @@ -496,6 +496,9 @@ volume <value> [abs] show_chapters_osd Show the list of chapters in the currently played file on the OSD. +show_tracks_osd + Show the list audio and subtitle tracks in the currently played file on the OSD. + Available properties: name type min max get set step comment @@ -2844,6 +2844,85 @@ static void show_chapters_on_osd(MPContext *mpctx) talloc_free(res); } +static void show_tracks_on_osd(MPContext *mpctx) +{ + struct MPOpts *opts = &mpctx->opts; + char *res = NULL; + const char *IND = ""; + int n; + int cnt = 0; + struct sh_audio *cur_a; + struct sh_sub *cur_s; + demux_stream_t *d_sub; + demuxer_t *demuxer = mpctx->demuxer; + + if (!demuxer) + return; + + cur_a = mpctx->sh_audio; + d_sub = mpctx->d_sub; + cur_s = d_sub && opts->sub_id >= 0 ? d_sub->sh : NULL; + + for (n = 0; n < MAX_V_STREAMS; n++) { + struct sh_video *v = demuxer->v_streams[n]; + if (v) { + cnt++; + } + } + if (cnt > 1) + res = talloc_asprintf_append(res, "(Warning: more than one video stream.)\n"); + +#define STD_TRACK_HDR(st, id) \ + res = talloc_asprintf_append(res, "%s(%d) ", IND, st->id); \ + if (st->title) { \ + res = talloc_asprintf_append(res, "'%s' ", st->title); \ + } \ + if (st->lang) { \ + res = talloc_asprintf_append(res, "(%s) ", st->lang); \ + } + + for (n = 0; n < MAX_A_STREAMS; n++) { + struct sh_audio *a = demuxer->a_streams[n]; + if (a) { + cnt++; + if (a == cur_a) + res = talloc_asprintf_append(res, "> "); + STD_TRACK_HDR(a, aid) + if (a == cur_a) + res = talloc_asprintf_append(res, "<"); + res = talloc_asprintf_append(res, "\n"); + } + } + + res = talloc_asprintf_append(res, "\n"); + + for (n = 0; n < MAX_S_STREAMS; n++) { + struct sh_sub *s = demuxer->s_streams[n]; + if (s) { + cnt++; + if (s == cur_s) + res = talloc_asprintf_append(res, "> "); + STD_TRACK_HDR(s, sid) + char *type = "?"; + switch (s->type) { + case 't': type = "SRT"; break; + case 'v': type = "VOB"; break; + case 'a': type = NULL; break; //"ASS/SSA"; + } + if (type) + res = talloc_asprintf_append(res, " [%s]", type); + if (s == cur_s) + res = talloc_asprintf_append(res, "<"); + res = talloc_asprintf_append(res, "\n"); + } + } + +#undef STD_TRACK_HDR + + set_osd_msg(OSD_MSG_TEXT, 1, opts->osd_duration, "%s", res); + talloc_free(res); +} + void run_command(MPContext *mpctx, mp_cmd_t *cmd) { struct MPOpts *opts = &mpctx->opts; @@ -3663,6 +3742,9 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd) case MP_CMD_SHOW_CHAPTERS: show_chapters_on_osd(mpctx); break; + case MP_CMD_SHOW_TRACKS: + show_tracks_on_osd(mpctx); + break; default: mp_msg(MSGT_CPLAYER, MSGL_V, diff --git a/input/input.c b/input/input.c index f99c3218dc..014216e093 100644 --- a/input/input.c +++ b/input/input.c @@ -223,6 +223,7 @@ static const mp_cmd_t mp_cmds[] = { { MP_CMD_AF_CMDLINE, "af_cmdline", { ARG_STRING, ARG_STRING } }, { MP_CMD_SHOW_CHAPTERS, "show_chapters_osd", }, + { MP_CMD_SHOW_TRACKS, "show_tracks_osd", }, {0} }; diff --git a/input/input.h b/input/input.h index 9bbf6bf7df..977901b6d3 100644 --- a/input/input.h +++ b/input/input.h @@ -155,6 +155,7 @@ enum mp_command_type { MP_CMD_AF_CMDLINE, MP_CMD_SHOW_CHAPTERS, + MP_CMD_SHOW_TRACKS, }; // The arg types |