[MPlayer-dev-eng] [PATCH] demux_lavf: make bluray language display work with lavf.

Reimar Döffinger Reimar.Doeffinger at gmx.de
Mon Jul 11 00:45:35 EEST 2022


We need the underlying MPEG-TS stream ID for that, which
is currently not passed on to MPlayer core.
As the least intrusive fix, add a demuxer ctrl to query them.
---
 libmpdemux/demux_lavf.c | 7 +++++++
 libmpdemux/demuxer.c    | 8 ++++++--
 libmpdemux/demuxer.h    | 3 +++
 3 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/libmpdemux/demux_lavf.c b/libmpdemux/demux_lavf.c
index f940e2934..9d17e1b73 100644
--- a/libmpdemux/demux_lavf.c
+++ b/libmpdemux/demux_lavf.c
@@ -790,6 +790,13 @@ static int demux_lavf_control(demuxer_t *demuxer, int cmd, void *arg)
 
 	    *((int *)arg) = (int)((priv->last_pts - priv->avfc->start_time)*100 / priv->avfc->duration);
 	    return DEMUXER_CTRL_OK;
+	case DEMUXER_CTRL_REMAP_AUDIO_ID:
+	case DEMUXER_CTRL_REMAP_SUB_ID:
+	{
+	    int id = *((int*)arg);
+	    if (priv->avfc && id >= 0 && id < priv->avfc->nb_streams) *(int *)arg = priv->avfc->streams[id]->id;
+	    return DEMUXER_CTRL_OK;
+	}
 	case DEMUXER_CTRL_SWITCH_AUDIO:
 	case DEMUXER_CTRL_SWITCH_VIDEO:
 	{
diff --git a/libmpdemux/demuxer.c b/libmpdemux/demuxer.c
index beb41f2db..77eba369f 100644
--- a/libmpdemux/demuxer.c
+++ b/libmpdemux/demuxer.c
@@ -1857,7 +1857,9 @@ int demuxer_audio_lang(demuxer_t *d, int id, char *buf, int buf_len)
         return 0;
     }
     req.type = stream_ctrl_audio;
-    req.id = sh->aid;
+    req.id = id;
+    if (demux_control(d, DEMUXER_CTRL_REMAP_AUDIO_ID, &req.id) != DEMUXER_CTRL_OK)
+        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;
@@ -1879,7 +1881,9 @@ int demuxer_sub_lang(demuxer_t *d, int id, char *buf, int buf_len)
     req.type = stream_ctrl_sub;
     // assume 1:1 mapping so we can show the language of
     // DVD subs even when we have not yet created the stream.
-    req.id = sh ? sh->sid : id;
+    req.id = id;
+    if (sh && demux_control(d, DEMUXER_CTRL_REMAP_SUB_ID, &req.id) != DEMUXER_CTRL_OK)
+        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;
diff --git a/libmpdemux/demuxer.h b/libmpdemux/demuxer.h
index e318556c9..381b198d8 100644
--- a/libmpdemux/demuxer.h
+++ b/libmpdemux/demuxer.h
@@ -111,6 +111,9 @@
 #define DEMUXER_CTRL_IDENTIFY_PROGRAM 15
 #define DEMUXER_CTRL_CORRECT_PTS 16
 #define DEMUXER_CTRL_GET_REPLAY_GAIN 17    // returns 10x the adjustment
+// Query stream IDs that the underlying device/stream would recognize
+#define DEMUXER_CTRL_REMAP_AUDIO_ID 18
+#define DEMUXER_CTRL_REMAP_SUB_ID 19
 
 #define SEEK_ABSOLUTE (1 << 0)
 #define SEEK_FACTOR   (1 << 1)
-- 
2.36.1



More information about the MPlayer-dev-eng mailing list