diff options
author | Yuichi Araki <yaraki@google.com> | 2016-03-03 03:46:54 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2016-03-03 03:46:54 +0000 |
commit | bce4098be78c971c40982fc29af109d7ef3150b4 (patch) | |
tree | 441ae829ae3d4a165a2dc3cbf6036ff89d830091 | |
parent | 9e5ab7f231e1f48e3faa2ccf161f119929c7c477 (diff) | |
parent | 9eea1ec6fb48b3b7234d3969a966b22fb616d49c (diff) | |
download | android-bce4098be78c971c40982fc29af109d7ef3150b4.tar.gz |
Merge "Camera2Video: Add comments" into mnc-docs
-rw-r--r-- | media/Camera2Video/Application/src/main/java/com/example/android/camera2video/Camera2VideoFragment.java | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/media/Camera2Video/Application/src/main/java/com/example/android/camera2video/Camera2VideoFragment.java b/media/Camera2Video/Application/src/main/java/com/example/android/camera2video/Camera2VideoFragment.java index 0d96ba2c..d191e77c 100644 --- a/media/Camera2Video/Application/src/main/java/com/example/android/camera2video/Camera2VideoFragment.java +++ b/media/Camera2Video/Application/src/main/java/com/example/android/camera2video/Camera2VideoFragment.java @@ -600,7 +600,8 @@ public class Camera2VideoFragment extends Fragment } private String getVideoFilePath(Context context) { - return context.getExternalFilesDir(null).getAbsolutePath() + "/" + System.currentTimeMillis() + ".mp4"; + return context.getExternalFilesDir(null).getAbsolutePath() + "/" + + System.currentTimeMillis() + ".mp4"; } private void startRecordingVideo() { @@ -614,19 +615,24 @@ public class Camera2VideoFragment extends Fragment assert texture != null; texture.setDefaultBufferSize(mPreviewSize.getWidth(), mPreviewSize.getHeight()); mPreviewBuilder = mCameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_RECORD); - List<Surface> surfaces = new ArrayList<Surface>(); + List<Surface> surfaces = new ArrayList<>(); + // Set up Surface for the camera preview Surface previewSurface = new Surface(texture); surfaces.add(previewSurface); mPreviewBuilder.addTarget(previewSurface); + // Set up Surface for the MediaRecorder mRecorderSurface = mMediaRecorder.getSurface(); surfaces.add(mRecorderSurface); mPreviewBuilder.addTarget(mRecorderSurface); + + // Start a capture session + // Once the session starts, we can update the UI and start recording mCameraDevice.createCaptureSession(surfaces, new CameraCaptureSession.StateCallback() { @Override - public void onConfigured(CameraCaptureSession cameraCaptureSession) { + public void onConfigured(@NonNull CameraCaptureSession cameraCaptureSession) { mPreviewSession = cameraCaptureSession; updatePreview(); getActivity().runOnUiThread(new Runnable() { @@ -643,7 +649,7 @@ public class Camera2VideoFragment extends Fragment } @Override - public void onConfigureFailed(CameraCaptureSession cameraCaptureSession) { + public void onConfigureFailed(@NonNull CameraCaptureSession cameraCaptureSession) { Activity activity = getActivity(); if (null != activity) { Toast.makeText(activity, "Failed", Toast.LENGTH_SHORT).show(); @@ -659,7 +665,7 @@ public class Camera2VideoFragment extends Fragment } private void closePreviewSession() { - if(mPreviewSession != null) { + if (mPreviewSession != null) { mPreviewSession.close(); mPreviewSession = null; } @@ -677,6 +683,7 @@ public class Camera2VideoFragment extends Fragment if (null != activity) { Toast.makeText(activity, "Video saved: " + mNextVideoAbsolutePath, Toast.LENGTH_SHORT).show(); + Log.d(TAG, "Video saved: " + mNextVideoAbsolutePath); } mNextVideoAbsolutePath = null; startPreview(); |