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

Implement Aspect Ratio property for Mozilla plugin

parent 4a31256b
......@@ -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
......@@ -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.
......@@ -564,7 +575,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 * );
/**
* Pauses the named broadcast.
* \param p_instance the instance
......@@ -573,8 +583,6 @@ void libvlc_vlm_stop_media ( libvlc_instance_t *, char *, libvlc_exception_t * )
*/
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)
......@@ -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 )
{
......@@ -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