summaryrefslogtreecommitdiff
path: root/camera2/extensions/sample/src/java/androidx/camera/extensions/impl/ExtenderStateListener.java
blob: f926cff9a521f4ee9a65cef25887bfd56667b3e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/*
 * 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.extensions.impl;

import android.content.Context;
import android.hardware.camera2.CameraCharacteristics;
import android.hardware.camera2.CameraDevice;
import android.hardware.camera2.CaptureRequest;

/**
 * Provides interfaces that the OEM needs to implement to handle the state change.
 *
 * @since 1.0
 * @hide
 */
public interface ExtenderStateListener {

    /**
     * Notify to initialize the extension. This will be called after bindToLifeCycle. This is
     * where the use case is started and would be able to allocate resources here. After onInit() is
     * called, the camera ID, cameraCharacteristics and context will not change until onDeInit()
     * has been called.
     *
     * @param cameraId The camera2 id string of the camera.
     * @param cameraCharacteristics The {@link CameraCharacteristics} of the camera.
     * @param context The {@link Context} used for CameraX.
     * @hide
     */
    void onInit(String cameraId, CameraCharacteristics cameraCharacteristics, Context context);

    /**
     * Notify to de-initialize the extension. This callback will be invoked after unbind.
     * After onDeInit() was called, it is expected that the camera ID, cameraCharacteristics will
     * no longer hold, this should be where to clear all resources allocated for this use case.
     * @hide
     */
    void onDeInit();

    /**
     * This will be invoked before creating a
     * {@link android.hardware.camera2.CameraCaptureSession}. The {@link CaptureRequest}
     * parameters returned via {@link CaptureStageImpl} 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 The request information to set the session wide camera parameters.
     * @hide
     */
    CaptureStageImpl onPresetSession();

    /**
     * This will be invoked once after the {@link android.hardware.camera2.CameraCaptureSession}
     * has been created. The {@link CaptureRequest} parameters returned via
     * {@link CaptureStageImpl} will be used to generate a single request to the current
     * configured {@link CameraDevice}. The generated request will be submitted to camera before
     * processing other single requests.
     *
     * @return The request information to create a single capture request to camera device.
     * @hide
     */
    CaptureStageImpl onEnableSession();

    /**
     * This will be invoked before the {@link android.hardware.camera2.CameraCaptureSession} is
     * closed. The {@link CaptureRequest} parameters returned via {@link CaptureStageImpl} will
     * be used to generate a single request to the currently configured {@link CameraDevice}. The
     * generated request will be submitted to camera before the CameraCaptureSession is closed.
     *
     * @return The request information to customize the session.
     * @hide
     */
    CaptureStageImpl onDisableSession();
}