From 4f1aad1f064f68ab957656f01f59e363d4258d7c Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 26 Sep 2012 23:56:48 +0200 Subject: [PATCH] commands: attempt to fix "program" property The user-visible track IDs are normalized and don't match with whatever the demuxer uses. Completely untested. It might actually work with both demux_lavf and demux_ts. --- command.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/command.c b/command.c index b736a56fde..d746c50db6 100644 --- a/command.c +++ b/command.c @@ -791,6 +791,18 @@ static int mp_property_video(m_option_t *prop, int action, void *arg, return property_switch_track(prop, action, arg, mpctx, STREAM_VIDEO); } +static struct track *find_track_by_demuxer_id(MPContext *mpctx, + enum stream_type type, + int demuxer_id) +{ + for (int n = 0; n < mpctx->num_tracks; n++) { + struct track *track = mpctx->tracks[n]; + if (track->type == type && track->demuxer_id == demuxer_id) + return track; + } + return NULL; +} + static int mp_property_program(m_option_t *prop, int action, void *arg, MPContext *mpctx) { @@ -816,8 +828,10 @@ static int mp_property_program(m_option_t *prop, int action, void *arg, "Selected program contains no audio or video streams!\n"); return M_PROPERTY_ERROR; } - mp_property_do("audio", M_PROPERTY_SET, &prog.aid, mpctx); - mp_property_do("video", M_PROPERTY_SET, &prog.vid, mpctx); + mp_switch_track(mpctx, STREAM_AUDIO, + find_track_by_demuxer_id(mpctx, STREAM_AUDIO, prog.aid)); + mp_switch_track(mpctx, STREAM_VIDEO, + find_track_by_demuxer_id(mpctx, STREAM_VIDEO, prog.vid)); return M_PROPERTY_OK; } return M_PROPERTY_NOT_IMPLEMENTED;