demux_lavf: handle new streams appearing during playback

Based on patch by KS Ng - dmbth [hk.dmbth gmail com]

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32439 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
reimar 2010-10-04 18:12:36 +00:00 committed by Uoti Urpala
parent db90a65d11
commit c310aa4628
1 changed files with 8 additions and 0 deletions

View File

@ -73,6 +73,7 @@ typedef struct lavf_priv {
int vstreams[MAX_V_STREAMS]; int vstreams[MAX_V_STREAMS];
int sstreams[MAX_S_STREAMS]; int sstreams[MAX_S_STREAMS];
int cur_program; int cur_program;
int nb_streams_last;
}lavf_priv_t; }lavf_priv_t;
static int mp_read(void *opaque, uint8_t *buf, int size) { static int mp_read(void *opaque, uint8_t *buf, int size) {
@ -565,6 +566,8 @@ static demuxer_t* demux_open_lavf(demuxer_t *demuxer){
for(i=0; i<avfc->nb_streams; i++) for(i=0; i<avfc->nb_streams; i++)
handle_stream(demuxer, avfc, i); handle_stream(demuxer, avfc, i);
priv->nb_streams_last = avfc->nb_streams;
if(avfc->nb_programs) { if(avfc->nb_programs) {
int p; int p;
for (p = 0; p < avfc->nb_programs; p++) { for (p = 0; p < avfc->nb_programs; p++) {
@ -604,6 +607,11 @@ static int demux_lavf_fill_buffer(demuxer_t *demux, demux_stream_t *dsds){
if(av_read_frame(priv->avfc, &pkt) < 0) if(av_read_frame(priv->avfc, &pkt) < 0)
return 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; id= pkt.stream_index;
if(id==demux->audio->id){ if(id==demux->audio->id){