diff options
author | 2011-04-08 02:33:57 +0300 | |
---|---|---|
committer | 2011-04-08 02:33:57 +0300 | |
commit | d4b5ee2cd55929f190fe626c6d74697709ae2858 (patch) | |
tree | 80b07091e2359f1db553368c6338a6ef3d6f22b1 | |
parent | ca5399d04fa14639d2a047f29280e8184b419dcb (diff) |
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".
-rw-r--r-- | libmpdemux/demux_mkv.c | 17 |
1 files changed, 17 insertions, 0 deletions
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; } |