diff options
author | wm4 <wm4@nowhere> | 2012-07-29 21:04:57 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2012-07-30 01:42:55 +0200 |
commit | 521a5980681885a8bc41a04c4c353a64c2f47992 (patch) | |
tree | 604b83d7ec4aff0f43015e2b18b6df0605697e2c /mplayer.c | |
parent | 3daf32adfd69e940585737631f1fb95264938268 (diff) | |
download | mpv-521a5980681885a8bc41a04c4c353a64c2f47992.tar.bz2 mpv-521a5980681885a8bc41a04c4c353a64c2f47992.tar.xz |
mplayer: let frontend print stream info, instead of demuxers
When playing a file, users (i.e. me) expect mplayer to print a list of
video/audio/subtitle streams. Currently, this is done in each demuxer
separately. This also means the output is formatted differently
depending which demuxer is active.
Add code to print an uniformly formatted streams list in the player
front end. Extend the streams headers to export additional information
about the streams. Change the lavf and mkv demuxers to follow this new
scheme, and raise the log level for the "old" printing functions.
The intention is to make every demuxer behave like this eventually.
The stream list output attempts to provide codec information. It's a
bit hacky and doesn't always provide useful output, and I'm not sure
how to do it better.
Diffstat (limited to 'mplayer.c')
-rw-r--r-- | mplayer.c | 74 |
1 files changed, 74 insertions, 0 deletions
@@ -428,6 +428,63 @@ char *get_metadata(struct MPContext *mpctx, metadata_t type) return talloc_strdup(NULL, ""); } +static void print_stream(struct MPContext *mpctx, sh_common_t *s) +{ + const char *tname = "?"; + const char *selopt = "?"; + const char *langopt = "?"; + switch (s->stream_type) { + case STREAM_VIDEO: + tname = "video"; selopt = "vid"; langopt = "vlang"; + break; + case STREAM_AUDIO: + tname = "audio"; selopt = "aid"; langopt = "alang"; + break; + case STREAM_SUBTITLE: + tname = "subtitle"; selopt = "sid"; langopt = "slang"; + break; + } + mp_msg(MSGT_CPLAYER, MSGL_INFO, "[stream] ID %d: %s", s->demuxer_id, tname); + mp_msg(MSGT_CPLAYER, MSGL_INFO, " --%s=%d", selopt, s->id); + if (s->lang) + mp_msg(MSGT_CPLAYER, MSGL_INFO, " --%s=%s", langopt, s->lang); + if (s->default_track) + mp_msg(MSGT_CPLAYER, MSGL_INFO, " (*)"); + if (s->title) + mp_msg(MSGT_CPLAYER, MSGL_INFO, " '%s'", s->title); + mp_msg(MSGT_CPLAYER, MSGL_INFO, " ("); + if (s->format) { + // not sure about endian crap + char name[sizeof(s->format) + 1] = {0}; + memcpy(name, &s->format, sizeof(s->format)); + bool ok = true; + for (int n = 0; name[n]; n++) { + if ((name[n] < 32 || name[n] >= 128) && name[n] != 0) + ok = false; + } + if (ok && strlen(name) > 0) { + mp_msg(MSGT_CPLAYER, MSGL_INFO, "%s", name); + } else { + mp_msg(MSGT_CPLAYER, MSGL_INFO, "%#x", s->format); + } + } else if (s->stream_type == STREAM_SUBTITLE) { + char t = ((sh_sub_t*)s)->type; + const char *name = NULL; + switch (t) { + case 't': name = "SRT"; break; + case 'a': name = "ASS"; break; + case 'v': name = "VobSub"; break; + } + if (!name) + name = (char[2]){t, '\0'}; + mp_msg(MSGT_CPLAYER, MSGL_INFO, "%s", name); + } + if (s->demuxer_codecname) + mp_msg(MSGT_CPLAYER, MSGL_INFO, "/%s", s->demuxer_codecname); + mp_msg(MSGT_CPLAYER, MSGL_INFO, ")"); + mp_msg(MSGT_CPLAYER, MSGL_INFO, "\n"); +} + static void print_file_properties(struct MPContext *mpctx, const char *filename) { double start_pts = MP_NOPTS_VALUE; @@ -503,6 +560,23 @@ static void print_file_properties(struct MPContext *mpctx, const char *filename) } } } + // xxx I think this might be invalid C + // should resolve the crapmess in stheader.h + for (int n = 0; n < MAX_V_STREAMS; n++) { + sh_common_t *s = (sh_common_t*)mpctx->demuxer->v_streams[n]; + if (s) + print_stream(mpctx, s); + } + for (int n = 0; n < MAX_A_STREAMS; n++) { + sh_common_t *s = (sh_common_t*)mpctx->demuxer->a_streams[n]; + if (s) + print_stream(mpctx, s); + } + for (int n = 0; n < MAX_S_STREAMS; n++) { + sh_common_t *s = (sh_common_t*)mpctx->demuxer->s_streams[n]; + if (s) + print_stream(mpctx, s); + } } /// step size of mixer changes |