1 /* 2 * Copyright 2019 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package androidx.camera.core.impl; 18 19 import org.jspecify.annotations.NonNull; 20 21 /** 22 * A callback object for tracking the progress of a capture request submitted to the camera device. 23 * Once one of the methods is called, other methods won't be called again on the same instance. 24 * 25 */ 26 public abstract class CameraCaptureCallback { 27 28 /** 29 * This method is called when a capture request starts to be processed. 30 * 31 * @param captureConfigId the ID of {@link CaptureConfig} that triggers the callback. 32 */ onCaptureStarted(int captureConfigId)33 public void onCaptureStarted(int captureConfigId) { 34 } 35 36 /** 37 * This method is called when an image capture has fully completed and all the result metadata 38 * is available. 39 * 40 * @param captureConfigId the ID of {@link CaptureConfig} that triggers the callback. 41 * @param cameraCaptureResult The output metadata from the capture. 42 */ onCaptureCompleted(int captureConfigId, @NonNull CameraCaptureResult cameraCaptureResult)43 public void onCaptureCompleted(int captureConfigId, 44 @NonNull CameraCaptureResult cameraCaptureResult) { 45 } 46 47 /** 48 * This method is called instead of {@link #onCaptureCompleted} when the camera device failed to 49 * produce a {@link CameraCaptureResult} for the request. 50 * 51 * @param captureConfigId the ID of {@link CaptureConfig} that triggers the callback. 52 * @param failure The output failure from the capture, including the failure reason. 53 */ onCaptureFailed(int captureConfigId, @NonNull CameraCaptureFailure failure)54 public void onCaptureFailed(int captureConfigId, @NonNull CameraCaptureFailure failure) { 55 } 56 57 58 /** 59 * This method is called when the capture request was not submitted to camera device. For 60 * Example, requests are cancelled when it is in an inappropriate state (such as closed). After 61 * onCaptureCancelled is called, other methods won't be called. 62 * 63 * @param captureConfigId the ID of {@link CaptureConfig} that triggers the callback. 64 */ onCaptureCancelled(int captureConfigId)65 public void onCaptureCancelled(int captureConfigId) { 66 } 67 68 /** 69 * This method is called to notify the client of the progress in the processing stage. 70 * 71 * @param captureConfigId the ID of {@link CaptureConfig} that triggers the callback. 72 */ onCaptureProcessProgressed(int captureConfigId, int progress)73 public void onCaptureProcessProgressed(int captureConfigId, int progress) { 74 75 } 76 } 77