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.internal.sessionprocessor;
18 
19 import android.util.Size;
20 
21 import com.google.auto.value.AutoValue;
22 
23 import org.jspecify.annotations.NonNull;
24 import org.jspecify.annotations.Nullable;
25 
26 import java.util.Collections;
27 import java.util.List;
28 
29 /**
30  * Surface will be created by constructing an ImageReader.
31  */
32 @AutoValue
33 public abstract class ImageReaderOutputConfig implements Camera2OutputConfig {
34     /**
35      * Creates the {@link ImageReaderOutputConfig} instance.
36      */
create(int id, int surfaceGroupId, @Nullable String physicalCameraId, @NonNull List<Camera2OutputConfig> sharedOutputConfigs, @NonNull Size size, int imageFormat, int maxImages)37     static ImageReaderOutputConfig create(int id, int surfaceGroupId,
38             @Nullable String physicalCameraId,
39             @NonNull List<Camera2OutputConfig> sharedOutputConfigs,
40             @NonNull Size size, int imageFormat, int maxImages) {
41         return new AutoValue_ImageReaderOutputConfig(id, surfaceGroupId, physicalCameraId,
42                 sharedOutputConfigs, size, imageFormat, maxImages);
43     }
44 
create( int id, @NonNull Size size, int imageFormat, int maxImages)45     static ImageReaderOutputConfig create(
46             int id, @NonNull Size size, int imageFormat, int maxImages) {
47         return new AutoValue_ImageReaderOutputConfig(id, -1, null,
48                 Collections.emptyList(), size, imageFormat, maxImages);
49     }
50     /**
51      * Returns the size of the surface.
52      */
getSize()53     abstract @NonNull Size getSize();
54 
55     /**
56      * Gets the image format of the surface.
57      */
getImageFormat()58     abstract int getImageFormat();
59 
60     /**
61      * Gets the capacity for the image reader.
62      */
getMaxImages()63     abstract int getMaxImages();
64 }
65