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.core.processing; 18 19 import androidx.annotation.IntRange; 20 import androidx.camera.core.SurfaceProcessor; 21 import androidx.camera.core.impl.utils.futures.Futures; 22 23 import com.google.common.util.concurrent.ListenableFuture; 24 25 import org.jspecify.annotations.NonNull; 26 27 /** 28 * An internal {@link SurfaceProcessor} that is releasable. 29 * 30 * <p>Note: the implementation of this interface must be thread-safe. e.g. methods can be 31 * safely invoked on any thread. 32 */ 33 public interface SurfaceProcessorInternal extends SurfaceProcessor { 34 35 /** 36 * Releases all the resources allocated by the processor. 37 * 38 * <p>An processor created by CameraX should be released by CameraX when it's no longer needed. 39 * On the other hand, an external processor should not be released by CameraX, because CameraX 40 * not does know if the processor will be needed again. In that case, the app is responsible for 41 * releasing the processor. It should be able to keep the processor alive across multiple 42 * attach/detach cycles if it's necessary. 43 * 44 * @see Node#release() 45 */ release()46 void release(); 47 48 /** 49 * Takes a snapshot of the next available frame and write it to JPEG outputs. 50 */ snapshot( @ntRangefrom = 0, to = 100) int jpegQuality, @IntRange(from = 0, to = 359) int rotationDegrees)51 default @NonNull ListenableFuture<Void> snapshot( 52 @IntRange(from = 0, to = 100) int jpegQuality, 53 @IntRange(from = 0, to = 359) int rotationDegrees) { 54 return Futures.immediateFuture(null); 55 } 56 } 57