summaryrefslogtreecommitdiffstats
path: root/command.c
diff options
context:
space:
mode:
Diffstat (limited to 'command.c')
-rw-r--r--command.c634
1 files changed, 327 insertions, 307 deletions
diff --git a/command.c b/command.c
index 0a67038a70..caf1ca5037 100644
--- a/command.c
+++ b/command.c
@@ -2,6 +2,7 @@
#include <inttypes.h>
#include <unistd.h>
#include <string.h>
+#include <stdbool.h>
#include "config.h"
#include "command.h"
@@ -18,6 +19,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 +68,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 +114,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 +129,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 +145,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 +169,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 +251,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 +271,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 +285,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 +299,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 +314,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 +327,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 +352,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 +367,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 +430,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 +527,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;
@@ -554,10 +560,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);
+ }
}
@@ -568,8 +595,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 +651,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 +689,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 +713,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 +722,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 +731,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 +740,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 +756,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 +782,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 +833,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 +845,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 +853,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 +862,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 +873,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 +889,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 +912,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 +924,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 +932,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 +948,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 +971,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 +1004,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 +1025,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 +1064,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 +1078,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 +1088,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 +1098,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 +1114,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 +1123,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 +1168,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 +1226,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 +1268,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 +1278,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 +1287,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 +1296,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 +1305,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 +1314,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 +1329,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 +1348,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 +1392,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 +1406,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 +1422,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 +1477,7 @@ static int mp_property_sub(m_option_t * prop, int action, void *arg,