]> git.sesse.net Git - vlc/commitdiff
Java bindings update.
authorFilippo Carone <littlejohn@videolan.org>
Sat, 10 Jun 2006 13:58:03 +0000 (13:58 +0000)
committerFilippo Carone <littlejohn@videolan.org>
Sat, 10 Jun 2006 13:58:03 +0000 (13:58 +0000)
* new JVLC.destroy() method to cleanup a JVLC object
* new GenericVideoWidget for general use (thx: Kuldipsingh Pabla)
* Status class removed
* new JVLC.isInputPlaying() and JVLC.hasVout() methods

bindings/java/Makefile.am
bindings/java/THANKS
bindings/java/org/videolan/jvlc/GenericVideoWidget.java [new file with mode: 0644]
bindings/java/org/videolan/jvlc/JVLC.java
bindings/java/org/videolan/jvlc/Playlist.java
bindings/java/org/videolan/jvlc/VideoIntf.java
bindings/java/vlc-libvlc-jni.cc

index 9c942ab872aec301a31e56f9e04eb710f80f00d7..318fff3bc5ede33173eeb8decd5f05bda82658ea 100644 (file)
@@ -4,7 +4,7 @@
 
 if BUILD_JAVA
 
-OBJECTS = org/videolan/jvlc/AudioIntf.class org/videolan/jvlc/InputIntf.class org/videolan/jvlc/PlaylistIntf.class org/videolan/jvlc/VideoIntf.class org/videolan/jvlc/JLibVLC.class org/videolan/jvlc/JVLC.class org/videolan/jvlc/JVLCCanvas.class org/videolan/jvlc/JVLCPanel.class org/videolan/jvlc/VLMIntf.class org/videolan/jvlc/Playlist.class org/videolan/jvlc/Status.class
+OBJECTS = org/videolan/jvlc/AudioIntf.class org/videolan/jvlc/InputIntf.class org/videolan/jvlc/PlaylistIntf.class org/videolan/jvlc/VideoIntf.class org/videolan/jvlc/JLibVLC.class org/videolan/jvlc/JVLC.class org/videolan/jvlc/JVLCCanvas.class org/videolan/jvlc/JVLCPanel.class org/videolan/jvlc/VLMIntf.class org/videolan/jvlc/Playlist.class org/videolan/jvlc/GenericVideoWidget.class
 
 JNIHEADERS = org_videolan_jvlc_JVLC.h org_videolan_jvlc_JVLCCanvas.h org_videolan_jvlc_JVLCPanel.h
 
index 6df278d0bd053234e3224146a41fd4dd5a1b0420..2d4251186215886f09777f230b413178b94e43b1 100644 (file)
@@ -2,6 +2,7 @@ Thanks to:
 
 * Kuldipsingh Pabla
   for solaris port and various contributions to the native interface.
+  for the GenericVideoWidget class
 
 * Tvrtko Bedekovic
   for initial win32 port
diff --git a/bindings/java/org/videolan/jvlc/GenericVideoWidget.java b/bindings/java/org/videolan/jvlc/GenericVideoWidget.java
new file mode 100644 (file)
index 0000000..ff23f3a
--- /dev/null
@@ -0,0 +1,59 @@
+/*****************************************************************************
+ * SWTVideoWidget.java: A component usable in SWT Application, embeds JVLC
+ *****************************************************************************
+ *
+ * Copyright (C) 1998-2006 the VideoLAN team
+ * 
+ * Author: Kuldipsingh Pabla <Kuldipsingh.Pabla@sun.com>
+ * 
+ * Created on 10-jun-2006
+ *
+ * $Id $
+ *
+ * This program is free software; you can redistribute it
+ * and/or modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * 
+ */
+
+
+package org.videolan.jvlc;
+import java.awt.Frame;
+import java.awt.Component;
+
+
+public class GenericVideoWidget {
+    /*
+     * This class implements a Composite container for VLC Video Output
+     */
+
+    /*
+     * The root SWT Frame we embed JVLCCanvas in
+     */
+    public Frame rootFrame;
+    private JVLCCanvas jvlcCanvas;
+    
+    public GenericVideoWidget( Component parent ) {
+       // allocate the new AWT Frame to embed in the Composite
+       rootFrame = new Frame ();
+
+       // add the JVLCCanvas to the Frame
+       jvlcCanvas = new JVLCCanvas();
+       rootFrame.add( jvlcCanvas );
+    }
+    
+    
+       public JVLC getJVLC() {
+               return jvlcCanvas.getJVLC();
+       }
+}
index 99bfe14d20f0db08150d03a92d166a18f85ae9eb..a7274df21d0a629ac037804be142128442ab79de 100644 (file)
 
 package org.videolan.jvlc;
 
