1 /* 2 * Copyright 2024 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; 18 19 import androidx.camera.core.CameraInfo; 20 import androidx.lifecycle.LiveData; 21 22 import org.jspecify.annotations.Nullable; 23 24 /** 25 * A camera extensions info instance that allows to observe or monitor capture request settings 26 * and results for supported camera extensions. 27 * 28 * <p>Applications can leverage the {@link ExtensionsManager#getCameraExtensionsInfo(CameraInfo)} 29 * method to acquire a CameraExtensionsInfo object for observing extension-specific settings and 30 * results. 31 */ 32 public interface CameraExtensionsInfo { 33 34 /** 35 * Returns whether extension strength is supported for the extensions-enabled camera that is 36 * associated with the CameraExtensionsInfo. 37 * 38 * <p>When extension strength is supported, applications can change the strength setting via 39 * {@link CameraExtensionsControl#setExtensionStrength(int)} and observe the strength value 40 * changes via the {@link LiveData} object returned by {@link #getExtensionStrength()}. 41 * 42 * @return {@code true} if extension strength is supported. Otherwise, returns {@code false}. 43 */ isExtensionStrengthAvailable()44 default boolean isExtensionStrengthAvailable() { 45 return false; 46 } 47 48 /** 49 * Returns a {@link LiveData} which observes the extension strength changes for the 50 * extensions-enabled camera that is associated with the CameraExtensionsInfo. 51 * 52 * <p>This is only available when {@link #isExtensionStrengthAvailable()} returns {@code true 53 * }. When this is supported, the extension strength value will range from 0 to 100 and will 54 * dynamically change based on the latest adjustments made within the current extension mode. 55 * 56 * @return a {@link LiveData} of {@link Integer} type to observe the extension strength 57 * changes when {@link #isExtensionStrengthAvailable()} returns {@code true}. Otherwise, 58 * returns {@code null}. 59 */ getExtensionStrength()60 default @Nullable LiveData<Integer> getExtensionStrength() { 61 return null; 62 } 63 64 /** 65 * Returns whether reporting the currently active extension mode is supported for the 66 * extensions-enabled camera that is associated with the CameraExtensionsInfo. 67 * 68 * <p>When current extension mode is supported, applications can observe the current extension 69 * value changes via the {@link LiveData} object returned by {@link #getCurrentExtensionMode()}. 70 * 71 * @return {@code true} if current extension mode is supported. Otherwise, returns {@code 72 * false}. 73 */ isCurrentExtensionModeAvailable()74 default boolean isCurrentExtensionModeAvailable() { 75 return false; 76 } 77 78 /** 79 * Returns a {@link LiveData} which observes the extension mode changes for the 80 * extensions-enabled camera that is associated with the CameraExtensionsInfo. 81 * 82 * <p>This is only available when {@link #isCurrentExtensionModeAvailable()} returns {@code 83 * true}. When this is supported, the initial value will be equal to the extension mode the 84 * session was started with. Then, the current extension mode may change over time. For 85 * example, when the extension mode is {@link ExtensionMode#AUTO}, the current extension mode 86 * may change to the {@link ExtensionMode#NIGHT} or {@link ExtensionMode#HDR} depending on 87 * the current lighting conditions or environment. 88 * 89 * @return a {@link LiveData} of {@link Integer} type to observe the extension mode changes 90 * when {@link #isCurrentExtensionModeAvailable()} returns {@code true}. Otherwise, returns 91 * {@code null}. 92 */ getCurrentExtensionMode()93 default @Nullable LiveData<Integer> getCurrentExtensionMode() { 94 return null; 95 } 96 } 97