diff --git a/talk/app/webrtc/java/android/org/webrtc/VideoRendererGui.java b/talk/app/webrtc/java/android/org/webrtc/VideoRendererGui.java index acaa31e785..dd1692cf0f 100644 --- a/talk/app/webrtc/java/android/org/webrtc/VideoRendererGui.java +++ b/talk/app/webrtc/java/android/org/webrtc/VideoRendererGui.java @@ -253,6 +253,8 @@ public class VideoRendererGui implements GLSurfaceView.Renderer { private FloatBuffer textureCoords; // Flag if texture vertices or coordinates update is needed. private boolean updateTextureProperties; + // Texture properties update lock. + private final Object updateTextureLock = new Object(); // Viewport dimensions. private int screenWidth; private int screenHeight; @@ -319,64 +321,68 @@ public class VideoRendererGui implements GLSurfaceView.Renderer { scalingType == ScalingType.SCALE_FILL) { return; } - // Re - calculate texture vertices to preserve video aspect ratio. - float texRight = this.texRight; - float texLeft = this.texLeft; - float texTop = this.texTop; - float texBottom = this.texBottom; - float texOffsetU = 0; - float texOffsetV = 0; - float displayWidth = (texRight - texLeft) * screenWidth / 2; - float displayHeight = (texTop - texBottom) * screenHeight / 2; - Log.d(TAG, "ID: " + id + ". Display: " + displayWidth + - " x " + displayHeight + ". Video: " + videoWidth + - " x " + videoHeight); - if (displayWidth > 1 && displayHeight > 1 && - videoWidth > 1 && videoHeight > 1) { - float displayAspectRatio = displayWidth / displayHeight; - float videoAspectRatio = (float)videoWidth / videoHeight; - if (scalingType == ScalingType.SCALE_ASPECT_FIT) { - // Need to re-adjust vertices width or height to match video AR. - if (displayAspectRatio > videoAspectRatio) { - float deltaX = (displayWidth - videoAspectRatio * displayHeight) / - instance.screenWidth; - texRight -= deltaX; - texLeft += deltaX; - } else { - float deltaY = (displayHeight - displayWidth / videoAspectRatio) / - instance.screenHeight; - texTop -= deltaY; - texBottom += deltaY; + synchronized(updateTextureLock) { + // Re - calculate texture vertices to preserve video aspect ratio. + float texRight = this.texRight; + float texLeft = this.texLeft; + float texTop = this.texTop; + float texBottom = this.texBottom; + float texOffsetU = 0; + float texOffsetV = 0; + float displayWidth = (texRight - texLeft) * screenWidth / 2; + float displayHeight = (texTop - texBottom) * screenHeight / 2; + Log.d(TAG, "ID: " + id + ". Display: " + displayWidth + + " x " + displayHeight + ". Video: " + videoWidth + + " x " + videoHeight); + if (displayWidth > 1 && displayHeight > 1 && + videoWidth > 1 && videoHeight > 1) { + float displayAspectRatio = displayWidth / displayHeight; + float videoAspectRatio = (float)videoWidth / videoHeight; + if (scalingType == ScalingType.SCALE_ASPECT_FIT) { + // Need to re-adjust vertices width or height to match video AR. + if (displayAspectRatio > videoAspectRatio) { + float deltaX = (displayWidth - videoAspectRatio * displayHeight) / + instance.screenWidth; + texRight -= deltaX; + texLeft += deltaX; + } else { + float deltaY = (displayHeight - displayWidth / videoAspectRatio) / + instance.screenHeight; + texTop -= deltaY; + texBottom += deltaY; + } } - } - if (scalingType == ScalingType.SCALE_ASPECT_FILL) { - // Need to re-adjust UV coordinates to match display AR. - if (displayAspectRatio > videoAspectRatio) { - texOffsetV = (1.0f - videoAspectRatio / displayAspectRatio) / 2.0f; - } else { - texOffsetU = (1.0f - displayAspectRatio / videoAspectRatio) / 2.0f; + if (scalingType == ScalingType.SCALE_ASPECT_FILL) { + // Need to re-adjust UV coordinates to match display AR. + if (displayAspectRatio > videoAspectRatio) { + texOffsetV = (1.0f - videoAspectRatio / displayAspectRatio) / + 2.0f; + } else { + texOffsetU = (1.0f - displayAspectRatio / videoAspectRatio) / + 2.0f; + } } - } - Log.d(TAG, " Texture vertices: (" + texLeft + "," + texBottom + - ") - (" + texRight + "," + texTop + ")"); - float textureVeticesFloat[] = new float[] { - texLeft, texTop, - texLeft, texBottom, - texRight, texTop, - texRight, texBottom - }; - textureVertices = directNativeFloatBuffer(textureVeticesFloat); + Log.d(TAG, " Texture vertices: (" + texLeft + "," + texBottom + + ") - (" + texRight + "," + texTop + ")"); + float textureVeticesFloat[] = new float[] { + texLeft, texTop, + texLeft, texBottom, + texRight, texTop, + texRight, texBottom + }; + textureVertices = directNativeFloatBuffer(textureVeticesFloat); - Log.d(TAG, " Texture UV offsets: " + texOffsetU + ", " + texOffsetV); - float textureCoordinatesFloat[] = new float[] { - texOffsetU, texOffsetV, // left top - texOffsetU, 1.0f - texOffsetV, // left bottom - 1.0f - texOffsetU, texOffsetV, // right top - 1.0f - texOffsetU, 1.0f - texOffsetV // right bottom - }; - textureCoords = directNativeFloatBuffer(textureCoordinatesFloat); + Log.d(TAG, " Texture UV offsets: " + texOffsetU + ", " + texOffsetV); + float textureCoordinatesFloat[] = new float[] { + texOffsetU, texOffsetV, // left top + texOffsetU, 1.0f - texOffsetV, // left bottom + 1.0f - texOffsetU, texOffsetV, // right top + 1.0f - texOffsetU, 1.0f - texOffsetV // right bottom + }; + textureCoords = directNativeFloatBuffer(textureCoordinatesFloat); + } + updateTextureProperties = false; } - updateTextureProperties = false; } private void draw() { @@ -489,19 +495,23 @@ public class VideoRendererGui implements GLSurfaceView.Renderer { } public void setScreenSize(final int screenWidth, final int screenHeight) { - this.screenWidth = screenWidth; - this.screenHeight = screenHeight; - updateTextureProperties = true; + synchronized(updateTextureLock) { + this.screenWidth = screenWidth; + this.screenHeight = screenHeight; + updateTextureProperties = true; + } } public void setPosition(int x, int y, int width, int height, ScalingType scalingType) { - texLeft = (x - 50) / 50.0f; - texTop = (50 - y) / 50.0f; - texRight = Math.min(1.0f, (x + width - 50) / 50.0f); - texBottom = Math.max(-1.0f, (50 - y - height) / 50.0f); - this.scalingType = scalingType; - updateTextureProperties = true; + synchronized(updateTextureLock) { + texLeft = (x - 50) / 50.0f; + texTop = (50 - y) / 50.0f; + texRight = Math.min(1.0f, (x + width - 50) / 50.0f); + texBottom = Math.max(-1.0f, (50 - y - height) / 50.0f); + this.scalingType = scalingType; + updateTextureProperties = true; + } } @Override diff --git a/talk/examples/android/res/drawable-hdpi/ic_action_full_screen.png b/talk/examples/android/res/drawable-hdpi/ic_action_full_screen.png new file mode 100644 index 0000000000..22f30d31ca Binary files /dev/null and b/talk/examples/android/res/drawable-hdpi/ic_action_full_screen.png differ diff --git a/talk/examples/android/res/drawable-hdpi/ic_action_return_from_full_screen.png b/talk/examples/android/res/drawable-hdpi/ic_action_return_from_full_screen.png new file mode 100644 index 0000000000..d9436e5248 Binary files /dev/null and b/talk/examples/android/res/drawable-hdpi/ic_action_return_from_full_screen.png differ diff --git a/talk/examples/android/res/drawable-hdpi/ic_loopback_call.png b/talk/examples/android/res/drawable-hdpi/ic_loopback_call.png new file mode 100644 index 0000000000..39311853b3 Binary files /dev/null and b/talk/examples/android/res/drawable-hdpi/ic_loopback_call.png differ diff --git a/talk/examples/android/res/drawable-ldpi/ic_action_full_screen.png b/talk/examples/android/res/drawable-ldpi/ic_action_full_screen.png new file mode 100644 index 0000000000..e4a9ff0a8e Binary files /dev/null and b/talk/examples/android/res/drawable-ldpi/ic_action_full_screen.png differ diff --git a/talk/examples/android/res/drawable-ldpi/ic_action_return_from_full_screen.png b/talk/examples/android/res/drawable-ldpi/ic_action_return_from_full_screen.png new file mode 100644 index 0000000000..f5c80f00e7 Binary files /dev/null and b/talk/examples/android/res/drawable-ldpi/ic_action_return_from_full_screen.png differ diff --git a/talk/examples/android/res/drawable-ldpi/ic_loopback_call.png b/talk/examples/android/res/drawable-ldpi/ic_loopback_call.png new file mode 100644 index 0000000000..39311853b3 Binary files /dev/null and b/talk/examples/android/res/drawable-ldpi/ic_loopback_call.png differ diff --git a/talk/examples/android/res/drawable-mdpi/ic_action_full_screen.png b/talk/examples/android/res/drawable-mdpi/ic_action_full_screen.png new file mode 100644 index 0000000000..e4a9ff0a8e Binary files /dev/null and b/talk/examples/android/res/drawable-mdpi/ic_action_full_screen.png differ diff --git a/talk/examples/android/res/drawable-mdpi/ic_action_return_from_full_screen.png b/talk/examples/android/res/drawable-mdpi/ic_action_return_from_full_screen.png new file mode 100644 index 0000000000..f5c80f00e7 Binary files /dev/null and b/talk/examples/android/res/drawable-mdpi/ic_action_return_from_full_screen.png differ diff --git a/talk/examples/android/res/drawable-mdpi/ic_loopback_call.png b/talk/examples/android/res/drawable-mdpi/ic_loopback_call.png new file mode 100644 index 0000000000..39311853b3 Binary files /dev/null and b/talk/examples/android/res/drawable-mdpi/ic_loopback_call.png differ diff --git a/talk/examples/android/res/drawable-xhdpi/ic_action_full_screen.png b/talk/examples/android/res/drawable-xhdpi/ic_action_full_screen.png new file mode 100644 index 0000000000..6d90c071d5 Binary files /dev/null and b/talk/examples/android/res/drawable-xhdpi/ic_action_full_screen.png differ diff --git a/talk/examples/android/res/drawable-xhdpi/ic_action_return_from_full_screen.png b/talk/examples/android/res/drawable-xhdpi/ic_action_return_from_full_screen.png new file mode 100644 index 0000000000..a773b34208 Binary files /dev/null and b/talk/examples/android/res/drawable-xhdpi/ic_action_return_from_full_screen.png differ diff --git a/talk/examples/android/res/drawable-xhdpi/ic_loopback_call.png b/talk/examples/android/res/drawable-xhdpi/ic_loopback_call.png new file mode 100644 index 0000000000..39311853b3 Binary files /dev/null and b/talk/examples/android/res/drawable-xhdpi/ic_loopback_call.png differ diff --git a/talk/examples/android/res/layout/activity_connect.xml b/talk/examples/android/res/layout/activity_connect.xml index 2d6f6f8adc..5ca0f191b1 100644 --- a/talk/examples/android/res/layout/activity_connect.xml +++ b/talk/examples/android/res/layout/activity_connect.xml @@ -7,37 +7,66 @@ android:weightSum="1" android:layout_margin="8dp" android:layout_centerHorizontal="true"> + + + + + + + + android:layout_margin="5dp" + android:text="@string/room_description"/> + android:imeOptions="actionDone"/> - + -