diff options
author | Uoti Urpala <uau@mplayer2.org> | 2011-07-03 20:41:46 +0300 |
---|---|---|
committer | Uoti Urpala <uau@mplayer2.org> | 2011-07-03 20:41:46 +0300 |
commit | 8ff5b2b88930146fb1931ead243703754e227709 (patch) | |
tree | b7b5b83dd3435573a6ac0a589ba42532e9de3b0f /libmpdemux | |
parent | c5364305bec6dff4566b988157b93d3d171465e3 (diff) | |
download | mpv-8ff5b2b88930146fb1931ead243703754e227709.tar.bz2 mpv-8ff5b2b88930146fb1931ead243703754e227709.tar.xz |
OSD: when switching sub/audio tracks show title of new track
If the played file has per-track titles for audio and subtitles show
those on the OSD when switching tracks. This changes the OSD message
from 'Audio: (2) eng' to 'Audio: (2) eng ("Director's commentary")'.
Diffstat (limited to 'libmpdemux')
-rw-r--r-- | libmpdemux/demux_lavf.c | 12 | ||||
-rw-r--r-- | libmpdemux/demux_mkv.c | 3 | ||||
-rw-r--r-- | libmpdemux/stheader.h | 1 |
3 files changed, 13 insertions, 3 deletions
diff --git a/libmpdemux/demux_lavf.c b/libmpdemux/demux_lavf.c index e8313fa4c2..73174437fb 100644 --- a/libmpdemux/demux_lavf.c +++ b/libmpdemux/demux_lavf.c @@ -362,9 +362,11 @@ static void handle_stream(demuxer_t *demuxer, AVFormatContext *avfc, int i) sh_audio->format = 0x7; break; } - if (title && title->value) + if (title && title->value) { + sh_audio->title = talloc_strdup(sh_audio, title->value); mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AID_%d_NAME=%s\n", priv->audio_streams, title->value); + } if (lang && lang->value) { sh_audio->lang = talloc_strdup(sh_audio, lang->value); mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AID_%d_LANG=%s\n", @@ -425,9 +427,11 @@ static void handle_stream(demuxer_t *demuxer, AVFormatContext *avfc, int i) sh_video->aspect = codec->width * codec->sample_aspect_ratio.num / (float)(codec->height * codec->sample_aspect_ratio.den); sh_video->i_bps = codec->bit_rate / 8; - if (title && title->value) + if (title && title->value) { + sh_video->title = talloc_strdup(sh_video, title->value); mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VID_%d_NAME=%s\n", priv->video_streams, title->value); + } mp_msg(MSGT_DEMUX, MSGL_DBG2, "aspect= %d*%d/(%d*%d)\n", codec->width, codec->sample_aspect_ratio.num, codec->height, codec->sample_aspect_ratio.den); @@ -480,9 +484,11 @@ static void handle_stream(demuxer_t *demuxer, AVFormatContext *avfc, int i) memcpy(sh_sub->extradata, codec->extradata, codec->extradata_size); sh_sub->extradata_len = codec->extradata_size; } - if (title && title->value) + if (title && title->value) { + sh_sub->title = talloc_strdup(sh_sub, title->value); mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_SID_%d_NAME=%s\n", priv->sub_streams, title->value); + } if (lang && lang->value) { sh_sub->lang = talloc_strdup(sh_sub, lang->value); mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_SID_%d_LANG=%s\n", diff --git a/libmpdemux/demux_mkv.c b/libmpdemux/demux_mkv.c index 7d84fa5f63..4b4d8704a5 100644 --- a/libmpdemux/demux_mkv.c +++ b/libmpdemux/demux_mkv.c @@ -1253,6 +1253,7 @@ static int demux_mkv_open_video(demuxer_t *demuxer, mkv_track_t *track, } sh_v = new_sh_video(demuxer, vid); + sh_v->title = talloc_strdup(sh_v, track->name); sh_v->bih = bih; sh_v->format = sh_v->bih->biCompression; if (track->v_frate == 0.0) @@ -1290,6 +1291,7 @@ static int demux_mkv_open_audio(demuxer_t *demuxer, mkv_track_t *track, if (track->language && (strcmp(track->language, "und") != 0)) sh_a->lang = talloc_strdup(sh_a, track->language); + sh_a->title = talloc_strdup(sh_a, track->name); sh_a->default_track = track->default_track; sh_a->ds = demuxer->audio; sh_a->wf = malloc(sizeof(*sh_a->wf)); @@ -1588,6 +1590,7 @@ static int demux_mkv_open_sub(demuxer_t *demuxer, mkv_track_t *track, sh->extradata_len = track->private_size; if (track->language && (strcmp(track->language, "und") != 0)) sh->lang = talloc_strdup(sh, track->language); + sh->title = talloc_strdup(sh, track->name); sh->default_track = track->default_track; } else { mp_tmsg(MSGT_DEMUX, MSGL_ERR, diff --git a/libmpdemux/stheader.h b/libmpdemux/stheader.h index e49d33f161..80818e8785 100644 --- a/libmpdemux/stheader.h +++ b/libmpdemux/stheader.h @@ -47,6 +47,7 @@ struct demuxer; /* decoder context */ \ void *context; \ char *lang; /* track language */ \ + char *title; /* track title */ \ bool default_track; \ typedef struct sh_common { |