public void surfaceChanged(SurfaceHolder arg0, int arg1, int arg2, int arg3) { Log.d(TAG, "call surfaceChanged event"); synchronized (mSyncObject) { if (!mSurfaceExist) { mSurfaceExist = true; checkCurrentState(); } else { /** Surface changed. We need to stop camera and restart with new parameters */ /* Pretend that old surface has been destroyed */ mSurfaceExist = false; checkCurrentState(); /* Now use new surface. Say we have it now */ mSurfaceExist = true; checkCurrentState(); } } }
/** * This method is provided for clients, so they can disable camera connection and stop the * delivery of frames even though the surface view itself is not destroyed and still stays on the * scren */ public void disableView() { synchronized (mSyncObject) { mEnabled = false; checkCurrentState(); } }
/** * This method is provided for clients, so they can enable the camera connection. The actual * onCameraViewStarted callback will be delivered only after both this method is called and * surface is available */ public void enableView() { synchronized (mSyncObject) { mEnabled = true; checkCurrentState(); } }
public void surfaceDestroyed(SurfaceHolder holder) { synchronized (mSyncObject) { mSurfaceExist = false; checkCurrentState(); } }