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 * );
/** 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
* \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?
......@@ -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
* as to libvlc_set_fullscreen().
*
* \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
* 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
*
* \param p_mediaplayer the media player
* \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.
*
* \param p_mediaplayer the media player
* \param p_e an initialized exception pointer
* \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
......@@ -557,35 +555,48 @@ void libvlc_video_set_key_input( libvlc_media_player_t *mp, unsigned on );
VLC_PUBLIC_API
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.
* You should use libvlc_video_get_size() instead.
*
* \param p_mediaplayer the media player
* \param p_e an initialized exception pointer
* \return the video height
* \return the video pixel height or 0 if not applicable
*/
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.
* You should use libvlc_video_get_size() instead.
*
* \param p_mediaplayer the media player
* \param p_e an initialized exception pointer
* \return the video width
* \return the video pixel width or 0 if not applicable
*/
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.
* See also libvlc_video_set_scale().
*
* \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
* to fit to the output window/drawable automatically.
*/
VLC_PUBLIC_API float libvlc_video_get_scale( libvlc_media_player_t *,
libvlc_exception_t *p_e );
VLC_PUBLIC_API float libvlc_video_get_scale( libvlc_media_player_t * );
/**
* 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 *,
*
* \param p_mediaplayer the media player
* \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,
libvlc_exception_t *p_e );
VLC_PUBLIC_API void libvlc_video_set_scale( libvlc_media_player_t *, float );
/**
* Get current video aspect ratio.
*
* \param p_mediaplayer the media player
* \param p_e an initialized exception pointer
* \return the video aspect ratio
* \return the video aspect ratio or NULL if unspecified
* (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.
*
* \param p_mediaplayer the media player
* \param psz_aspect new video aspect-ratio
* \param p_e an initialized exception pointer
* \param psz_aspect new video aspect-ratio or NULL to reset to default
* \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.
*
* \param p_mediaplayer the media player
* \param p_e an initialized exception pointer
* \return the video subtitle selected
* \return the video subtitle selected, or -1 if none
*/
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.
*
* \param p_mediaplayer the media player
* \param p_e an initialized exception pointer
* \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.
......@@ -653,9 +660,9 @@ VLC_PUBLIC_API libvlc_track_description_t *
*
* \param p_mediaplayer the media player
* \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.
......@@ -692,19 +699,18 @@ VLC_PUBLIC_API libvlc_track_description_t *
* Get current crop filter geometry.
*
* \param p_mediaplayer the media player
* \param p_e an initialized exception pointer
* \return the crop filter geometry
* \return the crop filter geometry or NULL if unset
*/
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.
*
* \param p_mediaplayer the media player
* \param psz_geometry new crop filter geometry
* \param p_e an initialized exception pointer
* \param psz_geometry new crop filter geometry (NULL to unset)
*/
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.
......@@ -726,7 +732,6 @@ VLC_PUBLIC_API int libvlc_video_get_track_count( libvlc_media_player_t * );
* Get the description of available video tracks.
*
* \param p_mi media player
* \param p_e an initialized exception
* \return list with description of available video tracks, or NULL on error
*/
VLC_PUBLIC_API libvlc_track_description_t *
......@@ -736,19 +741,19 @@ VLC_PUBLIC_API libvlc_track_description_t *
* Get current video track.
*
* \param p_mi media player
* \param p_e an initialized exception pointer
* \return the video track (int)
* \return the video track (int) or -1 if none
*/
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.
*
* \param p_mi media player
* \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.
......@@ -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.
*
* \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 i_width the snapshot's width
* \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
*
* \param p_mi libvlc media player
* \param b_enable boolean to enable or disable deinterlace filter
* \param psz_mode type of deinterlace filter to use
* \param p_e an initialized exception pointer
* \param psz_mode type of deinterlace filter, NULL to disable
*/
VLC_PUBLIC_API void libvlc_video_set_deinterlace( libvlc_media_player_t *,
int , const char *,
libvlc_exception_t *);
const char * );
/**
* Get an integer marquee option value
......
......@@ -356,7 +356,17 @@ libvlc_media_player_new( libvlc_instance_t *instance )
var_Create (mp, "mouse-events", VLC_VAR_BOOL);
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);
mp->p_md = NULL;
......
......@@ -44,27 +44,41 @@
/*
* Remember to release the returned vout_thread_t.
*/
static vout_thread_t *GetVout( libvlc_media_player_t *p_mi,
libvlc_exception_t *p_exception )
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 );
vout_thread_t *p_vout = NULL;
if( !p_input )
return NULL;
if( p_input )
{
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
vout_thread_t **pp_vouts;
if (input_Control( p_input, INPUT_GET_VOUTS, &pp_vouts, n))
{
libvlc_exception_raise( p_exception );
libvlc_printerr( "No active input" );
*n = 0;
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;
}
......@@ -72,49 +86,43 @@ static vout_thread_t *GetVout( libvlc_media_player_t *p_mi,
* Exported functions
**********************************************************************/
void libvlc_set_fullscreen( libvlc_media_player_t *p_mi, int b_fullscreen,
libvlc_exception_t *p_e )
void libvlc_set_fullscreen( libvlc_media_player_t *p_mi, int b_fullscreen )
{
/* We only work on the first vout */
vout_thread_t *p_vout = GetVout( p_mi, p_e );
/* GetVout will raise the exception for us */
if( !p_vout ) return;
/* This will work even if the video is not currently active */
var_SetBool (p_mi, "fullscreen", !!b_fullscreen);
var_SetBool( p_vout, "fullscreen", b_fullscreen );
vlc_object_release( p_vout );
/* 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++)
{
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,
libvlc_exception_t *p_e )
int libvlc_get_fullscreen( libvlc_media_player_t *p_mi )
{
/* We only work on the first vout */
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;
return var_GetBool (p_mi, "fullscreen");
}
void libvlc_toggle_fullscreen( libvlc_media_player_t *p_mi,
libvlc_exception_t *p_e )
void libvlc_toggle_fullscreen( libvlc_media_player_t *p_mi )
{
/* We only work on the first vout */
vout_thread_t *p_vout = GetVout( p_mi, p_e );
/* GetVout will raise the exception for us */
if( !p_vout ) return;
var_ToggleBool (p_mi, "fullscreen");
bool b_fullscreen = var_GetBool (p_mi, "fullscreen");
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 )
......@@ -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);
}
void
libvlc_video_take_snapshot( libvlc_media_player_t *p_mi, const char *psz_filepath,
unsigned int i_width, unsigned int i_height, libvlc_exception_t *p_e )
int
libvlc_video_take_snapshot( libvlc_media_player_t *p_mi, unsigned num,
const char *psz_filepath,
unsigned int i_width, unsigned int i_height )
{
vout_thread_t *p_vout;
assert( psz_filepath );
/* We must have an input */
if( !p_mi->p_input_thread )
{
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;
vout_thread_t *p_vout = GetVout (p_mi, num);
if (p_vout == NULL)
return -1;
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_SetString( p_vout, "snapshot-path", psz_filepath );
var_SetString( p_vout, "snapshot-format", "png" );
var_TriggerCallback( p_vout, "video-snapshot" );
vlc_object_release( p_vout );
var_TriggerCallback (p_vout, "video-snapshot" );
return 0;
}
int libvlc_video_get_height( libvlc_media_player_t *p_mi,
libvlc_exception_t *p_e )
int libvlc_video_get_size( libvlc_media_player_t *p_mi, unsigned num,
unsigned *restrict px, unsigned *restrict py )
{
int height;
vout_thread_t *p_vout = GetVout( p_mi, p_e );
if( !p_vout ) return 0;
vout_thread_t *p_vout = GetVout (p_mi, num);
if (p_vout == NULL)
return -1;
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;
}
int libvlc_video_get_width( libvlc_media_player_t *p_mi,
libvlc_exception_t *p_e )
int libvlc_video_get_width( libvlc_media_player_t *p_mi )
{
int 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 );
unsigned height, width;
if (libvlc_video_get_size (p_mi, 0, &height, &width))
return 0;
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);
bool has_vout = false;
if( p_input_thread )
{
vout_thread_t *p_vout;
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;
size_t n;
vout_thread_t **pp_vouts = GetVouts (p_mi, &n);
for (size_t i = 0; i < n; i++)
vlc_object_release (pp_vouts[i]);
free (pp_vouts);
return n;
}
float libvlc_video_get_scale( libvlc_media_player_t *p_mp,
libvlc_exception_t *p_e )
float libvlc_video_get_scale( libvlc_media_player_t *mp )
{
vout_thread_t *p_vout = GetVout( p_mp, p_e );
if( !p_vout )
return 0.;
float f_scale = var_GetFloat( p_vout, "scale" );
if( var_GetBool( p_vout, "autoscale" ) )
float f_scale = var_GetFloat (mp, "scale");
if (var_GetBool (mp, "autoscale"))
f_scale = 0.;
vlc_object_release( p_vout );
return f_scale;
}
void libvlc_video_set_scale( libvlc_media_player_t *p_mp, float f_scale,
libvlc_exception_t *p_e )
void libvlc_video_set_scale( libvlc_media_player_t *p_mp, float f_scale )
{
vout_thread_t *p_vout = GetVout( p_mp, p_e );
if( !p_vout )
return;
if (f_scale != 0.)
var_SetFloat (p_mp, "scale", f_scale);
var_SetBool (p_mp, "autoscale", f_scale != 0.);
if( f_scale != 0. )
var_SetFloat( p_vout, "scale", f_scale );
var_SetBool( p_vout, "autoscale", f_scale != 0. );
vlc_object_release( p_vout );
/* Apply to current video outputs (if any) */
size_t n;
vout_thread_t **pp_vouts = GetVouts (p_mp, &n);
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,
libvlc_exception_t *p_e )
char *libvlc_video_get_aspect_ratio( libvlc_media_player_t *p_mi )
{
char *psz_aspect = NULL;
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("");
return var_GetNonEmptyString (p_mi, "aspect-ratio");
}
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 );
int i_ret = -1;
if( !p_vout ) return;
if (psz_aspect == NULL)
psz_aspect = "";
var_SetString (p_mi, "aspect-ratio", psz_aspect);
i_ret = var_SetString( p_vout, "aspect-ratio", psz_aspect );
vlc_object_release( p_vout );
if( i_ret )
size_t n;
vout_thread_t **pp_vouts = GetVouts (p_mi, &n);
for (size_t i = 0; i < n; i++)
{
libvlc_exception_raise( p_e );
libvlc_printerr( "Bad or unsupported aspect ratio" );
vout_thread_t *p_vout = pp_vouts[i];
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,
libvlc_exception_t *p_e )
int libvlc_video_get_spu( libvlc_media_player_t *p_mi )
{
input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi );
vlc_value_t val_list;
......@@ -276,7 +261,6 @@ int libvlc_video_get_spu( libvlc_media_player_t *p_mi,
if( !p_input_thread )
{
libvlc_exception_raise( p_e );
libvlc_printerr( "No active input" );
return -1;
}
......@@ -285,9 +269,8 @@ int libvlc_video_get_spu( libvlc_media_player_t *p_mi,
if( i_ret < 0 )
{
vlc_object_release( p_input_thread );
libvlc_exception_raise( p_e );
libvlc_printerr( "Subtitle informations not found" );
return i_ret;
return -1;
}
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,
return i_spu;
}
int libvlc_video_get_spu_count( libvlc_media_player_t *p_mi,
libvlc_exception_t *p_e )
int libvlc_video_get_spu_count( libvlc_media_player_t *p_mi )
{
input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi );
int i_spu_count;
if( !p_input_thread )
{
libvlc_exception_raise( p_e );
libvlc_printerr( "No active input" );
return -1;
}
return 0;
i_spu_count = var_CountChoices( p_input_thread, "spu-es" );
vlc_object_release( p_input_thread );
return i_spu_count;
}
......@@ -329,42 +306,30 @@ libvlc_track_description_t *
return libvlc_get_track_description( p_mi, "spu-es" );
}
void libvlc_video_set_spu( libvlc_media_player_t *p_mi, int i_spu,
libvlc_exception_t *p_e )
int libvlc_video_set_spu( libvlc_media_player_t *p_mi, unsigned i_spu )
{
input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi );
vlc_value_t val_list;
vlc_value_t newval;
int i_ret = -1;
vlc_value_t list;
int i_ret = 0;
if( !p_input_thread )
{
libvlc_exception_raise( p_e );
libvlc_printerr( "No active input" );
return;
}
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, &list, NULL);
if( ( val_list.p_list->i_count == 0 )
|| (i_spu < 0) || (i_spu > val_list.p_list->i_count) )
if (i_spu > (unsigned)list.p_list->i_count)
{
libvlc_exception_raise( p_e );
libvlc_printerr( "Subtitle number out of range" );
libvlc_printerr( "Subtitle number out of range (%u/%u)",
i_spu, list.p_list->i_count );
i_ret = -1;
goto end;
}
newval = val_list.p_list->p_values[i_spu];
i_ret = var_Set( p_input_thread, "spu-es", newval );
if( i_ret < 0 )
{
libvlc_exception_raise( p_e );
libvlc_printerr( "Subtitle selection error" );
}
var_SetInteger (p_input_thread, "spu-es",
list.p_list->p_values[i_spu].i_int);
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,
......@@ -397,35 +362,30 @@ libvlc_track_description_t *