[Mplayer-cvslog] CVS: main/libmpdemux matroska.h, 1.14, 1.15 demux_mkv.c, 1.20, 1.21

Moritz Bunkus CVS syncmail at mplayerhq.hu
Tue Aug 24 23:37:44 CEST 2004


CVS change done by Moritz Bunkus CVS

Update of /cvsroot/mplayer/main/libmpdemux
In directory mail:/var2/tmp/cvs-serv2030/libmpdemux

Modified Files:
	matroska.h demux_mkv.c 
Log Message:
Display the language code for subtitles from Matroska files.

Index: matroska.h
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/matroska.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- matroska.h	24 Aug 2004 20:58:29 -0000	1.14
+++ matroska.h	24 Aug 2004 21:37:41 -0000	1.15
@@ -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 */

Index: demux_mkv.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_mkv.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- demux_mkv.c	24 Aug 2004 20:58:29 -0000	1.20
+++ demux_mkv.c	24 Aug 2004 21:37:41 -0000	1.21
@@ -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 */




More information about the MPlayer-cvslog mailing list