1/*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.camera.one.v2.camera2proxy;
18
19import java.util.List;
20
21import android.hardware.camera2.CameraAccessException;
22import android.hardware.camera2.CaptureFailure;
23import android.hardware.camera2.CaptureRequest;
24import android.hardware.camera2.CaptureResult;
25import android.hardware.camera2.TotalCaptureResult;
26import android.os.Handler;
27
28import com.android.camera.async.SafeCloseable;
29
30/**
31 * Interface for {@link android.hardware.camera2.CameraCaptureSession}.
32 * <p>
33 * Note that this also enables translation of IllegalStateException (an
34 * unchecked exception) resulting from the underlying session being closed into
35 * a checked exception, forcing callers to explicitly handle this edge case.
36 * </p>
37 */
38public interface CameraCaptureSessionProxy extends SafeCloseable {
39    public interface CaptureCallback {
40        public void onCaptureCompleted(CameraCaptureSessionProxy session, CaptureRequest request,
41                TotalCaptureResult result);
42
43        public void onCaptureFailed(CameraCaptureSessionProxy session, CaptureRequest request,
44                CaptureFailure failure);
45
46        public void onCaptureProgressed(CameraCaptureSessionProxy session, CaptureRequest request,
47                CaptureResult partialResult);
48
49        public void onCaptureSequenceAborted(CameraCaptureSessionProxy session, int sequenceId);
50
51        public void onCaptureSequenceCompleted(CameraCaptureSessionProxy session, int sequenceId,
52                long frameNumber);
53
54        public void onCaptureStarted(CameraCaptureSessionProxy session, CaptureRequest request,
55                long timestamp, long frameNumber);
56    }
57
58    public interface StateCallback {
59        public void onActive(CameraCaptureSessionProxy session);
60
61        public void onClosed(CameraCaptureSessionProxy session);
62
63        public void onConfigureFailed(CameraCaptureSessionProxy session);
64
65        public void onConfigured(CameraCaptureSessionProxy session);
66
67        public void onReady(CameraCaptureSessionProxy session);
68    }
69
70    public void abortCaptures() throws CameraAccessException, CameraCaptureSessionClosedException;
71
72    public int capture(CaptureRequest request, CaptureCallback listener, Handler handler)
73            throws CameraAccessException, CameraCaptureSessionClosedException;
74
75    public int captureBurst(List<CaptureRequest> requests, CaptureCallback listener, Handler
76            handler) throws CameraAccessException, CameraCaptureSessionClosedException;
77
78    @Override
79    public void close();
80
81    public CameraDeviceProxy getDevice();
82
83    public int setRepeatingBurst(List<CaptureRequest> requests, CaptureCallback listener, Handler
84            handler) throws CameraAccessException, CameraCaptureSessionClosedException;
85
86    public int setRepeatingRequest(CaptureRequest request, CaptureCallback listener, Handler
87            handler) throws CameraAccessException, CameraCaptureSessionClosedException;
88
89    public void stopRepeating() throws CameraAccessException, CameraCaptureSessionClosedException;
90}
91