|
|
@ -67,7 +67,14 @@ class Camera1 extends CameraController { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onSurfaceAvailable() { |
|
|
|
public void onSurfaceAvailable() { |
|
|
|
LOG.i("onSurfaceAvailable, size is", mPreview.getSurfaceSize()); |
|
|
|
LOG.i("onSurfaceAvailable, size is", mPreview.getSurfaceSize()); |
|
|
|
if (shouldSetup()) setup(); |
|
|
|
if (shouldSetup()) { |
|
|
|
|
|
|
|
mHandler.post(new Runnable() { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void run() { |
|
|
|
|
|
|
|
if (shouldSetup()) setup(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -340,6 +347,8 @@ class Camera1 extends CameraController { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
void setVideoQuality(VideoQuality videoQuality) { |
|
|
|
void setVideoQuality(VideoQuality videoQuality) { |
|
|
|
if (mIsCapturingVideo) { |
|
|
|
if (mIsCapturingVideo) { |
|
|
|
|
|
|
|
// TODO: actually any call to getParameters() could fail while recording a video.
|
|
|
|
|
|
|
|
// See. https://stackoverflow.com/questions/14941625/correct-handling-of-exception-getparameters-failed-empty-parameters
|
|
|
|
throw new IllegalStateException("Can't change video quality while recording a video."); |
|
|
|
throw new IllegalStateException("Can't change video quality while recording a video."); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -545,21 +554,21 @@ class Camera1 extends CameraController { |
|
|
|
mVideoFile = videoFile; |
|
|
|
mVideoFile = videoFile; |
|
|
|
if (mIsCapturingVideo) return false; |
|
|
|
if (mIsCapturingVideo) return false; |
|
|
|
if (!isCameraAvailable()) return false; |
|
|
|
if (!isCameraAvailable()) return false; |
|
|
|
Camera.Parameters params = mCamera.getParameters(); |
|
|
|
|
|
|
|
params.setVideoStabilization(false); |
|
|
|
|
|
|
|
if (mSessionType == SessionType.VIDEO) { |
|
|
|
if (mSessionType == SessionType.VIDEO) { |
|
|
|
mIsCapturingVideo = true; |
|
|
|
mIsCapturingVideo = true; |
|
|
|
initMediaRecorder(); |
|
|
|
initMediaRecorder(); |
|
|
|
try { |
|
|
|
try { |
|
|
|
mMediaRecorder.prepare(); |
|
|
|
mMediaRecorder.prepare(); |
|
|
|
|
|
|
|
mMediaRecorder.start(); |
|
|
|
|
|
|
|
return true; |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
Exception m = e; // FileNotFoundException: Read only file system.
|
|
|
|
|
|
|
|
LOG.e("Error while starting MediaRecorder.", e); |
|
|
|
mVideoFile = null; |
|
|
|
mVideoFile = null; |
|
|
|
|
|
|
|
mCamera.lock(); |
|
|
|
endVideo(); |
|
|
|
endVideo(); |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
mMediaRecorder.start(); |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
throw new IllegalStateException("Can't record video while session type is picture"); |
|
|
|
throw new IllegalStateException("Can't record video while session type is picture"); |
|
|
|
} |
|
|
|
} |
|
|
|