changeset 13129:cfce549da2f0

Display the language code for subtitles from Matroska files.
author mosu
date Tue, 24 Aug 2004 21:37:41 +0000
parents 07067695680a
children 96784ad2c469
files libmpdemux/demux_mkv.c libmpdemux/matroska.h mplayer.c
diffstat 3 files changed, 50 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/demux_mkv.c	Tue Aug 24 21:29:51 2004 +0000
+++ b/libmpdemux/demux_mkv.c	Tue Aug 24 21:37:41 2004 +0000
@@ -3217,4 +3217,38 @@
   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 */
--- a/libmpdemux/matroska.h	Tue Aug 24 21:29:51 2004 +0000
+++ b/libmpdemux/matroska.h	Tue Aug 24 21:37:41 2004 +0000
@@ -63,7 +63,9 @@
   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 */
--- a/mplayer.c	Tue Aug 24 21:29:51 2004 +0000
+++ b/mplayer.c	Tue Aug 24 21:37:41 2004 +0000
@@ -3641,7 +3641,7 @@
 		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);
@@ -3653,6 +3653,17 @@
 	      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
 #ifdef USE_SUB