Revereted changes to the onVideoTaken callback signature

pull/104/head
Raghav Petluru 8 years ago
parent 25092d4000
commit 402b72ccee
  1. 6
      cameraview/src/androidTest/java/com/otaliastudios/cameraview/CameraViewCallbacksTest.java
  2. 2
      cameraview/src/androidTest/java/com/otaliastudios/cameraview/IntegrationTest.java
  3. 7
      cameraview/src/androidTest/java/com/otaliastudios/cameraview/MockCameraController.java
  4. 20
      cameraview/src/main/java/com/otaliastudios/cameraview/Camera1.java
  5. 7
      cameraview/src/main/java/com/otaliastudios/cameraview/Camera2.java
  6. 11
      cameraview/src/main/java/com/otaliastudios/cameraview/CameraController.java
  7. 4
      cameraview/src/main/java/com/otaliastudios/cameraview/CameraListener.java
  8. 14
      cameraview/src/main/java/com/otaliastudios/cameraview/CameraView.java
  9. 4
      demo/src/main/java/com/otaliastudios/cameraview/demo/CameraActivity.java

@ -134,11 +134,11 @@ public class CameraViewCallbacksTest extends BaseTest {
@Test
public void testDispatchOnVideoTaken() {
completeTask().when(listener).onVideoTaken(null, false);
camera.mCameraCallbacks.dispatchOnVideoTaken(null, false);
completeTask().when(listener).onVideoTaken(null);
camera.mCameraCallbacks.dispatchOnVideoTaken(null);
assertNotNull(task.await(200));
verify(listener, times(1)).onVideoTaken(null, false);
verify(listener, times(1)).onVideoTaken(null);
}
@Test

@ -124,7 +124,7 @@ public class IntegrationTest extends BaseTest {
private void waitForVideoEnd(boolean expectSuccess) {
final Task<Boolean> video = new Task<>(true);
doEndTask(video, true).when(listener).onVideoTaken(any(File.class), false);
doEndTask(video, true).when(listener).onVideoTaken(any(File.class));
Boolean result = video.await(8000);
if (expectSuccess) {
assertNotNull("Can take video", result);

@ -126,12 +126,7 @@ public class MockCameraController extends CameraController {
}
@Override
void setMaxFileSize(long maxFileSizeInBytes) {
void setVideoMaxSize(long videoMaxSizeInBytes) {
}
@Override
boolean isRecordingVideo() {
return false;
}
}

@ -640,11 +640,9 @@ class Camera1 extends CameraController implements Camera.PreviewCallback, Camera
mMediaRecorder = null;
}
if (mVideoFile != null) {
mCameraCallbacks.dispatchOnVideoTaken(mVideoFile, mHasReachedMaxSize);
mCameraCallbacks.dispatchOnVideoTaken(mVideoFile);
mVideoFile = null;
}
mHasReachedMaxSize = false;
}
@WorkerThread
@ -680,8 +678,8 @@ class Camera1 extends CameraController implements Camera.PreviewCallback, Camera
mMediaRecorder.setOrientationHint(computeSensorToOutputOffset());
//If the user sets a max file size, set it to the max file size
if(mMaxFileSizeInBytes > 0) {
mMediaRecorder.setMaxFileSize(mMaxFileSizeInBytes);
if(mVideoMaxSizeInBytes > 0) {
mMediaRecorder.setMaxFileSize(mVideoMaxSizeInBytes);
//Attach a listener to the media recorder to listen for file size notifications
mMediaRecorder.setOnInfoListener(new MediaRecorder.OnInfoListener() {
@ -689,8 +687,7 @@ class Camera1 extends CameraController implements Camera.PreviewCallback, Camera
public void onInfo(MediaRecorder mediaRecorder, int i, int i1) {
switch (i){
case MediaRecorder.MEDIA_RECORDER_INFO_MAX_FILESIZE_REACHED:{
mHasReachedMaxSize = true;
endVideo();
endVideoImmediately();
break;
}
}
@ -857,16 +854,11 @@ class Camera1 extends CameraController implements Camera.PreviewCallback, Camera
}
@Override
void setMaxFileSize(long maxFileSizeInBytes) {
mMaxFileSizeInBytes = maxFileSizeInBytes;
void setVideoMaxSize(long videoMaxSizeInBytes) {
mVideoMaxSizeInBytes = videoMaxSizeInBytes;
}
// -----------------
// Additional helper info
@Override
boolean isRecordingVideo() {
return mIsCapturingVideo;
}
}

@ -116,12 +116,7 @@ class Camera2 extends CameraController {
}
@Override
void setMaxFileSize(long maxFileSizeInBytes) {
void setVideoMaxSize(long videoMaxSizeInBytes) {
}
@Override
boolean isRecordingVideo() {
return false;
}
}

@ -64,10 +64,9 @@ abstract class CameraController implements
protected boolean mIsCapturingImage = false;
protected boolean mIsCapturingVideo = false;
protected boolean mHasReachedMaxSize = false;
protected int mState = STATE_STOPPED;
protected long mMaxFileSizeInBytes = 0;
protected long mVideoMaxSizeInBytes = 0;
// Used for testing.
Task<Void> mZoomTask = new Task<>();
@ -319,9 +318,7 @@ abstract class CameraController implements
abstract void startAutoFocus(@Nullable Gesture gesture, PointF point);
abstract void setMaxFileSize(long maxFileSizeInBytes);
abstract boolean isRecordingVideo();
abstract void setVideoMaxSize(long videoMaxSizeInBytes);
//endregion
@ -389,6 +386,10 @@ abstract class CameraController implements
return mPreviewSize;
}
final boolean isRecordingVideo() {
return mIsCapturingVideo;
}
//endregion
//region Orientation utils

@ -73,11 +73,9 @@ public abstract class CameraListener {
* </code>
*
* @param video file hosting the mp4 video
* @param hasReachedMaxFileSize returns true if the user has set a max file size for videos and
* if the video ended because of the file size limit.
*/
@UiThread
public void onVideoTaken(File video, boolean hasReachedMaxFileSize) {
public void onVideoTaken(File video) {
}

@ -1233,7 +1233,7 @@ public class CameraView extends FrameLayout {
/**
* Stops capturing video, if there was a video record going on.
* This will fire {@link CameraListener#onVideoTaken(File, boolean)}.
* This will fire {@link CameraListener#onVideoTaken(File)}.
*/
public void stopCapturingVideo() {
mCameraController.endVideo();
@ -1339,10 +1339,10 @@ public class CameraView extends FrameLayout {
* Set a max file size (in bytes) for a video recording. There is no file size limit by default
* unless set by the user.
*
* @param maxFileSizeInBytes The maximum size of videos in bytes
* @param videoMaxSizeInBytes The maximum size of videos in bytes
*/
public void setMaxFileSize(long maxFileSizeInBytes){
mCameraController.setMaxFileSize(maxFileSizeInBytes);
public void setVideoMaxSize(long videoMaxSizeInBytes){
mCameraController.setVideoMaxSize(videoMaxSizeInBytes);
}
/**
@ -1364,7 +1364,7 @@ public class CameraView extends FrameLayout {
void onShutter(boolean shouldPlaySound);
void processImage(byte[] jpeg, boolean consistentWithView, boolean flipHorizontally);
void processSnapshot(YuvImage image, boolean consistentWithView, boolean flipHorizontally);
void dispatchOnVideoTaken(File file, boolean hasReachedMaxFileSize);
void dispatchOnVideoTaken(File file);
void dispatchOnFocusStart(@Nullable Gesture trigger, PointF where);
void dispatchOnFocusEnd(@Nullable Gesture trigger, boolean success, PointF where);
void dispatchOnZoomChanged(final float newValue, final PointF[] fingers);
@ -1505,13 +1505,13 @@ public class CameraView extends FrameLayout {
}
@Override
public void dispatchOnVideoTaken(final File video, final boolean hasReachedMaxFileSize) {
public void dispatchOnVideoTaken(final File video) {
mLogger.i("dispatchOnVideoTaken", video);
mUiHandler.post(new Runnable() {
@Override
public void run() {
for (CameraListener listener : mListeners) {
listener.onVideoTaken(video, hasReachedMaxFileSize);
listener.onVideoTaken(video);
}
}
});

@ -49,8 +49,8 @@ public class CameraActivity extends AppCompatActivity implements View.OnClickLis
public void onPictureTaken(byte[] jpeg) { onPicture(jpeg); }
@Override
public void onVideoTaken(File video, boolean hasReachedMaxFileSize) {
super.onVideoTaken(video, hasReachedMaxFileSize);
public void onVideoTaken(File video) {
super.onVideoTaken(video);
onVideo(video);
}
});

Loading…
Cancel
Save