Quick fixes & bump version (#471)

* Fix #460

* Fix #419

* Fix #443

* Bump version

* Fix #425

* Fix test
pull/477/head v2.0.0-beta05
Mattia Iavarone 6 years ago committed by GitHub
parent b9620b70e6
commit 8b66d5b575
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      README.md
  2. 2
      cameraview/build.gradle
  3. 2
      cameraview/src/androidTest/java/com/otaliastudios/cameraview/VideoRecorderTest.java
  4. 8
      cameraview/src/main/java/com/otaliastudios/cameraview/Camera1.java
  5. 2
      cameraview/src/main/java/com/otaliastudios/cameraview/CameraView.java
  6. 9
      cameraview/src/main/java/com/otaliastudios/cameraview/FullVideoRecorder.java
  7. 7
      cameraview/src/main/java/com/otaliastudios/cameraview/SnapshotPictureRecorder.java
  8. 7
      cameraview/src/main/java/com/otaliastudios/cameraview/SnapshotVideoRecorder.java
  9. 6
      cameraview/src/main/java/com/otaliastudios/cameraview/VideoRecorder.java
  10. 13
      docs/_posts/2018-12-20-changelog.md
  11. 2
      docs/_posts/2018-12-20-install.md

@ -22,7 +22,7 @@ CameraView is a well documented, high-level library that makes capturing picture
addressing most of the common issues and needs, and still leaving you with flexibility where needed.
```groovy
compile 'com.otaliastudios:cameraview:2.0.0-beta04'
compile 'com.otaliastudios:cameraview:2.0.0-beta05'
```
- Fast & reliable

@ -3,7 +3,7 @@ apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'
// Required by bintray
version = '2.0.0-beta04'
version = '2.0.0-beta05'
group = 'com.otaliastudios'
//region android dependencies

@ -28,7 +28,7 @@ public class VideoRecorderTest extends BaseTest {
};
recorder.start();
recorder.stop();
Mockito.verify(listener, Mockito.times(1)).onVideoResult(result);
Mockito.verify(listener, Mockito.times(1)).onVideoResult(result, null);
assertNull(recorder.mListener);
assertNull(recorder.mResult);
}

