changeset 26086:c9a877daca42

Demuxer-independent functions for selecting tracks based on language.
author eugeni
date Fri, 29 Feb 2008 17:25:43 +0000
parents 681f6ae38b68
children 2a112aed0dda
files libmpdemux/demuxer.c libmpdemux/demuxer.h
diffstat 2 files changed, 37 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/demuxer.c	Fri Feb 29 17:25:41 2008 +0000
+++ b/libmpdemux/demuxer.c	Fri Feb 29 17:25:43 2008 +0000
@@ -1405,3 +1405,35 @@
 
     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;
+}
--- a/libmpdemux/demuxer.h	Fri Feb 29 17:25:41 2008 +0000
+++ b/libmpdemux/demuxer.h	Fri Feb 29 17:25:43 2008 +0000
@@ -421,4 +421,9 @@
 /// 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 */