1 /*
2  * Copyright (C) 2015 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 android.media.ImageReader;
20 import android.os.Handler;
21 import android.view.Surface;
22 
23 import com.android.camera.async.SafeCloseable;
24 
25 import javax.annotation.Nonnull;
26 import javax.annotation.Nullable;
27 import javax.annotation.concurrent.ThreadSafe;
28 
29 /**
30  * Interface for {@link android.media.ImageReader}.
31  */
32 @ThreadSafe
33 public interface ImageReaderProxy extends SafeCloseable {
34     /**
35      * See {@link ImageReader.OnImageAvailableListener}
36      */
37     public interface OnImageAvailableListener {
38         /**
39          * See {@link ImageReader.OnImageAvailableListener#onImageAvailable}
40          */
onImageAvailable()41         public void onImageAvailable();
42     }
43 
44     /**
45      * @See {@link ImageReader#getWidth}.
46      */
getWidth()47     public int getWidth();
48 
49     /**
50      * @See {@link ImageReader#getHeight}.
51      */
getHeight()52     public int getHeight();
53 
54     /**
55      * @See {@link ImageReader#getImageFormat}.
56      */
getImageFormat()57     public int getImageFormat();
58 
59     /**
60      * @See {@link ImageReader#getMaxImages}.
61      */
getMaxImages()62     public int getMaxImages();
63 
64     /**
65      * @See {@link ImageReader#getSurface}.
66      */
67     @Nonnull
getSurface()68     public Surface getSurface();
69 
70     /**
71      * @See {@link ImageReader#acquireLatestImage}.
72      */
73     @Nullable
acquireLatestImage()74     public ImageProxy acquireLatestImage();
75 
76     /**
77      * @See {@link ImageReader#acquireNextImage}.
78      */
79     @Nullable
acquireNextImage()80     public ImageProxy acquireNextImage();
81 
82     /**
83      * @See {@link ImageReader#setOnImageAvailableListener}.
84      */
setOnImageAvailableListener( @onnull ImageReaderProxy.OnImageAvailableListener listener, @Nullable Handler handler)85     public void setOnImageAvailableListener(
86             @Nonnull ImageReaderProxy.OnImageAvailableListener listener,
87             @Nullable Handler handler);
88 
89     /**
90      * @See {@link ImageReader#close}.
91      */
92     @Override
close()93     public void close();
94 }
95