@ -336,7 +336,7 @@ class Camera1 extends CameraController implements Camera.PreviewCallback, Camera
return;
}
LOG.e("Error inside the onError callback.", error);
LOG.e("Internal Camera1 error.", error);
Exception runtime = new RuntimeException(CameraLogger.lastMessage);
int reason;
switch (error) {
@ -646,13 +646,13 @@ class Camera1 extends CameraController implements Camera.PreviewCallback, Camera
// Video recording stuff.
@Override
public void onVideoResult(@Nullable VideoResult result) {
public void onVideoResult(@Nullable VideoResult result, @Nullable Exception exception) {
mVideoRecorder = null;
if (result != null) {
mCameraCallbacks.dispatchOnVideoTaken(result);
} else {
// Something went wrong, lock the camera again.
mCameraCallbacks.dispatchError(new CameraException(CameraException.REASON_VIDEO_FAILED));
mCameraCallbacks.dispatchError(new CameraException(exception, CameraException.REASON_VIDEO_FAILED));
mCamera.lock();
}
}
@ -689,7 +689,7 @@ class Camera1 extends CameraController implements Camera.PreviewCallback, Camera
} catch (Exception e) {
// If this failed, we are unlikely able to record the video.
// Dispatch an error.
onVideoResult(null);
onVideoResult(null, e);
return;
}
mVideoRecorder = new FullVideoRecorder(videoResult, Camera1.this,

@ -104,7 +104,7 @@ public class CameraView extends FrameLayout implements LifecycleObserver {
Facing facing = Facing.fromValue(a.getInteger(R.styleable.CameraView_cameraFacing, Facing.DEFAULT(context).value()));
Flash flash = Flash.fromValue(a.getInteger(R.styleable.CameraView_cameraFlash, Flash.DEFAULT.value()));
Grid grid = Grid.fromValue(a.getInteger(R.styleable.CameraView_cameraGrid, Grid.DEFAULT.value()));
int gridColor = a.getColor(R.styleable.CameraView_cameraGrid, GridLinesLayout.DEFAULT_COLOR);
int gridColor = a.getColor(R.styleable.CameraView_cameraGridColor, GridLinesLayout.DEFAULT_COLOR);
WhiteBalance whiteBalance = WhiteBalance.fromValue(a.getInteger(R.styleable.CameraView_cameraWhiteBalance, WhiteBalance.DEFAULT.value()));
Mode mode = Mode.fromValue(a.getInteger(R.styleable.CameraView_cameraMode, Mode.DEFAULT.value()));
Hdr hdr = Hdr.fromValue(a.getInteger(R.styleable.CameraView_cameraHdr, Hdr.DEFAULT.value()));

@ -104,7 +104,9 @@ class FullVideoRecorder extends VideoRecorder {
mMediaRecorder.prepare();
mMediaRecorder.start();
} catch (Exception e) {
LOG.w("stop:", "Error while starting media recorder.", e);
mResult = null;
mError = e;
stop();
}
}
@ -115,9 +117,12 @@ class FullVideoRecorder extends VideoRecorder {
try {
mMediaRecorder.stop();
} catch (Exception e) {
// This can happen if stopVideo() is called right after takeVideo(). We don't care.
LOG.w("stop:", "Error while closing media recorder.", e);
// This can happen if stopVideo() is called right after takeVideo() (in which case we don't care)
// Or when prepare()/start() have failed for some reason and we are not allowed to call stop.
// Make sure we don't override the error if one exists already.
mResult = null;
LOG.w("stop:", "Error while closing media recorder. Swallowing", e);
if (mError == null) mError = e;
}
mMediaRecorder.release();
if (mController != null) {

@ -1,6 +1,7 @@
package com.otaliastudios.cameraview;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.graphics.Bitmap;
import android.graphics.ImageFormat;
import android.graphics.Rect;
@ -10,6 +11,8 @@ import android.hardware.Camera;
import android.opengl.EGL14;
import android.opengl.EGLContext;
import android.opengl.Matrix;
import android.os.Build;
import androidx.annotation.NonNull;
import java.io.ByteArrayOutputStream;
@ -42,14 +45,14 @@ class SnapshotPictureRecorder extends PictureRecorder {
@Override
void take() {
if (mPreview instanceof GlCameraPreview) {
if (mPreview instanceof GlCameraPreview && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
takeGl((GlCameraPreview) mPreview);
} else {
takeLegacy();
}
}
@SuppressLint("NewApi")
@TargetApi(Build.VERSION_CODES.KITKAT)
private void takeGl(@NonNull final GlCameraPreview preview) {
preview.addRendererFrameCallback(new GlCameraPreview.RendererFrameCallback() {

@ -124,7 +124,9 @@ class SnapshotVideoRecorder extends VideoRecorder implements GlCameraPreview.Ren
// If something failed, undo the result, since this is the mechanism
// to notify Camera1 about this.
if (e != null) {
LOG.e("Error onEncoderStop", e);
mResult = null;
mError = e;
} else {
if (stopReason == MediaEncoderEngine.STOP_BY_MAX_DURATION) {
mResult.endReason = VideoResult.REASON_MAX_DURATION_REACHED;
@ -132,11 +134,14 @@ class SnapshotVideoRecorder extends VideoRecorder implements GlCameraPreview.Ren
mResult.endReason = VideoResult.REASON_MAX_SIZE_REACHED;
}
}
mEncoderEngine = null;
// Cleanup
mCurrentState = STATE_NOT_RECORDING;
mDesiredState = STATE_NOT_RECORDING;
if (mPreview != null) {
mPreview.removeRendererFrameCallback(SnapshotVideoRecorder.this);
mPreview = null;
}
mEncoderEngine = null;
dispatchResult();
}
}

@ -12,6 +12,7 @@ abstract class VideoRecorder {
/* tests */ VideoResult mResult;
/* tests */ VideoResultListener mListener;
protected Exception mError;
VideoRecorder(@NonNull VideoResult stub, @Nullable VideoResultListener listener) {
mResult = stub;
@ -25,14 +26,15 @@ abstract class VideoRecorder {
@SuppressWarnings("WeakerAccess")
protected void dispatchResult() {
if (mListener != null) {
mListener.onVideoResult(mResult);
mListener.onVideoResult(mResult, mError);
mListener = null;
mResult = null;
mError = null;
}
}
interface VideoResultListener {
void onVideoResult(@Nullable VideoResult result);
void onVideoResult(@Nullable VideoResult result, @Nullable Exception exception);
}
}

@ -8,6 +8,13 @@ order: 3
New versions are released through GitHub, so the reference page is the [GitHub Releases](https://github.com/natario1/CameraView/releases) page.
### v2.0.0-beta05
- Fixed `FrameProcessor` freeze and release behavior, was broken ([#431][431])
- New: new api `setAutoFocusResetDelay` to control the delay to reset the focus after autofocus was performed, thanks to [@cneuwirt][cneuwirt] ([#435][435])
- Faster camera preview on layout changes ([#403][403])
- A few bug fixes ([#471][471])
### v2.0.0-beta04
- Renames setPreviewSize to setPreviewStreamSize (previewSize suggests it is related to the view size but it's not) ([#393][393])
@ -28,8 +35,14 @@ New versions are released through GitHub, so the reference page is the [GitHub R
This is the first beta release. For changes with respect to v1, please take a look at the [migration guide](../extra/v1-migration-guide.html).
[cneuwirt]: https://github.com/cneuwirt
[356]: https://github.com/natario1/CameraView/pull/356
[360]: https://github.com/natario1/CameraView/pull/360
[374]: https://github.com/natario1/CameraView/pull/374
[392]: https://github.com/natario1/CameraView/pull/392
[393]: https://github.com/natario1/CameraView/pull/393
[471]: https://github.com/natario1/CameraView/pull/471
[431]: https://github.com/natario1/CameraView/pull/431
[403]: https://github.com/natario1/CameraView/pull/403
[435]: https://github.com/natario1/CameraView/pull/435

@ -24,7 +24,7 @@ allprojects {
Then simply download the latest version:
```groovy
api 'com.otaliastudios:cameraview:2.0.0-beta04'
api 'com.otaliastudios:cameraview:2.0.0-beta05'
```
No other configuration steps are needed.
Loading…
Cancel
Save