changeset 24843:2bd6d730782f

permit the transititions no stream <-> some streams and viceversa (needed for forthcoming program switching patch)
author nicodvb
date Sat, 27 Oct 2007 19:04:37 +0000
parents d5f716b49cb4
children 4559076416de
files libmpdemux/demux_lavf.c
diffstat 1 files changed, 11 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/demux_lavf.c	Sat Oct 27 19:00:07 2007 +0000
+++ b/libmpdemux/demux_lavf.c	Sat Oct 27 19:04:37 2007 +0000
@@ -632,8 +632,14 @@
 	        nstreams = priv->audio_streams;
 	        pstreams = priv->astreams;
 	    }
-	    if(ds->id == -2)
-	        return DEMUXER_CTRL_NOTIMPL;
+	    if(id == -2)
+	    {
+	        if(ds->id >= 0)
+	            priv->avfc->streams[ds->id]->discard = AVDISCARD_ALL;
+	        ds_free_packs(ds);
+	        *((int*)arg) = ds->id = -2;
+	        return DEMUXER_CTRL_OK;
+	    } 
 	    for(i = 0; i < nstreams; i++)
 	    {
 	        if(pstreams[i] == ds->id) //current stream id
@@ -659,13 +665,15 @@
 		    }
 	        }
 	    }
-	    if(newid == -2 || i == curridx)
+	    if(i == curridx)
 	        return DEMUXER_CTRL_NOTIMPL;
 	    else
 	    {
 	        ds_free_packs(ds);
+	        if(ds->id >= 0)
 	        priv->avfc->streams[ds->id]->discard = AVDISCARD_ALL;
 	        *((int*)arg) = ds->id = newid;
+	        if(newid >= 0)
 	        priv->avfc->streams[newid]->discard = AVDISCARD_NONE;
 	        return DEMUXER_CTRL_OK;
 	    }