1 /* 2 * Copyright 2021 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.extensions.impl.advanced; 18 19 import android.annotation.SuppressLint; 20 import android.hardware.camera2.CaptureFailure; 21 import android.hardware.camera2.CaptureRequest; 22 import android.hardware.camera2.CaptureResult; 23 import android.hardware.camera2.TotalCaptureResult; 24 25 import java.util.List; 26 import java.util.Map; 27 28 /** 29 * A Interface to execute requests. 30 */ 31 @SuppressLint("UnknownNullness") 32 public interface RequestProcessorImpl { 33 /** 34 * Sets a {@link ImageProcessorImpl} to receive {@link ImageReferenceImpl} to process. 35 */ setImageProcessor(int outputconfigId, ImageProcessorImpl imageProcessor)36 void setImageProcessor(int outputconfigId, ImageProcessorImpl imageProcessor); 37 38 /** 39 * Submits a request. 40 * @return the id of the capture sequence or -1 in case the processor encounters a fatal error 41 * or receives and invalid argument. 42 */ submit(Request request, Callback callback)43 int submit(Request request, Callback callback); 44 45 /** 46 * Submits a list of requests. 47 * @return the id of the capture sequence or -1 in case the processor encounters a fatal error 48 * or receives and invalid argument. 49 */ submit(List<Request> requests, Callback callback)50 int submit(List<Request> requests, Callback callback); 51 52 /** 53 * Set repeating requests. 54 * @return the id of the capture sequence or -1 in case the processor encounters a fatal error 55 * or receives and invalid argument. 56 */ setRepeating(Request request, Callback callback)57 int setRepeating(Request request, Callback callback); 58 59 /** 60 * Abort captures. 61 */ abortCaptures()62 void abortCaptures(); 63 64 /** 65 * Stop Repeating. 66 */ stopRepeating()67 void stopRepeating(); 68 69 /** 70 * A interface representing a capture request configuration used for submitting requests in 71 * {@link RequestProcessorImpl}. 72 */ 73 interface Request { 74 /** 75 * Gets the target ids of {@link Camera2OutputConfigImpl} which identifies corresponding 76 * Surface to be the targeted for the request. 77 */ getTargetOutputConfigIds()78 List<Integer> getTargetOutputConfigIds(); 79 80 /** 81 * Gets all the parameters. 82 */ getParameters()83 Map<CaptureRequest.Key<?>, Object> getParameters(); 84 85 /** 86 * Gets the template id. 87 */ getTemplateId()88 Integer getTemplateId(); 89 } 90 91 /** 92 * Callback to be invoked during the capture. 93 */ 94 interface Callback { onCaptureStarted( Request request, long frameNumber, long timestamp)95 void onCaptureStarted( 96 Request request, 97 long frameNumber, 98 long timestamp); 99 onCaptureProgressed( Request request, CaptureResult partialResult)100 void onCaptureProgressed( 101 Request request, 102 CaptureResult partialResult); 103 onCaptureCompleted( Request request, TotalCaptureResult totalCaptureResult)104 void onCaptureCompleted( 105 Request request, 106 TotalCaptureResult totalCaptureResult); 107 onCaptureFailed( Request request, CaptureFailure captureFailure)108 void onCaptureFailed( 109 Request request, 110 CaptureFailure captureFailure); 111 onCaptureBufferLost( Request request, long frameNumber, int outputStreamId)112 void onCaptureBufferLost( 113 Request request, 114 long frameNumber, 115 int outputStreamId); 116 onCaptureSequenceCompleted(int sequenceId, long frameNumber)117 void onCaptureSequenceCompleted(int sequenceId, long frameNumber); 118 onCaptureSequenceAborted(int sequenceId)119 void onCaptureSequenceAborted(int sequenceId); 120 121 } 122 } 123