diff libmpdemux/demuxer.c @ 31609:cd81fce1f010

Make the stream language an argument to the stream creation function so that some code can be shared.
author reimar
date Sat, 10 Jul 2010 18:47:59 +0000
parents a3a50df246f8
children 616375aefdda
line wrap: on
line diff
--- a/libmpdemux/demuxer.c	Sat Jul 10 18:11:05 2010 +0000
+++ b/libmpdemux/demuxer.c	Sat Jul 10 18:47:59 2010 +0000
@@ -254,7 +254,7 @@
     return d;
 }
 
-sh_sub_t *new_sh_sub_sid(demuxer_t *demuxer, int id, int sid)
+sh_sub_t *new_sh_sub_sid(demuxer_t *demuxer, int id, int sid, const char *lang)
 {
     if (id > MAX_S_STREAMS - 1 || id < 0) {
         mp_msg(MSGT_DEMUXER, MSGL_WARN,
@@ -269,6 +269,10 @@
         demuxer->s_streams[id] = sh;
         sh->sid = sid;
         mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_SUBTITLE_ID=%d\n", sid);
+        if (lang && lang[0] && strcmp(lang, "und")) {
+            sh->lang = strdup(lang);
+            mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_SID_%d_LANG=%s\n", sid, lang);
+        }
     }
     if (sid == dvdsub_id) {
         demuxer->sub->id = id;
@@ -292,7 +296,7 @@
     free(sh);
 }
 
-sh_audio_t *new_sh_audio_aid(demuxer_t *demuxer, int id, int aid)
+sh_audio_t *new_sh_audio_aid(demuxer_t *demuxer, int id, int aid, const char *lang)
 {
     if (id > MAX_A_STREAMS - 1 || id < 0) {
         mp_msg(MSGT_DEMUXER, MSGL_WARN,
@@ -314,6 +318,10 @@
         sh->audio_out_minsize = 8192;   /* default size, maybe not enough for Win32/ACM */
         sh->pts = MP_NOPTS_VALUE;
         mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AUDIO_ID=%d\n", aid);
+        if (lang && lang[0] && strcmp(lang, "und")) {
+            sh->lang = strdup(lang);
+            mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AID_%d_LANG=%s\n", aid, lang);
+        }
     }
     return demuxer->a_streams[id];
 }