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.view.Surface;
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  * Use Surface directly to create the OutputConfiguration.
31  */
32 @AutoValue
33 public abstract class SurfaceOutputConfig implements Camera2OutputConfig {
34     /**
35      * Creates the {@link SurfaceOutputConfig} instance.
36      */
create(int id, int surfaceGroupId, @Nullable String physicalCameraId, @NonNull List<Camera2OutputConfig> sharedOutputConfigs, @NonNull Surface surface)37     static SurfaceOutputConfig create(int id, int surfaceGroupId,
38             @Nullable String physicalCameraId,
39             @NonNull List<Camera2OutputConfig> sharedOutputConfigs,
40             @NonNull Surface surface) {
41         return new AutoValue_SurfaceOutputConfig(id, surfaceGroupId, physicalCameraId,
42                 sharedOutputConfigs, surface);
43     }
44 
create(int id, @NonNull Surface surface)45     static SurfaceOutputConfig create(int id, @NonNull Surface surface) {
46         return create(id, -1, null, Collections.emptyList(), surface);
47     }
48 
49     /**
50      * Get the {@link Surface}. It'll return a valid surface only when type is TYPE_SURFACE.
51      */
getSurface()52     abstract @NonNull Surface getSurface();
53 }
54