changeset 21403:c91294804a0b

Implement stream switching for AVI demuxer.
author reimar
date Fri, 01 Dec 2006 17:57:29 +0000
parents 8c43ea1ea79a
children 896a8210ed9f
files libmpdemux/demux_avi.c
diffstat 1 files changed, 25 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/demux_avi.c	Fri Dec 01 17:56:41 2006 +0000
+++ b/libmpdemux/demux_avi.c	Fri Dec 01 17:57:29 2006 +0000
@@ -762,6 +762,31 @@
 	    if (sh_video->video.dwLength<=1) return DEMUXER_CTRL_GUESS;
 	    return DEMUXER_CTRL_OK;
 
+	case DEMUXER_CTRL_SWITCH_AUDIO:
+	case DEMUXER_CTRL_SWITCH_VIDEO: {
+	    int audio = (cmd == DEMUXER_CTRL_SWITCH_AUDIO);
+	    demux_stream_t *ds = audio ? demuxer->audio : demuxer->video;
+	    void **streams = audio ? demuxer->a_streams : demuxer->v_streams;
+	    int maxid = FFMAX(99, audio ? MAX_A_STREAMS : MAX_V_STREAMS);
+	    int chunkid;
+	    if (ds->id < -1)
+	      return DEMUXER_CTRL_NOTIMPL;
+
+	    if (*(int *)arg >= 0)
+	      ds->id = *(int *)arg;
+	    else {
+	      do {
+	        if (++ds->id >= maxid) ds->id = 0;
+	      } while (!streams[ds->id]);
+	    }
+
+	    chunkid = (ds->id / 10 + '0') | (ds->id % 10 + '0') << 8;
+	    ds->sh = NULL;
+	    demux_avi_select_stream(demuxer, chunkid);
+	    *(int *)arg = ds->id;
+	    return DEMUXER_CTRL_OK;
+	}
+
 	default:
 	    return DEMUXER_CTRL_NOTIMPL;
     }