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 
17 package com.android.camera.one.v2.camera2proxy;
18 
19 import java.util.List;
20 
21 import android.hardware.camera2.CameraAccessException;
22 import android.hardware.camera2.CaptureFailure;
23 import android.hardware.camera2.CaptureRequest;
24 import android.hardware.camera2.CaptureResult;
25 import android.hardware.camera2.TotalCaptureResult;
26 import android.os.Handler;
27 
28 import 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  */
38 public interface CameraCaptureSessionProxy extends SafeCloseable {
39     public interface CaptureCallback {
onCaptureCompleted(CameraCaptureSessionProxy session, CaptureRequest request, TotalCaptureResult result)40         public void onCaptureCompleted(CameraCaptureSessionProxy session, CaptureRequest request,
41                 TotalCaptureResult result);
42 
onCaptureFailed(CameraCaptureSessionProxy session, CaptureRequest request, CaptureFailure failure)43         public void onCaptureFailed(CameraCaptureSessionProxy session, CaptureRequest request,
44                 CaptureFailure failure);
45 
onCaptureProgressed(CameraCaptureSessionProxy session, CaptureRequest request, CaptureResult partialResult)46         public void onCaptureProgressed(CameraCaptureSessionProxy session, CaptureRequest request,
47                 CaptureResult partialResult);
48 
onCaptureSequenceAborted(CameraCaptureSessionProxy session, int sequenceId)49         public void onCaptureSequenceAborted(CameraCaptureSessionProxy session, int sequenceId);
50 
onCaptureSequenceCompleted(CameraCaptureSessionProxy session, int sequenceId, long frameNumber)51         public void onCaptureSequenceCompleted(CameraCaptureSessionProxy session, int sequenceId,
52                 long frameNumber);
53 
onCaptureStarted(CameraCaptureSessionProxy session, CaptureRequest request, long timestamp, long frameNumber)54         public void onCaptureStarted(CameraCaptureSessionProxy session, CaptureRequest request,
55                 long timestamp, long frameNumber);
56     }
57 
58     public interface StateCallback {
onActive(CameraCaptureSessionProxy session)59         public void onActive(CameraCaptureSessionProxy session);
60 
onClosed(CameraCaptureSessionProxy session)61         public void onClosed(CameraCaptureSessionProxy session);
62 
onConfigureFailed(CameraCaptureSessionProxy session)63         public void onConfigureFailed(CameraCaptureSessionProxy session);
64 
onConfigured(CameraCaptureSessionProxy session)65         public void onConfigured(CameraCaptureSessionProxy session);
66 
onReady(CameraCaptureSessionProxy session)67         public void onReady(CameraCaptureSessionProxy session);
68     }
69 
abortCaptures()70     public void abortCaptures() throws CameraAccessException, CameraCaptureSessionClosedException;
71 
capture(CaptureRequest request, CaptureCallback listener, Handler handler)72     public int capture(CaptureRequest request, CaptureCallback listener, Handler handler)
73             throws CameraAccessException, CameraCaptureSessionClosedException;
74 
captureBurst(List<CaptureRequest> requests, CaptureCallback listener, Handler handler)75     public int captureBurst(List<CaptureRequest> requests, CaptureCallback listener, Handler
76             handler) throws CameraAccessException, CameraCaptureSessionClosedException;
77 
78     @Override
close()79     public void close();
80 
getDevice()81     public CameraDeviceProxy getDevice();
82 
setRepeatingBurst(List<CaptureRequest> requests, CaptureCallback listener, Handler handler)83     public int setRepeatingBurst(List<CaptureRequest> requests, CaptureCallback listener, Handler
84             handler) throws CameraAccessException, CameraCaptureSessionClosedException;
85 
setRepeatingRequest(CaptureRequest request, CaptureCallback listener, Handler handler)86     public int setRepeatingRequest(CaptureRequest request, CaptureCallback listener, Handler
87             handler) throws CameraAccessException, CameraCaptureSessionClosedException;
88 
stopRepeating()89     public void stopRepeating() throws CameraAccessException, CameraCaptureSessionClosedException;
90 }
91