How to render mediacodec output in vive focus?

xulzee
Contributor

How to render mediacodec output in vive focus?

Hello everyone,

    Now, I am using vive foucus to dispaly video stream in HMD. So I need to use mediacode to decode the  stream, and use opengl to render the frame. But i am a newer in android an opengl, So how do I bind the meidiacodec output to the texture of opengl in ndk. Are there any examples?

    Thanks for any help or advice.

 

@Tony PH Lin

Vive Staff

Re: How to render mediacodec output in vive focus?

Hi @xulzee,

 

We don't have existing samples or further experiences to share now.

However maybe you can check "East Movie Texture" from Unity Asset Store for reference.

https://assetstore.unity.com/packages/tools/video/easy-movie-texture-video-texture-10032

We have partners to select this as base for development for video playing.

Hope other developers can provide more advises.

Thanks.

xulzee
Contributor

Re: How to render mediacodec output in vive focus?

Hi @Tony PH Lin

Thank you for your help.

Now I think I know a little bit about how to solve the problem. I create a texture in the native code and bind GL_TEXTURE_EXTERNAL_OES, and then I use the texture id to create a SurfaceTexture in the Java code to link the two together.

But now I have another question: it looks like I'm in Java code that's not the same opengl context as native code, so how do you make them have the same opengl context?

Thank you very much!

Vive Staff

Re: How to render mediacodec output in vive focus?

WaveSDK create a default context in the native. Developer can do what he wants to do and be sure the texture for WVR_SubmitFrame should create within native context which created by runtime. By using eglMakeCurrent to make sure what current context you want are working on.

Thanks.

xulzee
Contributor

Re: How to render mediacodec output in vive focus?

Hi,

Thank you for your help.

I have created a texture in native context, But now I want to create a surfacetexture in the Java layer that points to the texture id, can I do that? Or how do I get into this native context?
Is there any way I can get into this context?

Thank you very much for your help.

 

Vive Staff

Re: How to render mediacodec output in vive focus?

Calling eglGetCurrentContext may help you to get the current used context.

If you want to pass variable from native to Java or Java to native. You can also refer to JNI programming from internet.