WebRTCDemo: remove unnecessary stop & start during orientation change which isn't necessary since API v14.
(required bumping minSdkVersion to 14) This fixes a RuntimeException thrown on GalaxyNexus (but not N7, N4, or NS) during startPreview() after the sequence of Start(), Stop(), Start(); seemingly GN's OMX stack can't deal with parallel startPreview() & setPreviewDisplay() in this situation. Also: - Only set the surface in the camera when valid - Remove duplicate assignment - Fix error check on voiceChannel allocation to account for multiple channel creation due to orientation change causing onDestroy()/onCreate() on the app, and rampant use of process-static holders for VoE data. BUG=1537 Review URL: https://webrtc-codereview.appspot.com/1259005 git-svn-id: http://webrtc.googlecode.com/svn/trunk@3731 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
bfacda60be
commit
add50b94a5
@ -125,7 +125,6 @@ public class VideoCaptureAndroid implements PreviewCallback, Callback {
|
|||||||
isCaptureRunning = true;
|
isCaptureRunning = true;
|
||||||
previewBufferLock.unlock();
|
previewBufferLock.unlock();
|
||||||
|
|
||||||
isCaptureRunning = true;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,7 +134,8 @@ public class VideoCaptureAndroid implements PreviewCallback, Callback {
|
|||||||
// Get the local preview SurfaceHolder from the static render class
|
// Get the local preview SurfaceHolder from the static render class
|
||||||
localPreview = ViERenderer.GetLocalRenderer();
|
localPreview = ViERenderer.GetLocalRenderer();
|
||||||
if (localPreview != null) {
|
if (localPreview != null) {
|
||||||
if (localPreview.getSurface() != null) {
|
if (localPreview.getSurface() != null &&
|
||||||
|
localPreview.getSurface().isValid()) {
|
||||||
surfaceCreated(localPreview);
|
surfaceCreated(localPreview);
|
||||||
}
|
}
|
||||||
localPreview.addCallback(this);
|
localPreview.addCallback(this);
|
||||||
@ -210,39 +210,23 @@ public class VideoCaptureAndroid implements PreviewCallback, Callback {
|
|||||||
public void SetPreviewRotation(int rotation) {
|
public void SetPreviewRotation(int rotation) {
|
||||||
Log.v(TAG, "SetPreviewRotation:" + rotation);
|
Log.v(TAG, "SetPreviewRotation:" + rotation);
|
||||||
|
|
||||||
if (camera != null) {
|
if (camera == null) {
|
||||||
previewBufferLock.lock();
|
return;
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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,
|
public void surfaceChanged(SurfaceHolder holder,
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
</activity>
|
</activity>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
<uses-sdk android:minSdkVersion="10" />
|
<uses-sdk android:minSdkVersion="14" />
|
||||||
<uses-permission android:name="android.permission.CAMERA"></uses-permission>
|
<uses-permission android:name="android.permission.CAMERA"></uses-permission>
|
||||||
<uses-feature android:name="android.hardware.camera" />
|
<uses-feature android:name="android.hardware.camera" />
|
||||||
<uses-feature android:name="android.hardware.camera.autofocus" />
|
<uses-feature android:name="android.hardware.camera.autofocus" />
|
||||||
|
@ -739,7 +739,7 @@ public class WebRTCDemo extends TabActivity implements IViEAndroidCallback,
|
|||||||
|
|
||||||
// Create channel
|
// Create channel
|
||||||
voiceChannel = vieAndroidAPI.VoE_CreateChannel();
|
voiceChannel = vieAndroidAPI.VoE_CreateChannel();
|
||||||
if (0 != voiceChannel) {
|
if (0 > voiceChannel) {
|
||||||
Log.d(TAG, "VoE create channel failed");
|
Log.d(TAG, "VoE create channel failed");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user