aboutsummaryrefslogtreecommitdiff
path: root/talk
diff options
context:
space:
mode:
authorglaznev@webrtc.org <glaznev@webrtc.org>2014-11-24 17:31:01 +0000
committerglaznev@webrtc.org <glaznev@webrtc.org>2014-11-24 17:31:01 +0000
commitdab5d92df6e195b016f3a2e238f8e7a1cd5f9097 (patch)
tree48cf5bd76c5b34449e03b2bce4b7c202492be54d /talk
parent03499a0e9582acbff52784c7ee14720c0ae9917b (diff)
downloadwebrtc-dab5d92df6e195b016f3a2e238f8e7a1cd5f9097.tar.gz
Use mirror image for Android AppRTCDemo local preview.
Similar to Chrome apprtc using mirror image for camera local preview provides better experience when device is rotated. R=jiayl@webrtc.org Review URL: https://webrtc-codereview.appspot.com/25209004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@7741 4adac7df-926f-26a2-2b94-8c16560cd09d
Diffstat (limited to 'talk')
-rw-r--r--talk/app/webrtc/java/android/org/webrtc/VideoRendererGui.java38
-rw-r--r--talk/examples/android/src/org/appspot/apprtc/AppRTCDemoActivity.java4
2 files changed, 26 insertions, 16 deletions
diff --git a/talk/app/webrtc/java/android/org/webrtc/VideoRendererGui.java b/talk/app/webrtc/java/android/org/webrtc/VideoRendererGui.java
index dd1692cf0f..d9d9b4a612 100644
--- a/talk/app/webrtc/java/android/org/webrtc/VideoRendererGui.java
+++ b/talk/app/webrtc/java/android/org/webrtc/VideoRendererGui.java
@@ -227,6 +227,7 @@ public class VideoRendererGui implements GLSurfaceView.Renderer {
private static enum RendererType { RENDERER_YUV, RENDERER_TEXTURE };
private RendererType rendererType;
private ScalingType scalingType;
+ private boolean mirror;
// Flag if renderFrame() was ever called.
boolean seenFrame;
// Total number of video frames received in renderFrame() call.
@@ -265,11 +266,12 @@ public class VideoRendererGui implements GLSurfaceView.Renderer {
private YuvImageRenderer(
GLSurfaceView surface, int id,
int x, int y, int width, int height,
- ScalingType scalingType) {
+ ScalingType scalingType, boolean mirror) {
Log.d(TAG, "YuvImageRenderer.Create id: " + id);
this.surface = surface;
this.id = id;
this.scalingType = scalingType;
+ this.mirror = mirror;
frameToRenderQueue = new LinkedBlockingQueue<I420Frame>(1);
// Create texture vertices.
texLeft = (x - 50) / 50.0f;
@@ -373,11 +375,18 @@ public class VideoRendererGui implements GLSurfaceView.Renderer {
textureVertices = directNativeFloatBuffer(textureVeticesFloat);
Log.d(TAG, " Texture UV offsets: " + texOffsetU + ", " + texOffsetV);
+ float uLeft = texOffsetU;
+ float uRight = 1.0f - texOffsetU;
+ if (mirror) {
+ // Swap U coordinates for mirror image.
+ uLeft = 1.0f - texOffsetU;
+ uRight = texOffsetU;
+ }
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
+ uLeft, texOffsetV, // left top
+ uLeft, 1.0f - texOffsetV, // left bottom
+ uRight, texOffsetV, // right top
+ uRight, 1.0f - texOffsetV // right bottom
};
textureCoords = directNativeFloatBuffer(textureCoordinatesFloat);
}
@@ -599,16 +608,17 @@ public class VideoRendererGui implements GLSurfaceView.Renderer {
* Creates VideoRenderer with top left corner at (x, y) and resolution
* (width, height). All parameters are in percentage of screen resolution.
*/
- public static VideoRenderer createGui(
- int x, int y, int width, int height, ScalingType scalingType)
- throws Exception {
- YuvImageRenderer javaGuiRenderer = create(x, y, width, height, scalingType);
+ public static VideoRenderer createGui(int x, int y, int width, int height,
+ ScalingType scalingType, boolean mirror) throws Exception {
+ YuvImageRenderer javaGuiRenderer = create(
+ x, y, width, height, scalingType, mirror);
return new VideoRenderer(javaGuiRenderer);
}
public static VideoRenderer.Callbacks createGuiRenderer(
- int x, int y, int width, int height, ScalingType scalingType) {
- return create(x, y, width, height, scalingType);
+ int x, int y, int width, int height,
+ ScalingType scalingType, boolean mirror) {
+ return create(x, y, width, height, scalingType, mirror);
}
/**
@@ -616,8 +626,8 @@ public class VideoRendererGui implements GLSurfaceView.Renderer {
* resolution (width, height). All parameters are in percentage of
* screen resolution.
*/
- public static YuvImageRenderer create(
- int x, int y, int width, int height, ScalingType scalingType) {
+ public static YuvImageRenderer create(int x, int y, int width, int height,
+ ScalingType scalingType, boolean mirror) {
// Check display region parameters.
if (x < 0 || x > 100 || y < 0 || y > 100 ||
width < 0 || width > 100 || height < 0 || height > 100 ||
@@ -631,7 +641,7 @@ public class VideoRendererGui implements GLSurfaceView.Renderer {
}
final YuvImageRenderer yuvImageRenderer = new YuvImageRenderer(
instance.surface, instance.yuvImageRenderers.size(),
- x, y, width, height, scalingType);
+ x, y, width, height, scalingType, mirror);
synchronized (instance.yuvImageRenderers) {
if (instance.onSurfaceCreatedCalled) {
// onSurfaceCreated has already been called for VideoRendererGui -
diff --git a/talk/examples/android/src/org/appspot/apprtc/AppRTCDemoActivity.java b/talk/examples/android/src/org/appspot/apprtc/AppRTCDemoActivity.java
index 9093b238f6..1c5790f462 100644
--- a/talk/examples/android/src/org/appspot/apprtc/AppRTCDemoActivity.java
+++ b/talk/examples/android/src/org/appspot/apprtc/AppRTCDemoActivity.java
@@ -117,8 +117,8 @@ public class AppRTCDemoActivity extends Activity
VideoRendererGui.setView(videoView);
scalingType = ScalingType.SCALE_ASPECT_FILL;
- remoteRender = VideoRendererGui.create(0, 0, 100, 100, scalingType);
- localRender = VideoRendererGui.create(0, 0, 100, 100, scalingType);
+ remoteRender = VideoRendererGui.create(0, 0, 100, 100, scalingType, false);
+ localRender = VideoRendererGui.create(0, 0, 100, 100, scalingType, true);
videoView.setOnClickListener(
new View.OnClickListener() {