Commit bdab92b9 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

libvlc_video_*: rewrite

 - enable (non-ES) settings even if no output is present
 - best effort at handling multiple outputs
 - remove exceptions
 - libvlc_video_get_size returns both dimensions
 - libvlc_video_take_snapshot takes a parameter to select the output
parent b01e357d
...@@ -444,11 +444,12 @@ VLC_PUBLIC_API float libvlc_media_player_get_fps( libvlc_media_player_t * ); ...@@ -444,11 +444,12 @@ VLC_PUBLIC_API float libvlc_media_player_get_fps( libvlc_media_player_t * );
/** end bug */ /** end bug */
/** /**
* Does this media player have a video output? * How many video outputs does this media player have?
* *
* \param p_md the media player * \param p_md the media player
* \return the number of video outputs
*/ */
VLC_PUBLIC_API int libvlc_media_player_has_vout( libvlc_media_player_t * ); VLC_PUBLIC_API unsigned libvlc_media_player_has_vout( libvlc_media_player_t * );
/** /**
* Is this media player seekable? * Is this media player seekable?
...@@ -488,18 +489,17 @@ VLC_PUBLIC_API void libvlc_track_description_release( libvlc_track_description_t ...@@ -488,18 +489,17 @@ VLC_PUBLIC_API void libvlc_track_description_release( libvlc_track_description_t
*/ */
/** /**
* Toggle fullscreen status on a non-embedded video output. * Toggle fullscreen status on non-embedded video outputs.
* *
* @warning The same limitations applies to this function * @warning The same limitations applies to this function
* as to libvlc_set_fullscreen(). * as to libvlc_set_fullscreen().
* *
* \param p_mediaplayer the media player * \param p_mediaplayer the media player
* \param p_e an initialized exception pointer
*/ */
VLC_PUBLIC_API void libvlc_toggle_fullscreen( libvlc_media_player_t *, libvlc_exception_t * ); VLC_PUBLIC_API void libvlc_toggle_fullscreen( libvlc_media_player_t * );
/** /**
* Enable or disable fullscreen on a non-embedded video output. * Enable or disable fullscreen on non-embedded video outputs.
* *
* @warning With most window managers, only a top-level windows can switch to * @warning With most window managers, only a top-level windows can switch to
* full-screen mode. Hence, this function will not operate properly if * full-screen mode. Hence, this function will not operate properly if
...@@ -511,18 +511,16 @@ VLC_PUBLIC_API void libvlc_toggle_fullscreen( libvlc_media_player_t *, libvlc_ex ...@@ -511,18 +511,16 @@ VLC_PUBLIC_API void libvlc_toggle_fullscreen( libvlc_media_player_t *, libvlc_ex
* *
* \param p_mediaplayer the media player * \param p_mediaplayer the media player
* \param b_fullscreen boolean for fullscreen status * \param b_fullscreen boolean for fullscreen status
* \param p_e an initialized exception pointer
*/ */
VLC_PUBLIC_API void libvlc_set_fullscreen( libvlc_media_player_t *, int, libvlc_exception_t * ); VLC_PUBLIC_API void libvlc_set_fullscreen( libvlc_media_player_t *, int );
/** /**
* Get current fullscreen status. * Get current fullscreen status.
* *
* \param p_mediaplayer the media player * \param p_mediaplayer the media player
* \param p_e an initialized exception pointer
* \return the fullscreen status (boolean) * \return the fullscreen status (boolean)
*/ */
VLC_PUBLIC_API int libvlc_get_fullscreen( libvlc_media_player_t *, libvlc_exception_t * ); VLC_PUBLIC_API int libvlc_get_fullscreen( libvlc_media_player_t * );
/** /**
* Enable or disable key press events handling, according to the LibVLC hotkeys * Enable or disable key press events handling, according to the LibVLC hotkeys
...@@ -557,35 +555,48 @@ void libvlc_video_set_key_input( libvlc_media_player_t *mp, unsigned on ); ...@@ -557,35 +555,48 @@ void libvlc_video_set_key_input( libvlc_media_player_t *mp, unsigned on );
VLC_PUBLIC_API VLC_PUBLIC_API
void libvlc_video_set_mouse_input( libvlc_media_player_t *mp, unsigned on ); void libvlc_video_set_mouse_input( libvlc_media_player_t *mp, unsigned on );
/**
* Get the pixel dimensions of a video.
*
* \param mp media player
* \param num number of the video (starting from, and most commonly 0)
* \param px pointer to get the pixel width [OUT]
* \param py pointer to get the pixel height [OUT]
* \return 0 on success, -1 if the specified video does not exist
*/
VLC_PUBLIC_API
int libvlc_video_get_size( libvlc_media_player_t *mp, unsigned num,
unsigned *px, unsigned *py );
/** /**
* Get current video height. * Get current video height.
* You should use libvlc_video_get_size() instead.
* *
* \param p_mediaplayer the media player * \param p_mediaplayer the media player
* \param p_e an initialized exception pointer * \return the video pixel height or 0 if not applicable
* \return the video height
*/ */
VLC_PUBLIC_API int libvlc_video_get_height( libvlc_media_player_t *, libvlc_exception_t * ); VLC_DEPRECATED_API
int libvlc_video_get_height( libvlc_media_player_t * );
/** /**
* Get current video width. * Get current video width.
* You should use libvlc_video_get_size() instead.
* *
* \param p_mediaplayer the media player * \param p_mediaplayer the media player
* \param p_e an initialized exception pointer * \return the video pixel width or 0 if not applicable
* \return the video width
*/ */
VLC_PUBLIC_API int libvlc_video_get_width( libvlc_media_player_t *, libvlc_exception_t * ); VLC_DEPRECATED_API
int libvlc_video_get_width( libvlc_media_player_t * );
/** /**
* Get the current video scaling factor. * Get the current video scaling factor.
* See also libvlc_video_set_scale(). * See also libvlc_video_set_scale().
* *
* \param p_mediaplayer the media player * \param p_mediaplayer the media player
* \param p_e an initialized exception pointer
* \return the currently configured zoom factor, or 0. if the video is set * \return the currently configured zoom factor, or 0. if the video is set
* to fit to the output window/drawable automatically. * to fit to the output window/drawable automatically.
*/ */
VLC_PUBLIC_API float libvlc_video_get_scale( libvlc_media_player_t *, VLC_PUBLIC_API float libvlc_video_get_scale( libvlc_media_player_t * );
libvlc_exception_t *p_e );
/** /**
* Set the video scaling factor. That is the ratio of the number of pixels on * Set the video scaling factor. That is the ratio of the number of pixels on
...@@ -597,46 +608,42 @@ VLC_PUBLIC_API float libvlc_video_get_scale( libvlc_media_player_t *, ...@@ -597,46 +608,42 @@ VLC_PUBLIC_API float libvlc_video_get_scale( libvlc_media_player_t *,
* *
* \param p_mediaplayer the media player * \param p_mediaplayer the media player
* \param i_factor the scaling factor, or zero * \param i_factor the scaling factor, or zero
* \param p_e an initialized exception pointer
*/ */
VLC_PUBLIC_API void libvlc_video_set_scale( libvlc_media_player_t *, float, VLC_PUBLIC_API void libvlc_video_set_scale( libvlc_media_player_t *, float );
libvlc_exception_t *p_e );
/** /**
* Get current video aspect ratio. * Get current video aspect ratio.
* *
* \param p_mediaplayer the media player * \param p_mediaplayer the media player
* \param p_e an initialized exception pointer * \return the video aspect ratio or NULL if unspecified
* \return the video aspect ratio * (the result must be released with free() or libvlc_free()).
*/ */
VLC_PUBLIC_API char *libvlc_video_get_aspect_ratio( libvlc_media_player_t *, libvlc_exception_t * ); VLC_PUBLIC_API char *libvlc_video_get_aspect_ratio( libvlc_media_player_t * );
/** /**
* Set new video aspect ratio. * Set new video aspect ratio.
* *
* \param p_mediaplayer the media player * \param p_mediaplayer the media player
* \param psz_aspect new video aspect-ratio * \param psz_aspect new video aspect-ratio or NULL to reset to default
* \param p_e an initialized exception pointer * \note Invalid aspect ratios are ignored.
*/ */
VLC_PUBLIC_API void libvlc_video_set_aspect_ratio( libvlc_media_player_t *, const char *, libvlc_exception_t * ); VLC_PUBLIC_API void libvlc_video_set_aspect_ratio( libvlc_media_player_t *, const char * );
/** /**
* Get current video subtitle. * Get current video subtitle.
* *
* \param p_mediaplayer the media player * \param p_mediaplayer the media player
* \param p_e an initialized exception pointer * \return the video subtitle selected, or -1 if none
* \return the video subtitle selected
*/ */
VLC_PUBLIC_API int libvlc_video_get_spu( libvlc_media_player_t *, libvlc_exception_t * ); VLC_PUBLIC_API int libvlc_video_get_spu( libvlc_media_player_t * );
/** /**
* Get the number of available video subtitles. * Get the number of available video subtitles.
* *
* \param p_mediaplayer the media player * \param p_mediaplayer the media player
* \param p_e an initialized exception pointer
* \return the number of available video subtitles * \return the number of available video subtitles
*/ */
VLC_PUBLIC_API int libvlc_video_get_spu_count( libvlc_media_player_t *, libvlc_exception_t * ); VLC_PUBLIC_API int libvlc_video_get_spu_count( libvlc_media_player_t * );
/** /**
* Get the description of available video subtitles. * Get the description of available video subtitles.
...@@ -653,9 +660,9 @@ VLC_PUBLIC_API libvlc_track_description_t * ...@@ -653,9 +660,9 @@ VLC_PUBLIC_API libvlc_track_description_t *
* *
* \param p_mediaplayer the media player * \param p_mediaplayer the media player
* \param i_spu new video subtitle to select * \param i_spu new video subtitle to select
* \param p_e an initialized exception pointer * \return 0 on success, -1 if out of range
*/ */
VLC_PUBLIC_API void libvlc_video_set_spu( libvlc_media_player_t *, int , libvlc_exception_t * ); VLC_PUBLIC_API int libvlc_video_set_spu( libvlc_media_player_t *, unsigned );
/** /**
* Set new video subtitle file. * Set new video subtitle file.
...@@ -692,19 +699,18 @@ VLC_PUBLIC_API libvlc_track_description_t * ...@@ -692,19 +699,18 @@ VLC_PUBLIC_API libvlc_track_description_t *
* Get current crop filter geometry. * Get current crop filter geometry.
* *
* \param p_mediaplayer the media player * \param p_mediaplayer the media player
* \param p_e an initialized exception pointer * \return the crop filter geometry or NULL if unset
* \return the crop filter geometry
*/ */
VLC_PUBLIC_API char *libvlc_video_get_crop_geometry( libvlc_media_player_t *, libvlc_exception_t * ); VLC_PUBLIC_API char *libvlc_video_get_crop_geometry( libvlc_media_player_t * );
/** /**
* Set new crop filter geometry. * Set new crop filter geometry.
* *
* \param p_mediaplayer the media player * \param p_mediaplayer the media player
* \param psz_geometry new crop filter geometry * \param psz_geometry new crop filter geometry (NULL to unset)
* \param p_e an initialized exception pointer
*/ */
VLC_PUBLIC_API void libvlc_video_set_crop_geometry( libvlc_media_player_t *, const char *, libvlc_exception_t * ); VLC_PUBLIC_API
void libvlc_video_set_crop_geometry( libvlc_media_player_t *, const char * );
/** /**
* Toggle teletext transparent status on video output. * Toggle teletext transparent status on video output.
...@@ -726,7 +732,6 @@ VLC_PUBLIC_API int libvlc_video_get_track_count( libvlc_media_player_t * ); ...@@ -726,7 +732,6 @@ VLC_PUBLIC_API int libvlc_video_get_track_count( libvlc_media_player_t * );
* Get the description of available video tracks. * Get the description of available video tracks.
* *
* \param p_mi media player * \param p_mi media player
* \param p_e an initialized exception
* \return list with description of available video tracks, or NULL on error * \return list with description of available video tracks, or NULL on error
*/ */
VLC_PUBLIC_API libvlc_track_description_t * VLC_PUBLIC_API libvlc_track_description_t *
...@@ -736,19 +741,19 @@ VLC_PUBLIC_API libvlc_track_description_t * ...@@ -736,19 +741,19 @@ VLC_PUBLIC_API libvlc_track_description_t *
* Get current video track. * Get current video track.
* *
* \param p_mi media player * \param p_mi media player
* \param p_e an initialized exception pointer * \return the video track (int) or -1 if none
* \return the video track (int)
*/ */
VLC_PUBLIC_API int libvlc_video_get_track( libvlc_media_player_t *, libvlc_exception_t * ); VLC_PUBLIC_API int libvlc_video_get_track( libvlc_media_player_t * );
/** /**
* Set video track. * Set video track.
* *
* \param p_mi media player * \param p_mi media player
* \param i_track the track (int) * \param i_track the track (int)
* \param p_e an initialized exception pointer * \return 0 on success, -1 if out of range
*/ */
VLC_PUBLIC_API void libvlc_video_set_track( libvlc_media_player_t *, int, libvlc_exception_t * ); VLC_PUBLIC_API
int libvlc_video_set_track( libvlc_media_player_t *, int );
/** /**
* Take a snapshot of the current video window. * Take a snapshot of the current video window.
...@@ -757,24 +762,24 @@ VLC_PUBLIC_API void libvlc_video_set_track( libvlc_media_player_t *, int, libvlc ...@@ -757,24 +762,24 @@ VLC_PUBLIC_API void libvlc_video_set_track( libvlc_media_player_t *, int, libvlc
* If i_width XOR i_height is 0, original aspect-ratio is preserved. * If i_width XOR i_height is 0, original aspect-ratio is preserved.
* *
* \param p_mi media player instance * \param p_mi media player instance
* \param num number of video output (typically 0 for the first/only one)
* \param psz_filepath the path where to save the screenshot to * \param psz_filepath the path where to save the screenshot to
* \param i_width the snapshot's width * \param i_width the snapshot's width
* \param i_height the snapshot's height * \param i_height the snapshot's height
* \param p_e an initialized exception pointer * \return 0 on success, -1 if the video was not found
*/ */
VLC_PUBLIC_API void libvlc_video_take_snapshot( libvlc_media_player_t *, const char *,unsigned int, unsigned int, libvlc_exception_t * ); VLC_PUBLIC_API
int libvlc_video_take_snapshot( libvlc_media_player_t *, unsigned num,
const char *,unsigned int, unsigned int );
/** /**
* Enable or disable deinterlace filter * Enable or disable deinterlace filter
* *
* \param p_mi libvlc media player * \param p_mi libvlc media player
* \param b_enable boolean to enable or disable deinterlace filter * \param psz_mode type of deinterlace filter, NULL to disable
* \param psz_mode type of deinterlace filter to use
* \param p_e an initialized exception pointer
*/ */
VLC_PUBLIC_API void libvlc_video_set_deinterlace( libvlc_media_player_t *, VLC_PUBLIC_API void libvlc_video_set_deinterlace( libvlc_media_player_t *,
int , const char *, const char * );
libvlc_exception_t *);
/** /**
* Get an integer marquee option value * Get an integer marquee option value
......
...@@ -356,7 +356,17 @@ libvlc_media_player_new( libvlc_instance_t *instance ) ...@@ -356,7 +356,17 @@ libvlc_media_player_new( libvlc_instance_t *instance )
var_Create (mp, "mouse-events", VLC_VAR_BOOL); var_Create (mp, "mouse-events", VLC_VAR_BOOL);
var_SetBool (mp, "mouse-events", true); var_SetBool (mp, "mouse-events", true);
/* Audio */ var_Create (mp, "fullscreen", VLC_VAR_BOOL);
var_Create (mp, "autoscale", VLC_VAR_BOOL);
var_SetBool (mp, "autoscale", true);
var_Create (mp, "scale", VLC_VAR_FLOAT);
var_SetFloat (mp, "scale", 1.);
var_Create (mp, "aspect-ratio", VLC_VAR_STRING);
var_Create (mp, "crop", VLC_VAR_STRING);
var_Create (mp, "deinterlace", VLC_VAR_INTEGER);
var_Create (mp, "deinterlace-mode", VLC_VAR_STRING);
/* Audio */
var_Create (mp, "aout", VLC_VAR_STRING | VLC_VAR_DOINHERIT); var_Create (mp, "aout", VLC_VAR_STRING | VLC_VAR_DOINHERIT);
mp->p_md = NULL; mp->p_md = NULL;
......
...@@ -44,27 +44,41 @@ ...@@ -44,27 +44,41 @@
/* /*
* Remember to release the returned vout_thread_t. * Remember to release the returned vout_thread_t.
*/ */
static vout_thread_t *GetVout( libvlc_media_player_t *p_mi, static vout_thread_t **GetVouts( libvlc_media_player_t *p_mi, size_t *n )
libvlc_exception_t *p_exception )
{ {
input_thread_t *p_input = libvlc_get_input_thread( p_mi ); input_thread_t *p_input = libvlc_get_input_thread( p_mi );
vout_thread_t *p_vout = NULL; if( !p_input )
return NULL;
if( p_input ) vout_thread_t **pp_vouts;
{ if (input_Control( p_input, INPUT_GET_VOUTS, &pp_vouts, n))
p_vout = input_GetVout( p_input );
if( !p_vout )
{
libvlc_exception_raise( p_exception );
libvlc_printerr( "No active video output" );
}
vlc_object_release( p_input );
}
else
{ {
libvlc_exception_raise( p_exception ); *n = 0;
libvlc_printerr( "No active input" ); pp_vouts = NULL;
} }
vlc_object_release (p_input);
return pp_vouts;
}
static vout_thread_t *GetVout (libvlc_media_player_t *mp, size_t num)
{
vout_thread_t *p_vout = NULL;
size_t n;
vout_thread_t **pp_vouts = GetVouts (mp, &n);
if (pp_vouts == NULL)
goto err;
if (num < n)
p_vout = pp_vouts[num];
for (size_t i = 0; i < n; i++)
if (i != num)
vlc_object_release (pp_vouts[i]);
free (pp_vouts);
if (p_vout == NULL)
err:
libvlc_printerr ("Video output not active");
return p_vout; return p_vout;
} }
...@@ -72,49 +86,43 @@ static vout_thread_t *GetVout( libvlc_media_player_t *p_mi, ...@@ -72,49 +86,43 @@ static vout_thread_t *GetVout( libvlc_media_player_t *p_mi,
* Exported functions * Exported functions
**********************************************************************/ **********************************************************************/
void libvlc_set_fullscreen( libvlc_media_player_t *p_mi, int b_fullscreen, void libvlc_set_fullscreen( libvlc_media_player_t *p_mi, int b_fullscreen )
libvlc_exception_t *p_e )
{ {
/* We only work on the first vout */ /* This will work even if the video is not currently active */
vout_thread_t *p_vout = GetVout( p_mi, p_e ); var_SetBool (p_mi, "fullscreen", !!b_fullscreen);
/* GetVout will raise the exception for us */
if( !p_vout ) return;
var_SetBool( p_vout, "fullscreen", b_fullscreen ); /* Apply to current video outputs (if any) */
size_t n;
vlc_object_release( p_vout ); vout_thread_t **pp_vouts = GetVouts (p_mi, &n);
for (size_t i = 0; i < n; i++)
{
var_SetBool (pp_vouts[i], "fullscreen", b_fullscreen);
vlc_object_release (pp_vouts[i]);
}
free (pp_vouts);
} }
int libvlc_get_fullscreen( libvlc_media_player_t *p_mi, int libvlc_get_fullscreen( libvlc_media_player_t *p_mi )
libvlc_exception_t *p_e )
{ {
/* We only work on the first vout */ return var_GetBool (p_mi, "fullscreen");
vout_thread_t *p_vout = GetVout( p_mi, p_e );
int i_ret;
/* GetVout will raise the exception for us */
if( !p_vout ) return 0;
i_ret = var_GetBool( p_vout, "fullscreen" );
vlc_object_release( p_vout );
return i_ret;
} }
void libvlc_toggle_fullscreen( libvlc_media_player_t *p_mi, void libvlc_toggle_fullscreen( libvlc_media_player_t *p_mi )
libvlc_exception_t *p_e )
{ {
/* We only work on the first vout */ var_ToggleBool (p_mi, "fullscreen");
vout_thread_t *p_vout = GetVout( p_mi, p_e ); bool b_fullscreen = var_GetBool (p_mi, "fullscreen");
/* GetVout will raise the exception for us */
if( !p_vout ) return;
var_ToggleBool( p_vout, "fullscreen" ); /* Apply to current video outputs (if any) */
size_t n;
vout_thread_t **pp_vouts = GetVouts (p_mi, &n);
for (size_t i = 0; i < n; i++)
{
vout_thread_t *p_vout = pp_vouts[i];
vlc_object_release( p_vout ); var_SetBool (p_vout, "fullscreen", b_fullscreen);
vlc_object_release (p_vout);
}
free (pp_vouts);
} }
void libvlc_video_set_key_input( libvlc_media_player_t *p_mi, unsigned on ) void libvlc_video_set_key_input( libvlc_media_player_t *p_mi, unsigned on )
...@@ -127,145 +135,122 @@ void libvlc_video_set_mouse_input( libvlc_media_player_t *p_mi, unsigned on ) ...@@ -127,145 +135,122 @@ void libvlc_video_set_mouse_input( libvlc_media_player_t *p_mi, unsigned on )
var_SetBool (p_mi, "mouse-events", !!on); var_SetBool (p_mi, "mouse-events", !!on);
} }
void int
libvlc_video_take_snapshot( libvlc_media_player_t *p_mi, const char *psz_filepath, libvlc_video_take_snapshot( libvlc_media_player_t *p_mi, unsigned num,
unsigned int i_width, unsigned int i_height, libvlc_exception_t *p_e ) const char *psz_filepath,
unsigned int i_width, unsigned int i_height )
{ {
vout_thread_t *p_vout;
assert( psz_filepath ); assert( psz_filepath );
/* We must have an input */ vout_thread_t *p_vout = GetVout (p_mi, num);
if( !p_mi->p_input_thread ) if (p_vout == NULL)
{ return -1;
libvlc_exception_raise( p_e );
libvlc_printerr( "Input does not exist" );
return;
}
/* GetVout will raise the exception for us */
p_vout = GetVout( p_mi, p_e );
if( !p_vout ) return;
var_SetInteger( p_vout, "snapshot-width", i_width ); /* FIXME: This is not atomic. Someone else could change the values,
* at least in theory. */
var_SetInteger( p_vout, "snapshot-width", i_width);
var_SetInteger( p_vout, "snapshot-height", i_height ); var_SetInteger( p_vout, "snapshot-height", i_height );
var_SetString( p_vout, "snapshot-path", psz_filepath ); var_SetString( p_vout, "snapshot-path", psz_filepath );
var_SetString( p_vout, "snapshot-format", "png" ); var_SetString( p_vout, "snapshot-format", "png" );
var_TriggerCallback (p_vout, "video-snapshot" );
var_TriggerCallback( p_vout, "video-snapshot" ); return 0;
vlc_object_release( p_vout );
} }
int libvlc_video_get_height( libvlc_media_player_t *p_mi, int libvlc_video_get_size( libvlc_media_player_t *p_mi, unsigned num,
libvlc_exception_t *p_e ) unsigned *restrict px, unsigned *restrict py )
{ {
int height; vout_thread_t *p_vout = GetVout (p_mi, num);
if (p_vout == NULL)
vout_thread_t *p_vout = GetVout( p_mi, p_e ); return -1;
if( !p_vout ) return 0;
height = p_vout->i_window_height; *px = p_vout->i_window_height;
*py = p_vout->i_window_width;
vlc_object_release (p_vout);
return 0;
}
vlc_object_release( p_vout ); int libvlc_video_get_height( libvlc_media_player_t *p_mi )
{
unsigned height, width;
if (libvlc_video_get_size (p_mi, 0, &height, &width))
return 0;
return height; return height;
} }
int libvlc_video_get_width( libvlc_media_player_t *p_mi, int libvlc_video_get_width( libvlc_media_player_t *p_mi )
libvlc_exception_t *p_e )
{ {
int width; unsigned height, width;
vout_thread_t *p_vout = GetVout( p_mi, p_e );
if( !p_vout ) return 0;
width = p_vout->i_window_width;
vlc_object_release( p_vout );
if (libvlc_video_get_size (p_mi, 0, &height, &width))
return 0;
return width; return width;
} }
int libvlc_media_player_has_vout( libvlc_media_player_t *p_mi ) unsigned libvlc_media_player_has_vout( libvlc_media_player_t *p_mi )
{ {
input_thread_t *p_input_thread = libvlc_get_input_thread(p_mi); size_t n;
bool has_vout = false; vout_thread_t **pp_vouts = GetVouts (p_mi, &n);
for (size_t i = 0; i < n; i++)
if( p_input_thread ) vlc_object_release (pp_vouts[i]);
{ free (pp_vouts);
vout_thread_t *p_vout; return n;
p_vout = input_GetVout( p_input_thread );
if( p_vout )
{
has_vout = true;
vlc_object_release( p_vout );
}
vlc_object_release( p_input_thread );
}
return has_vout;
} }
float libvlc_video_get_scale( libvlc_media_player_t *p_mp, float libvlc_video_get_scale( libvlc_media_player_t *mp )
libvlc_exception_t *p_e )
{ {
vout_thread_t *p_vout = GetVout( p_mp, p_e ); float f_scale = var_GetFloat (mp, "scale");
if( !p_vout ) if (var_GetBool (mp, "autoscale"))
return 0.;
float f_scale = var_GetFloat( p_vout, "scale" );
if( var_GetBool( p_vout, "autoscale" ) )
f_scale = 0.; f_scale = 0.;
vlc_object_release( p_vout );
return f_scale; return f_scale;
} }
void libvlc_video_set_scale( libvlc_media_player_t *p_mp, float f_scale, void libvlc_video_set_scale( libvlc_media_player_t *p_mp, float f_scale )
libvlc_exception_t *p_e )
{ {
vout_thread_t *p_vout = GetVout( p_mp, p_e ); if (f_scale != 0.)
if( !p_vout ) var_SetFloat (p_mp, "scale", f_scale);
return; var_SetBool (p_mp, "autoscale", f_scale != 0.);
if( f_scale != 0. ) /* Apply to current video outputs (if any) */
var_SetFloat( p_vout, "scale", f_scale ); size_t n;
var_SetBool( p_vout, "autoscale", f_scale != 0. ); vout_thread_t **pp_vouts = GetVouts (p_mp, &n);
vlc_object_release( p_vout ); for (size_t i = 0; i < n; i++)
{
vout_thread_t *p_vout = pp_vouts[i];
if (f_scale != 0.)
var_SetFloat (p_vout, "scale", f_scale);
var_SetBool (p_mp, "autoscale", f_scale != 0.);
vlc_object_release (p_vout);
}
free (pp_vouts);
} }
char *libvlc_video_get_aspect_ratio( libvlc_media_player_t *p_mi, char *libvlc_video_get_aspect_ratio( libvlc_media_player_t *p_mi )
libvlc_exception_t *p_e )
{ {
char *psz_aspect = NULL; return var_GetNonEmptyString (p_mi, "aspect-ratio");
vout_thread_t *p_vout = GetVout( p_mi, p_e );
if( !p_vout ) return NULL;
psz_aspect = var_GetNonEmptyString( p_vout, "aspect-ratio" );
vlc_object_release( p_vout );
return psz_aspect ? psz_aspect : strdup("");
} }
void libvlc_video_set_aspect_ratio( libvlc_media_player_t *p_mi, void libvlc_video_set_aspect_ratio( libvlc_media_player_t *p_mi,
const char *psz_aspect, libvlc_exception_t *p_e ) const char *psz_aspect )
{ {
vout_thread_t *p_vout = GetVout( p_mi, p_e ); if (psz_aspect == NULL)
int i_ret = -1; psz_aspect = "";
var_SetString (p_mi, "aspect-ratio", psz_aspect);
if( !p_vout ) return;
i_ret = var_SetString( p_vout, "aspect-ratio", psz_aspect ); size_t n;
vlc_object_release( p_vout ); vout_thread_t **pp_vouts = GetVouts (p_mi, &n);
if( i_ret ) for (size_t i = 0; i < n; i++)
{ {
libvlc_exception_raise( p_e ); vout_thread_t *p_vout = pp_vouts[i];
libvlc_printerr( "Bad or unsupported aspect ratio" );
var_SetString (p_vout, "aspect-ratio", psz_aspect);
vlc_object_release (p_vout);
} }
free (pp_vouts);
} }
int libvlc_video_get_spu( libvlc_media_player_t *p_mi, int libvlc_video_get_spu( libvlc_media_player_t *p_mi )
libvlc_exception_t *p_e )
{ {
input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi ); input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi );
vlc_value_t val_list; vlc_value_t val_list;
...@@ -276,7 +261,6 @@ int libvlc_video_get_spu( libvlc_media_player_t *p_mi, ...@@ -276,7 +261,6 @@ int libvlc_video_get_spu( libvlc_media_player_t *p_mi,
if( !p_input_thread ) if( !p_input_thread )
{ {
libvlc_exception_raise( p_e );
libvlc_printerr( "No active input" ); libvlc_printerr( "No active input" );
return -1; return -1;
} }
...@@ -285,9 +269,8 @@ int libvlc_video_get_spu( libvlc_media_player_t *p_mi, ...@@ -285,9 +269,8 @@ int libvlc_video_get_spu( libvlc_media_player_t *p_mi,
if( i_ret < 0 ) if( i_ret < 0 )
{ {
vlc_object_release( p_input_thread ); vlc_object_release( p_input_thread );
libvlc_exception_raise( p_e );
libvlc_printerr( "Subtitle informations not found" ); libvlc_printerr( "Subtitle informations not found" );
return i_ret; return -1;
} }
var_Change( p_input_thread, "spu-es", VLC_VAR_GETCHOICES, &val_list, NULL ); var_Change( p_input_thread, "spu-es", VLC_VAR_GETCHOICES, &val_list, NULL );
...@@ -304,21 +287,15 @@ int libvlc_video_get_spu( libvlc_media_player_t *p_mi, ...@@ -304,21 +287,15 @@ int libvlc_video_get_spu( libvlc_media_player_t *p_mi,
return i_spu; return i_spu;
} }
int libvlc_video_get_spu_count( libvlc_media_player_t *p_mi, int libvlc_video_get_spu_count( libvlc_media_player_t *p_mi )
libvlc_exception_t *p_e )
{ {
input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi ); input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi );
int i_spu_count; int i_spu_count;
if( !p_input_thread ) if( !p_input_thread )
{ return 0;
libvlc_exception_raise( p_e );
libvlc_printerr( "No active input" );
return -1;
}
i_spu_count = var_CountChoices( p_input_thread, "spu-es" ); i_spu_count = var_CountChoices( p_input_thread, "spu-es" );
vlc_object_release( p_input_thread ); vlc_object_release( p_input_thread );
return i_spu_count; return i_spu_count;
} }
...@@ -329,42 +306,30 @@ libvlc_track_description_t * ...@@ -329,42 +306,30 @@ libvlc_track_description_t *
return libvlc_get_track_description( p_mi, "spu-es" ); return libvlc_get_track_description( p_mi, "spu-es" );
} }
void libvlc_video_set_spu( libvlc_media_player_t *p_mi, int i_spu, int libvlc_video_set_spu( libvlc_media_player_t *p_mi, unsigned i_spu )
libvlc_exception_t *p_e )
{ {
input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi ); input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi );
vlc_value_t val_list; vlc_value_t list;
vlc_value_t newval; int i_ret = 0;
int i_ret = -1;
if( !p_input_thread ) if( !p_input_thread )
{ return -1;
libvlc_exception_raise( p_e );
libvlc_printerr( "No active input" );
return;
}
var_Change( p_input_thread, "spu-es", VLC_VAR_GETCHOICES, &val_list, NULL ); var_Change (p_input_thread, "spu-es", VLC_VAR_GETCHOICES, &list, NULL);
if( ( val_list.p_list->i_count == 0 ) if (i_spu > (unsigned)list.p_list->i_count)
|| (i_spu < 0) || (i_spu > val_list.p_list->i_count) )
{ {
libvlc_exception_raise( p_e ); libvlc_printerr( "Subtitle number out of range (%u/%u)",
libvlc_printerr( "Subtitle number out of range" ); i_spu, list.p_list->i_count );
i_ret = -1;
goto end; goto end;
} }
var_SetInteger (p_input_thread, "spu-es",
newval = val_list.p_list->p_values[i_spu]; list.p_list->p_values[i_spu].i_int);
i_ret = var_Set( p_input_thread, "spu-es", newval );
if( i_ret < 0 )
{
libvlc_exception_raise( p_e );
libvlc_printerr( "Subtitle selection error" );
}
end: end:
var_FreeList( &val_list, NULL ); vlc_object_release (p_input_thread);
vlc_object_release( p_input_thread ); var_FreeList (&list, NULL);
return i_ret;
} }
int libvlc_video_set_subtitle_file( libvlc_media_player_t *p_mi, int libvlc_video_set_subtitle_file( libvlc_media_player_t *p_mi,
...@@ -397,35 +362,30 @@ libvlc_track_description_t * ...@@ -397,35 +362,30 @@ libvlc_track_description_t *
return libvlc_get_track_description( p_mi, psz_title ); return libvlc_get_track_description( p_mi, psz_title );
} }
char *libvlc_video_get_crop_geometry( libvlc_media_player_t *p_mi, char *libvlc_video_get_crop_geometry (libvlc_media_player_t *p_mi)
libvlc_exception_t *p_e )
{ {
char *psz_geometry = 0; return var_GetNonEmptyString (p_mi, "crop");
vout_thread_t *p_vout = GetVout( p_mi, p_e );
if( !p_vout ) return 0;
psz_geometry = var_GetNonEmptyString( p_vout, "crop" );
vlc_object_release( p_vout );
return psz_geometry ? psz_geometry : strdup("");
} }
void libvlc_video_set_crop_geometry( libvlc_media_player_t *p_mi, void libvlc_video_set_crop_geometry( libvlc_media_player_t *p_mi,
const char *psz_geometry, libvlc_exception_t *p_e ) const char *psz_geometry )
{ {
vout_thread_t *p_vout = GetVout( p_mi, p_e ); if (psz_geometry == NULL)
int i_ret = -1; psz_geometry = "";
if( !p_vout ) return; var_SetString (p_mi, "crop", psz_geometry);
i_ret = var_SetString( p_vout, "crop", psz_geometry ); size_t n;
vlc_object_release( p_vout ); vout_thread_t **pp_vouts = GetVouts (p_mi, &n);
if( i_ret ) for (size_t i = 0; i < n; i++)
{ {
libvlc_exception_raise( p_e ); vout_thread_t *p_vout = pp_vouts[i];
libvlc_printerr( "Bad or unsupported cropping geometry" );
var_SetString (p_vout, "crop", psz_geometry);
vlc_object_release (p_vout);
} }
free (pp_vouts);
} }
void libvlc_toggle_teletext( libvlc_media_player_t *p_mi ) void libvlc_toggle_teletext( libvlc_media_player_t *p_mi )
...@@ -479,30 +439,25 @@ libvlc_track_description_t * ...@@ -479,30 +439,25 @@ libvlc_track_description_t *
return libvlc_get_track_description( p_mi, "video-es" ); return libvlc_get_track_description( p_mi, "video-es" );
} }
int libvlc_video_get_track( libvlc_media_player_t *p_mi, int libvlc_video_get_track( libvlc_media_player_t *p_mi )
libvlc_exception_t *p_e )
{ {
input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi ); input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi );
vlc_value_t val_list; vlc_value_t val_list;
vlc_value_t val; vlc_value_t val;
int i_track = -1; int i_track = -1;
int i_ret = -1;
int i;
if( !p_input_thread ) if( !p_input_thread )
return -1; return -1;
i_ret = var_Get( p_input_thread, "video-es", &val ); if( var_Get( p_input_thread, "video-es", &val ) < 0 )
if( i_ret < 0 )
{ {
libvlc_exception_raise( p_e );
libvlc_printerr( "Video track information not found" ); libvlc_printerr( "Video track information not found" );
vlc_object_release( p_input_thread ); vlc_object_release( p_input_thread );
return -1; return -1;
} }
var_Change( p_input_thread, "video-es", VLC_VAR_GETCHOICES, &val_list, NULL ); var_Change( p_input_thread, "video-es", VLC_VAR_GETCHOICES, &val_list, NULL );
for( i = 0; i < val_list.p_list->i_count; i++ ) for( int i = 0; i < val_list.p_list->i_count; i++ )
{ {
if( val_list.p_list->p_values[i].i_int == val.i_int ) if( val_list.p_list->p_values[i].i_int == val.i_int )
{ {
...@@ -515,75 +470,74 @@ int libvlc_video_get_track( libvlc_media_player_t *p_mi, ...@@ -515,75 +470,74 @@ int libvlc_video_get_track( libvlc_media_player_t *p_mi,
return i_track; return i_track;
} }
void libvlc_video_set_track( libvlc_media_player_t *p_mi, int i_track, int libvlc_video_set_track( libvlc_media_player_t *p_mi, int i_track )
libvlc_exception_t *p_e )
{ {
input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi ); input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi );
vlc_value_t val_list; vlc_value_t val_list;
int i_ret = -1; int i_ret = -1;
int i;
if( !p_input_thread ) if( !p_input_thread )
return; return -1;
var_Change( p_input_thread, "video-es", VLC_VAR_GETCHOICES, &val_list, NULL ); var_Change( p_input_thread, "video-es", VLC_VAR_GETCHOICES, &val_list, NULL );
for( i = 0; i < val_list.p_list->i_count; i++ ) for( int i = 0; i < val_list.p_list->i_count; i++ )
{ {
if( i_track == val_list.p_list->p_values[i].i_int ) if( i_track == val_list.p_list->p_values[i].i_int )
{ {
i_ret = var_SetInteger( p_input_thread, "video-es", i_track ); if( var_SetInteger( p_input_thread, "video-es", i_track ) < 0 )
if( i_ret < 0 )
break; break;
i_ret = 0;
goto end; goto end;
} }
} }
libvlc_exception_raise( p_e );
libvlc_printerr( "Video track number out of range" ); libvlc_printerr( "Video track number out of range" );
end: end:
var_FreeList( &val_list, NULL ); var_FreeList( &val_list, NULL );
vlc_object_release( p_input_thread ); vlc_object_release( p_input_thread );
return i_ret;
} }
/****************************************************************************** /******************************************************************************
* libvlc_video_set_deinterlace : enable deinterlace * libvlc_video_set_deinterlace : enable deinterlace
*****************************************************************************/ *****************************************************************************/
void libvlc_video_set_deinterlace( libvlc_media_player_t *p_mi, int b_enable, void libvlc_video_set_deinterlace( libvlc_media_player_t *p_mi,
const char *psz_mode, const char *psz_mode )
libvlc_exception_t *p_e ) {
{ if (psz_mode == NULL)
vout_thread_t *p_vout = GetVout( p_mi, p_e ); psz_mode = "";
if (*psz_mode
if( !p_vout ) && strcmp (psz_mode, "blend") && strcmp (psz_mode, "bob")
&& strcmp (psz_mode, "discard") && strcmp (psz_mode, "linear")
&& strcmp (psz_mode, "mean") && strcmp (psz_mode, "x")
&& strcmp (psz_mode, "yadif") && strcmp (psz_mode, "yadif2x"))
return; return;
if( b_enable ) if (*psz_mode)
{ {
/* be sure that the filter name given is supported */ var_SetString (p_mi, "deinterlace-mode", psz_mode);
if( !strcmp(psz_mode, "blend") || !strcmp(psz_mode, "bob") var_SetInteger (p_mi, "deinterlace", 1);
|| !strcmp(psz_mode, "discard") || !strcmp(psz_mode, "linear")
|| !strcmp(psz_mode, "mean") || !strcmp(psz_mode, "x")
|| !strcmp(psz_mode, "yadif") || !strcmp(psz_mode, "yadif2x") )
{
/* set deinterlace filter chosen */
var_SetString( p_vout, "deinterlace-mode", psz_mode );
var_SetInteger( p_vout, "deinterlace", 1 );
}
else
{
libvlc_exception_raise( p_e );
libvlc_printerr( "Bad or unsupported deinterlacing mode" );
}
} }
else else
var_SetInteger (p_mi, "deinterlace", 0);
size_t n;
vout_thread_t **pp_vouts = GetVouts (p_mi, &n);
for (size_t i = 0; i < n; i++)
{ {
/* disable deinterlace filter */ vout_thread_t *p_vout = pp_vouts[i];
var_SetInteger( p_vout, "deinterlace", 0 );
}
vlc_object_release( p_vout ); if (*psz_mode)
{
var_SetString (p_vout, "deinterlace-mode", psz_mode);
var_SetInteger (p_vout, "deinterlace", 1);
}
else
var_SetInteger (p_vout, "deinterlace", 0);
vlc_object_release (p_vout);
}
free (pp_vouts);
} }
/* ************** */ /* ************** */
/* module helpers */ /* module helpers */
/* ************** */ /* ************** */
...@@ -593,7 +547,7 @@ static vlc_object_t *get_object( libvlc_media_player_t * p_mi, ...@@ -593,7 +547,7 @@ static vlc_object_t *get_object( libvlc_media_player_t * p_mi,
const char *name, libvlc_exception_t *p_e ) const char *name, libvlc_exception_t *p_e )
{ {
vlc_object_t *object = NULL; vlc_object_t *object = NULL;
vout_thread_t *vout = GetVout( p_mi, p_e ); vout_thread_t *vout = GetVout( p_mi, 0 );
libvlc_exception_clear( p_e ); libvlc_exception_clear( p_e );
if( vout ) if( vout )
{ {
...@@ -623,8 +577,7 @@ set_int( libvlc_media_player_t *p_mi, const char *name, ...@@ -623,8 +577,7 @@ set_int( libvlc_media_player_t *p_mi, const char *name,
if( !opt->type ) /* the enabler */ if( !opt->type ) /* the enabler */
{ {
vout_thread_t *vout = GetVout( p_mi, p_e ); vout_thread_t *vout = GetVout( p_mi, 0 );
libvlc_exception_clear( p_e );
if (vout) if (vout)
{ {
vout_EnableFilter( vout, opt->name, value, false ); vout_EnableFilter( vout, opt->name, value, false );
......
...@@ -167,6 +167,7 @@ libvlc_track_description_release ...@@ -167,6 +167,7 @@ libvlc_track_description_release
libvlc_video_get_aspect_ratio libvlc_video_get_aspect_ratio
libvlc_video_get_chapter_description libvlc_video_get_chapter_description
libvlc_video_get_crop_geometry libvlc_video_get_crop_geometry
libvlc_video_get_size
libvlc_video_get_height libvlc_video_get_height
libvlc_video_get_logo_int libvlc_video_get_logo_int
libvlc_video_get_marquee_int libvlc_video_get_marquee_int
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment