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.
...@@ -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
...@@ -342,7 +360,6 @@ void libvlc_video_take_snapshot( libvlc_input_t *, char *, libvlc_exception_t * ...@@ -342,7 +360,6 @@ 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
...@@ -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.
...@@ -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)
...@@ -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 )
{ {
...@@ -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