| 1 | /* |
| 2 | * Copyright (C) 2020 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 | package android.hardware.camera2.params; |
| 17 | |
| 18 | import android.annotation.NonNull; |
| 19 | |
| 20 | import android.hardware.camera2.CameraExtensionCharacteristics.Extension; |
| 21 | import android.hardware.camera2.CameraExtensionSession; |
| 22 | |
| 23 | import java.util.List; |
| 24 | import java.util.concurrent.Executor; |
| 25 | |
| 26 | /** |
| 27 | * A class that aggregates all supported arguments for |
| 28 | * {@link CameraExtensionSession} initialization. |
| 29 | */ |
| 30 | public final class ExtensionSessionConfiguration { |
| 31 | private static final String TAG = "ExtensionSessionConfiguration"; |
| 32 | |
| 33 | private int mExtensionType; |
| 34 | private List<OutputConfiguration> mOutputs; |
| 35 | private Executor mExecutor = null; |
| 36 | private CameraExtensionSession.StateCallback mCallback = null; |
| 37 | |
| 38 | /** |
| 39 | * Create a new ExtensionSessionConfiguration |
| 40 | * |
| 41 | * @param extension to be used for processing |
| 42 | * @param outputs a list of output configurations for the capture session |
| 43 | * @param executor the executor which will be used for invoking the callbacks |
| 44 | * @param listener callbacks to be invoked when the state of the |
| 45 | * CameraExtensionSession changes |
| 46 | */ |
| 47 | public ExtensionSessionConfiguration(@Extension int extension, |
| 48 | @NonNull List<OutputConfiguration> outputs, @NonNull Executor executor, |
| 49 | @NonNull CameraExtensionSession.StateCallback listener) { |
| 50 | mExtensionType = extension; |
| 51 | mOutputs = outputs; |
| 52 | mExecutor = executor; |
| 53 | mCallback = listener; |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Retrieve the extension type. |
| 58 | * |
| 59 | * @return the extension type. |
| 60 | */ |
| 61 | public @Extension |
| 62 | int getExtension() { |
| 63 | return mExtensionType; |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * Retrieve the {@link OutputConfiguration} list for the capture |
| 68 | * session. |
| 69 | * |
| 70 | * @return A list of output configurations for the capture session. |
| 71 | */ |
| 72 | public @NonNull |
| 73 | List<OutputConfiguration> getOutputConfigurations() { |
| 74 | return mOutputs; |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * Retrieve the CameraCaptureSession.StateCallback |
| 79 | * listener. |
| 80 | * |
| 81 | * @return A state callback interface implementation. |
| 82 | */ |
| 83 | public @NonNull |
| 84 | CameraExtensionSession.StateCallback getStateCallback() { |
| 85 | return mCallback; |
| 86 | } |
| 87 | |
| 88 | /** |
| 89 | * Retrieve the Executor for the CameraExtensionSession instance. |
| 90 | * |
| 91 | * @return The Executor on which the callback will be invoked. |
| 92 | */ |
| 93 | public @NonNull |
| 94 | Executor getExecutor() { |
| 95 | return mExecutor; |
| 96 | } |
| 97 | } |