-public class JVLC implements JLibVLC {
+/**
+ * @author little
+ *
+ */
+public class JVLC implements JLibVLC, Runnable {
     
     static {
         System.load(System.getProperty( "user.dir" ) + "/libjvlc.so" );
     }
 
+    /**
+     * These are set as final since they live along the jvlc object
+     */
+    private final long _instance;
+    public  final Playlist playlist;
 
-    private long _instance;
-    public Playlist playlist;
-    public Status status;      
+    
+    private boolean beingDestroyed = false;
+    private long resolution = 50;
+       private boolean inputPlaying = false;
+       private boolean inputVout = false;
     
     public JVLC() {
         _instance = createInstance();
         playlist = new Playlist( _instance );
-        status = new Status(this);
+        new Thread(this).start();
     }
     
     public JVLC(String[] args) {
         _instance = createInstance( args );
         playlist = new Playlist( _instance );
-        status = new Status(this);
+        new Thread(this).start();
     }
     
-    /*
+    
+    /**
+     * Destroys the current instance of jvlc, cleaning up objects.
+     * This is unreversible.
+     */
+    public void destroy() {
+       beingDestroyed = true;
+       _destroy();
+    }
+
+       /*
      * Core methods
      */
     private native long createInstance();
     private native long createInstance( String[] args );
-    
+    private native void _destroy();   
     /*
      *         Audio native methods
      */
@@ -170,5 +192,60 @@ public class JVLC implements JLibVLC {
        public void getSnapshot(String filename) {
                _getSnapshot(filename);
        }
+       
+       /**
+        * Checks if the input is playing.
+        * @return True if there is a playing input.
+        */
+       public boolean isInputPlaying() {
+               return inputPlaying;
+       }
+
+       /**
+        * Checks if the input has spawned a video window.
+        * @return True if there is a video window.
+        */
+       public boolean hasVout() {
+               return inputVout;
+       }
+
+       /*
+        * (non-Javadoc)
+        * @see java.lang.Runnable#run()
+        * 
+        * In this thread we check the playlist and input status.
+        */
+       public void run() {
+               while (! beingDestroyed) {
+                       while (playlist.isRunning()) {
+                               if (playlist.inputIsPlaying()) {
+                                       inputPlaying = true;
+                               }
+                               else {
+                                       inputPlaying = false;
+                }
+                           
+                               if (playlist.inputHasVout()) {
+                                       inputVout = true;
+                }
+                               else {
+                                       inputVout = false;
+                }
+                               try {
+                                       Thread.sleep(resolution);
+                               } catch (InterruptedException e) {
+                                       e.printStackTrace();
+                               } 
+                       } // while playlist running
+                  inputPlaying = false;
+                  inputVout = false;
+                       try {
+                               Thread.sleep(resolution);
+                       } catch (InterruptedException e) {
+                               e.printStackTrace();
+                       } // try
+               } // while ! being destroyed
+       } // run
 
 }
+
index 26120d49a07cc8ab40727cb9b5d0aeeb19dde7f9..0e620662662d43ea7db68da423f27fedf37beecc 100644 (file)
@@ -93,11 +93,7 @@ public class Playlist implements PlaylistIntf {
     }
 
     public synchronized void clear() {
-       /*
-        * This method has been commented out until
-        * playlist_Clear has been fixed in vlc.
-        */
-        //_clear();
+       _clear();
     }
 
     public synchronized int add(String uri, String name, String[] options) {
index 10396185c5e9c5c6e602096831bad8e3f18f6b83..8b0d333cd89cdb03fec78358fb6e95a38bfe2158 100644 (file)
 
 package org.videolan.jvlc;
 
+/**
+ * @author little
+ *
+ */
+/**
+ * @author little
+ *
+ */
 public interface VideoIntf {
-    void toggleFullscreen();
-    void setFullscreen( boolean value );
+    /**
+     * Toggles the fullscreen.
+     */
+    void       toggleFullscreen();
+    
+    
+    /**
+     * Sets fullscreen if fullscreen argument is true. 
+     * @param fullscreen
+     */
+    void       setFullscreen( boolean fullscreen );
+    
+    
+    /**
+     * @return True if the current video window is in fullscreen mode.
+     */
     boolean getFullscreen();
-    void getSnapshot(String filepath);
-    int getVideoHeight();
-    int getVideoWidth();
     
+    
+    /**
+     * Saves a snapshot of the current video window.
+     * @param filepath The full path (including filename) were to save the snapshot to.
+     */
+    void       getSnapshot(String filepath);
+    
+    
+    /**
+     * @return The current video window height
+     */
+    int                getVideoHeight();
+
+    /**
+     * @return The current video window width
+     */
+    int                getVideoWidth();    
 }
index 630794df8b33ec92e8b6232348b009825bdacdf8..4615d83bff34073803940bb3bb54b6a7d07cc68e 100644 (file)
@@ -91,6 +91,20 @@ JNIEXPORT jlong JNICALL Java_org_videolan_jvlc_JVLC_createInstance___3Ljava_lang
 
 }
 
+JNIEXPORT void JNICALL Java_org_videolan_jvlc_JVLC__1destroy (JNIEnv *env, jobject _this) 
+{
+    long instance;
+    
+    instance = getClassInstance( env, _this );
+
+    libvlc_destroy( (libvlc_instance_t *) instance);
+
+    return;
+}
+
+
+
+
 /*
  * Audio native functions
  */