diff options
author | nicodvb <nicodvb@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2007-10-27 19:15:43 +0000 |
---|---|---|
committer | nicodvb <nicodvb@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2007-10-27 19:15:43 +0000 |
commit | af64793313bfb991ed6ac9ac67b902fa83b2387c (patch) | |
tree | 7122a9307b0ea8fa8f1251189d367031d57eafe7 /libmpdemux | |
parent | fd0f0236575de00f77b811e92c0bab2bac322f32 (diff) | |
download | mpv-af64793313bfb991ed6ac9ac67b902fa83b2387c.tar.bz2 mpv-af64793313bfb991ed6ac9ac67b902fa83b2387c.tar.xz |
implemented DEMUXER_CTRL_IDENTIFY_PROGRAM to permit program switching
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@24873 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpdemux')
-rw-r--r-- | libmpdemux/demux_lavf.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/libmpdemux/demux_lavf.c b/libmpdemux/demux_lavf.c index e8746e0a3a..940cc9519d 100644 --- a/libmpdemux/demux_lavf.c +++ b/libmpdemux/demux_lavf.c @@ -707,6 +707,60 @@ static int demux_lavf_control(demuxer_t *demuxer, int cmd, void *arg) return DEMUXER_CTRL_OK; } } + case DEMUXER_CTRL_IDENTIFY_PROGRAM: + { + demux_program_t *prog = arg; + AVProgram *program; + int p, i; + + if(priv->avfc->nb_programs < 2) + return DEMUXER_CTRL_NOTIMPL; + + if(prog->progid == -1) + { + p = 0; + while(p<priv->avfc->nb_programs && priv->avfc->programs[p]->id != priv->cur_program) + p++; + p = (p + 1) % priv->avfc->nb_programs; + } + else + { + for(i=0; i<priv->avfc->nb_programs; i++) + if(priv->avfc->programs[i]->id == prog->progid) + break; + if(i==priv->avfc->nb_programs) + return DEMUXER_CTRL_NOTIMPL; + p = i; + } + prog->vid = prog->aid = prog->sid = -2; //no audio and no video by default +redo: + program = priv->avfc->programs[p]; + for(i=0; i<program->nb_stream_indexes; i++) + { + switch(priv->avfc->streams[program->stream_index[i]]->codec->codec_type) + { + case CODEC_TYPE_VIDEO: + if(prog->vid == -2) + prog->vid = program->stream_index[i]; + break; + case CODEC_TYPE_AUDIO: + if(prog->aid == -2) + prog->aid = program->stream_index[i]; + break; + case CODEC_TYPE_SUBTITLE: + if(prog->sid == -2 && priv->avfc->streams[program->stream_index[i]]->codec->codec_id == CODEC_ID_TEXT) + prog->sid = program->stream_index[i]; + break; + } + } + if(prog->progid == -1 && prog->vid == -2 && prog->aid == -2) + { + p = (p + 1) % priv->avfc->nb_programs; + goto redo; + } + priv->cur_program = prog->progid = program->id; + return DEMUXER_CTRL_OK; + } default: return DEMUXER_CTRL_NOTIMPL; } |