Implementation of opengl display in android linphone

Source: Internet
Author: User

1. java Layer

Create GL2JNIView in the interface (the base class is GLSurfaceView ).

Create the AndroidVideoWindowImpl object and pass GL2JNIView as the parameter to the constructor. Listen to the GL2JNIView surface event (mVideoRenderingView. getHolder (). addCallback) in this object ).

When the surface changes (for example, the window size changes and the activity is covered by other programs), the callback function is triggered:

Public voidSurfaceChanged (SurfaceHolderholder,IntFormat,

IntWidth,IntHeight)

Call LinphoneManager. getLc (). setVideoWindow (Vw); Upload the androidvideow.wimpl object to the c code layer.

The corresponding function in C code in mediastreamer2 \ src \ android \ android-opengl-display.c android_display_set_window,

The procedure for calling this function is as follows:

(1) (* jenv)-> CallVoidMethod (jenv, window, ad-> set_opengles_display_id, ptr );

Window is the androidvideow.wimpl object passed through java; ad-> set_opengles_display_id is the java class androidvideo=wimpl member function setOpenGLESDisplay; ptr is the struct variable opengles_display, which stores yuv data, it will be used when each frame is displayed later.

(2) Assign androidvideow.wimpl to ad-> android_video_window

This function swaps object pointers in java and c. This is mainly because opengl must refresh each video frame by the onDrawFrame of the java layer, while the linphone video stream receives and decodes the video stream in the c layer, which must be triggered by the c function.

2. c code Layer

In the android_display_process function for each frame of the android-opengl-display.c,

Call (* jenv)-> CallVoidMethod (jenv, ad-> android_video_window, ad-> request_render_id); where ad-> android_video_window is the androidvideo1_wimpl object passed by setVideoWindow; ad-> request_render_id is the java class androidvideo=wimpl member function requestRender

This function triggers opengl to refresh a frame and calls onDrawFrame at the java layer.

The onDrawFrame function calls the render of the c code layer. The parameter is the opengles_display struct transmitted to the java layer in step (1.

The C code layer corresponds to the ogl_display_render function in mediastreamer2 \ src \ utils \ opengles_display.c. In this function, yuv data in opengles_display is drawn to opengl surface.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.