Commit c26e07cd authored by Filippo Carone's avatar Filippo Carone

integrate patch from Ticket #725. needs testing.

parent b6eebc11
......@@ -88,6 +88,7 @@ Jeroen Massar <jeroen at unfix dot org> - IPv6 hostname resolution fix
Jérôme Guilbaud - Update of the WinAmp 5 VLC skin
Joel Arvidsson <dogai at privat.utfors.se> - Swedish translation
Joeri van Dooren <joeri at van.dooren.be> - OS X icon (v0.4.0)
Jörg<vlc-ml at aab.noctis dot de> - VLM seek/show media functions
Johen Michael Zorko <zorko at att.net> - fix for delay issues in udp sout
John Paul Lorenti <jpl31 at columbia.edu> - ALSA device selection patch
Jonas Larsen <jonas at vrt.dk> - Danish translation
......
......@@ -19,6 +19,15 @@ public class VLM implements VLMIntf {
private native void _playMedia(String mediaName);
private native void _stopMedia(String mediaName);
private native void _pauseMedia(String mediaName);
private native void _seekMedia(String mediaName, float percentage);
private native String _showMedia(String mediaName);
private native float _getMediaposition(String name, int mediaInstance);
private native int _getMediatime(String name, int mediaInstance);
private native int _getMedialength(String name, int mediaInstance);
private native int _getMediarate(String name, int mediaInstance);
private native int _getMediatitle(String name, int mediaInstance);
private native int _getMediachapter(String name, int mediaInstance);
private native int _getMediaseekable(String name, int mediaInstance);
public VLM( long instance ) {
this.libvlcInstance = instance;
......@@ -68,6 +77,43 @@ public class VLM implements VLMIntf {
_pauseMedia(name);
}
public void seekMedia(String name, float percentage) throws VLCException {
_seekMedia(name, percentage);
}
public String showMedia(String name) throws VLCException {
return _showMedia(name);
}
public float getMediaPosition(String name, int mediaInstance) throws VLCException {
return _getMediaposition(name, mediaInstance);
}
public int getMediaTime(String name, int mediaInstance) throws VLCException {
return _getMediatime(name, mediaInstance);
}
public int getMediaLength(String name, int mediaInstance) throws VLCException {
return _getMedialength(name, mediaInstance);
}
public int getMediaRate(String name, int mediaInstance) throws VLCException {
return _getMediarate(name, mediaInstance);
}
public int getMediaTitle(String name, int mediaInstance) throws VLCException {
return _getMediatitle(name, mediaInstance);
}
public int getMediaChapter(String name, int mediaInstance) throws VLCException {
return _getMediachapter(name, mediaInstance);
}
public boolean getMediaSeekable(String name, int mediaInstance) throws VLCException {
return _getMediaseekable(name, mediaInstance) > 0;
}
public long getInstance() {
return libvlcInstance;
}
......
......@@ -200,7 +200,7 @@ JNIEXPORT void JNICALL Java_org_videolan_jvlc_Video__1reparent (JNIEnv *env, job
XSetBackground(dsi_x11->display, gc, 0);
/* and reparent */
libvlc_video_reparent( input, dsi_x11->drawable, exception );
libvlc_video_reparent( input, (libvlc_drawable_t)dsi_x11->drawable, exception );
CHECK_EXCEPTION_FREE ;
......
......@@ -217,3 +217,61 @@ JNIEXPORT void JNICALL Java_org_videolan_jvlc_VLM__1pauseMedia (JNIEnv *env, job
}
}
JNIEXPORT void JNICALL Java_org_videolan_jvlc_VLM__1seekMedia (JNIEnv *env, jobject _this, jstring name, jfloat percentage)
{
INIT_FUNCTION;
const char* psz_name = env->GetStringUTFChars( name, 0 );
libvlc_vlm_seek_media( (libvlc_instance_t *) instance, (char*)psz_name, (float)percentage, exception );
CHECK_EXCEPTION_FREE ;
if (psz_name != NULL) {
env->ReleaseStringUTFChars( name, psz_name );
}
}
JNIEXPORT jstring JNICALL Java_org_videolan_jvlc_VLM__1showMedia (JNIEnv *env, jobject _this, jstring name)
{
INIT_FUNCTION;
const char* psz_name = env->GetStringUTFChars( name, 0 );
char *psz_response;
jstring js_response;
psz_response = libvlc_vlm_show_media( (libvlc_instance_t *) instance, (char*)psz_name, exception );
CHECK_EXCEPTION_FREE ;
if (psz_name != NULL) {
env->ReleaseStringUTFChars( name, psz_name );
}
js_response = env->NewStringUTF(psz_response);
if (psz_response != NULL) {
free(psz_response);
}
return js_response;
}
#define LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( attr, returnType, dummyGetType, dummyDefault)\
JNIEXPORT j ## returnType JNICALL Java_org_videolan_jvlc_VLM__1getMedia ## attr(JNIEnv *env, jobject _this, jstring name, jint index) \
{ \
INIT_FUNCTION; \
const char* psz_name = env->GetStringUTFChars( name, 0 ); \
returnType response; \
\
response = libvlc_vlm_get_media_ ## attr( (libvlc_instance_t *) instance, (char*)psz_name, (int)index, exception ); \
CHECK_EXCEPTION_FREE ; \
\
if (psz_name != NULL) { \
env->ReleaseStringUTFChars( name, psz_name ); \
} \
return response; \
}
LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( position, float, Float, -1);
LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( time, int, Integer, -1);
LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( length, int, Integer, -1);
LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( rate, int, Integer, -1);
LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( title, int, Integer, 0);
LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( chapter, int, Integer, 0);
LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( seekable, int, Bool, 0);
#undef LIBVLC_VLM_GET_MEDIA_ATTRIBUTE
......@@ -580,7 +580,37 @@ void libvlc_vlm_stop_media ( libvlc_instance_t *, char *, libvlc_exception_t * )
*/
void libvlc_vlm_pause_media( libvlc_instance_t *, char *, libvlc_exception_t * );
/**
* Seeks in the named broadcast.
* \param p_instance the instance
* \param psz_name the name of the broadcast
* \param f_percentage the percentage to seek to
* \param p_exception an initialized exception
*/
void libvlc_vlm_seek_media( libvlc_instance_t *, char *,
float, libvlc_exception_t * );
/**
* Return information of the named broadcast.
* \param p_instance the instance
* \param psz_name the name of the broadcast
* \param p_exception an initialized exception
*/
char* libvlc_vlm_show_media( libvlc_instance_t *, char *, libvlc_exception_t * );
#define LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( attr, returnType, getType, default)\
returnType libvlc_vlm_get_media_## attr( libvlc_instance_t *, \
char *, int , libvlc_exception_t * );
LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( position, float, Float, -1);
LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( time, int, Integer, -1);
LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( length, int, Integer, -1);
LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( rate, int, Integer, -1);
LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( title, int, Integer, 0);
LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( chapter, int, Integer, 0);
LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( seekable, int, Bool, 0);
#undef LIBVLC_VLM_GET_MEDIA_ATTRIBUTE
/** @} */
/** @} */
......
......@@ -290,6 +290,141 @@ void libvlc_vlm_pause_media( libvlc_instance_t *p_instance, char *psz_name,
libvlc_exception_raise( p_exception, "Unable to pause %s",
psz_name );
}
free( psz_message);
free( psz_message );
#endif
}
void libvlc_vlm_seek_media( libvlc_instance_t *p_instance, char *psz_name,
float f_percentage, libvlc_exception_t *p_exception )
{
char *psz_message;
vlm_message_t *answer;
CHECK_VLM;
#ifdef ENABLE_VLM
asprintf( &psz_message, "control %s seek %f", psz_name, f_percentage );
vlm_ExecuteCommand( p_instance->p_vlm, psz_message, &answer );
if( answer->psz_value )
{
libvlc_exception_raise( p_exception, "Unable to seek %s to %f",
psz_name, f_percentage );
}
free( psz_message );
#endif
}
#ifdef ENABLE_VLM
#define LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( attr, returnType, getType, default)\
returnType libvlc_vlm_get_media_## attr( libvlc_instance_t *p_instance, \
char *psz_name, int i_instance, \
libvlc_exception_t *p_exception ) \
{ \
vlm_media_instance_t *p_media_instance; \
CHECK_VLM; \
vlm_media_t *p_media; \
p_media = vlm_MediaSearch( p_instance->p_vlm, psz_name ); \
if ( p_media == NULL ) \
{ \
libvlc_exception_raise( p_exception, "Unable to find media %s", \
psz_name); \
} \
else \
{ \
if ( i_instance < p_media->i_instance ) \
{ \
p_media_instance = p_media->instance[ i_instance ]; \
return var_Get ## getType( p_media_instance->p_input, #attr );\
} \
else \
{ \
libvlc_exception_raise( p_exception, "Media index %i out of range",\
i_instance); \
} \
} \
return default; \
}
#else
#define LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( attr, returnType, getType, default)\
returnType libvlc_vlm_get_media_## attr( libvlc_instance_t *p_instance, \
char *psz_name, int i_instance, libvlc_exception_t *p_exception ) \
{ \
char *psz_message; \
vlm_message_t *answer; \
CHECK_VLM; \
return default; \
}
#endif
LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( position, float, Float, -1);
LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( time, int, Integer, -1);
LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( length, int, Integer, -1);
LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( rate, int, Integer, -1);
LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( title, int, Integer, 0);
LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( chapter, int, Integer, 0);
LIBVLC_VLM_GET_MEDIA_ATTRIBUTE( seekable, int, Bool, 0);
#undef LIBVLC_VLM_GET_MEDIA_ATTRIBUTE
char* libvlc_vlm_show_media( libvlc_instance_t *p_instance, char *psz_name,
libvlc_exception_t *p_exception )
{
char* recurse_answer( char* psz_prefix, vlm_message_t *p_answer ) {
char* psz_childprefix;
char* psz_response="";
char* response_tmp;
int i;
vlm_message_t *aw_child, **paw_child;
asprintf( &psz_childprefix, "%s%s.", psz_prefix, p_answer->psz_name );
if ( p_answer->i_child )
{
paw_child = p_answer->child;
aw_child = *( paw_child );
for( i = 0; i < p_answer->i_child; i++ )
{
asprintf( &response_tmp, "%s%s%s:%s\n",
psz_response, psz_prefix, aw_child->psz_name,
aw_child->psz_value );
free( psz_response );
psz_response = response_tmp;
if ( aw_child->i_child )
{
asprintf(&response_tmp, "%s%s", psz_response,
recurse_answer(psz_childprefix, aw_child));
free( psz_response );
psz_response = response_tmp;
}
paw_child++;
aw_child = *( paw_child );
}
}
free( psz_childprefix );
return psz_response;
}
char *psz_message;
vlm_message_t *answer;
char *psz_response;
CHECK_VLM;
#ifdef ENABLE_VLM
asprintf( &psz_message, "show %s", psz_name );
asprintf( &psz_response, "", psz_name );
vlm_ExecuteCommand( p_instance->p_vlm, psz_message, &answer );
if( answer->psz_value )
{
libvlc_exception_raise( p_exception, "Unable to call show %s: %s",
psz_name, answer->psz_value );
}
else
{
if ( answer->child )
{
psz_response = recurse_answer( "", answer );
}
}
free( psz_message );
return(psz_response );
#endif
}
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