# HG changeset patch # User reimar # Date 1286215956 0 # Node ID a5ed4bcb11497fae72f387066c9908aa181f6a84 # Parent 76f94c00a69fc58ea7d67409ced5678c2df4b96c Handle libavformat adding additional streams during playback. Based on patch by KS Ng - dmbth [hk.dmbth gmail com] diff -r 76f94c00a69f -r a5ed4bcb1149 libmpdemux/demux_lavf.c --- a/libmpdemux/demux_lavf.c Mon Oct 04 06:40:32 2010 +0000 +++ b/libmpdemux/demux_lavf.c Mon Oct 04 18:12:36 2010 +0000 @@ -77,6 +77,7 @@ int vstreams[MAX_V_STREAMS]; int sstreams[MAX_S_STREAMS]; int cur_program; + int nb_streams_last; }lavf_priv_t; static int mp_read(void *opaque, uint8_t *buf, int size) { @@ -552,6 +553,8 @@ for(i=0; inb_streams; i++) handle_stream(demuxer, avfc, i); + priv->nb_streams_last = avfc->nb_streams; + if(avfc->nb_programs) { int p; for (p = 0; p < avfc->nb_programs; p++) { @@ -589,6 +592,11 @@ if(av_read_frame(priv->avfc, &pkt) < 0) return 0; + // handle any new streams that might have been added + for (id = priv->nb_streams_last; id < priv->avfc->nb_streams; id++) + handle_stream(demux, priv->avfc, id); + priv->nb_streams_last = priv->avfc->nb_streams; + id= pkt.stream_index; if(id==demux->audio->id){