Commit 16941507 authored by ivoire's avatar ivoire

Create a libVLC java class as an interface for all jni calls.

parent 11cdd63f
......@@ -3,8 +3,31 @@
#include <vlc/libvlc.h>
#include "libvlcjni.h"
jstring Java_vlc_android_vlc_getLibvlcVersion(JNIEnv* env, jobject thiz)
{
jlong Java_vlc_android_libVLC_init(JNIEnv *env, jobject thiz)
{
const char *argv[] = { "-I dummy", "-vvv", "--no-plugins-cache" };
return (jlong)libvlc_new_with_builtins( 3, argv, vlc_builtins_modules );
}
void Java_vlc_android_libVLC_destroy(JNIEnv *env, jobject thiz, jlong instance)
{
libvlc_instance_t *p_instance = (libvlc_instance_t*)instance;
libvlc_release(p_instance);
}
jstring Java_vlc_android_libVLC_version(JNIEnv* env, jobject thiz)
{
return (*env)->NewStringUTF(env, libvlc_get_version());
}
jstring Java_vlc_android_libVLC_compiler(JNIEnv* env, jobject thiz)
{
return (*env)->NewStringUTF(env, libvlc_get_compiler());
}
jstring Java_vlc_android_libVLC_changeset(JNIEnv* env, jobject thiz)
{
return (*env)->NewStringUTF(env, libvlc_get_changeset());
}
package vlc.android;
public class libVLC {
/**
* Constructor
*/
public libVLC()
{
System.loadLibrary("vlcjni");
};
/**
* Destructor
*/
public void finalize()
{
if(this.p_instance != 0)
this.destroy(p_instance);
}
/**
* Initialize the libVLC class
* @return true if the libVLC C library was created correctly, false overwise
*/
public boolean Init()
{
this.p_instance = this.init();
return this.p_instance != 0;
}
/** libVLC instance C pointer */
private long p_instance;
/**
* Initialize the libvlc C library
* @return a pointer to the libvlc instance
*/
private native long init();
/**
* Close the libvlc C library
* @param instance: the instance of libVLC
*/
private native void destroy(long instance);
/**
* Get the libVLC version
* @return the libVLC version string
*/
public native String version();
/**
* Get the libVLC compiler
* @return the libVLC compiler string
*/
public native String compiler();
/**
* Get the libVLC changeset
* @return the libVLC changeset string
*/
public native String changeset();
}
package vlc.android;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
......@@ -14,18 +15,20 @@ public class vlc extends Activity {
TextView tv = new TextView(this);
try
{
System.loadLibrary("vlcjni");
tv.setText("Loaded libVLC version:" + getLibvlcVersion());
}
catch (UnsatisfiedLinkError e)
{
tv.setText("Couldn't load libVLC. :-(");
}
// Create the libVLC instance
libVLC libvlc = new libVLC();
if(libvlc.Init())
tv.setText("Loaded libVLC:\n* version: " + libvlc.version() +
"\n* compiler: " + libvlc.compiler() +
"\n* changeset: " + libvlc.changeset() +
"\n* libvlccore loaded\n");
else
tv.setText("Loaded libVLC:\n* version: " + libvlc.version() +
"\n* compiler: " + libvlc.compiler() +
"\n* changeset: " + libvlc.changeset() +
"\n* libvlccore failed!!!\n");
setContentView(tv);
}
public native String getLibvlcVersion();
}
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