added video recording callback

pull/498/head
Suneet Agrawal 6 years ago committed by Mattia Iavarone
parent 389da0467f
commit c7b9f7ff7c
  1. 12
      cameraview/src/main/java/com/otaliastudios/cameraview/CameraListener.java
  2. 13
      cameraview/src/main/java/com/otaliastudios/cameraview/CameraView.java
  3. 5
      cameraview/src/main/java/com/otaliastudios/cameraview/engine/Camera1Engine.java
  4. 5
      cameraview/src/main/java/com/otaliastudios/cameraview/engine/Camera2Engine.java
  5. 1
      cameraview/src/main/java/com/otaliastudios/cameraview/engine/CameraEngine.java
  6. 1
      cameraview/src/main/java/com/otaliastudios/cameraview/video/FullVideoRecorder.java
  7. 1
      cameraview/src/main/java/com/otaliastudios/cameraview/video/SnapshotVideoRecorder.java
  8. 15
      cameraview/src/main/java/com/otaliastudios/cameraview/video/VideoRecorder.java

@ -127,4 +127,16 @@ public abstract class CameraListener {
@UiThread @UiThread
public void onExposureCorrectionChanged(float newValue, @NonNull float[] bounds, @Nullable PointF[] fingers) { } public void onExposureCorrectionChanged(float newValue, @NonNull float[] bounds, @Nullable PointF[] fingers) { }
/**
* Notifies that the actual video recording has started
* When we request for video recording, it doesn't start the recording the immediately.
* Instead it checks for hardware availability first and later on available,
* it sets all the config and then start the actual recording.
*/
@UiThread
public void onActualVideoRecordingStarted() {
}
} }

@ -2062,6 +2062,19 @@ public class CameraView extends FrameLayout implements LifecycleObserver {
} }
}); });
} }
@Override
public void onActualVideoRecordingStarted() {
mLogger.i("onActualVideoRecordingStarted", "onActualVideoRecordingStarted");
mUiHandler.post(new Runnable() {
@Override
public void run() {
for (CameraListener listener : mListeners) {
listener.onActualVideoRecordingStarted();
}
}
});
}
} }
//endregion //endregion

@ -375,6 +375,11 @@ public class Camera1Engine extends CameraEngine implements
} }
} }
@Override
public void onActualVideoRecordingStarted() {
mCallback.onActualVideoRecordingStarted();
}
//endregion //endregion
//region Parameters //region Parameters

@ -726,6 +726,11 @@ public class Camera2Engine extends CameraEngine implements ImageReader.OnImageAv
} }
} }
@Override
public void onActualVideoRecordingStarted() {
mCallback.onActualVideoRecordingStarted();
}
//endregion //endregion
//region Parameters //region Parameters

@ -134,6 +134,7 @@ public abstract class CameraEngine implements
void dispatchOnExposureCorrectionChanged(float newValue, @NonNull float[] bounds, @Nullable PointF[] fingers); void dispatchOnExposureCorrectionChanged(float newValue, @NonNull float[] bounds, @Nullable PointF[] fingers);
void dispatchFrame(Frame frame); void dispatchFrame(Frame frame);
void dispatchError(CameraException exception); void dispatchError(CameraException exception);
void onActualVideoRecordingStarted();
} }
private static final String TAG = CameraEngine.class.getSimpleName(); private static final String TAG = CameraEngine.class.getSimpleName();

@ -130,6 +130,7 @@ public abstract class FullVideoRecorder extends VideoRecorder {
try { try {
mMediaRecorder.start(); mMediaRecorder.start();
dispatchActualVideoRecordingStarted();
} catch (Exception e) { } catch (Exception e) {
LOG.w("start:", "Error while starting media recorder.", e); LOG.w("start:", "Error while starting media recorder.", e);
mResult = null; mResult = null;

@ -60,6 +60,7 @@ public class SnapshotVideoRecorder extends VideoRecorder implements RendererFram
mPreview.addRendererFrameCallback(this); mPreview.addRendererFrameCallback(this);
mFlipped = mEngine.getAngles().flip(Reference.SENSOR, Reference.VIEW); mFlipped = mEngine.getAngles().flip(Reference.SENSOR, Reference.VIEW);
mDesiredState = STATE_RECORDING; mDesiredState = STATE_RECORDING;
dispatchActualVideoRecordingStarted();
} }
@Override @Override

@ -24,6 +24,11 @@ public abstract class VideoRecorder {
* @param exception the error or null if everything went fine * @param exception the error or null if everything went fine
*/ */
void onVideoResult(@Nullable VideoResult.Stub result, @Nullable Exception exception); void onVideoResult(@Nullable VideoResult.Stub result, @Nullable Exception exception);
/**
* The callback for the actual video recording starting.
*/
void onActualVideoRecordingStarted();
} }
@VisibleForTesting(otherwise = VisibleForTesting.PROTECTED) VideoResult.Stub mResult; @VisibleForTesting(otherwise = VisibleForTesting.PROTECTED) VideoResult.Stub mResult;
@ -84,4 +89,14 @@ public abstract class VideoRecorder {
mResult = null; mResult = null;
mError = null; mError = null;
} }
/**
* Subclasses can call this to notify that the video recording has started,
* this will be called when camera is prepared and started.
*/
protected void dispatchActualVideoRecordingStarted(){
if(mListener != null){
mListener.onActualVideoRecordingStarted();
}
}
} }

Loading…
Cancel
Save