diff options
Diffstat (limited to 'command.c')
-rw-r--r-- | command.c | 865 |
1 files changed, 434 insertions, 431 deletions
@@ -2,8 +2,10 @@ #include <inttypes.h> #include <unistd.h> #include <string.h> +#include <stdbool.h> #include "config.h" +#include "talloc.h" #include "command.h" #include "input/input.h" #include "stream/stream.h" @@ -18,6 +20,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" @@ -28,6 +31,7 @@ #include "vobsub.h" #include "spudec.h" #include "get_path.h" +#include "ass_mp.h" #include "stream/tv.h" #include "stream/stream_radio.h" #include "stream/pvr.h" @@ -38,11 +42,8 @@ #include "stream/stream_dvd.h" #endif #include "stream/stream_dvdnav.h" -#include "libass/ass.h" -#include "libass/ass_mp.h" #include "m_struct.h" #include "libmenu/menu.h" -#include "gui/interface.h" #include "mp_core.h" #include "mp_fifo.h" @@ -52,35 +53,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; @@ -95,7 +99,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); } @@ -110,7 +114,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; @@ -126,14 +130,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]); @@ -150,77 +154,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); + return m_property_choice(prop, action, arg, &mpctx->opts.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; @@ -229,8 +236,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; @@ -249,8 +256,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; @@ -263,8 +270,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; @@ -277,8 +284,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; @@ -292,8 +299,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; @@ -305,8 +312,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) @@ -330,14 +337,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; @@ -345,34 +352,31 @@ 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) static int mp_property_chapter(m_option_t *prop, int action, void *arg, MPContext *mpctx) { + struct MPOpts *opts = &mpctx->opts; int chapter = -1; - float next_pts = 0; - int chapter_num; int step_all; char *chapter_name = NULL; if (mpctx->demuxer) - chapter = demuxer_get_current_chapter(mpctx->demuxer); + chapter = get_current_chapter(mpctx); if (chapter < 0) return M_PROPERTY_UNAVAILABLE; @@ -385,7 +389,7 @@ static int mp_property_chapter(m_option_t *prop, int action, void *arg, case M_PROPERTY_PRINT: { if (!arg) return M_PROPERTY_ERROR; - chapter_name = demuxer_chapter_display_name(mpctx->demuxer, chapter); + chapter_name = chapter_display_name(mpctx, chapter); if (!chapter_name) return M_PROPERTY_UNAVAILABLE; *(char **) arg = chapter_name; @@ -410,26 +414,27 @@ 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; - chapter = demuxer_seek_chapter(mpctx->demuxer, chapter, 1, - &next_pts, &chapter_num, &chapter_name); + + double next_pts = 0; + chapter = seek_chapter(mpctx, chapter, &next_pts, &chapter_name); + mpctx->rel_seek_secs = 0; + mpctx->abs_seek_pos = 0; 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); + set_osd_msg(OSD_MSG_TEXT, 1, opts->osd_duration, + _("Chapter: (%d) %s"), 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); + set_osd_msg(OSD_MSG_TEXT, 1, opts->osd_duration, + _("Chapter: (%d) %s"), 0, _("unknown")); if (chapter_name) - free(chapter_name); + talloc_free(chapter_name); return M_PROPERTY_OK; } @@ -448,6 +453,7 @@ static int mp_property_chapters(m_option_t *prop, int action, void *arg, static int mp_property_angle(m_option_t *prop, int action, void *arg, MPContext *mpctx) { + struct MPOpts *opts = &mpctx->opts; int angle = -1; int angles; char *angle_name = NULL; @@ -499,19 +505,19 @@ static int mp_property_angle(m_option_t *prop, int action, void *arg, return M_PROPERTY_NOT_IMPLEMENTED; } angle = demuxer_set_angle(mpctx->demuxer, angle); - set_osd_msg(OSD_MSG_TEXT, 1, osd_duration, - MSGTR_OSDAngle, angle, angles); + set_osd_msg(OSD_MSG_TEXT, 1, opts->osd_duration, + _("Angle: %d/%d"), angle, angles); if (angle_name) free(angle_name); return M_PROPERTY_OK; } /// 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; @@ -540,10 +546,31 @@ static int mp_property_metadata(m_option_t * prop, int action, void *arg, return M_PROPERTY_NOT_IMPLEMENTED; } -static int mp_property_pause(m_option_t * prop, int action, void *arg, - MPContext * mpctx) +static int mp_property_pause(m_option_t *prop, int action, void *arg, + void *ctx) { - return m_property_flag_ro(prop, action, arg, mpctx->osd_function == OSD_PAUSE); + MPContext *mpctx = ctx; + + switch (action) { + case M_PROPERTY_SET: + if (!arg) + return M_PROPERTY_ERROR; + if (mpctx->paused == (bool)*(int *) arg) + return M_PROPERTY_OK; + case M_PROPERTY_STEP_UP: + case M_PROPERTY_STEP_DOWN: + if (mpctx->paused) { + unpause_player(mpctx); + mpctx->osd_function = OSD_PLAY; + } + else { + pause_player(mpctx); + mpctx->osd_function = OSD_PAUSE; + } + return M_PROPERTY_OK; + default: + return m_property_flag(prop, action, arg, &mpctx->paused); + } } @@ -554,8 +581,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) @@ -610,8 +637,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) @@ -638,7 +665,7 @@ static int mp_property_mute(m_option_t * prop, int action, void *arg, if (!arg) return M_PROPERTY_ERROR; if (mpctx->edl_muted) { - *(char **) arg = strdup(MSGTR_EnabledEdl); + *(char **) arg = strdup(_("enabled (EDL)")); return M_PROPERTY_OK; } default: @@ -648,8 +675,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; @@ -672,8 +699,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; @@ -681,8 +708,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; @@ -690,8 +717,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; @@ -699,8 +726,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; @@ -715,8 +742,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; @@ -741,8 +768,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; @@ -792,9 +819,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) { @@ -803,7 +831,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) @@ -811,16 +839,16 @@ static int mp_property_audio(m_option_t * prop, int action, void *arg, if (!arg) return M_PROPERTY_ERROR; - if (audio_id < 0) - *(char **) arg = strdup(MSGTR_Disabled); + if (opts->audio_id < 0) + *(char **) arg = strdup(_("disabled")); else { - char lang[40] = MSGTR_Unknown; + char lang[40] = _("unknown"); sh_audio_t* sh = mpctx->sh_audio; if (sh && sh->lang) 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; @@ -831,10 +859,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; @@ -847,21 +875,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; @@ -870,9 +898,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) { @@ -881,7 +910,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) @@ -889,12 +918,12 @@ static int mp_property_video(m_option_t * prop, int action, void *arg, if (!arg) return M_PROPERTY_ERROR; - if (video_id < 0) - *(char **) arg = strdup(MSGTR_Disabled); + if (opts->video_id < 0) + *(char **) arg = strdup(_("disabled")); else { - char lang[40] = MSGTR_Unknown; + char lang[40] = _("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; @@ -905,22 +934,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: @@ -928,8 +957,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; @@ -961,8 +990,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) @@ -977,21 +1006,17 @@ static int mp_property_fullscreen(m_option_t * prop, int action, void *arg, return M_PROPERTY_OK; case M_PROPERTY_STEP_UP: case M_PROPERTY_STEP_DOWN: -#ifdef CONFIG_GUI - if (use_gui) - 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); + mpctx->opts.fullscreen = vo_fs; 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; @@ -1021,12 +1046,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) { @@ -1035,7 +1060,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: @@ -1045,7 +1070,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); @@ -1055,8 +1080,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) @@ -1071,8 +1096,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); @@ -1080,32 +1105,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) @@ -1115,9 +1140,9 @@ static int mp_property_framedropping(m_option_t * prop, int action, case M_PROPERTY_PRINT: if (!arg) return M_PROPERTY_ERROR; - *(char **) arg = strdup(frame_dropping == 1 ? MSGTR_Enabled : - (frame_dropping == 2 ? MSGTR_HardFrameDrop : - MSGTR_Disabled)); + *(char **) arg = strdup(frame_dropping == 1 ? _("enabled") : + (frame_dropping == 2 ? _("hard") : + _("disabled"))); return M_PROPERTY_OK; default: return m_property_choice(prop, action, arg, &frame_dropping); @@ -1125,10 +1150,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; @@ -1182,15 +1208,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) @@ -1224,8 +1250,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; @@ -1234,8 +1260,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; @@ -1243,8 +1269,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; @@ -1252,8 +1278,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 *ar |