Commit 82e4cda8 authored by Jean-Paul Saman's avatar Jean-Paul Saman

(Forward port of [17371]) Implement Aspect Ratio property for Mozilla plugin

parent e86b20c4
...@@ -137,10 +137,12 @@ void libvlc_destroy( libvlc_instance_t *, libvlc_exception_t * ); ...@@ -137,10 +137,12 @@ void libvlc_destroy( libvlc_instance_t *, libvlc_exception_t * );
* LibVLC Playlist handling * LibVLC Playlist handling
* @{ * @{
*/ */
/** /**
* Set loop variable * Set loop variable
*/ */
void libvlc_playlist_loop( libvlc_instance_t* , vlc_bool_t, libvlc_exception_t * ); void libvlc_playlist_loop( libvlc_instance_t* , vlc_bool_t, libvlc_exception_t * );
/** /**
* Start playing. You can give some additionnal playlist item options * Start playing. You can give some additionnal playlist item options
* that will be added to the item before playing it. * that will be added to the item before playing it.
...@@ -239,7 +241,7 @@ int libvlc_playlist_add_extended( libvlc_instance_t *, const char *, ...@@ -239,7 +241,7 @@ int libvlc_playlist_add_extended( libvlc_instance_t *, const char *,
*/ */
int libvlc_playlist_delete_item( libvlc_instance_t *, int, int libvlc_playlist_delete_item( libvlc_instance_t *, int,
libvlc_exception_t * ); libvlc_exception_t * );
typedef struct libvlc_input_t libvlc_input_t; typedef struct libvlc_input_t libvlc_input_t;
/* Get the input that is currently being played by the playlist /* Get the input that is currently being played by the playlist
...@@ -276,7 +278,7 @@ vlc_bool_t libvlc_input_will_play ( libvlc_input_t *, libvlc_exception_t * ...@@ -276,7 +278,7 @@ vlc_bool_t libvlc_input_will_play ( libvlc_input_t *, libvlc_exception_t *
float libvlc_input_get_rate ( libvlc_input_t *, libvlc_exception_t *); float libvlc_input_get_rate ( libvlc_input_t *, libvlc_exception_t *);
void libvlc_input_set_rate ( libvlc_input_t *, float, libvlc_exception_t *); void libvlc_input_set_rate ( libvlc_input_t *, float, libvlc_exception_t *);
int libvlc_input_get_state ( libvlc_input_t *, libvlc_exception_t *); int libvlc_input_get_state ( libvlc_input_t *, libvlc_exception_t *);
/** @} */ /** @} */
/** defgroup libvlc_video Video /** defgroup libvlc_video Video
...@@ -315,7 +317,7 @@ void libvlc_set_fullscreen( libvlc_input_t *, int, libvlc_exception_t * ); ...@@ -315,7 +317,7 @@ void libvlc_set_fullscreen( libvlc_input_t *, int, libvlc_exception_t * );
* \return the fullscreen status (boolean) * \return the fullscreen status (boolean)
*/ */
int libvlc_get_fullscreen( libvlc_input_t *, libvlc_exception_t * ); int libvlc_get_fullscreen( libvlc_input_t *, libvlc_exception_t * );
/** /**
* Get current video height * Get current video height
* \param p_input the input * \param p_input the input
...@@ -332,6 +334,22 @@ int libvlc_video_get_height( libvlc_input_t *, libvlc_exception_t * ); ...@@ -332,6 +334,22 @@ int libvlc_video_get_height( libvlc_input_t *, libvlc_exception_t * );
*/ */
int libvlc_video_get_width( libvlc_input_t *, libvlc_exception_t * ); int libvlc_video_get_width( libvlc_input_t *, libvlc_exception_t * );
/**
* Get current video aspect ratio
* \param p_input the input
* \param p_exception an initialized exception
* \return the video aspect ratio
*/
char *libvlc_video_get_aspect_ratio( libvlc_input_t *, libvlc_exception_t * );
/**
* Set new video aspect ratio
* \param p_input the input
* \param psz_aspect new video aspect-ratio
* \param p_exception an initialized exception
*/
void libvlc_video_set_aspect_ratio( libvlc_input_t *, char *, libvlc_exception_t * );
/** /**
* Take a snapshot of the current video window * Take a snapshot of the current video window
* \param p_input the input * \param p_input the input
...@@ -339,10 +357,9 @@ int libvlc_video_get_width( libvlc_input_t *, libvlc_exception_t * ); ...@@ -339,10 +357,9 @@ int libvlc_video_get_width( libvlc_input_t *, libvlc_exception_t * );
* \param p_exception an initialized exception * \param p_exception an initialized exception
*/ */
void libvlc_video_take_snapshot( libvlc_input_t *, char *, libvlc_exception_t * ); void libvlc_video_take_snapshot( libvlc_input_t *, char *, libvlc_exception_t * );
int libvlc_video_destroy( libvlc_input_t *, libvlc_exception_t *); int libvlc_video_destroy( libvlc_input_t *, libvlc_exception_t *);
/** /**
* Resize the current video output window * Resize the current video output window
* \param p_instance libvlc instance * \param p_instance libvlc instance
...@@ -352,7 +369,7 @@ int libvlc_video_destroy( libvlc_input_t *, libvlc_exception_t *); ...@@ -352,7 +369,7 @@ int libvlc_video_destroy( libvlc_input_t *, libvlc_exception_t *);
* \return the mute status (boolean) * \return the mute status (boolean)
*/ */
void libvlc_video_resize( libvlc_input_t *, int, int, libvlc_exception_t *); void libvlc_video_resize( libvlc_input_t *, int, int, libvlc_exception_t *);
/** /**
* Downcast to this general type as placeholder for a platform specific one, such as: * Downcast to this general type as placeholder for a platform specific one, such as:
* Drawable on X11, * Drawable on X11,
...@@ -453,7 +470,6 @@ vlc_bool_t libvlc_audio_get_mute( libvlc_instance_t *, libvlc_exception_t * ); ...@@ -453,7 +470,6 @@ vlc_bool_t libvlc_audio_get_mute( libvlc_instance_t *, libvlc_exception_t * );
*/ */
void libvlc_audio_set_mute( libvlc_instance_t *, vlc_bool_t , libvlc_exception_t * ); void libvlc_audio_set_mute( libvlc_instance_t *, vlc_bool_t , libvlc_exception_t * );
/** /**
* Get current audio level * Get current audio level
* \param p_instance libvlc instance * \param p_instance libvlc instance
...@@ -462,7 +478,6 @@ void libvlc_audio_set_mute( libvlc_instance_t *, vlc_bool_t , libvlc_exception_t ...@@ -462,7 +478,6 @@ void libvlc_audio_set_mute( libvlc_instance_t *, vlc_bool_t , libvlc_exception_t
*/ */
int libvlc_audio_get_volume( libvlc_instance_t *, libvlc_exception_t * ); int libvlc_audio_get_volume( libvlc_instance_t *, libvlc_exception_t * );
/** /**
* Set current audio level * Set current audio level
* \param p_instance libvlc instance * \param p_instance libvlc instance
...@@ -539,9 +554,6 @@ void libvlc_vlm_set_input( libvlc_instance_t *, char *, char*, ...@@ -539,9 +554,6 @@ void libvlc_vlm_set_input( libvlc_instance_t *, char *, char*,
void libvlc_vlm_set_loop( libvlc_instance_t *, char *, int, void libvlc_vlm_set_loop( libvlc_instance_t *, char *, int,
libvlc_exception_t *); libvlc_exception_t *);
/** /**
* Edit the parameters of a media. This will delete all existing inputs and * Edit the parameters of a media. This will delete all existing inputs and
* add the specified one. * add the specified one.
...@@ -563,7 +575,7 @@ void libvlc_vlm_change_media( libvlc_instance_t *, char *, char *, char* , ...@@ -563,7 +575,7 @@ void libvlc_vlm_change_media( libvlc_instance_t *, char *, char *, char* ,
* \param p_instance the instance * \param p_instance the instance
* \param psz_name the name of the broadcast * \param psz_name the name of the broadcast
* \param p_exception an initialized exception * \param p_exception an initialized exception
*/ */
void libvlc_vlm_play_media ( libvlc_instance_t *, char *, libvlc_exception_t * ); void libvlc_vlm_play_media ( libvlc_instance_t *, char *, libvlc_exception_t * );
/** /**
...@@ -574,7 +586,6 @@ void libvlc_vlm_play_media ( libvlc_instance_t *, char *, libvlc_exception_t * ) ...@@ -574,7 +586,6 @@ void libvlc_vlm_play_media ( libvlc_instance_t *, char *, libvlc_exception_t * )
*/ */
void libvlc_vlm_stop_media ( libvlc_instance_t *, char *, libvlc_exception_t * ); void libvlc_vlm_stop_media ( libvlc_instance_t *, char *, libvlc_exception_t * );
/** /**
* Pauses the named broadcast. * Pauses the named broadcast.
* \param p_instance the instance * \param p_instance the instance
...@@ -643,6 +654,7 @@ typedef struct libvlc_log_message_t ...@@ -643,6 +654,7 @@ typedef struct libvlc_log_message_t
const char *psz_header; /* optional header */ const char *psz_header; /* optional header */
const char *psz_message; /* message */ const char *psz_message; /* message */
} libvlc_log_message_t; } libvlc_log_message_t;
/** /**
* Returns the VLC messaging verbosity level * Returns the VLC messaging verbosity level
* \param p_instance libvlc instance * \param p_instance libvlc instance
......
...@@ -1078,7 +1078,7 @@ enum LibvlcPlaylistNPObjectMethodIds ...@@ -1078,7 +1078,7 @@ enum LibvlcPlaylistNPObjectMethodIds
ID_next, ID_next,
ID_prev, ID_prev,
ID_clear, ID_clear,
ID_removeitem, ID_removeitem
}; };
RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant &result) RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant &result)
...@@ -1323,7 +1323,7 @@ RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::invoke(int index, const NP ...@@ -1323,7 +1323,7 @@ RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::invoke(int index, const NP
} }
return INVOKERESULT_GENERIC_ERROR; return INVOKERESULT_GENERIC_ERROR;
} }
void LibvlcPlaylistNPObject::parseOptions(const NPString &s, int *i_options, char*** ppsz_options) void LibvlcPlaylistNPObject::parseOptions(const NPString &s, int *i_options, char*** ppsz_options)
{ {
if( s.utf8length ) if( s.utf8length )
...@@ -1460,6 +1460,7 @@ const NPUTF8 * const LibvlcVideoNPObject::propertyNames[] = ...@@ -1460,6 +1460,7 @@ const NPUTF8 * const LibvlcVideoNPObject::propertyNames[] =
"fullscreen", "fullscreen",
"height", "height",
"width", "width",
"aspectRatio"
}; };
enum LibvlcVideoNPObjectPropertyIds enum LibvlcVideoNPObjectPropertyIds
...@@ -1467,6 +1468,7 @@ enum LibvlcVideoNPObjectPropertyIds ...@@ -1467,6 +1468,7 @@ enum LibvlcVideoNPObjectPropertyIds
ID_fullscreen, ID_fullscreen,
ID_height, ID_height,
ID_width, ID_width,
ID_aspectratio
}; };
const int LibvlcVideoNPObject::propertyCount = sizeof(LibvlcVideoNPObject::propertyNames)/sizeof(NPUTF8 *); const int LibvlcVideoNPObject::propertyCount = sizeof(LibvlcVideoNPObject::propertyNames)/sizeof(NPUTF8 *);
...@@ -1528,6 +1530,22 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::getProperty(int index, NPVari ...@@ -1528,6 +1530,22 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::getProperty(int index, NPVari
INT32_TO_NPVARIANT(val, result); INT32_TO_NPVARIANT(val, result);
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
case ID_aspectratio:
{
NPUTF8 *psz_aspect = libvlc_video_get_aspect_ratio(p_input, &ex);
libvlc_input_free(p_input);
if( libvlc_exception_raised(&ex) )
{
NPN_SetException(this, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
return INVOKERESULT_GENERIC_ERROR;
}
if( !psz_aspect )
return INVOKERESULT_GENERIC_ERROR;
STRINGZ_TO_NPVARIANT(psz_aspect, result);
return INVOKERESULT_NO_ERROR;
}
} }
libvlc_input_free(p_input); libvlc_input_free(p_input);
} }
...@@ -1571,6 +1589,33 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::setProperty(int index, const ...@@ -1571,6 +1589,33 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::setProperty(int index, const
} }
return INVOKERESULT_NO_ERROR; return INVOKERESULT_NO_ERROR;
} }
case ID_aspectratio:
{
char *psz_aspect = NULL;
if( ! NPVARIANT_IS_STRING(value) )
{
libvlc_input_free(p_input);
return INVOKERESULT_INVALID_VALUE;
}
psz_aspect = stringValue(NPVARIANT_TO_STRING(value));
if( !psz_aspect )
return INVOKERESULT_GENERIC_ERROR;
libvlc_video_set_aspect_ratio(p_input, psz_aspect, &ex);
if( psz_aspect )
free(psz_aspect );
libvlc_input_free(p_input);
if( libvlc_exception_raised(&ex) )
{
NPN_SetException(this, libvlc_exception_get_message(&ex));
libvlc_exception_clear(&ex);
return INVOKERESULT_GENERIC_ERROR;
}
return INVOKERESULT_NO_ERROR;
}
} }
libvlc_input_free(p_input); libvlc_input_free(p_input);
} }
......
...@@ -210,7 +210,6 @@ vlc_bool_t libvlc_input_has_vout( libvlc_input_t *p_input, ...@@ -210,7 +210,6 @@ vlc_bool_t libvlc_input_has_vout( libvlc_input_t *p_input,
return VLC_TRUE; return VLC_TRUE;
} }
int libvlc_video_reparent( libvlc_input_t *p_input, libvlc_drawable_t d, int libvlc_video_reparent( libvlc_input_t *p_input, libvlc_drawable_t d,
libvlc_exception_t *p_e ) libvlc_exception_t *p_e )
{ {
...@@ -305,7 +304,7 @@ void libvlc_video_set_viewport( libvlc_instance_t *p_instance, ...@@ -305,7 +304,7 @@ void libvlc_video_set_viewport( libvlc_instance_t *p_instance,
libvlc_input_t *p_input = libvlc_playlist_get_input(p_instance, p_e); libvlc_input_t *p_input = libvlc_playlist_get_input(p_instance, p_e);
if( p_input ) if( p_input )
{ {
vout_thread_t *p_vout = GetVout( p_input, p_e ); vout_thread_t *p_vout = GetVout( p_input, p_e );
if( p_vout ) if( p_vout )
{ {
/* change viewport for running vout */ /* change viewport for running vout */
...@@ -319,6 +318,37 @@ void libvlc_video_set_viewport( libvlc_instance_t *p_instance, ...@@ -319,6 +318,37 @@ void libvlc_video_set_viewport( libvlc_instance_t *p_instance,
} }
} }
char *libvlc_video_get_aspect_ratio( libvlc_input_t *p_input,
libvlc_exception_t *p_e )
{
char *psz_aspect = 0;
vout_thread_t *p_vout = GetVout( p_input, p_e );
if( !p_vout )
return 0;
psz_aspect = var_GetString( p_vout1, "aspect-ratio" );
vlc_object_release( p_vout );
return psz_aspect;
}
void libvlc_video_set_aspect_ratio( libvlc_input_t *p_input,
char *psz_aspect, libvlc_exception_t *p_e )
{
vout_thread_t *p_vout = GetVout( p_input, p_e );
int i_ret = -1;
if( !p_vout )
return;
i_ret = var_SetString( p_vout, "aspect-ratio", psz_aspect );
if( i_ret )
libvlc_exception_raise( p_e,
"Unexpected error while setting aspect-ratio value" );
vlc_object_release( p_vout );
}
int libvlc_video_destroy( libvlc_input_t *p_input, int libvlc_video_destroy( libvlc_input_t *p_input,
libvlc_exception_t *p_e ) libvlc_exception_t *p_e )
{ {
......
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