在较低分辨率的设备中,大多数时候屏幕在渲染视图时变黑。得到以下错误如下:
java.lang.RuntimeException: glUseProgram: GLES20 error: 1285
at org.webrtc.GlUtil.checkNoGLES2Error(GlUtil.java:29)
at org.webrtc.GlShader.useProgram(GlShader.java:117)
at org.webrtc.GlRectDrawer.prepareShader(GlRectDrawer.java:198)
at org.webrtc.GlRectDrawer.drawYuv(GlRectDrawer.java:152) org.webrtc.SurfaceViewRenderer.renderFrameOnRenderThread(SurfaceViewRenderer.java:492)
at org.webrtc.SurfaceViewRenderer.access$000(SurfaceViewRenderer.java:38)
at org.webrtc.SurfaceViewRenderer$1.run(SurfaceViewRenderer.java:109)
at android.os.Handler.handleCallback(Handler.java:815)
at android.os.Handler.dispatchMessage(Handler.java:104)
at android.os.Looper.loop(Looper.java:194)
at android.os.HandlerThread.run(HandlerThread.java:61)
我在给定方法中找到了在连接呼叫之前创建本地媒体流的问题。
public void createMediaStream(final EglBase.Context renderEGLContext, final VideoRenderer.Callbacks localRender, final boolean isAudioCallOnly) {
this.localRender = localRender;
executor.execute(new Runnable() {
@Override
public void run() {
createMediaConstraintsInternal();
if (mediaStream != null)
return;
mediaStream = factory.createLocalMediaStream("ARDAMS");
if (videoCallEnabled) {
factory.setVideoHwAccelerationOptions(renderEGLContext, renderEGLContext);
String cameraDeviceName = CameraEnumerationAndroid.getDeviceName(0);
String frontCameraDeviceName =
CameraEnumerationAndroid.getNameOfFrontFacingDevice();
if (numberOfCameras > 1 && frontCameraDeviceName != null) {
cameraDeviceName = frontCameraDeviceName;
}
AppData.showLogMessage("Opening camera: "+ cameraDeviceName);
videoCapturer = VideoCapturerAndroid.create(cameraDeviceName, null, peerConnectionParameters.captureToTexture ? renderEGLContext : null);
if (videoCapturer == null) {
reportError("Failed to open camera");
return;
}
mediaStream.addTrack(createVideoTrack(videoCapturer));
// videoToggle(isAudioCallOnly);
}
mediaStream.addTrack(factory.createAudioTrack(
AUDIO_TRACK_ID,
factory.createAudioSource(audioConstraints)));
}
});
}