#include <vlc_vout.h>
#include "media_player_internal.h"
-#include <vlc_osd.h>
#include <assert.h>
/*
{
input_thread_t *p_input = libvlc_get_input_thread( p_mi );
if( !p_input )
+ {
+ *n = 0;
return NULL;
+ }
vout_thread_t **pp_vouts;
if (input_Control( p_input, INPUT_GET_VOUTS, &pp_vouts, n))
void libvlc_toggle_fullscreen( libvlc_media_player_t *p_mi )
{
- var_ToggleBool (p_mi, "fullscreen");
- bool b_fullscreen = var_GetBool (p_mi, "fullscreen");
+ bool b_fullscreen = var_ToggleBool (p_mi, "fullscreen");
/* Apply to current video outputs (if any) */
size_t n;
int libvlc_video_get_size( libvlc_media_player_t *p_mi, unsigned num,
unsigned *restrict px, unsigned *restrict py )
{
+#if 0
vout_thread_t *p_vout = GetVout (p_mi, num);
if (p_vout == NULL)
return -1;
*py = p_vout->i_window_width;
vlc_object_release (p_vout);
return 0;
+#else
+ return -1;
+#endif
}
int libvlc_video_get_height( libvlc_media_player_t *p_mi )
return width;
}
+int libvlc_video_get_cursor( libvlc_media_player_t *mp, unsigned num,
+ int *restrict px, int *restrict py )
+{
+ vout_thread_t *p_vout = GetVout (mp, num);
+ if (p_vout == NULL)
+ return -1;
+
+ var_GetCoords (p_vout, "mouse-moved", px, py);
+ vlc_object_release (p_vout);
+ return 0;
+}
+
unsigned libvlc_media_player_has_vout( libvlc_media_player_t *p_mi )
{
size_t n;
{
if (f_scale != 0.)
var_SetFloat (p_mp, "scale", f_scale);
- var_SetBool (p_mp, "autoscale", f_scale != 0.);
+ var_SetBool (p_mp, "autoscale", f_scale == 0.);
/* Apply to current video outputs (if any) */
size_t n;
if (f_scale != 0.)
var_SetFloat (p_vout, "scale", f_scale);
- var_SetBool (p_mp, "autoscale", f_scale != 0.);
+ var_SetBool (p_vout, "autoscale", f_scale == 0.);
vlc_object_release (p_vout);
}
free (pp_vouts);
if( i_ret < 0 )
{
vlc_object_release( p_input_thread );
- libvlc_printerr( "Subtitle informations not found" );
+ libvlc_printerr( "Subtitle information not found" );
return -1;
}
for (size_t i = 0; i < n; i++)
{
vout_thread_t *p_vout = pp_vouts[i];
-
+ vlc_value_t val;
+
+ /* Make sure the geometry is in the choice list */
+ /* Earlier choices are removed to not grow a long list over time. */
+ /* FIXME: not atomic - lock? */
+ val.psz_string = (char *)psz_geometry;
+ var_Change (p_vout, "crop", VLC_VAR_CLEARCHOICES, NULL, NULL);
+ var_Change (p_vout, "crop", VLC_VAR_ADDCHOICE, &val, &val);
var_SetString (p_vout, "crop", psz_geometry);
vlc_object_release (p_vout);
}
int libvlc_video_get_teletext( libvlc_media_player_t *p_mi )
{
- input_thread_t *p_input_thread;
- vlc_object_t *p_zvbi = NULL;
- int i_ret = -1, telx;
-
- p_input_thread = libvlc_get_input_thread( p_mi );
- if( !p_input_thread ) return i_ret;
-
- if( var_CountChoices( p_input_thread, "teletext-es" ) <= 0 )
- {
- vlc_object_release( p_input_thread );
- return i_ret;
- }
-
- telx = var_GetInteger( p_input_thread, "teletext-es" );
- if( input_GetEsObjects( p_input_thread, telx, &p_zvbi, NULL, NULL )
- != VLC_SUCCESS )
- {
- i_ret = var_GetInteger( p_zvbi, "vbi-page" );
- vlc_object_release( p_zvbi );
- }
- vlc_object_release( p_input_thread );
- return i_ret;
+ return var_GetInteger (p_mi, "vbi-page");
}
-void libvlc_video_set_teletext( libvlc_media_player_t *p_mi, int i_page,
- libvlc_exception_t *p_e )
+void libvlc_video_set_teletext( libvlc_media_player_t *p_mi, int i_page )
{
input_thread_t *p_input_thread;
vlc_object_t *p_zvbi = NULL;
int telx;
+ var_SetInteger (p_mi, "vbi-page", i_page);
+
p_input_thread = libvlc_get_input_thread( p_mi );
if( !p_input_thread ) return;
telx = var_GetInteger( p_input_thread, "teletext-es" );
if( input_GetEsObjects( p_input_thread, telx, &p_zvbi, NULL, NULL )
- != VLC_SUCCESS )
+ == VLC_SUCCESS )
{
- int i_ret = var_SetInteger( p_zvbi, "vbi-page", i_page );
+ var_SetInteger( p_zvbi, "vbi-page", i_page );
vlc_object_release( p_zvbi );
- if( i_ret )
- {
- libvlc_exception_raise( p_e );
- libvlc_printerr( "Unexpected error while setting teletext page" );
- }
}
vlc_object_release( p_input_thread );
}
static vlc_object_t *get_object( libvlc_media_player_t * p_mi,
- const char *name, libvlc_exception_t *p_e )
+ const char *name )
{
- vlc_object_t *object = NULL;
- vout_thread_t *vout = GetVout( p_mi, 0 );
- libvlc_exception_clear( p_e );
+ vlc_object_t *object;
+ vout_thread_t *vout = GetVout( p_mi, 0 );
+
if( vout )
{
object = vlc_object_find_name( vout, name, FIND_CHILD );
vlc_object_release(vout);
}
+ else
+ object = NULL;
+
if( !object )
- {
- libvlc_exception_raise( p_e );
libvlc_printerr( "%s not enabled", name );
- }
return object;
}
typedef const struct {
- const char name[20]; /* probably will become a const char * sometime */
+ const char name[20];
unsigned type;
} opt_t;
static void
-set_int( libvlc_media_player_t *p_mi, const char *name,
- const opt_t *opt, int value, libvlc_exception_t *p_e )
+set_int( libvlc_media_player_t *p_mi, const char *restrict name,
+ const opt_t *restrict opt, int value )
{
if( !opt ) return;
return;
}
- vlc_object_t *object = get_object( p_mi, name, p_e );
- if( !object ) return;
+ if( opt->type != VLC_VAR_INTEGER )
+ {
+ libvlc_printerr( "Invalid argument to %s in %s", name, "set int" );
+ return;
+ }
- switch( opt->type )
+ var_SetInteger(p_mi, opt->name, value);
+ vlc_object_t *object = get_object( p_mi, name );
+ if( object )
{
- case VLC_VAR_INTEGER:
var_SetInteger(object, opt->name, value);
- break;
- default:
- libvlc_exception_raise( p_e );
- libvlc_printerr( "Invalid argument for %s in %s", name, "set int" );
- break;
+ vlc_object_release( object );
}
- vlc_object_release( object );
}
static int
-get_int( libvlc_media_player_t *p_mi, const char *name,
- const opt_t *opt, libvlc_exception_t *p_e )
+get_int( libvlc_media_player_t *p_mi, const char *restrict name,
+ const opt_t *restrict opt )
{
if( !opt ) return 0;
- vlc_object_t *object = get_object( p_mi, name, p_e );
- if( !object ) return 0;
-
- int ret;
switch( opt->type )
{
- case 0: /* the enabler */
- ret = NULL != object;
- break;
+ case 0: /* the enabler */
+ {
+ vlc_object_t *object = get_object( p_mi, name );
+ vlc_object_release( object );
+ return object != NULL;
+ }
case VLC_VAR_INTEGER:
- ret = var_GetInteger(object, opt->name);
- break;
+ return var_GetInteger(p_mi, opt->name);
default:
- libvlc_exception_raise( p_e );
- libvlc_printerr( "Invalid argument for %s in %s", name, "get int" );
- ret = 0;
- break;
+ libvlc_printerr( "Invalid argument to %s in %s", name, "get int" );
+ return 0;
}
- vlc_object_release( object );
- return ret;
}
static void
-set_string( libvlc_media_player_t *p_mi, const char *name, const opt_t *opt,
- const char *psz_value, libvlc_exception_t *p_e )
+set_float( libvlc_media_player_t *p_mi, const char *restrict name,
+ const opt_t *restrict opt, float value )
{
if( !opt ) return;
- vlc_object_t *object = get_object( p_mi, name, p_e );
- if( !object ) return;
- switch( opt->type )
+ if( opt->type != VLC_VAR_FLOAT )
{
- case VLC_VAR_STRING:
- var_SetString( object, opt->name, psz_value );
- break;
- default:
- libvlc_exception_raise( p_e );
- libvlc_printerr( "Invalid argument for %s in %s", name, "set string" );
- break;
+ libvlc_printerr( "Invalid argument to %s in %s", name, "set float" );
+ return;
+ }
+
+ var_SetFloat( p_mi, opt->name, value );
+
+ vlc_object_t *object = get_object( p_mi, name );
+ if( object )
+ {
+ var_SetFloat(object, opt->name, value );
+ vlc_object_release( object );
+ }
+}
+
+
+static float
+get_float( libvlc_media_player_t *p_mi, const char *restrict name,
+ const opt_t *restrict opt )
+{
+ if( !opt ) return 0.0;
+
+
+ if( opt->type != VLC_VAR_FLOAT )
+ {
+ libvlc_printerr( "Invalid argument to %s in %s", name, "get float" );
+ return 0.0;
+ }
+
+ return var_GetFloat( p_mi, opt->name );
+}
+
+
+static void
+set_string( libvlc_media_player_t *p_mi, const char *restrict name,
+ const opt_t *restrict opt, const char *restrict psz_value )
+{
+ if( !opt ) return;
+
+ if( opt->type != VLC_VAR_STRING )
+ {
+ libvlc_printerr( "Invalid argument to %s in %s", name, "set string" );
+ return;
+ }
+
+ var_SetString( p_mi, opt->name, psz_value );
+
+ vlc_object_t *object = get_object( p_mi, name );
+ if( object )
+ {
+ var_SetString(object, opt->name, psz_value );
+ vlc_object_release( object );
}
- vlc_object_release( object );
}
static char *
-get_string( libvlc_media_player_t *p_mi, const char *name,
- const opt_t *opt, libvlc_exception_t *p_e )
+get_string( libvlc_media_player_t *p_mi, const char *restrict name,
+ const opt_t *restrict opt )
{
if( !opt ) return NULL;
- vlc_object_t *object = get_object( p_mi, name, p_e );
- if( !object ) return NULL;
- char *ret;
- switch( opt->type )
+ if( opt->type != VLC_VAR_STRING )
{
- case VLC_VAR_STRING:
- ret = var_GetString( object, opt->name );
- break;
- default:
- libvlc_exception_raise( p_e );
- libvlc_printerr( "Invalid argument for %s in %s", name, "get string" );
- ret = NULL;
- break;
+ libvlc_printerr( "Invalid argument to %s in %s", name, "get string" );
+ return NULL;
}
- vlc_object_release( object );
- return ret;
-}
+ return var_GetString( p_mi, opt->name );
+}
-/*****************************************************************************
- * Marquee: FIXME: That implementation has no persistent state and requires
- * a vout
- *****************************************************************************/
static const opt_t *
-marq_option_bynumber(unsigned option, libvlc_exception_t *p_e)
+marq_option_bynumber(unsigned option)
{
- opt_t optlist[] =
+ static const opt_t optlist[] =
{
{ "marq", 0 },
{ "marq-marquee", VLC_VAR_STRING },
};
enum { num_opts = sizeof(optlist) / sizeof(*optlist) };
- opt_t *r = option < num_opts ? optlist+option : NULL;
+ const opt_t *r = option < num_opts ? optlist+option : NULL;
if( !r )
- {
- libvlc_exception_raise( p_e );
libvlc_printerr( "Unknown marquee option" );
- }
return r;
}
-static vlc_object_t *get_object( libvlc_media_player_t *,
- const char *, libvlc_exception_t *);
+static vlc_object_t *get_object( libvlc_media_player_t *, const char *);
/*****************************************************************************
* libvlc_video_get_marquee_int : get a marq option value
*****************************************************************************/
int libvlc_video_get_marquee_int( libvlc_media_player_t *p_mi,
- unsigned option, libvlc_exception_t *p_e )
+ unsigned option )
{
- return get_int( p_mi, "marq", marq_option_bynumber(option,p_e), p_e );
+ return get_int( p_mi, "marq", marq_option_bynumber(option) );
}
/*****************************************************************************
* libvlc_video_get_marquee_string : get a marq option value
*****************************************************************************/
char * libvlc_video_get_marquee_string( libvlc_media_player_t *p_mi,
- unsigned option, libvlc_exception_t *p_e )
+ unsigned option )
{
- return get_string( p_mi, "marq", marq_option_bynumber(option,p_e), p_e );
+ return get_string( p_mi, "marq", marq_option_bynumber(option) );
}
/*****************************************************************************
* libvlc_video_set_marquee_int: enable, disable or set an int option
*****************************************************************************/
void libvlc_video_set_marquee_int( libvlc_media_player_t *p_mi,
- unsigned option, int value, libvlc_exception_t *p_e )
+ unsigned option, int value )
{
- set_int( p_mi, "marq", marq_option_bynumber(option,p_e), value, p_e );
+ set_int( p_mi, "marq", marq_option_bynumber(option), value );
}
/*****************************************************************************
* libvlc_video_set_marquee_string: set a string option
*****************************************************************************/
void libvlc_video_set_marquee_string( libvlc_media_player_t *p_mi,
- unsigned option, const char * value, libvlc_exception_t *p_e )
+ unsigned option, const char * value )
{
- set_string( p_mi, "marq", marq_option_bynumber(option,p_e), value, p_e );
+ set_string( p_mi, "marq", marq_option_bynumber(option), value );
}
/* logo module support */
-static opt_t *
-logo_option_bynumber( unsigned option, libvlc_exception_t *p_e )
+static const opt_t *
+logo_option_bynumber( unsigned option )
{
- opt_t vlogo_optlist[] = /* depends on libvlc_video_logo_option_t */
+ static const opt_t vlogo_optlist[] =
+ /* depends on libvlc_video_logo_option_t */
{
{ "logo", 0 },
{ "logo-file", VLC_VAR_STRING },
};
enum { num_vlogo_opts = sizeof(vlogo_optlist) / sizeof(*vlogo_optlist) };
- opt_t *r = option < num_vlogo_opts ? vlogo_optlist+option : NULL;
+ const opt_t *r = option < num_vlogo_opts ? vlogo_optlist+option : NULL;
if( !r )
- {
- libvlc_exception_raise( p_e );
libvlc_printerr( "Unknown logo option" );
- }
return r;
}
void libvlc_video_set_logo_string( libvlc_media_player_t *p_mi,
- unsigned option, const char *psz_value,
- libvlc_exception_t *p_e )
+ unsigned option, const char *psz_value )
{
- set_string( p_mi,"logo",logo_option_bynumber(option,p_e),psz_value,p_e );
+ set_string( p_mi,"logo",logo_option_bynumber(option),psz_value );
}
void libvlc_video_set_logo_int( libvlc_media_player_t *p_mi,
- unsigned option, int value,
- libvlc_exception_t *p_e )
+ unsigned option, int value )
{
- set_int( p_mi, "logo", logo_option_bynumber(option, p_e), value, p_e );
+ set_int( p_mi, "logo", logo_option_bynumber(option), value );
}
int libvlc_video_get_logo_int( libvlc_media_player_t *p_mi,
- unsigned option, libvlc_exception_t *p_e )
+ unsigned option )
{
- return get_int( p_mi, "logo", logo_option_bynumber(option,p_e), p_e );
+ return get_int( p_mi, "logo", logo_option_bynumber(option) );
+}
+
+
+/* adjust module support */
+
+
+static const opt_t *
+adjust_option_bynumber( unsigned option )
+{
+ static const opt_t optlist[] =
+ {
+ { "adjust", 0 },
+ { "contrast", VLC_VAR_FLOAT },
+ { "brightness", VLC_VAR_FLOAT },
+ { "hue", VLC_VAR_INTEGER },
+ { "saturation", VLC_VAR_FLOAT },
+ { "gamma", VLC_VAR_FLOAT },
+ };
+ enum { num_opts = sizeof(optlist) / sizeof(*optlist) };
+
+ const opt_t *r = option < num_opts ? optlist+option : NULL;
+ if( !r )
+ libvlc_printerr( "Unknown adjust option" );
+ return r;
}
+void libvlc_video_set_adjust_int( libvlc_media_player_t *p_mi,
+ unsigned option, int value )
+{
+ set_int( p_mi, "adjust", adjust_option_bynumber(option), value );
+}
+
+
+int libvlc_video_get_adjust_int( libvlc_media_player_t *p_mi,
+ unsigned option )
+{
+ return get_int( p_mi, "adjust", adjust_option_bynumber(option) );
+}
+
+
+void libvlc_video_set_adjust_float( libvlc_media_player_t *p_mi,
+ unsigned option, float value )
+{
+ set_float( p_mi, "adjust", adjust_option_bynumber(option), value );
+}
+
+
+float libvlc_video_get_adjust_float( libvlc_media_player_t *p_mi,
+ unsigned option )
+{
+ return get_float( p_mi, "adjust", adjust_option_bynumber(option) );
+}