Update theme submodule
[platform/upstream/gstreamer.git] / examples / tutorials / android-tutorial-1 / jni / tutorial-1.c
1 #include <string.h>
2 #include <jni.h>
3 #include <android/log.h>
4 #include <gst/gst.h>
5
6 /*
7  * Java Bindings
8  */
9 static jstring gst_native_get_gstreamer_info (JNIEnv* env, jobject thiz) {
10   char *version_utf8 = gst_version_string();
11   jstring *version_jstring = (*env)->NewStringUTF(env, version_utf8);
12   g_free (version_utf8);
13   return version_jstring;
14 }
15
16 static JNINativeMethod native_methods[] = {
17   { "nativeGetGStreamerInfo", "()Ljava/lang/String;", (void *) gst_native_get_gstreamer_info}
18 };
19
20 jint JNI_OnLoad(JavaVM *vm, void *reserved) {
21   JNIEnv *env = NULL;
22
23   if ((*vm)->GetEnv(vm, (void**) &env, JNI_VERSION_1_4) != JNI_OK) {
24     __android_log_print (ANDROID_LOG_ERROR, "tutorial-1", "Could not retrieve JNIEnv");
25     return 0;
26   }
27   jclass klass = (*env)->FindClass (env, "org/freedesktop/gstreamer/tutorials/tutorial_1/Tutorial1");
28   (*env)->RegisterNatives (env, klass, native_methods, G_N_ELEMENTS(native_methods));
29
30   return JNI_VERSION_1_4;
31 }