From d4b5ee2cd55929f190fe626c6d74697709ae2858 Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Fri, 8 Apr 2011 02:33:57 +0300 Subject: demux_mkv: support runtime video track switching Add code identical to the audio case to also support switching video tracks at runtime. Patch by "Hermi". --- libmpdemux/demux_mkv.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/libmpdemux/demux_mkv.c b/libmpdemux/demux_mkv.c index 535c749c48..ba0eaf4800 100644 --- a/libmpdemux/demux_mkv.c +++ b/libmpdemux/demux_mkv.c @@ -184,6 +184,7 @@ typedef struct mkv_demuxer { int v_skip_to_keyframe, a_skip_to_keyframe; int num_audio_tracks; + int num_video_tracks; } mkv_demuxer_t; #define REALHEADER_SIZE 16 @@ -1112,6 +1113,7 @@ static void display_create_tracks(demuxer_t *demuxer) str); } mkv_d->num_audio_tracks = aid; + mkv_d->num_video_tracks = vid; } typedef struct { @@ -2482,6 +2484,21 @@ static int demux_mkv_control(demuxer_t *demuxer, int cmd, void *arg) demuxer->audio->id = new_aid; return DEMUXER_CTRL_OK; + case DEMUXER_CTRL_SWITCH_VIDEO:; + int new_vid = *(int *) arg; + int current_vid = demuxer->video->id; + if (current_vid < 0) + current_vid = -1; + if (new_vid == -1) // cycle to next + new_vid = (current_vid + 2) % (mkv_d->num_video_tracks + 1) - 1; + if (new_vid < 0 || new_vid >= mkv_d->num_video_tracks) + new_vid = -2; + *(int *) arg = new_vid; + if (current_vid != new_vid) + ds_free_packs(demuxer->video); + demuxer->video->id = new_vid; + return DEMUXER_CTRL_OK; + default: return DEMUXER_CTRL_NOTIMPL; } -- cgit v1.2.3