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

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

index 9c942ab..318fff3 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
 
diff --git a/THANKS b/THANKS
index 6df278d..2d42511 100644 (file)
--- a/THANKS
+++ b/THANKS
@@ -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/org/videolan/jvlc/GenericVideoWidget.java b/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 99bfe14..a7274df 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 26120d4..0e62066 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 1039618..8b0d333 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 630794d..4615d83 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
  */