Skip to content

M69 comm egl fix #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: M60_COMM
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions sdk/android/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,7 @@ generate_jni("generated_java_audio_jni") {

rtc_android_library("video_java") {
java_files = [
"api/org/webrtc/EglError.java",
"api/org/webrtc/EglRenderer.java",
"api/org/webrtc/GlRectDrawer.java",
"api/org/webrtc/VideoDecoderFallback.java",
Expand Down
5 changes: 5 additions & 0 deletions sdk/android/api/org/webrtc/EglError.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package org.webrtc;

public interface EglError {
public void onSurfaceCreationFailed(Exception exception);
}
32 changes: 23 additions & 9 deletions sdk/android/api/org/webrtc/EglRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,25 @@ public synchronized void setSurface(Object surface) {
// TODO(bugs.webrtc.org/8491): Remove NoSynchronizedMethodCheck suppression.
@SuppressWarnings("NoSynchronizedMethodCheck")
public synchronized void run() {
if (surface != null && eglBase != null && !eglBase.hasSurface()) {
if (surface instanceof Surface) {
eglBase.createSurface((Surface) surface);
} else if (surface instanceof SurfaceTexture) {
eglBase.createSurface((SurfaceTexture) surface);
try {
if (surface != null && eglBase != null && !eglBase.hasSurface()) {
if (surface instanceof Surface) {
eglBase.createSurface((Surface) surface);
} else if (surface instanceof SurfaceTexture) {
eglBase.createSurface((SurfaceTexture) surface);
} else {
throw new IllegalStateException("Invalid surface: " + surface);
}
eglBase.makeCurrent();
// Necessary for YUV frames with odd width.
GLES20.glPixelStorei(GLES20.GL_UNPACK_ALIGNMENT, 1);
}
} catch (Exception e) {
if (eglError != null) {
eglError.onSurfaceCreationFailed(e);
} else {
throw new IllegalStateException("Invalid surface: " + surface);
throw e;
}
eglBase.makeCurrent();
// Necessary for YUV frames with odd width.
GLES20.glPixelStorei(GLES20.GL_UNPACK_ALIGNMENT, 1);
}
}
}
Expand All @@ -99,6 +107,7 @@ public synchronized void run() {
// EGL and GL resources for drawing YUV/OES textures. After initilization, these are only accessed
// from the render thread.
@Nullable private EglBase eglBase;
private EglError eglError;
private final VideoFrameDrawer frameDrawer = new VideoFrameDrawer();
@Nullable private RendererCommon.GlDrawer drawer;
private final Matrix drawMatrix = new Matrix();
Expand Down Expand Up @@ -157,6 +166,11 @@ public EglRenderer(String name) {
this.name = name;
}

public EglRenderer(String name, EglError eglError) {
this.name = name;
this.eglError = eglError;
}

/**
* Initialize this class, sharing resources with |sharedContext|. The custom |drawer| will be used
* for drawing frames on the EGLSurface. This class is responsible for calling release() on
Expand Down
4 changes: 4 additions & 0 deletions sdk/android/api/org/webrtc/SurfaceEglRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ public SurfaceEglRenderer(String name) {
super(name);
}

public SurfaceEglRenderer(String name, EglError eglError) {
super(name, eglError);
}

/**
* Initialize this class, sharing resources with |sharedContext|. The custom |drawer| will be used
* for drawing frames on the EGLSurface. This class is responsible for calling release() on
Expand Down
8 changes: 8 additions & 0 deletions sdk/android/api/org/webrtc/SurfaceViewRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ public SurfaceViewRenderer(Context context) {
getHolder().addCallback(eglRenderer);
}

public SurfaceViewRenderer(Context context, EglError eglError) {
super(context);
this.resourceName = getResourceName();
eglRenderer = new SurfaceEglRenderer(resourceName, eglError);
getHolder().addCallback(this);
getHolder().addCallback(eglRenderer);
}

/**
* Standard View constructor. In order to render something, you must first call init().
*/
Expand Down