]> git.sesse.net Git - vlc/commitdiff
bindings for new audio functions, thanks to Philippe Morin
authorFilippo Carone <littlejohn@videolan.org>
Sat, 16 Dec 2006 11:05:17 +0000 (11:05 +0000)
committerFilippo Carone <littlejohn@videolan.org>
Sat, 16 Dec 2006 11:05:17 +0000 (11:05 +0000)
bindings/java/VLCExample.java
bindings/java/org/videolan/jvlc/Audio.java
bindings/java/org/videolan/jvlc/AudioIntf.java
bindings/java/src/audio-jni.cc

index 5660a4700cd1b858ea2afc4136e4df478802cc10..25ab90668e0ca0405041394e9f74a72a95913c68 100644 (file)
@@ -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 ;)");
index a0c53a65d98c9dcaefcbada5f7ce31078bb817ef..c94e317e2318d82936a90f2f34c07a71938998be 100644 (file)
@@ -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 );
         
     }
index 6d656069bbe79201bf003dd16c3d6c347ee1cd55..1dd7b9e1436186384c50a8f8937b664736667521 100644 (file)
 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
index 6d90b925154f44139e72d0c04791de8d6635bfb2..695f8ed1287c55bcca0fb09e77d4a2e7f2edbe59 100644 (file)
@@ -4,6 +4,7 @@
  * Copyright (C) 1998-2006 the VideoLAN team
  *
  * Authors: Filippo Carone <filippo@carone.org>
+ *          Philippe Morin <phmorin@free.fr>
  *
  *
  * $Id $
 #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;
     
@@ -50,8 +99,8 @@ JNIEXPORT void JNICALL Java_org_videolan_jvlc_Audio__1setMute (JNIEnv *env, jobj
     INIT_FUNCTION;
 
     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;
 }
-