summaryrefslogtreecommitdiffstats
path: root/command.c
diff options
context:
space:
mode:
Diffstat (limited to 'command.c')
-rw-r--r--command.c1084
1 files changed, 610 insertions, 474 deletions
diff --git a/command.c b/command.c
index cd9d2abf5d..54b1332d16 100644
--- a/command.c
+++ b/command.c
@@ -20,8 +20,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"
@@ -36,6 +38,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"
@@ -47,6 +50,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"
@@ -57,10 +61,8 @@
#include "stream/stream_dvd.h"
#endif
#include "stream/stream_dvdnav.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"
@@ -70,35 +72,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);
+ "\r\nrescaled coordinates: %.3f, %.3f, screen (%d x %d), vodisplay: (%d, %d), fullscreen: %d\r\n",
+ *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;
@@ -113,7 +118,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);
}
@@ -128,7 +133,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;
@@ -144,14 +149,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]);
@@ -168,77 +173,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;
@@ -247,8 +255,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;
@@ -267,8 +275,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;
@@ -281,8 +289,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;
@@ -295,8 +303,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;
@@ -310,8 +318,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;
@@ -323,8 +331,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)
@@ -348,14 +356,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;
@@ -363,34 +371,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;
@@ -403,7 +408,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;
@@ -428,26 +433,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_tmsg(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_tmsg(OSD_MSG_TEXT, 1, opts->osd_duration,
+ "Chapter: (%d) %s", 0, mp_gtext("unknown"));
if (chapter_name)
- free(chapter_name);
+ talloc_free(chapter_name);
return M_PROPERTY_OK;
}
@@ -466,6 +472,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;
@@ -517,19 +524,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_tmsg(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;
@@ -558,10 +565,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);
+ }
}
@@ -572,8 +600,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)
@@ -628,8 +656,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)
@@ -656,7 +684,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(mp_gtext("enabled (EDL)"));
return M_PROPERTY_OK;
}
default:
@@ -666,8 +694,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;
@@ -690,8 +718,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;
@@ -699,8 +727,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;
@@ -708,8 +736,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;
@@ -717,8 +745,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;
@@ -733,8 +761,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;
@@ -759,8 +787,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;
@@ -810,9 +838,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, tmp;
if (!mpctx->demuxer || !mpctx->demuxer->audio)
return M_PROPERTY_UNAVAILABLE;
@@ -829,9 +858,10 @@ static int mp_property_audio(m_option_t * prop, int action, void *arg,
return M_PROPERTY_ERROR;
if (current_id < 0)
- *(char **) arg = strdup(MSGTR_Disabled);
+ *(char **) arg = strdup(mp_gtext("disabled"));
else {
- char lang[40] = MSGTR_Unknown;
+ char lang[40];
+ strncpy(lang, mp_gtext("unknown"), sizeof(lang));
sh_audio_t* sh = mpctx->sh_audio;
if (sh && sh->lang)
av_strlcpy(lang, sh->lang, 40);
@@ -861,21 +891,21 @@ static int mp_property_audio(m_option_t * prop, int action, void *arg,
tmp = *((int *) arg);
else
tmp = -1;
- 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 +914,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, tmp;
if (!mpctx->demuxer || !mpctx->demuxer->video)
return M_PROPERTY_UNAVAILABLE;
@@ -903,9 +934,10 @@ static int mp_property_video(m_option_t * prop, int action, void *arg,
return M_PROPERTY_ERROR;
if (current_id < 0)
- *(char **) arg = strdup(MSGTR_Disabled);
+ *(char **) arg = strdup(mp_gtext("disabled"));
else {
- char lang[40] = MSGTR_Unknown;
+ char lang[40];
+ strncpy(lang, mp_gtext("unknown"), sizeof(lang));
*(char **) arg = malloc(64);
snprintf(*(char **) arg, 64, "(%d) %s", current_id, lang);
}
@@ -917,22 +949,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:
@@ -940,8 +972,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;
@@ -977,8 +1009,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)
@@ -993,21 +1025,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;
@@ -1031,20 +1059,62 @@ static int mp_property_deinterlace(m_option_t * prop, int action,
vf->control(vf, VFCTRL_GET_DEINTERLACE, &deinterlace);
deinterlace = !deinterlace;
vf->control(vf, VFCTRL_SET_DEINTERLACE, &deinterlace);
- set_osd_msg(OSD_MSG_SPEED, 1, osd_duration, MSGTR_OSDDeinterlace,
- deinterlace ? MSGTR_Enabled : MSGTR_Disabled);
+ return M_PROPERTY_OK;
+ }
+ int value = 0;
+ vf->control(vf, VFCTRL_GET_DEINTERLACE, &value);
+ return m_property_flag_ro(prop, action, arg, value);
+}
+
+static int mp_property_yuv_colorspace(m_option_t *prop, int action,
+ void *arg, MPContext *mpctx)
+{
+ if (!mpctx->sh_video || !mpctx->sh_video->vfilter)
+ return M_PROPERTY_UNAVAILABLE;
+
+ struct vf_instance *vf = mpctx->sh_video->vfilter;
+ int colorspace;
+ switch (action) {
+ case M_PROPERTY_GET:
+ if (!arg)
+ return M_PROPERTY_ERROR;
+ if (vf->control(vf, VFCTRL_GET_YUV_COLORSPACE, arg) != true)
+ return M_PROPERTY_UNAVAILABLE;
+ return M_PROPERTY_OK;
+ case M_PROPERTY_PRINT:
+ if (!arg)
+ return M_PROPERTY_ERROR;
+ if (vf->control(vf, VFCTRL_GET_YUV_COLORSPACE, &colorspace) != true)
+ return M_PROPERTY_UNAVAILABLE;
+ char * const names[] = {"BT.601 (SD)", "BT.709 (HD)", "SMPTE-240M"};
+ if (colorspace < 0 || colorspace >= sizeof(names) / sizeof(names[0]))
+ *(char **)arg = strdup("Unknown");
+ else
+ *(char**)arg = strdup(names[colorspace]);
+ return M_PROPERTY_OK;
+ case M_PROPERTY_SET:
+ if (!arg)
+ return M_PROPERTY_ERROR;
+ M_PROPERTY_CLAMP(prop, *(int *) arg);
+ vf->control(vf, VFCTRL_SET_YUV_COLORSPACE, arg);
+ return M_PROPERTY_OK;
+ case M_PROPERTY_STEP_UP:;
+ if (vf->control(vf, VFCTRL_GET_YUV_COLORSPACE, &colorspace) != true)
+ return M_PROPERTY_UNAVAILABLE;
+ colorspace += 1;
+ vf->control(vf, VFCTRL_SET_YUV_COLORSPACE, &colorspace);
return M_PROPERTY_OK;
}
return M_PROPERTY_NOT_IMPLEMENTED;
}
/// 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) {
@@ -1053,7 +1123,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:
@@ -1063,7 +1133,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);
@@ -1073,8 +1143,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)
@@ -1089,8 +1159,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);
@@ -1098,32 +1168,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)
@@ -1133,9 +1203,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 ? mp_gtext("enabled") :
+ (frame_dropping == 2 ? mp_gtext("hard") :
+ mp_gtext("disabled")));
return M_PROPERTY_OK;
default:
return m_property_choice(prop, action, arg, &frame_dropping);
@@ -1143,10 +1213,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;
@@ -1200,15 +1271,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)
@@ -1242,8 +1313,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;
@@ -1252,8 +1323,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;
@@ -1261,8 +1332,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 *ar