public interface

CameraConfig

implements ReadableConfig

 androidx.camera.core.impl.CameraConfig

Gradle dependencies

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

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

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

Overview

Configuration for a Camera.

Summary

Fields
public static final Config.Option<java.lang.Boolean>OPTION_CAPTURE_PROCESS_PROGRESS_SUPPORTED

public static final Config.Option<Identifier>OPTION_COMPATIBILITY_ID

public static final Config.Option<java.lang.Boolean>OPTION_POSTVIEW_SUPPORTED

public static final Config.Option<SessionProcessor>OPTION_SESSION_PROCESSOR

public static final Config.Option<java.lang.Integer>OPTION_USE_CASE_COMBINATION_REQUIRED_RULE

public static final Config.Option<UseCaseConfigFactory>OPTION_USECASE_CONFIG_FACTORY

public static final Config.Option<java.lang.Boolean>OPTION_ZSL_DISABLED

public static final intREQUIRED_RULE_COEXISTING_PREVIEW_AND_IMAGE_CAPTURE

Both Preview and ImageCapture use cases are needed when the camera is opened by the camera config.

public static final intREQUIRED_RULE_NONE

No rule is required when the camera is opened by the camera config.

Methods
public IdentifiergetCompatibilityId()

Retrieves the compatibility Identifier.

public SessionProcessorgetSessionProcessor()

Returns the session processor which will transform the stream configurations and will perform the repeating request and still capture request when being requested by CameraX.

public SessionProcessorgetSessionProcessor(SessionProcessor valueIfMissing)

Returns the session processor which will transform the stream configurations and will perform the repeating request and still capture request when being requested by CameraX.

public intgetUseCaseCombinationRequiredRule()

Returns the use case combination required rule when the camera is opened by the camera config.

public UseCaseConfigFactorygetUseCaseConfigFactory()

Retrieves the use case config factory instance.

public booleanisCaptureProcessProgressSupported()

Returns if capture process progress is supported.

public booleanisPostviewSupported()

Returns if postview is supported or not.

Fields

public static final Config.Option<UseCaseConfigFactory> OPTION_USECASE_CONFIG_FACTORY

public static final Config.Option<Identifier> OPTION_COMPATIBILITY_ID

public static final Config.Option<java.lang.Integer> OPTION_USE_CASE_COMBINATION_REQUIRED_RULE

public static final Config.Option<SessionProcessor> OPTION_SESSION_PROCESSOR

public static final Config.Option<java.lang.Boolean> OPTION_ZSL_DISABLED

public static final Config.Option<java.lang.Boolean> OPTION_POSTVIEW_SUPPORTED

public static final Config.Option<java.lang.Boolean> OPTION_CAPTURE_PROCESS_PROGRESS_SUPPORTED

public static final int REQUIRED_RULE_NONE

No rule is required when the camera is opened by the camera config.

public static final int REQUIRED_RULE_COEXISTING_PREVIEW_AND_IMAGE_CAPTURE

Both Preview and ImageCapture use cases are needed when the camera is opened by the camera config. An extra Preview or ImageCapture will be added only if one use case is lacking. If both Preview and ImageCapture are not bound, no extra Preview and ImageCapture will be added.

Methods

public UseCaseConfigFactory getUseCaseConfigFactory()

Retrieves the use case config factory instance.

public Identifier getCompatibilityId()

Retrieves the compatibility Identifier.

If camera configs have the same compatibility identifier, they will allow to bind a new use case without unbinding all use cases first.

public int getUseCaseCombinationRequiredRule()

Returns the use case combination required rule when the camera is opened by the camera config.

public SessionProcessor getSessionProcessor(SessionProcessor valueIfMissing)

Returns the session processor which will transform the stream configurations and will perform the repeating request and still capture request when being requested by CameraX.

Parameters:

valueIfMissing: The value to return if this configuration option has not been set.

Returns:

The stored value or valueIfMissing if the value does not exist in this configuration.

public boolean isPostviewSupported()

Returns if postview is supported or not.

public boolean isCaptureProcessProgressSupported()

Returns if capture process progress is supported.

public SessionProcessor getSessionProcessor()

Returns the session processor which will transform the stream configurations and will perform the repeating request and still capture request when being requested by CameraX.

Returns:

The stored value, if it exists in this configuration.

Source

/*
 * Copyright 2020 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.IntDef;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.camera.core.ImageCapture;
import androidx.camera.core.Preview;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

/**
 * Configuration for a {@link androidx.camera.core.Camera}.
 */
public interface CameraConfig extends ReadableConfig {

    // Option Declarations:
    // *********************************************************************************************
    Option<UseCaseConfigFactory> OPTION_USECASE_CONFIG_FACTORY =
            Option.create("camerax.core.camera.useCaseConfigFactory",
                    UseCaseConfigFactory.class);

    Option<Identifier> OPTION_COMPATIBILITY_ID =
            Option.create("camerax.core.camera.compatibilityId",
                    Identifier.class);

    Option<Integer> OPTION_USE_CASE_COMBINATION_REQUIRED_RULE =
            Option.create("camerax.core.camera.useCaseCombinationRequiredRule", Integer.class);

    Option<SessionProcessor> OPTION_SESSION_PROCESSOR =
            Option.create("camerax.core.camera.SessionProcessor", SessionProcessor.class);

