Android WEBRTC Video Rotation problem

Source: Internet
Author: User

Recently in the docking WebRTC to Android phone, there is a demand is the mobile phone horizontal screen when the other side of the image rotation, study the code of WEBRTC Video_render found that the remote video rendering using OPENGLES20 or Surfaceview implementation, Where OPENGLES20 uses hardware rendering, so performance is better, so simply add the VideoRenderOpenGles20 class in the video_render_opengles20.h to the rotation interface.

OPENGLES20 and Opengles compared to cancel the Glrotatex, such as the operation function, the rotation operation is replaced by the shader vertex rendering implementation, the rewritten shader code is as follows:

  

Uniform mat4 Umvpmatrix; The total transformation matrix attribute vec4 aposition;  Vertex position attribute VEC2 atexturecoord;varying vec2 vtexturecoord;void Main ()     {                                      gl_position = Umvpmatrix * Aposition; Calculates this vertex position based on the total transformation matrix   Vtexturecoord = atexturecoord;//passes the received color to the slice shader}

  

Note that the transform matrix Umvpmatrix is added, which is called before drawing:

int mumvpmatrixhandle = glgetuniformlocation (Mprogram, "Umvpmatrix");

Mmmatrix.setrotate (rotate);

glUniformMatrix4fv(muMVPMatrixHandle, 1false, (float*)mMMatrix);

Android WEBRTC Video Rotation problem

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.