mirror of
https://github.com/mpv-player/mpv
synced 2025-04-04 15:34:31 +00:00
adds a parameter to the switch_audio command to directly select a track.
Patch by kiriuja mplayer-patches at en-directo net git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@15286 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
68f4daf93b
commit
be54f4813f
@ -91,8 +91,9 @@ use_master
|
|||||||
mute
|
mute
|
||||||
Mute/unmute sound output.
|
Mute/unmute sound output.
|
||||||
|
|
||||||
switch_audio (MPEG and Matroska only)
|
switch_audio [<value>] (MPEG and Matroska only)
|
||||||
Cycle through the available audio tracks.
|
Switch to the audio track with the id <value>. Cycle through the
|
||||||
|
available tracks if <value> is omitted or negative.
|
||||||
|
|
||||||
[contrast|gamma|brightness|hue|saturation] <-100 - 100> [<abs>]
|
[contrast|gamma|brightness|hue|saturation] <-100 - 100> [<abs>]
|
||||||
Set/adjust video parameters.
|
Set/adjust video parameters.
|
||||||
|
@ -82,7 +82,7 @@ static mp_cmd_t mp_cmds[] = {
|
|||||||
{ MP_CMD_SUB_LOG, "sub_log", 0, { {-1,{0}} } },
|
{ MP_CMD_SUB_LOG, "sub_log", 0, { {-1,{0}} } },
|
||||||
{ MP_CMD_GET_PERCENT_POS, "get_percent_pos", 0, { {-1,{0}} } },
|
{ MP_CMD_GET_PERCENT_POS, "get_percent_pos", 0, { {-1,{0}} } },
|
||||||
{ MP_CMD_GET_TIME_LENGTH, "get_time_length", 0, { {-1,{0}} } },
|
{ MP_CMD_GET_TIME_LENGTH, "get_time_length", 0, { {-1,{0}} } },
|
||||||
{ MP_CMD_SWITCH_AUDIO, "switch_audio", 0, { {-1,{0}} } },
|
{ MP_CMD_SWITCH_AUDIO, "switch_audio", 0, { { MP_CMD_ARG_INT,{-1} }, {-1,{0}} } },
|
||||||
#ifdef USE_TV
|
#ifdef USE_TV
|
||||||
{ MP_CMD_TV_STEP_CHANNEL, "tv_step_channel", 1, { { MP_CMD_ARG_INT ,{0}}, {-1,{0}} }},
|
{ MP_CMD_TV_STEP_CHANNEL, "tv_step_channel", 1, { { MP_CMD_ARG_INT ,{0}}, {-1,{0}} }},
|
||||||
{ MP_CMD_TV_STEP_NORM, "tv_step_norm",0, { {-1,{0}} } },
|
{ MP_CMD_TV_STEP_NORM, "tv_step_norm",0, { {-1,{0}} } },
|
||||||
|
@ -2118,16 +2118,17 @@ demux_mkv_open_sub (demuxer_t *demuxer, mkv_track_t *track)
|
|||||||
|
|
||||||
void demux_mkv_seek (demuxer_t *demuxer, float rel_seek_secs, int flags);
|
void demux_mkv_seek (demuxer_t *demuxer, float rel_seek_secs, int flags);
|
||||||
|
|
||||||
/** \brief Given a matroska track number, find the subtitle number that mplayer would ask for.
|
/** \brief Given a matroska track number and type, find the id that mplayer would ask for.
|
||||||
* \param d The demuxer for which the subtitle id should be returned.
|
* \param d The demuxer for which the subtitle id should be returned.
|
||||||
* \param num The matroska track number we are looking up.
|
* \param num The matroska track number we are looking up.
|
||||||
|
* \param type The track type.
|
||||||
*/
|
*/
|
||||||
static int demux_mkv_sub_reverse_id(mkv_demuxer_t *d, int num)
|
static int demux_mkv_reverse_id(mkv_demuxer_t *d, int num, int type)
|
||||||
{
|
{
|
||||||
int i, id;
|
int i, id;
|
||||||
|
|
||||||
for (i=0, id=0; i < d->num_tracks; i++)
|
for (i=0, id=0; i < d->num_tracks; i++)
|
||||||
if (d->tracks[i] != NULL && d->tracks[i]->type == MATROSKA_TRACK_SUBTITLE) {
|
if (d->tracks[i] != NULL && d->tracks[i]->type == type) {
|
||||||
if (d->tracks[i]->tnum == num)
|
if (d->tracks[i]->tnum == num)
|
||||||
return id;
|
return id;
|
||||||
id++;
|
id++;
|
||||||
@ -2351,7 +2352,7 @@ demux_mkv_open (demuxer_t *demuxer)
|
|||||||
{
|
{
|
||||||
mp_msg (MSGT_DEMUX, MSGL_INFO,
|
mp_msg (MSGT_DEMUX, MSGL_INFO,
|
||||||
"[mkv] Will display subtitle track %u\n", track->tnum);
|
"[mkv] Will display subtitle track %u\n", track->tnum);
|
||||||
dvdsub_id = demux_mkv_sub_reverse_id(mkv_d, track->tnum);
|
dvdsub_id = demux_mkv_reverse_id(mkv_d, track->tnum, MATROSKA_TRACK_SUBTITLE);
|
||||||
demuxer->sub->id = track->tnum;
|
demuxer->sub->id = track->tnum;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -3344,12 +3345,13 @@ demux_mkv_control (demuxer_t *demuxer, int cmd, void *arg)
|
|||||||
if (demuxer->audio && demuxer->audio->sh) {
|
if (demuxer->audio && demuxer->audio->sh) {
|
||||||
int i;
|
int i;
|
||||||
demux_stream_t *d_audio = demuxer->audio;
|
demux_stream_t *d_audio = demuxer->audio;
|
||||||
sh_audio_t *sh_audio = d_audio->sh;
|
|
||||||
int idx = d_audio->id - 1; // track ids are 1 based
|
int idx = d_audio->id - 1; // track ids are 1 based
|
||||||
int num = mkv_d->num_tracks;
|
int num = mkv_d->num_tracks;
|
||||||
mkv_track_t *otrack = mkv_d->tracks[idx];
|
mkv_track_t *otrack = mkv_d->tracks[idx];
|
||||||
for (i = 1; i < num; i++) {
|
mkv_track_t *track = 0;
|
||||||
mkv_track_t *track = mkv_d->tracks[(idx+i)%num];
|
if (*((int*)arg) < 0)
|
||||||
|
for (i = 1; i <= num; i++) {
|
||||||
|
track = mkv_d->tracks[(idx+i)%num];
|
||||||
if ((track->type == MATROSKA_TRACK_AUDIO) &&
|
if ((track->type == MATROSKA_TRACK_AUDIO) &&
|
||||||
!strcmp(track->codec_id, otrack->codec_id) &&
|
!strcmp(track->codec_id, otrack->codec_id) &&
|
||||||
(track->a_channels == otrack->a_channels) &&
|
(track->a_channels == otrack->a_channels) &&
|
||||||
@ -3358,12 +3360,21 @@ demux_mkv_control (demuxer_t *demuxer, int cmd, void *arg)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (i < num) {
|
else {
|
||||||
d_audio->id = (idx+i)%num + 1;
|
track = demux_mkv_find_track_by_num (mkv_d, *((int*)arg), MATROSKA_TRACK_AUDIO);
|
||||||
|
if (track == NULL ||
|
||||||
|
strcmp (track->codec_id, otrack->codec_id) ||
|
||||||
|
track->a_channels != otrack->a_channels ||
|
||||||
|
track->a_bps != otrack->a_bps ||
|
||||||
|
track->a_sfreq != otrack->a_sfreq)
|
||||||
|
track = otrack;
|
||||||
|
}
|
||||||
|
if (track != otrack) {
|
||||||
|
d_audio->id = track->tnum;
|
||||||
ds_free_packs(d_audio);
|
ds_free_packs(d_audio);
|
||||||
}
|
}
|
||||||
*((int *)arg)=(int)d_audio->id;
|
|
||||||
}
|
}
|
||||||
|
*((int*)arg) = demux_mkv_reverse_id (mkv_d, demuxer->audio->id, MATROSKA_TRACK_AUDIO);
|
||||||
return DEMUXER_CTRL_OK;
|
return DEMUXER_CTRL_OK;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -643,6 +643,8 @@ int demux_mpg_control(demuxer_t *demuxer,int cmd, void *arg){
|
|||||||
sh_audio_t *sh_audio = d_audio->sh;
|
sh_audio_t *sh_audio = d_audio->sh;
|
||||||
sh_audio_t *sh_a;
|
sh_audio_t *sh_a;
|
||||||
int i;
|
int i;
|
||||||
|
if (*((int*)arg) < 0)
|
||||||
|
{
|
||||||
for (i = 0; i < mpg_d->num_a_streams; i++) {
|
for (i = 0; i < mpg_d->num_a_streams; i++) {
|
||||||
if (d_audio->id == mpg_d->a_stream_ids[i]) break;
|
if (d_audio->id == mpg_d->a_stream_ids[i]) break;
|
||||||
}
|
}
|
||||||
@ -650,13 +652,22 @@ int demux_mpg_control(demuxer_t *demuxer,int cmd, void *arg){
|
|||||||
i = (i+1) % mpg_d->num_a_streams;
|
i = (i+1) % mpg_d->num_a_streams;
|
||||||
sh_a = (sh_audio_t*)demuxer->a_streams[mpg_d->a_stream_ids[i]];
|
sh_a = (sh_audio_t*)demuxer->a_streams[mpg_d->a_stream_ids[i]];
|
||||||
} while (sh_a->format != sh_audio->format);
|
} while (sh_a->format != sh_audio->format);
|
||||||
if (d_audio->id != mpg_d->a_stream_ids[i]) {
|
}
|
||||||
|
else {
|
||||||
|
for (i = 0; i < mpg_d->num_a_streams; i++)
|
||||||
|
if (*((int*)arg) == mpg_d->a_stream_ids[i]) break;
|
||||||
|
if (i < mpg_d->num_a_streams)
|
||||||
|
sh_a = (sh_audio_t*)demuxer->a_streams[*((int*)arg)];
|
||||||
|
if (sh_a->format != sh_audio->format)
|
||||||
|
i = mpg_d->num_a_streams;
|
||||||
|
}
|
||||||
|
if (i < mpg_d->num_a_streams && d_audio->id != mpg_d->a_stream_ids[i]) {
|
||||||
d_audio->id = mpg_d->a_stream_ids[i];
|
d_audio->id = mpg_d->a_stream_ids[i];
|
||||||
d_audio->sh = sh_a;
|
d_audio->sh = sh_a;
|
||||||
ds_free_packs(d_audio);
|
ds_free_packs(d_audio);
|
||||||
}
|
}
|
||||||
*((int *)arg)=(int)d_audio->id;
|
|
||||||
}
|
}
|
||||||
|
*((int*)arg) = demuxer->audio->id;
|
||||||
return DEMUXER_CTRL_OK;
|
return DEMUXER_CTRL_OK;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -1778,8 +1778,9 @@ int demuxer_get_percent_pos(demuxer_t *demuxer){
|
|||||||
return ans;
|
return ans;
|
||||||
}
|
}
|
||||||
|
|
||||||
int demuxer_switch_audio(demuxer_t *demuxer){
|
int demuxer_switch_audio(demuxer_t *demuxer, int index){
|
||||||
int ans = 0;
|
int res = demux_control(demuxer, DEMUXER_CTRL_SWITCH_AUDIO, &index);
|
||||||
int res = demux_control(demuxer, DEMUXER_CTRL_SWITCH_AUDIO, &ans);
|
if (res == DEMUXER_CTRL_NOTIMPL)
|
||||||
return ans;
|
index = demuxer->audio->id;
|
||||||
|
return index;
|
||||||
}
|
}
|
||||||
|
@ -287,6 +287,6 @@ char *demux_ogg_sub_lang(demuxer_t *demuxer, int index);
|
|||||||
|
|
||||||
extern unsigned long demuxer_get_time_length(demuxer_t *demuxer);
|
extern unsigned long demuxer_get_time_length(demuxer_t *demuxer);
|
||||||
extern int demuxer_get_percent_pos(demuxer_t *demuxer);
|
extern int demuxer_get_percent_pos(demuxer_t *demuxer);
|
||||||
extern int demuxer_switch_audio(demuxer_t *demuxer);
|
extern int demuxer_switch_audio(demuxer_t *demuxer, int index);
|
||||||
|
|
||||||
extern int demuxer_type_by_filename(char* filename);
|
extern int demuxer_type_by_filename(char* filename);
|
||||||
|
@ -3494,9 +3494,11 @@ if (stream->type==STREAMTYPE_DVDNAV && dvd_nav_still)
|
|||||||
case MP_CMD_GET_PERCENT_POS : {
|
case MP_CMD_GET_PERCENT_POS : {
|
||||||
mp_msg(MSGT_GLOBAL,MSGL_INFO,MSGTR_AnsPercentPos, demuxer_get_percent_pos(demuxer));
|
mp_msg(MSGT_GLOBAL,MSGL_INFO,MSGTR_AnsPercentPos, demuxer_get_percent_pos(demuxer));
|
||||||
} break;
|
} break;
|
||||||
case MP_CMD_SWITCH_AUDIO :
|
case MP_CMD_SWITCH_AUDIO : {
|
||||||
demuxer_switch_audio(demuxer);
|
int v = demuxer_switch_audio(demuxer, cmd->args[0].v.i);
|
||||||
break;
|
if (identify)
|
||||||
|
mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_AUDIO_TRACK=%d\n", v);
|
||||||
|
} break;
|
||||||
case MP_CMD_RUN : {
|
case MP_CMD_RUN : {
|
||||||
#ifndef __MINGW32__
|
#ifndef __MINGW32__
|
||||||
if(!fork()) {
|
if(!fork()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user