X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fcontrol%2Fvideo.c;h=2f122a54a18cc53ce55ed319b7316c58cc779830;hb=57a4f916876060dc51583f40483522a0ad1de8bc;hp=aac2c653ab92194e14330c853da6754f6eb082d7;hpb=4a95265a63091fee2bd7ef99ababec5ff0090b6d;p=vlc diff --git a/src/control/video.c b/src/control/video.c index aac2c653ab..2f122a54a1 100644 --- a/src/control/video.c +++ b/src/control/video.c @@ -38,7 +38,6 @@ #include #include "media_player_internal.h" -#include #include /* @@ -48,7 +47,10 @@ static vout_thread_t **GetVouts( libvlc_media_player_t *p_mi, size_t *n ) { 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)) @@ -158,6 +160,7 @@ libvlc_video_take_snapshot( libvlc_media_player_t *p_mi, unsigned num, 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; @@ -166,6 +169,9 @@ int libvlc_video_get_size( libvlc_media_player_t *p_mi, unsigned num, *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 ) @@ -220,7 +226,7 @@ void libvlc_video_set_scale( libvlc_media_player_t *p_mp, float f_scale ) { 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; @@ -231,7 +237,7 @@ void libvlc_video_set_scale( libvlc_media_player_t *p_mp, float f_scale ) 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); @@ -280,7 +286,7 @@ int libvlc_video_get_spu( libvlc_media_player_t *p_mi ) if( i_ret < 0 ) { vlc_object_release( p_input_thread ); - libvlc_printerr( "Subtitle informations not found" ); + libvlc_printerr( "Subtitle information not found" ); return -1; } @@ -392,7 +398,14 @@ void libvlc_video_set_crop_geometry( libvlc_media_player_t *p_mi, 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); } @@ -668,6 +681,46 @@ get_int( libvlc_media_player_t *p_mi, const char *restrict name, } +static void +set_float( libvlc_media_player_t *p_mi, const char *restrict name, + const opt_t *restrict opt, float value ) +{ + if( !opt ) return; + + if( opt->type != VLC_VAR_FLOAT ) + { + 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 ) @@ -725,7 +778,7 @@ marq_option_bynumber(unsigned option) }; 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_printerr( "Unknown marquee option" ); return r; @@ -773,7 +826,7 @@ void libvlc_video_set_marquee_string( libvlc_media_player_t *p_mi, /* logo module support */ -static opt_t * +static const opt_t * logo_option_bynumber( unsigned option ) { static const opt_t vlogo_optlist[] = @@ -790,7 +843,7 @@ logo_option_bynumber( unsigned option ) }; 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_printerr( "Unknown logo option" ); return r; @@ -818,3 +871,53 @@ int libvlc_video_get_logo_int( libvlc_media_player_t *p_mi, } +/* 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) ); +}