5

I'm writing an application that shows video. The application is written using the Android NDK and JNI.

I want to use OpenMAX. In the OpenMAX example, it retrieves the surface from Java, but where I can get the surface to render? I can get a nativeWindow only through applicationContext.

Example:

void Java_com_example_nativemedia_NativeMedia_setSurface(JNIEnv *env, jclass clazz, jobject surface)                
{   
    theNativeWindow = ANativeWindow_fromSurface(env, surface);  
}

But I don't have the surface.

Thanks

James M
  • 18,506
  • 3
  • 48
  • 56

1 Answers1

0

The surface is retrieved from the SurfaceHolder that is passed in as a parameter in the methods in SurfaceHolder.Callback, ie surfaceChanged or surfaceCreated.

Look for where the JNI function setSurface is called by Java:

wilhelm\tests\native-media\src\com\example\nativemedia\NativeMedia.java

Peter Tran
  • 1,626
  • 1
  • 17
  • 26
  • but . i dont have a surfaceView. where i can get surfaceHolder. example on java + c++ . application only on c++. i may create surfaceview on c++ with jni? – Constantine Kuznetsov Jan 18 '13 at 11:08
  • 1
    Constantine, are you writing a 100% native C++ app? Are you using NativeActivity? If so then according to [NativeActivity docs](http://developer.android.com/reference/android/app/NativeActivity.html) you should be able to implement [SurfaceHolder.Callback2](http://developer.android.com/reference/android/view/SurfaceHolder.Callback2.html) and get a SurfaceHolder. – Peter Tran Jan 24 '13 at 22:09