Commit 7d6c6693 authored by Jean-Paul Saman's avatar Jean-Paul Saman

Implement Aspect Ratio property for Mozilla plugin

parent 4a31256b
......@@ -236,7 +236,7 @@ int libvlc_playlist_add_extended( libvlc_instance_t *, const char *,
*/
int libvlc_playlist_delete_item( libvlc_instance_t *, int,
libvlc_exception_t * );
typedef struct libvlc_input_t libvlc_input_t;
/* Get the input that is currently being played by the playlist
......@@ -273,7 +273,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 *);
void libvlc_input_set_rate ( libvlc_input_t *, float, libvlc_exception_t *);
int libvlc_input_get_state ( libvlc_input_t *, libvlc_exception_t *);
/** @} */
/** defgroup libvlc_video Video
......@@ -312,7 +312,7 @@ void libvlc_set_fullscreen( libvlc_input_t *, int, libvlc_exception_t * );
* \return the fullscreen status (boolean)
*/
int libvlc_get_fullscreen( libvlc_input_t *, libvlc_exception_t * );
/**
* Get current video height
* \param p_input the input
......@@ -329,6 +329,22 @@ int libvlc_video_get_height( 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
* \param p_input the input
......@@ -336,7 +352,7 @@ int libvlc_video_get_width( libvlc_input_t *, libvlc_exception_t * );
* \param p_exception an initialized exception
*/
void libvlc_video_take_snapshot( libvlc_input_t *, char *, libvlc_exception_t * );
int libvlc_video_destroy( libvlc_input_t *, libvlc_exception_t *);
/**
......@@ -348,7 +364,7 @@ int libvlc_video_destroy( libvlc_input_t *, libvlc_exception_t *);
* \return the mute status (boolean)
*/
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:
* Drawable on X11,
......@@ -443,7 +459,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 * );
/**
* Get current audio level
* \param p_instance libvlc instance
......@@ -452,7 +467,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 * );
/**
* Set current audio level
* \param p_instance libvlc instance
......@@ -529,9 +543,6 @@ void libvlc_vlm_set_input( libvlc_instance_t *, char *, char*,
void libvlc_vlm_set_loop( libvlc_instance_t *, char *, int,
libvlc_exception_t *);
/**
* Edit the parameters of a media. This will delete all existing inputs and
* add the specified one.
......@@ -553,7 +564,7 @@ void libvlc_vlm_change_media( libvlc_instance_t *, char *, char *, char* ,
* \param p_instance the instance
* \param psz_name the name of the broadcast
* \param p_exception an initialized exception
*/
*/
void libvlc_vlm_play_media ( libvlc_instance_t *, char *, libvlc_exception_t * );
/**
......@@ -561,19 +572,16 @@ void libvlc_vlm_play_media ( libvlc_instance_t *, char *, libvlc_exception_t * )
* \param p_instance the instance
* \param psz_name the name of the broadcast
* \param p_exception an initialized exception
*/
*/
void libvlc_vlm_stop_media ( libvlc_instance_t *, char *, libvlc_exception_t * );
/**
* Pauses the named broadcast.
* \param p_instance the instance
* \param psz_name the name of the broadcast
* \param p_exception an initialized exception
*/
*/
void libvlc_vlm_pause_media( libvlc_instance_t *, char *, libvlc_exception_t * );
/** @} */
/** @} */
......
......@@ -623,7 +623,7 @@ enum LibvlcPlaylistNPObjectMethodIds
ID_next,
ID_prev,
ID_clear,
ID_removeitem,
ID_removeitem
};
RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::invoke(int index, const NPVariant *args, uint32_t argCount, NPVariant &result)
......@@ -868,7 +868,7 @@ RuntimeNPObject::InvokeResult LibvlcPlaylistNPObject::invoke(int index, const NP
}
return INVOKERESULT_GENERIC_ERROR;
}
void LibvlcPlaylistNPObject::parseOptions(const NPString &s, int *i_options, char*** ppsz_options)
{
if( s.utf8length )
......@@ -1005,6 +1005,7 @@ const NPUTF8 * const LibvlcVideoNPObject::propertyNames[] =
"fullscreen",
"height",
"width",
"aspectRatio"
};
enum LibvlcVideoNPObjectPropertyIds
......@@ -1012,6 +1013,7 @@ enum LibvlcVideoNPObjectPropertyIds
ID_fullscreen,
ID_height,
ID_width,
ID_aspectratio
};
const int LibvlcVideoNPObject::propertyCount = sizeof(LibvlcVideoNPObject::propertyNames)/sizeof(NPUTF8 *);
......@@ -1073,6 +1075,22 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::getProperty(int index, NPVari
INT32_TO_NPVARIANT(val, result);
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);
}
......@@ -1116,6 +1134,33 @@ RuntimeNPObject::InvokeResult LibvlcVideoNPObject::setProperty(int index, const
}
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);
}
......
......@@ -213,7 +213,6 @@ vlc_bool_t libvlc_input_has_vout( libvlc_input_t *p_input,
return VLC_TRUE;
}
int libvlc_video_reparent( libvlc_input_t *p_input, libvlc_drawable_t d,
libvlc_exception_t *p_e )
{
......@@ -308,7 +307,7 @@ void libvlc_video_set_viewport( libvlc_instance_t *p_instance,
libvlc_input_t *p_input = libvlc_playlist_get_input(p_instance, p_e);
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 )
{
/* change viewport for running vout */
......@@ -322,6 +321,35 @@ 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_vout1 = GetVout( p_input, p_e );
if( !p_vout1 )
return 0;
psz_aspect = var_GetString( p_vout1, "aspect-ratio" );
vlc_object_release( p_vout1 );
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_vout1 = GetVout( p_input, p_e );
int i_ret = -1;
if( !p_vout1 )
return;
i_ret = var_SetString( p_vout1, "aspect-ratio", psz_aspect );
if( i_ret )
libvlc_exception_raise( p_e,
"Unexpected error while setting aspect-ratio value" );
}
int libvlc_video_destroy( libvlc_input_t *p_input,
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