[MPlayer-cvslog] r26118 - in trunk/libmpdemux: demuxer.c demuxer.h

eugeni subversion at mplayerhq.hu
Fri Feb 29 18:25:43 CET 2008


Author: eugeni
Date: Fri Feb 29 18:25:43 2008
New Revision: 26118

Log:
Demuxer-independent functions for selecting tracks based on language.


Modified:
   trunk/libmpdemux/demuxer.c
   trunk/libmpdemux/demuxer.h

Modified: trunk/libmpdemux/demuxer.c
==============================================================================
--- trunk/libmpdemux/demuxer.c	(original)
+++ trunk/libmpdemux/demuxer.c	Fri Feb 29 18:25:43 2008
@@ -1405,3 +1405,35 @@ int demuxer_set_angle(demuxer_t *demuxer
 
     return angle;
 }
+
+int demuxer_audio_track_by_lang(demuxer_t* d, char* lang)
+{
+    int i, len;
+    lang += strspn(lang, ",");
+    while((len = strcspn(lang, ",")) > 0) {
+        for (i=0; i < MAX_A_STREAMS; ++i) {
+            sh_audio_t* sh = d->a_streams[i];
+            if (sh && sh->lang && strncmp(sh->lang, lang, len) == 0)
+                return sh->aid;
+        }
+        lang += len;
+        lang += strspn(lang, ",");
+    }
+    return -1;
+}
+
+int demuxer_sub_track_by_lang(demuxer_t* d, char* lang)
+{
+    int i, len;
+    lang += strspn(lang, ",");
+    while((len = strcspn(lang, ",")) > 0) {
+        for (i=0; i < MAX_S_STREAMS; ++i) {
+            sh_sub_t* sh = d->s_streams[i];
+            if (sh && sh->lang && strncmp(sh->lang, lang, len) == 0)
+                return sh->sid;
+        }
+        lang += len;
+        lang += strspn(lang, ",");
+    }
+    return -1;
+}

Modified: trunk/libmpdemux/demuxer.h
==============================================================================
--- trunk/libmpdemux/demuxer.h	(original)
+++ trunk/libmpdemux/demuxer.h	Fri Feb 29 18:25:43 2008
@@ -421,4 +421,9 @@ int demuxer_set_angle(demuxer_t *demuxer
 /// Get number of angles.
 int demuxer_angles_count(demuxer_t *demuxer);
 
+// get the index of a track
+// lang is a comma-separated list
+int demuxer_audio_track_by_lang(demuxer_t* demuxer, char* lang);
+int demuxer_sub_track_by_lang(demuxer_t* demuxer, char* lang);
+
 #endif /* MPLAYER_DEMUXER_H */



More information about the MPlayer-cvslog mailing list