1 /* 2 * Copyright 2023 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.impl; 18 19 import static android.media.CamcorderProfile.QUALITY_1080P; 20 import static android.media.CamcorderProfile.QUALITY_2160P; 21 import static android.media.CamcorderProfile.QUALITY_480P; 22 import static android.media.CamcorderProfile.QUALITY_4KDCI; 23 import static android.media.CamcorderProfile.QUALITY_720P; 24 import static android.media.CamcorderProfile.QUALITY_8KUHD; 25 import static android.media.CamcorderProfile.QUALITY_CIF; 26 import static android.media.CamcorderProfile.QUALITY_QCIF; 27 import static android.media.CamcorderProfile.QUALITY_QHD; 28 import static android.media.CamcorderProfile.QUALITY_QVGA; 29 import static android.media.CamcorderProfile.QUALITY_VGA; 30 31 import static java.util.Arrays.asList; 32 import static java.util.Collections.unmodifiableList; 33 34 import android.media.CamcorderProfile; 35 36 import org.jspecify.annotations.Nullable; 37 38 import java.util.List; 39 40 /** 41 * EncoderProfilesProvider is used to obtain the {@link EncoderProfilesProxy}. 42 */ 43 public interface EncoderProfilesProvider { 44 45 /** 46 * Checks if the quality is supported on this device. 47 * 48 * <p>The quality should be one of quality constants defined in {@link CamcorderProfile}. 49 */ hasProfile(int quality)50 boolean hasProfile(int quality); 51 52 /** 53 * Gets the {@link EncoderProfilesProxy} if the quality is supported on the device. 54 * 55 * <p>The quality should be one of quality constants defined in {@link CamcorderProfile}. 56 * 57 * @see #hasProfile(int) 58 */ getAll(int quality)59 @Nullable EncoderProfilesProxy getAll(int quality); 60 61 /** An implementation that contains no data. */ 62 EncoderProfilesProvider EMPTY = new EncoderProfilesProvider() { 63 @Override 64 public boolean hasProfile(int quality) { 65 return false; 66 } 67 68 @Override 69 public @Nullable EncoderProfilesProxy getAll(int quality) { 70 return null; 71 } 72 }; 73 74 List<Integer> QUALITY_HIGH_TO_LOW = unmodifiableList(asList( 75 QUALITY_8KUHD, // 7680x4320 76 QUALITY_4KDCI, // 4096x2160 77 QUALITY_2160P, // 3840x2160 78 QUALITY_QHD, // 2560x1440 79 QUALITY_1080P, // 1920x1080 80 QUALITY_720P, // 1280x720 81 QUALITY_480P, // 720x480 82 QUALITY_VGA, // 640x480 83 QUALITY_CIF, // 352x288 84 QUALITY_QVGA, // 320x240 85 QUALITY_QCIF // 176x144 86 )); 87 } 88