1 /* 2 * Copyright 2022 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.camera2.pipe 18 19 import androidx.annotation.RestrictTo 20 21 /** Create and submit [CaptureSequence]s to an active camera instance. */ 22 @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) 23 public interface CaptureSequenceProcessor< 24 out TCaptureRequest, 25 TCaptureSequence : CaptureSequence<TCaptureRequest> 26 > { 27 28 /** 29 * Build a [CaptureSequence] instance. 30 * 31 * @param isRepeating determines if this CaptureSequence should repeat until replaced by another 32 * repeating CaptureSequence, or closed, or stopRepeating is invoked. 33 * @param requests the list of [Request] to use when constructing this [CaptureSequence] 34 * @param defaultParameters are the parameters to start with when building an individual 35 * [TCaptureRequest] object. Parameters not specified on a [Request] will use these parameters 36 * by default. 37 * @param requiredParameters are parameters that will override all [defaultParameters] *and* 38 * parameters that are defined on the [Request]. 39 * @param listeners are global and internal [Request.Listener]s that should be invoked every 40 * time the listeners on the [Request] are invoked. Since these often track and update 41 * internal state they should be invoked before listeners on the individual [Request]. 42 * @param sequenceListener is an extra listener that should be invoked whenever a specific 43 * [CaptureSequence] should no longer receive any additional events. 44 * @return a [TCaptureSequence] instance that can be used to capture images using the underlying 45 * camera by passing this [submit]. This method will return null if the underlying camera has 46 * been closed or disconnected, and will throw unchecked exceptions if invalid values are 47 * passed to the [build] call. 48 */ buildnull49 public fun build( 50 isRepeating: Boolean, 51 requests: List<Request>, 52 defaultParameters: Map<*, Any?>, 53 graphParameters: Map<*, Any?>, 54 requiredParameters: Map<*, Any?>, 55 sequenceListener: CaptureSequence.CaptureSequenceListener, 56 listeners: List<Request.Listener> 57 ): TCaptureSequence? 58 59 /** Issue a previously created [CaptureSequence] to the active camera instance. */ 60 public fun submit(captureSequence: TCaptureSequence): Int? 61 62 /** 63 * Opportunistically abort any ongoing captures by the camera. This may or may not complete 64 * quickly depending on the underlying camera. 65 */ 66 public fun abortCaptures() 67 68 /** Opportunistically cancel any currently active repeating [TCaptureSequence]. */ 69 public fun stopRepeating() 70 71 /** 72 * Signal that this [CaptureSequenceProcessor] is no longer in use. Active requests may continue 73 * to be processed, and [abortCaptures] and [stopRepeating] may still be invoked. 74 */ 75 public suspend fun shutdown() 76 } 77