public class

VirtualCameraCaptureResult

extends java.lang.Object

implements CameraCaptureResult

 java.lang.Object

↳androidx.camera.core.streamsharing.VirtualCameraCaptureResult

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

A virtual CameraCaptureResult which based on a real instance with some fields overridden.

Summary

Constructors
publicVirtualCameraCaptureResult(TagBundle tagBundle, CameraCaptureResult baseCameraCaptureResult)

Creates an instance based on another CameraCaptureResult.

publicVirtualCameraCaptureResult(TagBundle tagBundle, long timestamp)

Creates empty instance with timestamp overridden.

Methods
public CameraCaptureMetaData.AeModegetAeMode()

public CameraCaptureMetaData.AeStategetAeState()

public CameraCaptureMetaData.AfModegetAfMode()

public CameraCaptureMetaData.AfStategetAfState()

public CameraCaptureMetaData.AwbModegetAwbMode()

public CameraCaptureMetaData.AwbStategetAwbState()

public CameraCaptureMetaData.FlashStategetFlashState()

public TagBundlegetTagBundle()

public longgetTimestamp()

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

Constructors

public VirtualCameraCaptureResult(TagBundle tagBundle, CameraCaptureResult baseCameraCaptureResult)

Creates an instance based on another CameraCaptureResult.

Parameters:

baseCameraCaptureResult: Most of the fields return the value of the base instance.
tagBundle: the overridden value for the VirtualCameraCaptureResult.getTagBundle() field.

public VirtualCameraCaptureResult(TagBundle tagBundle, long timestamp)

Creates empty instance with timestamp overridden.

Parameters:

tagBundle: the overridden value for the VirtualCameraCaptureResult.getTagBundle() field.
timestamp: the overridden value for the VirtualCameraCaptureResult.getTimestamp() field.

Methods

public TagBundle getTagBundle()

public CameraCaptureMetaData.AfMode getAfMode()

public CameraCaptureMetaData.AfState getAfState()

public CameraCaptureMetaData.AeState getAeState()

public CameraCaptureMetaData.AwbState getAwbState()

public CameraCaptureMetaData.FlashState getFlashState()

public CameraCaptureMetaData.AeMode getAeMode()

public CameraCaptureMetaData.AwbMode getAwbMode()

public long getTimestamp()

Source

/*
 * Copyright 2023 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.streamsharing;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.camera.core.impl.CameraCaptureMetaData;
import androidx.camera.core.impl.CameraCaptureResult;
import androidx.camera.core.impl.TagBundle;

/**
 * A virtual {@link CameraCaptureResult} which based on a real instance with some fields
 * overridden.
 */
public class VirtualCameraCaptureResult implements CameraCaptureResult {

    private static final long INVALID_TIMESTAMP = -1;

    @Nullable
    private final CameraCaptureResult mBaseCameraCaptureResult;
    @NonNull
    private final TagBundle mTagBundle;
    private final long mTimestamp;

    /**
     * Creates an instance based on another {@link CameraCaptureResult}.
     *
     * @param baseCameraCaptureResult Most of the fields return the value of the base instance.
     * @param tagBundle               the overridden value for the {@link #getTagBundle()} field.
     */
    public VirtualCameraCaptureResult(
            @NonNull TagBundle tagBundle,
            @Nullable CameraCaptureResult baseCameraCaptureResult) {
        this(baseCameraCaptureResult, tagBundle, INVALID_TIMESTAMP);
    }

    /**
     * Creates empty instance with timestamp overridden.
     *
     * @param tagBundle the overridden value for the {@link #getTagBundle()} field.
     * @param timestamp the overridden value for the {@link #getTimestamp()} field.
     */
    public VirtualCameraCaptureResult(
            @NonNull TagBundle tagBundle,
            long timestamp) {
        this(/*baseCameraCaptureResult*/null, tagBundle, timestamp);
    }

    private VirtualCameraCaptureResult(
            @Nullable CameraCaptureResult baseCameraCaptureResult,
            @NonNull TagBundle tagBundle,
            long timestamp) {
        mBaseCameraCaptureResult = baseCameraCaptureResult;
        mTagBundle = tagBundle;
        mTimestamp = timestamp;
    }

    @NonNull
    @Override
    public TagBundle getTagBundle() {
        // Returns the overridden value.
        return mTagBundle;
    }

    @NonNull
    @Override
    public CameraCaptureMetaData.AfMode getAfMode() {
        return mBaseCameraCaptureResult != null ? mBaseCameraCaptureResult.getAfMode() :
                CameraCaptureMetaData.AfMode.UNKNOWN;
    }

    @NonNull
    @Override
    public CameraCaptureMetaData.AfState getAfState() {
        return mBaseCameraCaptureResult != null ? mBaseCameraCaptureResult.getAfState() :
                CameraCaptureMetaData.AfState.UNKNOWN;
    }

    @NonNull
    @Override
    public CameraCaptureMetaData.AeState getAeState() {
        return mBaseCameraCaptureResult != null ? mBaseCameraCaptureResult.getAeState() :
                CameraCaptureMetaData.AeState.UNKNOWN;
    }

    @NonNull
    @Override
    public CameraCaptureMetaData.AwbState getAwbState() {
        return mBaseCameraCaptureResult != null ? mBaseCameraCaptureResult.getAwbState() :
                CameraCaptureMetaData.AwbState.UNKNOWN;
    }

    @NonNull
    @Override
    public CameraCaptureMetaData.FlashState getFlashState() {
        return mBaseCameraCaptureResult != null ? mBaseCameraCaptureResult.getFlashState() :
                CameraCaptureMetaData.FlashState.UNKNOWN;
    }

    @NonNull
    @Override
    public CameraCaptureMetaData.AeMode getAeMode() {
        return mBaseCameraCaptureResult != null ? mBaseCameraCaptureResult.getAeMode() :
                CameraCaptureMetaData.AeMode.UNKNOWN;
    }

    @NonNull
    @Override
    public CameraCaptureMetaData.AwbMode getAwbMode() {
        return mBaseCameraCaptureResult != null ? mBaseCameraCaptureResult.getAwbMode() :
                CameraCaptureMetaData.AwbMode.UNKNOWN;
    }

    @Override
    public long getTimestamp() {
        if (mBaseCameraCaptureResult != null) {
            return mBaseCameraCaptureResult.getTimestamp();
        } else if (mTimestamp != INVALID_TIMESTAMP) {
            return mTimestamp;
        }
        throw new IllegalStateException("No timestamp is available.");
    }
}