diff libmpdemux/demuxer.c @ 34648:26eddbd6353a

Code cleanup: Use a stream_control instead of global functions to get the language associate with a audio or subtitle stream from the streaming layer.
author reimar
date Sun, 19 Feb 2012 13:15:41 +0000
parents f3d53cd55376
children e92fb6cc0836
line wrap: on
line diff
--- a/libmpdemux/demuxer.c	Sat Feb 18 19:33:47 2012 +0000
+++ b/libmpdemux/demuxer.c	Sun Feb 19 13:15:41 2012 +0000
@@ -53,6 +53,7 @@
 #endif
 #include "av_helpers.h"
 #endif
+#include "libavutil/avstring.h"
 
 // This is quite experimental, in particular it will mess up the pts values
 // in the queue - on the other hand it might fix some issues like generating
@@ -1785,6 +1786,50 @@
     return angle;
 }
 
+int demuxer_audio_lang(demuxer_t *d, int id, char *buf, int buf_len)
+{
+    struct stream_lang_req req;
+    sh_audio_t *sh;
+    if (id < 0 || id >= MAX_A_STREAMS)
+        return -1;
+    sh = d->a_streams[id];
+    if (!sh)
+        return -1;
+    if (sh->lang) {
+        av_strlcpy(buf, sh->lang, buf_len);
+        return 0;
+    }
+    req.type = stream_ctrl_audio;
+    req.id = sh->aid;
+    if (stream_control(d->stream, STREAM_CTRL_GET_LANG, &req) == STREAM_OK) {
+        av_strlcpy(buf, req.buf, buf_len);
+        return 0;
+    }
+    return -1;
+}
+
+int demuxer_sub_lang(demuxer_t *d, int id, char *buf, int buf_len)
+{
+    struct stream_lang_req req;
+    sh_sub_t *sh;
+    if (id < 0 || id >= MAX_S_STREAMS)
+        return -1;
+    sh = d->s_streams[id];
+    if (!sh)
+        return -1;
+    if (sh->lang) {
+        av_strlcpy(buf, sh->lang, buf_len);
+        return 0;
+    }
+    req.type = stream_ctrl_sub;
+    req.id = sh->sid;
+    if (stream_control(d->stream, STREAM_CTRL_GET_LANG, &req) == STREAM_OK) {
+        av_strlcpy(buf, req.buf, buf_len);
+        return 0;
+    }
+    return -1;
+}
+
 int demuxer_audio_track_by_lang(demuxer_t *d, char *lang)
 {
     int i, len;