I am implementing the webrtc in an Android project and I am based on this sample in github.
This example uses the libjingle library. This is how the video render view is created:
// Create video renderers.
VideoRendererGui.setView((GLSurfaceView)videoView, new Runnable() {
@Override
public void run() {
createPeerConnectionFactory();
}
});
remoteRender = VideoRendererGui.create(
REMOTE_X, REMOTE_Y,
REMOTE_WIDTH, REMOTE_HEIGHT, scalingType, false);
localRender = VideoRendererGui.create(
LOCAL_X_CONNECTING, LOCAL_Y_CONNECTING,
LOCAL_WIDTH_CONNECTING, LOCAL_HEIGHT_CONNECTING, scalingType, true);
My question is how can I manage to customize the remoteRender
and localRender
, so that I can change it position
in the GLSurfaceView
and its width and height
EDIT:
I have made a listener and I have tried this:
@Override
public void onWidthHeightChange(int width, int height) {
VideoRendererGui.update(remoteRender,
REMOTE_X-width, REMOTE_X-height,
REMOTE_WIDTH-width, REMOTE_HEIGHT-height, scalingType, false);
if (iceConnected) {
VideoRendererGui.update(localRender,
LOCAL_X_CONNECTED, LOCAL_Y_CONNECTED,
LOCAL_WIDTH_CONNECTED, LOCAL_HEIGHT_CONNECTED,
ScalingType.SCALE_ASPECT_FIT, true);
} else {
VideoRendererGui.update(localRender,
LOCAL_X_CONNECTING, LOCAL_Y_CONNECTING,
LOCAL_WIDTH_CONNECTING, LOCAL_HEIGHT_CONNECTING, scalingType, true);
}
}
When I give value 150 for both width and height it gives me this error:
08-21 14:34:01.621 7636-7636/org.appspot.apprtc E/AppRTCDemoActivity﹕ Fatal error: glUseProgram: GLES20 error: 1281
java.lang.RuntimeException: glUseProgram: GLES20 error: 1281
at org.webrtc.GlUtil.checkNoGLES2Error(GlUtil.java:48)
at org.webrtc.GlShader.useProgram(GlShader.java:123)
at org.webrtc.GlRectDrawer.drawOes(GlRectDrawer.java:132)
at org.webrtc.VideoRendererGui$YuvImageRenderer.draw(VideoRendererGui.java:371)
at org.webrtc.VideoRendererGui$YuvImageRenderer.access$800(VideoRendererGui.java:131)
at org.webrtc.VideoRendererGui.onDrawFrame(VideoRendererGui.java:722)
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1522)
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1239)
EDIT 2 with the solution:
When I was looking at mattm
answer I understood that he was right.
While I was searching for my exception I found that it was an exception thrown from libjingle
library. I found this piece of code here VideoRendererGui.java at line 368, 347 I found the solution for my questions.
When adding the view height and width it has to be inside these ranges based on this code:
/**
* Creates VideoRenderer.Callbacks with top left corner at (x, y) and
* resolution (width, height). All parameters are in percentage of
* screen resolution.
*/
public static YuvImageRenderer create(
int x, int y, int width, int height) {
// Check display region parameters.
if (x < 0 || x > 100 || y < 0 || y > 100 ||
width < 0 || width > 100 || height < 0 || height > 100 ||
x + width > 100 || y + height > 100) {
throw new RuntimeException("Incorrect window parameters.");
}
So for as long as I follow these rules calling the method VideoRendererGui.update(...
will work perfectly
Thanks
It's as simple as changing the fields
REMOTE_X
, REMOTE_Y
, or LOCAL_X_CONNECTING
, LOCAL_Y_CONNECTING
,REMOTE_WIDTH
, REMOTE_HEIGHT
or LOCAL_WIDTH_CONNECTING
, LOCAL_HEIGHT_CONNECTING
If you want to change the rendering once the objects have been created, call VideoRendererGui.update(remoteRender, ...)
.