Commit f17ac07e authored by Filippo Carone's avatar Filippo Carone

bindings for new audio functions, thanks to Philippe Morin

parent 24977cae
......@@ -10,7 +10,8 @@ public class VLCExample
boolean videoInput = false;
JVLC jvlc = new JVLC(args);
try {
jvlc.playlist.add("file://" + System.getProperty( "user.dir" ) + "/a.avi", "a.avi");
//jvlc.playlist.add("file://" + System.getProperty( "user.dir" ) + "/a.avi", "a.avi");
jvlc.playlist.add("file:///home/little/a.avi", "a.avi");
jvlc.playlist.add("file://" + System.getProperty( "user.dir" ) + "/a.mp3", "a.mp3");
jvlc.playlist.play( -1 , null );
} catch (VLCException e) {
......@@ -65,6 +66,15 @@ public class VLCExample
System.out.print("Setting volume to 150... ");
jvlc.audio.setVolume(150);
System.out.println("done");
System.out.println("Audio channel info: " + jvlc.audio.getChannel());
System.out.println("Audio track info: " + jvlc.audio.getTrack());
System.out.print("Setting left channel... ");
jvlc.audio.setChannel("left");
System.out.print("done.");
Thread.sleep(3000);
System.out.print("Setting right channel... ");
jvlc.audio.setChannel("right");
System.out.print("done.");
Thread.sleep(3000);
System.out.println("INPUT INFORMATION");
System.out.println("-----------------");
......@@ -81,6 +91,7 @@ public class VLCExample
{
System.out.println("Something was wrong. I die :(.");
jvlc.destroy();
e.printStackTrace();
}
System.out.println("Everything fine ;)");
......
......@@ -4,6 +4,10 @@ public class Audio implements AudioIntf {
private long libvlcInstance;
private native int _getTrack();
private native void _setTrack(int track);
private native String _getChannel();
private native void _setChannel(String channel);
private native boolean _getMute();
private native void _setMute( boolean value );
private native void _toggleMute();
......@@ -14,11 +18,27 @@ public class Audio implements AudioIntf {
this.libvlcInstance = instance;
}
public int getTrack() throws VLCException {
return _getTrack();
}
public void setTrack( int track ) throws VLCException {
_setTrack(track);
}
public String getChannel() throws VLCException {
return _getChannel();
}
public void setChannel( String channel ) throws VLCException {
_setChannel(channel);
}
public boolean getMute() throws VLCException {
return _getMute();
}
public void setMute(boolean value) throws VLCException {
public void setMute( boolean value ) throws VLCException {
_setMute( value );
}
......
......@@ -30,6 +30,56 @@
package org.videolan.jvlc;
public interface AudioIntf {
/**
* Constant for left channel audio
*/
final String LEFT_CHANNEL = "left";
/**
* Constant for right channel audio
*/
final String RIGHT_CHANNEL = "right";
/**
* Constant for reverse channel audio
*/
final String REVERSE_CHANNEL = "reverse";
/**
* Constant for stereo channel audio
*/
final String STEREO_CHANNEL = "stereo";
/**
* Constant for dolby channel audio
*/
final String DOLBY_CHANNEL = "dolby";
/**
* @return audio track
* @throws VLCException
*/
int getTrack() throws VLCException;
/**
* @param audio track
* @throws VLCException
*/
void setTrack(int track) throws VLCException;
/**
* @return channel
* @throws VLCException
*/
String getChannel() throws VLCException;
/**
* @param channel
* @throws VLCException
*/
void setChannel(String channel) throws VLCException;
/**
* @return True if input is currently muted.
* @throws VLCException
......
......@@ -4,6 +4,7 @@
* Copyright (C) 1998-2006 the VideoLAN team
*
* Authors: Filippo Carone <filippo@carone.org>
* Philippe Morin <phmorin@free.fr>
*
*
* $Id $
......@@ -32,6 +33,54 @@
#include "../includes/Audio.h"
#include "utils.h"
JNIEXPORT jint JNICALL Java_org_videolan_jvlc_Audio__1getTrack (JNIEnv *env, jobject _this)
{
INIT_FUNCTION;
jint res = 0;
res = libvlc_audio_get_track( ( libvlc_instance_t * ) instance, exception );
CHECK_EXCEPTION_FREE;
return res;
}
JNIEXPORT void JNICALL Java_org_videolan_jvlc_Audio__1setTrack (JNIEnv *env, jobject _this, jint value)
{
INIT_FUNCTION;
libvlc_audio_set_track( ( libvlc_instance_t * ) instance, value, exception );
CHECK_EXCEPTION_FREE;
}
JNIEXPORT jstring JNICALL Java_org_videolan_jvlc_Audio__1getChannel (JNIEnv *env, jobject _this)
{
INIT_FUNCTION;
char* res;
res = libvlc_audio_get_channel( (libvlc_instance_t *) instance, exception);
CHECK_EXCEPTION_FREE;
return env->NewStringUTF(res);
}
JNIEXPORT void JNICALL Java_org_videolan_jvlc_Audio__1setChannel (JNIEnv *env, jobject _this, jstring channel)
{
INIT_FUNCTION;
const char* value = env->GetStringUTFChars( channel, 0 );
libvlc_audio_set_channel( (libvlc_instance_t *) instance, (char *) value, exception);
env->ReleaseStringUTFChars( channel, value );
CHECK_EXCEPTION_FREE;
}
JNIEXPORT jboolean JNICALL Java_org_videolan_jvlc_Audio__1getMute (JNIEnv *env, jobject _this)
{
INIT_FUNCTION;
......@@ -39,7 +88,7 @@ JNIEXPORT jboolean JNICALL Java_org_videolan_jvlc_Audio__1getMute (JNIEnv *env,
res = (jboolean) libvlc_audio_get_mute( ( libvlc_instance_t * ) instance, exception );
CHECK_EXCEPTION;
CHECK_EXCEPTION_FREE;
return res;
......@@ -51,7 +100,7 @@ JNIEXPORT void JNICALL Java_org_videolan_jvlc_Audio__1setMute (JNIEnv *env, jobj
libvlc_audio_set_mute( ( libvlc_instance_t * ) instance, value, exception );
CHECK_EXCEPTION;
CHECK_EXCEPTION_FREE;
}
JNIEXPORT void JNICALL Java_org_videolan_jvlc_Audio__1toggleMute (JNIEnv *env, jobject _this)
......@@ -60,7 +109,7 @@ JNIEXPORT void JNICALL Java_org_videolan_jvlc_Audio__1toggleMute (JNIEnv *env, j
libvlc_audio_get_mute( ( libvlc_instance_t * ) instance, exception );
CHECK_EXCEPTION;
CHECK_EXCEPTION_FREE;
}
JNIEXPORT jint JNICALL Java_org_videolan_jvlc_Audio__1getVolume (JNIEnv *env, jobject _this)
......@@ -70,7 +119,7 @@ JNIEXPORT jint JNICALL Java_org_videolan_jvlc_Audio__1getVolume (JNIEnv *env, jo
res = libvlc_audio_get_volume( ( libvlc_instance_t * ) instance, exception );
CHECK_EXCEPTION;
CHECK_EXCEPTION_FREE;
return res;
}
......@@ -81,6 +130,5 @@ JNIEXPORT void JNICALL Java_org_videolan_jvlc_Audio__1setVolume (JNIEnv *env, jo
libvlc_audio_set_volume( ( libvlc_instance_t * ) instance, volume, exception );
CHECK_EXCEPTION;
CHECK_EXCEPTION_FREE;
}
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