Question

I am building a video system, which contains video capture from camera, video encode and video mux.

I want to use the encode in C level, since there is some algorithm I want to implement before the data is sent to the encoder.

There is a 'native-media' project in NDK samples, in which it calls OMX functions in C level to do the video decode and play stuff, but it seems that NDK doesn't support encode of OMX now, is that true?

I've successfully used MediaCodec API in Java level, if NDK doesn't support encode of OMX, can I use the MediaCodec API through C code?

Was it helpful?

Solution

Yes, from C code you can call Java methods. For example, if we want to call the method x.doSomething(5), supposing x is an instance of class MyClass in the "com.example.ndk" package and the method returns void, we can use:

jclass cls = (*env)->FindClass(env, "com/example/ndk/MyClass");

jmethodID mid = (*env)->GetMethodID(env, cls, "doSomething", "(I)V");

(*env)->CallObjectMethod(env, x, mid, 5);

Where:

  • "env" is the JNIEnv pointer which you receive in the C JNI method (read here for information about the JNIEnv pointer and native methods).
  • "(I)V" is the method signature, which in this case it says that the method has an int parameter (I), and returns void (V).
  • "x" is a jobject obtained in some previous *env function (here you can find all of JNI functions pointed by env).
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top