    Option<Boolean> OPTION_ZSL_DISABLED =
            Option.create("camerax.core.camera.isZslDisabled", Boolean.class);

    Option<Boolean> OPTION_POSTVIEW_SUPPORTED =
            Option.create("camerax.core.camera.isPostviewSupported", Boolean.class);

    Option<Boolean> OPTION_CAPTURE_PROCESS_PROGRESS_SUPPORTED =
            Option.create("camerax.core.camera.isCaptureProcessProgressSupported", Boolean.class);

    /**
     * No rule is required when the camera is opened by the camera config.
     */
    int REQUIRED_RULE_NONE = 0;

    /**
     * Both {@link Preview} and {@link ImageCapture} use cases are needed when the camera is
     * opened by the camera config. An extra {@link Preview} or {@link ImageCapture} will be
     * added only if one use case is lacking. If both {@link Preview} and {@link ImageCapture}
     * are not bound, no extra {@link Preview} and {@link ImageCapture} will be added.
     */
    int REQUIRED_RULE_COEXISTING_PREVIEW_AND_IMAGE_CAPTURE = 1;

    @IntDef({REQUIRED_RULE_NONE,
            REQUIRED_RULE_COEXISTING_PREVIEW_AND_IMAGE_CAPTURE})
    @Retention(RetentionPolicy.SOURCE)
    @interface RequiredRule {
    }

    /**
     * Retrieves the use case config factory instance.
     */
    @NonNull
    default UseCaseConfigFactory getUseCaseConfigFactory() {
        return retrieveOption(OPTION_USECASE_CONFIG_FACTORY, UseCaseConfigFactory.EMPTY_INSTANCE);
    }

    /**
     * Retrieves the compatibility {@link Identifier}.
     *
     * <p>If camera configs have the same compatibility identifier, they will allow to bind a new
     * use case without unbinding all use cases first.
     */
    @NonNull
    Identifier getCompatibilityId();

    /**
     * Returns the use case combination required rule when the camera is opened by the camera
     * config.
     */
    @RequiredRule
    default int getUseCaseCombinationRequiredRule() {
        return retrieveOption(OPTION_USE_CASE_COMBINATION_REQUIRED_RULE, REQUIRED_RULE_NONE);
    }

    /**
     * Returns the session processor which will transform the stream configurations and
     * will perform the repeating request and still capture request when being requested by CameraX.
     *
     * @param valueIfMissing The value to return if this configuration option has not been set.
     * @return The stored value or <code>valueIfMissing</code> if the value does not exist in this
     * configuration.
     */
    @Nullable
    default SessionProcessor getSessionProcessor(@Nullable SessionProcessor valueIfMissing) {
        return retrieveOption(OPTION_SESSION_PROCESSOR, valueIfMissing);
    }

    /**
     * Returns if postview is supported or not.
     */
    default boolean isPostviewSupported() {
        return retrieveOption(OPTION_POSTVIEW_SUPPORTED, false);
    }

    /**
     * Returns if capture process progress is supported.
     */
    default boolean isCaptureProcessProgressSupported() {
        return retrieveOption(OPTION_CAPTURE_PROCESS_PROGRESS_SUPPORTED, false);
    }

    /**
     * Returns the session processor which will transform the stream configurations and will
     * perform the repeating request and still capture request when being requested by CameraX.
     *
     * @return The stored value, if it exists in this configuration.
     * @throws IllegalArgumentException if the option does not exist in this configuration.
     */
    @NonNull
    default SessionProcessor getSessionProcessor() {
        return retrieveOption(OPTION_SESSION_PROCESSOR);
    }

    /**
     * Builder for creating a {@link CameraConfig}.
     *
     * @param <B> the top level builder type for which this builder is composed with.
     */
    interface Builder<B> {
        /**
         * Sets a {@link UseCaseConfigFactory} for the camera config.
         */
        @NonNull
        B setUseCaseConfigFactory(@NonNull UseCaseConfigFactory factory);

        /**
         * Sets compatibility {@link Identifier} for the camera config.
         */
        @NonNull
        B setCompatibilityId(@NonNull Identifier identifier);

        /**
         * Sets use case combination required rule to this configuration.
         */
        @NonNull
        B setUseCaseCombinationRequiredRule(@RequiredRule int useCaseCombinationRequiredRule);

        /**
         * Sets the session processor which will transform the stream configurations and will
         * perform the repeating request and still capture request when being requested by CameraX.
         */
        @NonNull
        B setSessionProcessor(@NonNull SessionProcessor sessionProcessor);

        /**
         * Sets zsl disabled or not. If disabled is true, zero-shutter lag should be disabled.
         * Otherwise, zero-shutter lag should not be disabled. However, enabling zero-shutter lag
         * needs other conditions e.g. flash mode OFF, so setting to false doesn't guarantee
         * zero-shutter lag to be always ON.
         */
        @NonNull
        B setZslDisabled(boolean disabled);

        /**
         * Sets if the postview is supported or not.
         */
        B setPostviewSupported(boolean postviewSupported);

        /**
         * Sets if the capture process progress is supported.
         */
        B setCaptureProcessProgressSupported(boolean supported);
    }
}