mirror of
https://github.com/mpv-player/mpv
synced 2024-12-29 02:22:19 +00:00
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".
This commit is contained in:
parent
ca5399d04f
commit
d4b5ee2cd5
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user