1
0
mirror of https://github.com/mpv-player/mpv synced 2025-01-31 04:02:06 +00:00

Display the language code for subtitles from Matroska files.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@13130 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
mosu 2004-08-24 21:37:41 +00:00
parent 36f2212fe2
commit 51fe7e4a6a
3 changed files with 50 additions and 3 deletions

View File

@ -3217,4 +3217,38 @@ demux_mkv_change_subs (demuxer_t *demuxer, int new_num)
return track->tnum;
}
/** \brief Get the language code for a subtitle track.
Retrieves the language code for a subtitle track if it is known.
If the language code is "und" then do not copy it ("und" = "undefined").
\param demuxer The demuxer to work on
\param track_num The n'th subtitle track to get the language from
\param lang Store the language here
\param maxlen The maximum number of characters to copy into lang
*/
void
demux_mkv_get_sub_lang(demuxer_t *demuxer, int track_num, char *lang,
int maxlen)
{
mkv_demuxer_t *mkv_d = (mkv_demuxer_t *) demuxer->priv;
mkv_track_t *track;
int i, num;
num = 0;
for (i = 0; i < mkv_d->num_tracks; i++)
{
track = mkv_d->tracks[i];
if (track->type == MATROSKA_TRACK_SUBTITLE)
num++;
if (num == (track_num + 1))
{
if ((track->language != NULL) &&
strcmp(track->language, "und"))
strncpy(lang, track->language, maxlen);
return;
}
}
}
#endif /* HAVE_MATROSKA */

View File

@ -63,7 +63,9 @@ typedef struct {
int forced_subs_only;
} mkv_sh_sub_t;
int demux_mkv_num_subs(demuxer_t *);
int demux_mkv_change_subs(demuxer_t *, int);
int demux_mkv_num_subs(demuxer_t *demuxer);
int demux_mkv_change_subs(demuxer_t *demuxer, int new_num);
void demux_mkv_get_sub_lang(demuxer_t *demuxer, int track_num, char *lang,
int maxlen);
#endif /* __MATROSKA_H */

View File

@ -3641,7 +3641,7 @@ if(rel_seek_secs || abs_seek_pos){
snprintf(osd_text_tmp, 63, "Subtitles: (%d)", dvdsub_id);
}
#ifdef USE_DVDREAD
if (vo_spudec) {
if (vo_spudec && (demuxer->type != DEMUXER_TYPE_MATROSKA)) {
char lang[5] = "none";
int code = 0;
if (dvdsub_id >= 0) code = dvd_lang_from_sid(stream, dvdsub_id);
@ -3652,6 +3652,17 @@ if(rel_seek_secs || abs_seek_pos){
}
snprintf(osd_text_tmp, 63, "Subtitles: (%d) %s", dvdsub_id, lang);
}
#endif
#ifdef HAVE_MATROSKA
if (demuxer->type == DEMUXER_TYPE_MATROSKA) {
char lang[10] = "unknown";
if (dvdsub_id >= 0) {
demux_mkv_get_sub_lang(demuxer, dvdsub_id, lang, 9);
lang[9] = 0;
} else
strcpy(lang, "off");
snprintf(osd_text_tmp, 63, "Subtitles: (%d) %s", dvdsub_id, lang);
}
#endif
osd_show_vobsub_changed--;
} else