public class

Camera2PhysicalCameraInfoImpl

extends java.lang.Object

implements CameraInfo

 java.lang.Object

↳androidx.camera.camera2.internal.Camera2PhysicalCameraInfoImpl

Gradle dependencies

compile group: 'androidx.camera', name: 'camera-camera2', version: '1.5.0-alpha01'

  • groupId: androidx.camera
  • artifactId: camera-camera2
  • version: 1.5.0-alpha01

Artifact androidx.camera:camera-camera2:1.5.0-alpha01 it located at Google repository (https://maven.google.com/)

Summary

Constructors
publicCamera2PhysicalCameraInfoImpl(java.lang.String cameraId, CameraManagerCompat cameraManager)

Methods
public Camera2CameraInfogetCamera2CameraInfo()

Gets the implementation of Camera2CameraInfo.

public CameraCharacteristicsCompatgetCameraCharacteristicsCompat()

public java.lang.StringgetCameraId()

public CameraSelectorgetCameraSelector()

public LiveData<CameraState>getCameraState()

public ExposureStategetExposureState()

public java.lang.StringgetImplementationType()

public floatgetIntrinsicZoomRatio()

public intgetLensFacing()

public java.util.Set<CameraInfo>getPhysicalCameraInfos()

public intgetSensorRotationDegrees()

public intgetSensorRotationDegrees(int relativeRotation)

public java.util.Set<>getSupportedFrameRateRanges()

public LiveData<java.lang.Integer>getTorchState()

public LiveData<ZoomState>getZoomState()

public booleanhasFlashUnit()

public booleanisFocusMeteringSupported(FocusMeteringAction action)

public booleanisLogicalMultiCameraSupported()

public booleanisPrivateReprocessingSupported()

public booleanisZslSupported()

public java.util.Set<DynamicRange>querySupportedDynamicRanges(java.util.Set<DynamicRange> candidateDynamicRanges)

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public Camera2PhysicalCameraInfoImpl(java.lang.String cameraId, CameraManagerCompat cameraManager)

Methods

public Camera2CameraInfo getCamera2CameraInfo()

Gets the implementation of Camera2CameraInfo.

public java.lang.String getCameraId()

public CameraCharacteristicsCompat getCameraCharacteristicsCompat()

public int getSensorRotationDegrees()

public int getSensorRotationDegrees(int relativeRotation)

public boolean hasFlashUnit()

public LiveData<java.lang.Integer> getTorchState()

public LiveData<ZoomState> getZoomState()

public ExposureState getExposureState()

public LiveData<CameraState> getCameraState()

public java.lang.String getImplementationType()

public CameraSelector getCameraSelector()

public int getLensFacing()

public float getIntrinsicZoomRatio()

public boolean isFocusMeteringSupported(FocusMeteringAction action)

public boolean isZslSupported()

public java.util.Set<> getSupportedFrameRateRanges()

public boolean isLogicalMultiCameraSupported()

public boolean isPrivateReprocessingSupported()

public java.util.Set<DynamicRange> querySupportedDynamicRanges(java.util.Set<DynamicRange> candidateDynamicRanges)

public java.util.Set<CameraInfo> getPhysicalCameraInfos()

Source

/*
 * Copyright 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package androidx.camera.camera2.internal;

import android.annotation.SuppressLint;
import android.hardware.camera2.CameraCharacteristics;
import android.util.Range;
import android.view.Surface;

import androidx.annotation.NonNull;
import androidx.camera.camera2.internal.compat.CameraAccessExceptionCompat;
import androidx.camera.camera2.internal.compat.CameraCharacteristicsCompat;
import androidx.camera.camera2.internal.compat.CameraManagerCompat;
import androidx.camera.camera2.interop.Camera2CameraInfo;
import androidx.camera.camera2.interop.ExperimentalCamera2Interop;
import androidx.camera.core.CameraInfo;
import androidx.camera.core.CameraSelector;
import androidx.camera.core.CameraState;
import androidx.camera.core.DynamicRange;
import androidx.camera.core.ExperimentalZeroShutterLag;
import androidx.camera.core.ExposureState;
import androidx.camera.core.FocusMeteringAction;
import androidx.camera.core.ZoomState;
import androidx.camera.core.impl.utils.CameraOrientationUtil;
import androidx.core.util.Preconditions;
import androidx.lifecycle.LiveData;

import java.util.Set;

@ExperimentalCamera2Interop
public class Camera2PhysicalCameraInfoImpl implements CameraInfo {

    @NonNull private final String mCameraId;
    @NonNull private final CameraCharacteristicsCompat mCameraCharacteristicsCompat;
    @NonNull private final Camera2CameraInfo mCamera2CameraInfo;

    public Camera2PhysicalCameraInfoImpl(@NonNull String cameraId,
            @NonNull CameraManagerCompat cameraManager) throws CameraAccessExceptionCompat {
        mCameraId = cameraId;
        mCameraCharacteristicsCompat = cameraManager.getCameraCharacteristicsCompat(mCameraId);
        mCamera2CameraInfo = new Camera2CameraInfo(this);
    }

    /**
     * Gets the implementation of {@link Camera2CameraInfo}.
     */
    @NonNull
    public Camera2CameraInfo getCamera2CameraInfo() {
        return mCamera2CameraInfo;
    }

    @NonNull
    public String getCameraId() {
        return mCameraId;
    }

    @NonNull
    public CameraCharacteristicsCompat getCameraCharacteristicsCompat() {
        return mCameraCharacteristicsCompat;
    }

    @Override
    public int getSensorRotationDegrees() {
        return getSensorRotationDegrees(Surface.ROTATION_0);
    }

    @Override
    public int getSensorRotationDegrees(int relativeRotation) {
        int sensorOrientation = getSensorOrientation();
        int relativeRotationDegrees =
                CameraOrientationUtil.surfaceRotationToDegrees(relativeRotation);
        // Currently this assumes that a back-facing camera is always opposite to the screen.
        // This may not be the case for all devices, so in the future we may need to handle that
        // scenario.
        final int lensFacing = getLensFacing();
        boolean isOppositeFacingScreen = CameraSelector.LENS_FACING_BACK == lensFacing;
        return CameraOrientationUtil.getRelativeImageRotation(
                relativeRotationDegrees,
                sensorOrientation,
                isOppositeFacingScreen);
    }

    @Override
    public boolean hasFlashUnit() {
        throw new UnsupportedOperationException("Physical camera doesn't support this function");
    }

    @NonNull
    @Override
    public LiveData<Integer> getTorchState() {
        throw new UnsupportedOperationException("Physical camera doesn't support this function");
    }

    @NonNull
    @Override
    public LiveData<ZoomState> getZoomState() {
        throw new UnsupportedOperationException("Physical camera doesn't support this function");
    }

    @NonNull
    @Override
    public ExposureState getExposureState() {
        throw new UnsupportedOperationException("Physical camera doesn't support this function");
    }

    @NonNull
    @Override
    public LiveData<CameraState> getCameraState() {
        throw new UnsupportedOperationException("Physical camera doesn't support this function");
    }

    @NonNull
    @Override
    public String getImplementationType() {
        throw new UnsupportedOperationException("Physical camera doesn't support this function");
    }

    @NonNull
    @Override
    public CameraSelector getCameraSelector() {
        throw new UnsupportedOperationException("Physical camera doesn't support this function");
    }

    @Override
    public int getLensFacing() {
        Integer lensFacing = mCameraCharacteristicsCompat.get(CameraCharacteristics.LENS_FACING);
        Preconditions.checkArgument(lensFacing != null, "Unable to get the lens facing of the "
                + "camera.");
        return LensFacingUtil.getCameraSelectorLensFacing(lensFacing);
    }

    @Override
    public float getIntrinsicZoomRatio() {
        throw new UnsupportedOperationException("Physical camera doesn't support this function");
    }

    @Override
    public boolean isFocusMeteringSupported(@NonNull FocusMeteringAction action) {
        throw new UnsupportedOperationException("Physical camera doesn't support this function");
    }

    @SuppressLint("NullAnnotationGroup")
    @ExperimentalZeroShutterLag
    @Override
    public boolean isZslSupported() {
        throw new UnsupportedOperationException("Physical camera doesn't support this function");
    }

    @NonNull
    @Override
    public Set<Range<Integer>> getSupportedFrameRateRanges() {
        throw new UnsupportedOperationException("Physical camera doesn't support this function");
    }

    @Override
    public boolean isLogicalMultiCameraSupported() {
        throw new UnsupportedOperationException("Physical camera doesn't support this function");
    }

    @Override
    public boolean isPrivateReprocessingSupported() {
        throw new UnsupportedOperationException("Physical camera doesn't support this function");
    }

    @NonNull
    @Override
    public Set<DynamicRange> querySupportedDynamicRanges(
            @NonNull Set<DynamicRange> candidateDynamicRanges) {
        throw new UnsupportedOperationException("Physical camera doesn't support this function");
    }

    @NonNull
    @Override
    public Set<CameraInfo> getPhysicalCameraInfos() {
        throw new UnsupportedOperationException("Physical camera doesn't support this function");
    }

    int getSensorOrientation() {
        Integer sensorOrientation =
                mCameraCharacteristicsCompat.get(CameraCharacteristics.SENSOR_ORIENTATION);
        Preconditions.checkNotNull(sensorOrientation);
        return sensorOrientation;
    }
}