public abstract class

CameraEventCallback

extends java.lang.Object

 java.lang.Object

↳androidx.camera.camera2.impl.CameraEventCallback

Subclasses:

PreviewExtender.PreviewExtenderAdapter, ImageCaptureExtender.ImageCaptureAdapter

Gradle dependencies

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

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

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

Overview

A callback object for tracking the camera capture session event and get request data.

Summary

Constructors
publicCameraEventCallback()

Methods
public CaptureConfigonDisableSession()

This will be invoked once before the CameraCaptureSession is closed.

public CaptureConfigonEnableSession()

This will be invoked once after a CameraCaptureSession is created.

public CaptureConfigonPresetSession()

This will be invoked before creating a CameraCaptureSession.

public CaptureConfigonRepeating()

This callback will be invoked before starting the repeating request in the CameraCaptureSession.

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

Constructors

public CameraEventCallback()

Methods

public CaptureConfig onPresetSession()

This will be invoked before creating a CameraCaptureSession. The returned parameter in CaptureConfig will be passed to the camera device as part of the capture session initialization via setSessionParameters(). The valid parameter is a subset of the available capture request parameters.

Returns:

CaptureConfig The request information to customize the session.

public CaptureConfig onEnableSession()

This will be invoked once after a CameraCaptureSession is created. The returned parameter in CaptureConfig will be used to generate a single request to the current configured camera device. The generated request would be submitted to camera before process other single request.

Returns:

CaptureConfig The request information to customize the session.

public CaptureConfig onRepeating()

This callback will be invoked before starting the repeating request in the CameraCaptureSession. The returned CaptureConfig will be used to generate a capture request, and would be used in setRepeatingRequest().

Returns:

CaptureConfig The request information to customize the session.

public CaptureConfig onDisableSession()

This will be invoked once before the CameraCaptureSession is closed. The returned parameter in CaptureConfig will be used to generate a single request to the current configured camera device. The generated request would be submitted to camera before the capture session was closed.

Returns:

CaptureConfig The request information to customize the session.

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.camera2.impl;

import android.hardware.camera2.CameraCaptureSession;

import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.camera.core.impl.CaptureConfig;

/**
 * A callback object for tracking the camera capture session event and get request data.
 */
@RequiresApi(21) // TODO(b/200306659): Remove and replace with annotation on package-info.java
public abstract class CameraEventCallback {

    /**
     * This will be invoked before creating a {@link CameraCaptureSession}. The returned
     * parameter in CaptureConfig will be passed to the camera device as part of the capture session
     * initialization via setSessionParameters(). The valid parameter is a subset of the
     * available capture request parameters.
     *
     * @return CaptureConfig The request information to customize the session.
     */
    @Nullable
    public CaptureConfig onPresetSession() {
        return null;
    }

    /**
     * This will be invoked once after a {@link CameraCaptureSession} is created. The returned
     * parameter in CaptureConfig will be used to generate a single request to the current
     * configured camera device. The generated request would be submitted to camera before process
     * other single request.
     *
     * @return CaptureConfig The request information to customize the session.
     */
    @Nullable
    public CaptureConfig onEnableSession() {
        return null;
    }

    /**
     * This callback will be invoked before starting the repeating request in the
     * {@link CameraCaptureSession}. The returned CaptureConfig will be used to generate a
     * capture request, and would be used in setRepeatingRequest().
     *
     * @return CaptureConfig The request information to customize the session.
     */
    @Nullable
    public CaptureConfig onRepeating() {
        return null;
    }

    /**
     * This will be invoked once before the {@link CameraCaptureSession} is closed. The
     * returned parameter in CaptureConfig will be used to generate a single request to the current
     * configured camera device. The generated request would be submitted to camera before the
     * capture session was closed.
     *
     * @return CaptureConfig The request information to customize the session.
     */
    @Nullable
    public CaptureConfig onDisableSession() {
        return null;
    }

}