1
mirror of https://github.com/mpv-player/mpv synced 2025-01-16 22:37:28 +01:00

Fill sh_audio_t.lang in lavf and mkv demuxers. Use it for printing audio track

language when available.


git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@26115 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
eugeni 2008-02-29 17:25:37 +00:00
parent 85a8aa6f8e
commit 18fea2aa49
4 changed files with 7 additions and 25 deletions

View File

@ -810,8 +810,9 @@ static int mp_property_audio(m_option_t * prop, int action, void *arg,
*(char **) arg = strdup(MSGTR_Disabled);
else {
char lang[40] = MSGTR_Unknown;
if (mpctx->demuxer->type == DEMUXER_TYPE_MATROSKA)
demux_mkv_get_audio_lang(mpctx->demuxer, audio_id, lang, 9);
sh_audio_t* sh = mpctx->sh_audio;
if (sh && sh->lang)
av_strlcpy(lang, sh->lang, 40);
#ifdef USE_DVDREAD
else if (mpctx->stream->type == STREAMTYPE_DVD) {
int code = dvd_lang_from_aid(mpctx->stream, audio_id);

View File

@ -335,6 +335,8 @@ static void handle_stream(demuxer_t *demuxer, AVFormatContext *avfc, int i) {
sh_audio->format = 0x7;
break;
}
if (st->language)
sh_audio->lang = strdup(st->language);
if(mp_msg_test(MSGT_HEADER,MSGL_V) ) print_wave_header(sh_audio->wf, MSGL_V);
if((audio_lang && st->language[0] && !strncmp(audio_lang, st->language, 3))
|| (demuxer->audio->id == i || demuxer->audio->id == -1)) {

View File

@ -1873,6 +1873,8 @@ demux_mkv_open_audio (demuxer_t *demuxer, mkv_track_t *track, int aid)
if(!sh_a) return 1;
mkv_d->audio_tracks[mkv_d->last_aid] = track->tnum;
if (track->language && (strcmp(track->language, "und") != 0))
sh_a->lang = strdup(track->language);
sh_a->ds = demuxer->audio;
sh_a->wf = malloc (sizeof (WAVEFORMATEX));
if (track->ms_compat && (track->private_size >= sizeof(WAVEFORMATEX)))
@ -3502,27 +3504,6 @@ demux_mkv_get_sub_lang(demuxer_t *demuxer, int track_num, char *lang,
av_strlcpy(lang, track->language, maxlen);
}
/** \brief Get the language code for an audio track.
Retrieves the language code for an audio 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 audio 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_audio_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 = demux_mkv_find_track_by_num (mkv_d, track_num, MATROSKA_TRACK_AUDIO);
if (track && track->language && strcmp(track->language, "und"))
av_strlcpy(lang, track->language, maxlen);
}
const demuxer_desc_t demuxer_desc_matroska = {
"Matroska demuxer",
"mkv",

View File

@ -62,8 +62,6 @@
#define MKV_S_ASS "S_ASS" // Deprecated
int demux_mkv_change_subs(demuxer_t *demuxer, int new_num);
void demux_mkv_get_audio_lang(demuxer_t *demuxer, int track_num, char *lang,
int maxlen);
void demux_mkv_get_sub_lang(demuxer_t *demuxer, int track_num, char *lang,
int maxlen);