diff --git a/webrtc/modules/video_capture/android/java/org/webrtc/videoengine/VideoCaptureAndroid.java b/webrtc/modules/video_capture/android/java/org/webrtc/videoengine/VideoCaptureAndroid.java
index eaf195fe27..b9095064d0 100644
--- a/webrtc/modules/video_capture/android/java/org/webrtc/videoengine/VideoCaptureAndroid.java
+++ b/webrtc/modules/video_capture/android/java/org/webrtc/videoengine/VideoCaptureAndroid.java
@@ -125,7 +125,6 @@ public class VideoCaptureAndroid implements PreviewCallback, Callback {
isCaptureRunning = true;
previewBufferLock.unlock();
- isCaptureRunning = true;
return 0;
}
@@ -135,7 +134,8 @@ public class VideoCaptureAndroid implements PreviewCallback, Callback {
// Get the local preview SurfaceHolder from the static render class
localPreview = ViERenderer.GetLocalRenderer();
if (localPreview != null) {
- if (localPreview.getSurface() != null) {
+ if (localPreview.getSurface() != null &&
+ localPreview.getSurface().isValid()) {
surfaceCreated(localPreview);
}
localPreview.addCallback(this);
@@ -210,39 +210,23 @@ public class VideoCaptureAndroid implements PreviewCallback, Callback {
public void SetPreviewRotation(int rotation) {
Log.v(TAG, "SetPreviewRotation:" + rotation);
- if (camera != null) {
- previewBufferLock.lock();
- int width = 0;
- int height = 0;
- int framerate = 0;
- boolean wasCaptureRunning = isCaptureRunning;
-
- if (isCaptureRunning) {
- width = mCaptureWidth;
- height = mCaptureHeight;
- framerate = mCaptureFPS;
- StopCapture();
- }
-
- int resultRotation = 0;
- if (currentDevice.frontCameraType ==
- VideoCaptureDeviceInfoAndroid.FrontFacingCameraType.Android23) {
- // this is a 2.3 or later front facing camera.
- // SetDisplayOrientation will flip the image horizontally
- // before doing the rotation.
- resultRotation=(360-rotation) % 360; // compensate the mirror
- }
- else {
- // Back facing or 2.2 or previous front camera
- resultRotation=rotation;
- }
- camera.setDisplayOrientation(resultRotation);
-
- if (wasCaptureRunning) {
- StartCapture(width, height, framerate);
- }
- previewBufferLock.unlock();
+ if (camera == null) {
+ return;
}
+
+ int resultRotation = 0;
+ if (currentDevice.frontCameraType ==
+ VideoCaptureDeviceInfoAndroid.FrontFacingCameraType.Android23) {
+ // this is a 2.3 or later front facing camera.
+ // SetDisplayOrientation will flip the image horizontally
+ // before doing the rotation.
+ resultRotation = ( 360 - rotation ) % 360; // compensate the mirror
+ }
+ else {
+ // Back facing or 2.2 or previous front camera
+ resultRotation = rotation;
+ }
+ camera.setDisplayOrientation(resultRotation);
}
public void surfaceChanged(SurfaceHolder holder,
diff --git a/webrtc/video_engine/test/android/AndroidManifest.xml b/webrtc/video_engine/test/android/AndroidManifest.xml
index 8b4447789b..72631ca486 100644
--- a/webrtc/video_engine/test/android/AndroidManifest.xml
+++ b/webrtc/video_engine/test/android/AndroidManifest.xml
@@ -18,7 +18,7 @@
-
+
diff --git a/webrtc/video_engine/test/android/src/org/webrtc/videoengineapp/WebRTCDemo.java b/webrtc/video_engine/test/android/src/org/webrtc/videoengineapp/WebRTCDemo.java
index df2f5f7e16..3385c582f9 100644
--- a/webrtc/video_engine/test/android/src/org/webrtc/videoengineapp/WebRTCDemo.java
+++ b/webrtc/video_engine/test/android/src/org/webrtc/videoengineapp/WebRTCDemo.java
@@ -739,7 +739,7 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
// Create channel
voiceChannel = vieAndroidAPI.VoE_CreateChannel();
- if (0 != voiceChannel) {
+ if (0 > voiceChannel) {
Log.d(TAG, "VoE create channel failed");
return -1;
}