Thursday, January 24, 2013

Android JNI tips

So many time I thought - wtf with this function signature. Then I found that I can copy signature from .class file. And it was success.

After that I no need more to look at JNI signature spec. But today all changes))) I found javap command))) so

nika@nika_gt ~/work/Android/Test/VideoLoopback $ javap -s -classpath ./bin/classes com.dummy.android.loopback.JavaCapturer
Compiled from "JavaCapturer.java"
public class com.dummy.android.loopback.JavaCapturer extends java.lang.Object implements android.hardware.Camera$PreviewCallback{
native void setJCPreviewDisplay(android.hardware.Camera, android.view.Surface);
  Signature: (Landroid/hardware/Camera;Landroid/view/Surface;)V
native void processFrame(byte[], int, int);
  Signature: ([BII)V
protected native boolean fillPreviewRes(int[]);
  Signature: ([I)Z
public static com.dummy.android.loopback.JavaCapturer Init();
  Signature: ()Lcom/dummy/android/loopback/JavaCapturer;
public synchronized void CameraStart(android.view.Surface, int);
  Signature: (Landroid/view/Surface;I)V
public synchronized void CameraStop();
  Signature: ()V
public void onPreviewFrame(byte[], android.hardware.Camera);
  Signature: ([BLandroid/hardware/Camera;)V
static {};
  Signature: ()V
}


crap))) it's wonderful))) And for native func declaration (if you nerd like me and use vim for Android dev instead of fat eclipse)

javah  -verbose -classpath ./bin/classes com.dummy.AndroidUA.CapturerInterface

will create header file with function declaration))) I will save much time with these tweaks during JNI development.

1 comment: