public interface

CameraInfoInternal

implements CameraInfo

 androidx.camera.core.impl.CameraInfoInternal

Subclasses:

Camera2CameraInfoImpl

Gradle dependencies

compile group: 'androidx.camera', name: 'camera-core', version: '1.2.0-alpha01'

  • groupId: androidx.camera
  • artifactId: camera-core
  • version: 1.2.0-alpha01

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

Overview

An interface for retrieving camera information.

Contains methods for retrieving characteristics for a specific camera.

Summary

Methods
public voidaddSessionCaptureCallback(java.util.concurrent.Executor executor, CameraCaptureCallback callback)

Adds a CameraCaptureCallback which will be invoked when session capture request is completed, failed or cancelled.

public CamcorderProfileProvidergetCamcorderProfileProvider()

Returns the CamcorderProfileProvider associated with this camera.

public java.lang.StringgetCameraId()

Returns the camera id of this camera.

public QuirksgetCameraQuirks()

Returns a list of quirks related to the camera.

public CameraSelectorgetCameraSelector()

public java.lang.IntegergetLensFacing()

Returns the LensFacing of this camera.

public voidremoveSessionCaptureCallback(CameraCaptureCallback callback)

Removes the CameraCaptureCallback which was added in CameraInfoInternal.addSessionCaptureCallback(Executor, CameraCaptureCallback).

Methods

public java.lang.Integer getLensFacing()

Returns the LensFacing of this camera.

Returns:

One of CameraSelector.LENS_FACING_FRONT, CameraSelector.LENS_FACING_BACK, or null if the LensFacing does not fall into one of these two categories.

public java.lang.String getCameraId()

Returns the camera id of this camera.

Returns:

the camera id

public void addSessionCaptureCallback(java.util.concurrent.Executor executor, CameraCaptureCallback callback)

Adds a CameraCaptureCallback which will be invoked when session capture request is completed, failed or cancelled.

The callback will be invoked on the specified java.util.concurrent.Executor.

public void removeSessionCaptureCallback(CameraCaptureCallback callback)

Removes the CameraCaptureCallback which was added in CameraInfoInternal.addSessionCaptureCallback(Executor, CameraCaptureCallback).

public Quirks getCameraQuirks()

Returns a list of quirks related to the camera.

public CamcorderProfileProvider getCamcorderProfileProvider()

Returns the CamcorderProfileProvider associated with this camera.

public CameraSelector getCameraSelector()

Source

/*
 * Copyright 2019 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.core.impl;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.camera.core.CameraInfo;
import androidx.camera.core.CameraSelector;
import androidx.core.util.Preconditions;

import java.util.Collections;
import java.util.concurrent.Executor;

/**
 * An interface for retrieving camera information.
 *
 * <p>Contains methods for retrieving characteristics for a specific camera.
 */
@RequiresApi(21) // TODO(b/200306659): Remove and replace with annotation on package-info.java
public interface CameraInfoInternal extends CameraInfo {
    /**
     * Returns the LensFacing of this camera.
     *
     * @return One of {@link androidx.camera.core.CameraSelector#LENS_FACING_FRONT},
     * {@link androidx.camera.core.CameraSelector#LENS_FACING_BACK}, or <code>null</code> if the
     * LensFacing does not fall into one of these two categories.
     */
    // TODO(b/122975195): Remove @Nullable and null return type once we have a LensFacing type which
    // can be used to represent non-BACK or FRONT facing lenses.
    @Nullable
    Integer getLensFacing();

    /**
     * Returns the camera id of this camera.
     *
     * @return the camera id
     */
    @NonNull
    String getCameraId();

    /**
     * Adds a {@link CameraCaptureCallback} which will be invoked when session capture request is
     * completed, failed or cancelled.
     *
     * <p>The callback will be invoked on the specified {@link Executor}.
     */
    void addSessionCaptureCallback(@NonNull Executor executor,
            @NonNull CameraCaptureCallback callback);

    /**
     * Removes the {@link CameraCaptureCallback} which was added in
     * {@link #addSessionCaptureCallback(Executor, CameraCaptureCallback)}.
     */
    void removeSessionCaptureCallback(@NonNull CameraCaptureCallback callback);

    /** Returns a list of quirks related to the camera. */
    @NonNull
    Quirks getCameraQuirks();

    /** Returns the {@link CamcorderProfileProvider} associated with this camera. */
    @NonNull
    CamcorderProfileProvider getCamcorderProfileProvider();

    /** {@inheritDoc} */
    @NonNull
    @Override
    default CameraSelector getCameraSelector() {
        return new CameraSelector.Builder()
                .addCameraFilter(cameraInfos -> {
                    final String cameraId = getCameraId();
                    for (CameraInfo cameraInfo : cameraInfos) {
                        Preconditions.checkArgument(cameraInfo instanceof CameraInfoInternal);
                        final CameraInfoInternal cameraInfoInternal =
                                (CameraInfoInternal) cameraInfo;
                        if (cameraInfoInternal.getCameraId().equals(cameraId)) {
                            return Collections.singletonList(cameraInfo);
                        }
                    }
                    throw new IllegalStateException("Unable to find camera with id " + cameraId
                            + " from list of available cameras.");
                })
                .build();
    }
}