diff options
Diffstat (limited to 'command.c')
-rw-r--r-- | command.c | 578 |
1 files changed, 295 insertions, 283 deletions
@@ -18,6 +18,7 @@ #include "metadata.h" #include "libmpcodecs/vf.h" #include "libmpcodecs/vd.h" +#include "mp_osd.h" #include "libvo/video_out.h" #include "libvo/font_load.h" #include "playtree.h" @@ -66,35 +67,38 @@ extern int use_menu; -static void rescale_input_coordinates(int ix, int iy, double *dx, double *dy) +static void rescale_input_coordinates(struct MPContext *mpctx, int ix, int iy, + double *dx, double *dy) { + struct MPOpts *opts = &mpctx->opts; + struct vo *vo = mpctx->video_out; //remove the borders, if any, and rescale to the range [0,1],[0,1] if (vo_fs) { //we are in full-screen mode - if (vo_screenwidth > vo_dwidth) //there are borders along the x axis - ix -= (vo_screenwidth - vo_dwidth) / 2; - if (vo_screenheight > vo_dheight) //there are borders along the y axis (usual way) - iy -= (vo_screenheight - vo_dheight) / 2; + if (opts->vo_screenwidth > vo->dwidth) //there are borders along the x axis + ix -= (opts->vo_screenwidth - vo->dwidth) / 2; + if (opts->vo_screenheight > vo->dheight) //there are borders along the y axis (usual way) + iy -= (opts->vo_screenheight - vo->dheight) / 2; - if (ix < 0 || ix > vo_dwidth) { + if (ix < 0 || ix > vo->dwidth) { *dx = *dy = -1.0; return; } //we are on one of the borders - if (iy < 0 || iy > vo_dheight) { + if (iy < 0 || iy > vo->dheight) { *dx = *dy = -1.0; return; } //we are on one of the borders } - *dx = (double) ix / (double) vo_dwidth; - *dy = (double) iy / (double) vo_dheight; + *dx = (double) ix / (double) vo->dwidth; + *dy = (double) iy / (double) vo->dheight; mp_msg(MSGT_CPLAYER, MSGL_V, "\r\nrescaled coordinates: %.3lf, %.3lf, screen (%d x %d), vodisplay: (%d, %d), fullscreen: %d\r\n", - *dx, *dy, vo_screenwidth, vo_screenheight, vo_dwidth, - vo_dheight, vo_fs); + *dx, *dy, opts->vo_screenwidth, opts->vo_screenheight, vo->dwidth, + vo->dheight, vo_fs); } -static int sub_source_by_pos(MPContext * mpctx, int pos) +static int sub_source_by_pos(MPContext *mpctx, int pos) { int source = -1; int top = -1; @@ -109,7 +113,7 @@ static int sub_source_by_pos(MPContext * mpctx, int pos) return source; } -static int sub_source(MPContext * mpctx) +static int sub_source(MPContext *mpctx) { return sub_source_by_pos(mpctx, mpctx->global_sub_pos); } @@ -124,7 +128,7 @@ static int sub_source(MPContext * mpctx) * which need to be fixed while watching the movie. */ -static void log_sub(void) +static void log_sub(struct MPContext *mpctx) { char *fname; FILE *f; @@ -140,14 +144,14 @@ static void log_sub(void) if (subdata->sub_uses_time) { fprintf(f, "N: %s S: %02ld:%02ld:%02ld.%02ld E: %02ld:%02ld:%02ld.%02ld\n", - filename, vo_sub_last->start / 360000, + mpctx->filename, vo_sub_last->start / 360000, (vo_sub_last->start / 6000) % 60, (vo_sub_last->start / 100) % 60, vo_sub_last->start % 100, vo_sub_last->end / 360000, (vo_sub_last->end / 6000) % 60, (vo_sub_last->end / 100) % 60, vo_sub_last->end % 100); } else { - fprintf(f, "N: %s S: %ld E: %ld\n", filename, vo_sub_last->start, - vo_sub_last->end); + fprintf(f, "N: %s S: %ld E: %ld\n", mpctx->filename, + vo_sub_last->start, vo_sub_last->end); } for (i = 0; i < vo_sub_last->lines; i++) { fprintf(f, "%s\n", vo_sub_last->text[i]); @@ -164,77 +168,80 @@ static void log_sub(void) ///@{ /// OSD level (RW) -static int mp_property_osdlevel(m_option_t * prop, int action, void *arg, - MPContext * mpctx) +static int mp_property_osdlevel(m_option_t *prop, int action, void *arg, + MPContext *mpctx) { return m_property_choice(prop, action, arg, &osd_level); } /// Loop (RW) -static int mp_property_loop(m_option_t * prop, int action, void *arg, - MPContext * mpctx) +static int mp_property_loop(m_option_t *prop, int action, void *arg, + MPContext *mpctx) { + struct MPOpts *opts = &mpctx->opts; switch (action) { case M_PROPERTY_PRINT: if (!arg) return M_PROPERTY_ERROR; - if (mpctx->loop_times < 0) + if (opts->loop_times < 0) *(char**)arg = strdup("off"); - else if (mpctx->loop_times == 0) + else if (opts->loop_times == 0) *(char**)arg = strdup("inf"); else break; return M_PROPERTY_OK; } - return m_property_int_range(prop, action, arg, &mpctx->loop_times); + return m_property_int_range(prop, action, arg, &opts->loop_times); } /// Playback speed (RW) -static int mp_property_playback_speed(m_option_t * prop, int action, - void *arg, MPContext * mpctx) +static int mp_property_playback_speed(m_option_t *prop, int action, + void *arg, MPContext *mpctx) { + struct MPOpts *opts = &mpctx->opts; switch (action) { case M_PROPERTY_SET: if (!arg) return M_PROPERTY_ERROR; M_PROPERTY_CLAMP(prop, *(float *) arg); - playback_speed = *(float *) arg; - build_afilter_chain(mpctx->sh_audio, &ao_data); + opts->playback_speed = *(float *) arg; + build_afilter_chain(mpctx, mpctx->sh_audio, &ao_data); return M_PROPERTY_OK; case M_PROPERTY_STEP_UP: case M_PROPERTY_STEP_DOWN: - playback_speed += (arg ? *(float *) arg : 0.1) * + opts->playback_speed += (arg ? *(float *) arg : 0.1) * (action == M_PROPERTY_STEP_DOWN ? -1 : 1); - M_PROPERTY_CLAMP(prop, playback_speed); - build_afilter_chain(mpctx->sh_audio, &ao_data); + M_PROPERTY_CLAMP(prop, opts->playback_speed); + build_afilter_chain(mpctx, mpctx->sh_audio, &ao_data); return M_PROPERTY_OK; } - return m_property_float_range(prop, action, arg, &playback_speed); + return m_property_float_range(prop, action, arg, &opts->playback_speed); } /// filename with path (RO) -static int mp_property_path(m_option_t * prop, int action, void *arg, - MPContext * mpctx) +static int mp_property_path(m_option_t *prop, int action, void *arg, + MPContext *mpctx) { - return m_property_string_ro(prop, action, arg, filename); + return m_property_string_ro(prop, action, arg, mpctx->filename); } /// filename without path (RO) -static int mp_property_filename(m_option_t * prop, int action, void *arg, - MPContext * mpctx) +static int mp_property_filename(m_option_t *prop, int action, void *arg, + MPContext *mpctx) { char *f; - if (!filename) + if (!mpctx->filename) return M_PROPERTY_UNAVAILABLE; - if (((f = strrchr(filename, '/')) || (f = strrchr(filename, '\\'))) && f[1]) + if (((f = strrchr(mpctx->filename, '/')) + || (f = strrchr(mpctx->filename, '\\'))) && f[1]) f++; else - f = filename; + f = mpctx->filename; return m_property_string_ro(prop, action, arg, f); } /// Demuxer name (RO) -static int mp_property_demuxer(m_option_t * prop, int action, void *arg, - MPContext * mpctx) +static int mp_property_demuxer(m_option_t *prop, int action, void *arg, + MPContext *mpctx) { if (!mpctx->demuxer) return M_PROPERTY_UNAVAILABLE; @@ -243,8 +250,8 @@ static int mp_property_demuxer(m_option_t * prop, int action, void *arg, } /// Position in the stream (RW) -static int mp_property_stream_pos(m_option_t * prop, int action, void *arg, - MPContext * mpctx) +static int mp_property_stream_pos(m_option_t *prop, int action, void *arg, + MPContext *mpctx) { if (!mpctx->demuxer || !mpctx->demuxer->stream) return M_PROPERTY_UNAVAILABLE; @@ -263,8 +270,8 @@ static int mp_property_stream_pos(m_option_t * prop, int action, void *arg, } /// Stream start offset (RO) -static int mp_property_stream_start(m_option_t * prop, int action, - void *arg, MPContext * mpctx) +static int mp_property_stream_start(m_option_t *prop, int action, + void *arg, MPContext *mpctx) { if (!mpctx->demuxer || !mpctx->demuxer->stream) return M_PROPERTY_UNAVAILABLE; @@ -277,8 +284,8 @@ static int mp_property_stream_start(m_option_t * prop, int action, } /// Stream end offset (RO) -static int mp_property_stream_end(m_option_t * prop, int action, void *arg, - MPContext * mpctx) +static int mp_property_stream_end(m_option_t *prop, int action, void *arg, + MPContext *mpctx) { if (!mpctx->demuxer || !mpctx->demuxer->stream) return M_PROPERTY_UNAVAILABLE; @@ -291,8 +298,8 @@ static int mp_property_stream_end(m_option_t * prop, int action, void *arg, } /// Stream length (RO) -static int mp_property_stream_length(m_option_t * prop, int action, - void *arg, MPContext * mpctx) +static int mp_property_stream_length(m_option_t *prop, int action, + void *arg, MPContext *mpctx) { if (!mpctx->demuxer || !mpctx->demuxer->stream) return M_PROPERTY_UNAVAILABLE; @@ -306,8 +313,8 @@ static int mp_property_stream_length(m_option_t * prop, int action, } /// Media length in seconds (RO) -static int mp_property_length(m_option_t * prop, int action, void *arg, - MPContext * mpctx) +static int mp_property_length(m_option_t *prop, int action, void *arg, + MPContext *mpctx) { double len; @@ -319,8 +326,8 @@ static int mp_property_length(m_option_t * prop, int action, void *arg, } /// Current position in percent (RW) -static int mp_property_percent_pos(m_option_t * prop, int action, - void *arg, MPContext * mpctx) { +static int mp_property_percent_pos(m_option_t *prop, int action, + void *arg, MPContext *mpctx) { int pos; if (!mpctx->demuxer) @@ -344,14 +351,14 @@ static int mp_property_percent_pos(m_option_t * prop, int action, demuxer_get_percent_pos(mpctx->demuxer)); } - abs_seek_pos = SEEK_ABSOLUTE | SEEK_FACTOR; - rel_seek_secs = pos / 100.0; + mpctx->abs_seek_pos = SEEK_ABSOLUTE | SEEK_FACTOR; + mpctx->rel_seek_secs = pos / 100.0; return M_PROPERTY_OK; } /// Current position in seconds (RW) -static int mp_property_time_pos(m_option_t * prop, int action, - void *arg, MPContext * mpctx) { +static int mp_property_time_pos(m_option_t *prop, int action, + void *arg, MPContext *mpctx) { if (!(mpctx->sh_video || (mpctx->sh_audio && mpctx->audio_out))) return M_PROPERTY_UNAVAILABLE; @@ -359,20 +366,18 @@ static int mp_property_time_pos(m_option_t * prop, int action, case M_PROPERTY_SET: if(!arg) return M_PROPERTY_ERROR; M_PROPERTY_CLAMP(prop, *(double*)arg); - abs_seek_pos = SEEK_ABSOLUTE; - rel_seek_secs = *(double*)arg; + mpctx->abs_seek_pos = SEEK_ABSOLUTE; + mpctx->rel_seek_secs = *(double*)arg; return M_PROPERTY_OK; case M_PROPERTY_STEP_UP: case M_PROPERTY_STEP_DOWN: - rel_seek_secs += (arg ? *(double*)arg : 10.0) * + mpctx->rel_seek_secs += (arg ? *(double*)arg : 10.0) * (action == M_PROPERTY_STEP_UP ? 1.0 : -1.0); return M_PROPERTY_OK; } return m_property_time_ro(prop, action, arg, mpctx->sh_video ? mpctx->sh_video->pts : - playing_audio_pts(mpctx->sh_audio, - mpctx->d_audio, - mpctx->audio_out)); + playing_audio_pts(mpctx)); } /// Current chapter (RW) @@ -424,21 +429,21 @@ static int mp_property_chapter(m_option_t *prop, int action, void *arg, default: return M_PROPERTY_NOT_IMPLEMENTED; } - rel_seek_secs = 0; - abs_seek_pos = 0; + mpctx->rel_seek_secs = 0; + mpctx->abs_seek_pos = 0; chapter = demuxer_seek_chapter(mpctx->demuxer, chapter, 1, &next_pts, &chapter_num, &chapter_name); if (chapter >= 0) { if (next_pts > -1.0) { - abs_seek_pos = SEEK_ABSOLUTE; - rel_seek_secs = next_pts; + mpctx->abs_seek_pos = SEEK_ABSOLUTE; + mpctx->rel_seek_secs = next_pts; } if (chapter_name) set_osd_msg(OSD_MSG_TEXT, 1, osd_duration, MSGTR_OSDChapter, chapter + 1, chapter_name); } else if (step_all > 0) - rel_seek_secs = 1000000000.; + mpctx->rel_seek_secs = 1000000000.; else set_osd_msg(OSD_MSG_TEXT, 1, osd_duration, MSGTR_OSDChapter, 0, MSGTR_Unknown); @@ -521,11 +526,11 @@ static int mp_property_angle(m_option_t *prop, int action, void *arg, } /// Demuxer meta data -static int mp_property_metadata(m_option_t * prop, int action, void *arg, - MPContext * mpctx) { +static int mp_property_metadata(m_option_t *prop, int action, void *arg, + MPContext *mpctx) { m_property_action_t* ka; char* meta; - static m_option_t key_type = + static const m_option_t key_type = { "metadata", NULL, CONF_TYPE_STRING, 0, 0, 0, NULL }; if (!mpctx->demuxer) return M_PROPERTY_UNAVAILABLE; @@ -568,8 +573,8 @@ static int mp_property_pause(m_option_t * prop, int action, void *arg, ///@{ /// Volume (RW) -static int mp_property_volume(m_option_t * prop, int action, void *arg, - MPContext * mpctx) +static int mp_property_volume(m_option_t *prop, int action, void *arg, + MPContext *mpctx) { if (!mpctx->sh_audio) @@ -624,8 +629,8 @@ static int mp_property_volume(m_option_t * prop, int action, void *arg, } /// Mute (RW) -static int mp_property_mute(m_option_t * prop, int action, void *arg, - MPContext * mpctx) +static int mp_property_mute(m_option_t *prop, int action, void *arg, + MPContext *mpctx) { if (!mpctx->sh_audio) @@ -662,8 +667,8 @@ static int mp_property_mute(m_option_t * prop, int action, void *arg, } /// Audio delay (RW) -static int mp_property_audio_delay(m_option_t * prop, int action, - void *arg, MPContext * mpctx) +static int mp_property_audio_delay(m_option_t *prop, int action, + void *arg, MPContext *mpctx) { if (!(mpctx->sh_audio && mpctx->sh_video)) return M_PROPERTY_UNAVAILABLE; @@ -686,8 +691,8 @@ static int mp_property_audio_delay(m_option_t * prop, int action, } /// Audio codec tag (RO) -static int mp_property_audio_format(m_option_t * prop, int action, - void *arg, MPContext * mpctx) +static int mp_property_audio_format(m_option_t *prop, int action, + void *arg, MPContext *mpctx) { if (!mpctx->sh_audio) return M_PROPERTY_UNAVAILABLE; @@ -695,8 +700,8 @@ static int mp_property_audio_format(m_option_t * prop, int action, } /// Audio codec name (RO) -static int mp_property_audio_codec(m_option_t * prop, int action, - void *arg, MPContext * mpctx) +static int mp_property_audio_codec(m_option_t *prop, int action, + void *arg, MPContext *mpctx) { if (!mpctx->sh_audio || !mpctx->sh_audio->codec) return M_PROPERTY_UNAVAILABLE; @@ -704,8 +709,8 @@ static int mp_property_audio_codec(m_option_t * prop, int action, } /// Audio bitrate (RO) -static int mp_property_audio_bitrate(m_option_t * prop, int action, - void *arg, MPContext * mpctx) +static int mp_property_audio_bitrate(m_option_t *prop, int action, + void *arg, MPContext *mpctx) { if (!mpctx->sh_audio) return M_PROPERTY_UNAVAILABLE; @@ -713,8 +718,8 @@ static int mp_property_audio_bitrate(m_option_t * prop, int action, } /// Samplerate (RO) -static int mp_property_samplerate(m_option_t * prop, int action, void *arg, - MPContext * mpctx) +static int mp_property_samplerate(m_option_t *prop, int action, void *arg, + MPContext *mpctx) { if (!mpctx->sh_audio) return M_PROPERTY_UNAVAILABLE; @@ -729,8 +734,8 @@ static int mp_property_samplerate(m_option_t * prop, int action, void *arg, } /// Number of channels (RO) -static int mp_property_channels(m_option_t * prop, int action, void *arg, - MPContext * mpctx) +static int mp_property_channels(m_option_t *prop, int action, void *arg, + MPContext *mpctx) { if (!mpctx->sh_audio) return M_PROPERTY_UNAVAILABLE; @@ -755,8 +760,8 @@ static int mp_property_channels(m_option_t * prop, int action, void *arg, } /// Balance (RW) -static int mp_property_balance(m_option_t * prop, int action, void *arg, - MPContext * mpctx) +static int mp_property_balance(m_option_t *prop, int action, void *arg, + MPContext *mpctx) { float bal; @@ -806,9 +811,10 @@ static int mp_property_balance(m_option_t * prop, int action, void *arg, } /// Selected audio id (RW) -static int mp_property_audio(m_option_t * prop, int action, void *arg, - MPContext * mpctx) +static int mp_property_audio(m_option_t *prop, int action, void *arg, + MPContext *mpctx) { + struct MPOpts *opts = &mpctx->opts; int current_id = -1, tmp; switch (action) { @@ -817,7 +823,7 @@ static int mp_property_audio(m_option_t * prop, int action, void *arg, return M_PROPERTY_UNAVAILABLE; if (!arg) return M_PROPERTY_ERROR; - *(int *) arg = audio_id; + *(int *) arg = opts->audio_id; return M_PROPERTY_OK; case M_PROPERTY_PRINT: if (!mpctx->sh_audio) @@ -825,7 +831,7 @@ static int mp_property_audio(m_option_t * prop, int action, void *arg, if (!arg) return M_PROPERTY_ERROR; - if (audio_id < 0) + if (opts->audio_id < 0) *(char **) arg = strdup(MSGTR_Disabled); else { char lang[40] = MSGTR_Unknown; @@ -834,7 +840,7 @@ static int mp_property_audio(m_option_t * prop, int action, void *arg, av_strlcpy(lang, sh->lang, 40); #ifdef CONFIG_DVDREAD else if (mpctx->stream->type == STREAMTYPE_DVD) { - int code = dvd_lang_from_aid(mpctx->stream, audio_id); + int code = dvd_lang_from_aid(mpctx->stream, opts->audio_id); if (code) { lang[0] = code >> 8; lang[1] = code; @@ -845,10 +851,10 @@ static int mp_property_audio(m_option_t * prop, int action, void *arg, #ifdef CONFIG_DVDNAV else if (mpctx->stream->type == STREAMTYPE_DVDNAV) - mp_dvdnav_lang_from_aid(mpctx->stream, audio_id, lang); + mp_dvdnav_lang_from_aid(mpctx->stream, opts->audio_id, lang); #endif *(char **) arg = malloc(64); - snprintf(*(char **) arg, 64, "(%d) %s", audio_id, lang); + snprintf(*(char **) arg, 64, "(%d) %s", opts->audio_id, lang); } return M_PROPERTY_OK; @@ -861,21 +867,21 @@ static int mp_property_audio(m_option_t * prop, int action, void *arg, else tmp = -1; current_id = mpctx->demuxer->audio->id; - audio_id = demuxer_switch_audio(mpctx->demuxer, tmp); - if (audio_id == -2 - || (audio_id > -1 + opts->audio_id = demuxer_switch_audio(mpctx->demuxer, tmp); + if (opts->audio_id == -2 + || (opts->audio_id > -1 && mpctx->demuxer->audio->id != current_id && current_id != -2)) - uninit_player(INITIALIZED_AO | INITIALIZED_ACODEC); - if (audio_id > -1 && mpctx->demuxer->audio->id != current_id) { + uninit_player(mpctx, INITIALIZED_AO | INITIALIZED_ACODEC); + if (opts->audio_id > -1 && mpctx->demuxer->audio->id != current_id) { sh_audio_t *sh2; sh2 = mpctx->demuxer->a_streams[mpctx->demuxer->audio->id]; if (sh2) { sh2->ds = mpctx->demuxer->audio; mpctx->sh_audio = sh2; - reinit_audio_chain(); + reinit_audio_chain(mpctx); } } - mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AUDIO_TRACK=%d\n", audio_id); + mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AUDIO_TRACK=%d\n", opts->audio_id); return M_PROPERTY_OK; default: return M_PROPERTY_NOT_IMPLEMENTED; @@ -884,9 +890,10 @@ static int mp_property_audio(m_option_t * prop, int action, void *arg, } /// Selected video id (RW) -static int mp_property_video(m_option_t * prop, int action, void *arg, - MPContext * mpctx) +static int mp_property_video(m_option_t *prop, int action, void *arg, + MPContext *mpctx) { + struct MPOpts *opts = &mpctx->opts; int current_id = -1, tmp; switch (action) { @@ -895,7 +902,7 @@ static int mp_property_video(m_option_t * prop, int action, void *arg, return M_PROPERTY_UNAVAILABLE; if (!arg) return M_PROPERTY_ERROR; - *(int *) arg = video_id; + *(int *) arg = opts->video_id; return M_PROPERTY_OK; case M_PROPERTY_PRINT: if (!mpctx->sh_video) @@ -903,12 +910,12 @@ static int mp_property_video(m_option_t * prop, int action, void *arg, if (!arg) return M_PROPERTY_ERROR; - if (video_id < 0) + if (opts->video_id < 0) *(char **) arg = strdup(MSGTR_Disabled); else { char lang[40] = MSGTR_Unknown; *(char **) arg = malloc(64); - snprintf(*(char **) arg, 64, "(%d) %s", video_id, lang); + snprintf(*(char **) arg, 64, "(%d) %s", opts->video_id, lang); } return M_PROPERTY_OK; @@ -919,22 +926,22 @@ static int mp_property_video(m_option_t * prop, int action, void *arg, tmp = *((int *) arg); else tmp = -1; - video_id = demuxer_switch_video(mpctx->demuxer, tmp); - if (video_id == -2 - || (video_id > -1 && mpctx->demuxer->video->id != current_id + opts->video_id = demuxer_switch_video(mpctx->demuxer, tmp); + if (opts->video_id == -2 + || (opts->video_id > -1 && mpctx->demuxer->video->id != current_id && current_id != -2)) - uninit_player(INITIALIZED_VCODEC | - (fixed_vo && video_id != -2 ? 0 : INITIALIZED_VO)); - if (video_id > -1 && mpctx->demuxer->video->id != current_id) { + uninit_player(mpctx, INITIALIZED_VCODEC | + (mpctx->opts.fixed_vo && opts->video_id != -2 ? 0 : INITIALIZED_VO)); + if (opts->video_id > -1 && mpctx->demuxer->video->id != current_id) { sh_video_t *sh2; sh2 = mpctx->demuxer->v_streams[mpctx->demuxer->video->id]; if (sh2) { sh2->ds = mpctx->demuxer->video; mpctx->sh_video = sh2; - reinit_video_chain(); + reinit_video_chain(mpctx); } } - mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VIDEO_TRACK=%d\n", video_id); + mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_VIDEO_TRACK=%d\n", opts->video_id); return M_PROPERTY_OK; default: @@ -942,8 +949,8 @@ static int mp_property_video(m_option_t * prop, int action, void *arg, } } -static int mp_property_program(m_option_t * prop, int action, void *arg, - MPContext * mpctx) +static int mp_property_program(m_option_t *prop, int action, void *arg, + MPContext *mpctx) { demux_program_t prog; @@ -975,8 +982,8 @@ static int mp_property_program(m_option_t * prop, int action, void *arg, ///@{ /// Fullscreen state (RW) -static int mp_property_fullscreen(m_option_t * prop, int action, void *arg, - MPContext * mpctx) +static int mp_property_fullscreen(m_option_t *prop, int action, void *arg, + MPContext *mpctx) { if (!mpctx->video_out) @@ -996,16 +1003,16 @@ static int mp_property_fullscreen(m_option_t * prop, int action, void *arg, guiGetEvent(guiIEvent, (char *) MP_CMD_GUI_FULLSCREEN); else #endif - if (vo_config_count) - mpctx->video_out->control(VOCTRL_FULLSCREEN, 0); + if (mpctx->video_out->config_ok) + vo_control(mpctx->video_out, VOCTRL_FULLSCREEN, 0); return M_PROPERTY_OK; default: return m_property_flag(prop, action, arg, &vo_fs); } } -static int mp_property_deinterlace(m_option_t * prop, int action, - void *arg, MPContext * mpctx) +static int mp_property_deinterlace(m_option_t *prop, int action, + void *arg, MPContext *mpctx) { int deinterlace; vf_instance_t *vf; @@ -1035,12 +1042,12 @@ static int mp_property_deinterlace(m_option_t * prop, int action, } /// Panscan (RW) -static int mp_property_panscan(m_option_t * prop, int action, void *arg, - MPContext * mpctx) +static int mp_property_panscan(m_option_t *prop, int action, void *arg, + MPContext *mpctx) { if (!mpctx->video_out - || mpctx->video_out->control(VOCTRL_GET_PANSCAN, NULL) != VO_TRUE) + || vo_control(mpctx->video_out, VOCTRL_GET_PANSCAN, NULL) != VO_TRUE) return M_PROPERTY_UNAVAILABLE; switch (action) { @@ -1049,7 +1056,7 @@ static int mp_property_panscan(m_option_t * prop, int action, void *arg, return M_PROPERTY_ERROR; M_PROPERTY_CLAMP(prop, *(float *) arg); vo_panscan = *(float *) arg; - mpctx->video_out->control(VOCTRL_SET_PANSCAN, NULL); + vo_control(mpctx->video_out, VOCTRL_SET_PANSCAN, NULL); return M_PROPERTY_OK; case M_PROPERTY_STEP_UP: case M_PROPERTY_STEP_DOWN: @@ -1059,7 +1066,7 @@ static int mp_property_panscan(m_option_t * prop, int action, void *arg, vo_panscan = 1; else if (vo_panscan < 0) vo_panscan = 0; - mpctx->video_out->control(VOCTRL_SET_PANSCAN, NULL); + vo_control(mpctx->video_out, VOCTRL_SET_PANSCAN, NULL); return M_PROPERTY_OK; default: return m_property_float_range(prop, action, arg, &vo_panscan); @@ -1069,8 +1076,8 @@ static int mp_property_panscan(m_option_t * prop, int action, void *arg, /// Helper to set vo flags. /** \ingroup PropertyImplHelper */ -static int mp_property_vo_flag(m_option_t * prop, int action, void *arg, - int vo_ctrl, int *vo_var, MPContext * mpctx) +static int mp_property_vo_flag(m_option_t *prop, int action, void *arg, + int vo_ctrl, int *vo_var, MPContext *mpctx) { if (!mpctx->video_out) @@ -1085,8 +1092,8 @@ static int mp_property_vo_flag(m_option_t * prop, int action, void *arg, return M_PROPERTY_OK; case M_PROPERTY_STEP_UP: case M_PROPERTY_STEP_DOWN: - if (vo_config_count) - mpctx->video_out->control(vo_ctrl, 0); + if (mpctx->video_out->config_ok) + vo_control(mpctx->video_out, vo_ctrl, 0); return M_PROPERTY_OK; default: return m_property_flag(prop, action, arg, vo_var); @@ -1094,32 +1101,32 @@ static int mp_property_vo_flag(m_option_t * prop, int action, void *arg, } /// Window always on top (RW) -static int mp_property_ontop(m_option_t * prop, int action, void *arg, - MPContext * mpctx) +static int mp_property_ontop(m_option_t *prop, int action, void *arg, + MPContext *mpctx) { - return mp_property_vo_flag(prop, action, arg, VOCTRL_ONTOP, &vo_ontop, - mpctx); + return mp_property_vo_flag(prop, action, arg, VOCTRL_ONTOP, + &mpctx->opts.vo_ontop, mpctx); } /// Display in the root window (RW) -static int mp_property_rootwin(m_option_t * prop, int action, void *arg, - MPContext * mpctx) +static int mp_property_rootwin(m_option_t *prop, int action, void *arg, + MPContext *mpctx) { return mp_property_vo_flag(prop, action, arg, VOCTRL_ROOTWIN, &vo_rootwin, mpctx); } /// Show window borders (RW) -static int mp_property_border(m_option_t * prop, int action, void *arg, - MPContext * mpctx) +static int mp_property_border(m_option_t *prop, int action, void *arg, + MPContext *mpctx) { return mp_property_vo_flag(prop, action, arg, VOCTRL_BORDER, &vo_border, mpctx); } /// Framedropping state (RW) -static int mp_property_framedropping(m_option_t * prop, int action, - void *arg, MPContext * mpctx) +static int mp_property_framedropping(m_option_t *prop, int action, + void *arg, MPContext *mpctx) { if (!mpctx->sh_video) @@ -1139,10 +1146,11 @@ static int mp_property_framedropping(m_option_t * prop, int action, } /// Color settings, try to use vf/vo then fall back on TV. (RW) -static int mp_property_gamma(m_option_t * prop, int action, void *arg, - MPContext * mpctx) +static int mp_property_gamma(m_option_t *prop, int action, void *arg, + MPContext *mpctx) { - int *gamma = prop->priv, r, val; + int *gamma = (int *)((char *)&mpctx->opts + (int)prop->priv); + int r, val; if (!mpctx->sh_video) return M_PROPERTY_UNAVAILABLE; @@ -1196,15 +1204,15 @@ static int mp_property_gamma(m_option_t * prop, int action, void *arg, } /// VSync (RW) -static int mp_property_vsync(m_option_t * prop, int action, void *arg, - MPContext * mpctx) +static int mp_property_vsync(m_option_t *prop, int action, void *arg, + MPContext *mpctx) { return m_property_flag(prop, action, arg, &vo_vsync); } /// Video codec tag (RO) -static int mp_property_video_format(m_option_t * prop, int action, - void *arg, MPContext * mpctx) +static int mp_property_video_format(m_option_t *prop, int action, + void *arg, MPContext *mpctx) { char* meta; if (!mpctx->sh_video) @@ -1238,8 +1246,8 @@ static int mp_property_video_format(m_option_t * prop, int action, } /// Video codec name (RO) -static int mp_property_video_codec(m_option_t * prop, int action, - void *arg, MPContext * mpctx) +static int mp_property_video_codec(m_option_t *prop, int action, + void *arg, MPContext *mpctx) { if (!mpctx->sh_video || !mpctx->sh_video->codec) return M_PROPERTY_UNAVAILABLE; @@ -1248,8 +1256,8 @@ static int mp_property_video_codec(m_option_t * prop, int action, /// Video bitrate (RO) -static int mp_property_video_bitrate(m_option_t * prop, int action, - void *arg, MPContext * mpctx) +static int mp_property_video_bitrate(m_option_t *prop, int action, + void *arg, MPContext *mpctx) { if (!mpctx->sh_video) return M_PROPERTY_UNAVAILABLE; @@ -1257,8 +1265,8 @@ static int mp_property_video_bitrate(m_option_t * prop, int action, } /// Video display width (RO) -static int mp_property_width(m_option_t * prop, int action, void *arg, - MPContext * mpctx) +static int mp_property_width(m_option_t *prop, int action, void *arg, + MPContext *mpctx) { if (!mpctx->sh_video) return M_PROPERTY_UNAVAILABLE; @@ -1266,8 +1274,8 @@ static int mp_property_width(m_option_t * prop, int action, void *arg, } /// Video display height (RO) -static int mp_property_height(m_option_t * prop, int action, void *arg, - MPContext * mpctx) +static int mp_property_height(m_option_t *prop, int action, void *arg, + MPContext *mpctx) { if (!mpctx->sh_video) return M_PROPERTY_UNAVAILABLE; @@ -1275,8 +1283,8 @@ static int mp_property_height(m_option_t * prop, int action, void *arg, } /// Video fps (RO) -static int mp_property_fps(m_option_t * prop, int action, void *arg, - MPContext * mpctx) +static int mp_property_fps(m_option_t *prop, int action, void *arg, + MPContext *mpctx) { if (!mpctx->sh_video) return M_PROPERTY_UNAVAILABLE; @@ -1284,8 +1292,8 @@ static int mp_property_fps(m_option_t * prop, int action, void *arg, } /// Video aspect (RO) -static int mp_property_aspect(m_option_t * prop, int action, void *arg, - MPContext * mpctx) +static int mp_property_aspect(m_option_t *prop, int action, void *arg, + MPContext *mpctx) { if (!mpctx->sh_video) return M_PROPERTY_UNAVAILABLE; @@ -1299,8 +1307,8 @@ static int mp_property_aspect(m_option_t * prop, int action, void *arg, ///@{ /// Text subtitle position (RW) -static int mp_property_sub_pos(m_option_t * prop, int action, void *arg, - MPContext * mpctx) +static int mp_property_sub_pos(m_option_t *prop, int action, void *arg, + MPContext *mpctx) { if (!mpctx->sh_video) return M_PROPERTY_UNAVAILABLE; @@ -1318,9 +1326,10 @@ static int mp_property_sub_pos(m_option_t * prop, int action, void *arg, } /// Selected subtitles (RW) -static int mp_property_sub(m_option_t * prop, int action, void *arg, - MPContext * mpctx) +static int mp_property_sub(m_option_t *prop, int action, void *arg, + MPContext *mpctx) { + struct MPOpts *opts = &mpctx->opts; demux_stream_t *const d_sub = mpctx->d_sub; const int global_sub_size = mpctx->global_sub_size; int source = -1, reset_spu = 0; @@ -1361,10 +1370,10 @@ static int mp_property_sub(m_option_t * prop, int action, void *arg, } #ifdef CONFIG_DVDNAV if (mpctx->stream->type == STREAMTYPE_DVDNAV) { - if (vo_spudec && dvdsub_id >= 0) { + if (vo_spudec && opts->sub_id >= 0) { unsigned char lang[3]; - if (mp_dvdnav_lang_from_sid(mpctx->stream, dvdsub_id, lang)) { - snprintf(*(char **) arg, 63, "(%d) %s", dvdsub_id, lang); + if (mp_dvdnav_lang_from_sid(mpctx->stream, opts->sub_id, lang)) { + snprintf(*(char **) arg, 63, "(%d) %s", opts->sub_id, lang); return M_PROPERTY_OK; } } @@ -1375,10 +1384,10 @@ static int mp_property_sub(m_option_t * prop, int action, void *arg, || mpctx->demuxer->type == DEMUXER_TYPE_LAVF || mpctx->demuxer->type == DEMUXER_TYPE_LAVF_PREFERRED || mpctx->demuxer->type == DEMUXER_TYPE_OGG) - && d_sub && d_sub->sh && dvdsub_id >= 0) { + && d_sub && d_sub->sh && opts->sub_id >= 0) { const char* lang = ((sh_sub_t*)d_sub->sh)->lang; if (!lang) lang = MSGTR_Unknown; - snprintf(*(char **) arg, 63, "(%d) %s", dvdsub_id, lang); + snprintf(*(char **) arg, 63, "(%d) %s", opts->sub_id, lang); return M_PROPERTY_OK; } @@ -1391,18 +1400,18 @@ static int mp_property_sub(m_option_t * prop, int action, void *arg, } #ifdef CONFIG_DVDREAD if (vo_spudec && mpctx->stream->type == STREAMTYPE_DVD - && dvdsub_id >= 0) { + && opts->sub_id >= 0) { char lang[3]; - int code = dvd_lang_from_sid(mpctx->stream, dvdsub_id); + int code = dvd_lang_from_sid(mpctx->stream, opts->sub_id); lang[0] = code >> 8; lang[1] = code; lang[2] = 0; - snprintf(*(char **) arg, 63, "(%d) %s", dvdsub_id, lang); + snprintf(*(char **) arg, 63, "(%d) %s", opts->sub_id, lang); return M_PROPERTY_OK; } #endif - if (dvdsub_id >= 0) { - snprintf(*(char **) arg, 63, "(%d) %s", dvdsub_id, MSGTR_Unknown); + if (opts->sub_id >= 0) { + snprintf(*(char **) arg, 63, "(%d) %s", opts->sub_id, MSGTR_Unknown); return M_PROPERTY_OK; } snprintf(*(char **) arg, 63, MSGTR_Disabled); @@ -1446,7 +1455,7 @@ static int mp_property_sub(m_option_t * prop, int action, void *arg, subdata = NULL; vobsub_id = -1; - dvdsub_id = -1; + opts->sub_id = -1; if (d_sub) { if (d_sub->id > -2) reset_spu = 1; @@ -1471,17 +1480,17 @@ static int mp_property_sub(m_option_t * prop, int action, void *arg, vo_osd_changed(OSDTYPE_SUBTITLE); } } else if (source == SUB_SOURCE_DEMUX) { - dvdsub_id = + opts->sub_id = mpctx->global_sub_pos - mpctx->global_sub_indices[SUB_SOURCE_DEMUX]; - if (d_sub && dvdsub_id < MAX_S_STREAMS) { + if (d_sub && opts->sub_id < MAX_S_STREAMS) { int i = 0; // default: assume 1:1 mapping of sid and stream id - d_sub->id = dvdsub_id; + d_sub->id = opts->sub_id; d_sub->sh = mpctx->demuxer->s_streams[d_sub->id]; ds_free_packs(d_sub); for (i = 0; i < MAX_S_STREAMS; i++) { sh_sub_t *sh = mpctx->demuxer->s_streams[i]; - if (sh && sh->sid == dvdsub_id) { + if (sh && sh->sid == opts->sub_id) { d_sub->id = i; d_sub->sh = sh; break; @@ -1490,7 +1499,7 @@ static int mp_property_sub(m_option_t * prop, int action, void *arg, if (d_sub->sh && d_sub->id >= |