diff options
author | wm4 <wm4@nowhere> | 2012-09-26 23:56:48 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2012-10-12 10:10:32 +0200 |
commit | 4f1aad1f064f68ab957656f01f59e363d4258d7c (patch) | |
tree | 23a45d7eafbb38f6e9ded52a9e6fa9b7caa4dbac | |
parent | 8fc2aef3b7f95a10de01a9f441907b9cd5d41c45 (diff) | |
download | mpv-4f1aad1f064f68ab957656f01f59e363d4258d7c.tar.bz2 mpv-4f1aad1f064f68ab957656f01f59e363d4258d7c.tar.xz |
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.
-rw-r--r-- | command.c | 18 |
1 files changed, 16 insertions, 2 deletions
@@ -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; |