Home | History | Annotate | Download | only in devcamera
      1 /*
      2  * Copyright (C) 2016 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 package com.android.devcamera;
     17 
     18 import android.util.Size;
     19 import android.view.Surface;
     20 
     21 /**
     22  * This is a simple camera interface not specific to API1 or API2.
     23  */
     24 public interface CameraInterface {
     25     /**
     26      * Return preview size to use pass thru from camera API.
     27      */
     28     Size getPreviewSize();
     29 
     30     /**
     31      * Get camera field of view, in degrees. Entry 0 is horizontal, entry 1 is vertical FOV.
     32      */
     33     float[] getFieldOfView();
     34 
     35     /**
     36      * Get the camera sensor orientation relative to device native orientation
     37      * Typically 90 or 270 for phones, 0 or 180 for tablets, though many tables are also
     38      * portrait-native.
     39      */
     40     int getOrientation();
     41 
     42     /**
     43      * Open the camera. Call startPreview() to actually see something.
     44      */
     45     void openCamera();
     46 
     47     /**
     48      * Start preview to a surface. Also need to call openCamera().
     49      * @param surface
     50      */
     51     void startPreview(Surface surface);
     52 
     53     /**
     54      * Close the camera.
     55      */
     56     void closeCamera();
     57 
     58     /**
     59      * Take a picture and return data with provided callback.
     60      * Preview must be started.
     61      */
     62     void takePicture();
     63 
     64     /**
     65      * Set whether we are continuously taking pictures, or not.
     66      */
     67     void setBurst(boolean go);
     68 
     69     /**
     70      * Take a picture and return data with provided callback.
     71      * Preview must be started.
     72      */
     73     void setCallback(MyCameraCallback callback);
     74 
     75     /**
     76      * Is a raw stream available.
     77      */
     78     boolean isRawAvailable();
     79 
     80     /**
     81      * Is a reprocessing available.
     82      */
     83     boolean isReprocessingAvailable();
     84 
     85     /**
     86      * Triggers an AF scan. Leaves camera in AUTO.
     87      */
     88     void triggerAFScan();
     89 
     90     /**
     91      * Runs CAF (continuous picture).
     92      */
     93     void setCAF();
     94 
     95     /**
     96      * Camera picture callbacks.
     97      */
     98     interface MyCameraCallback {
     99         /**
    100          * What text to display on the Edge and NR mode buttons.
    101          */
    102         void setNoiseEdgeText(String s1, String s2);
    103 
    104         /**
    105          * What text to display on the Edge and NR mode buttons (reprocessing flow).
    106          */
    107         void setNoiseEdgeTextForReprocessing(String s1, String s2);
    108 
    109         /**
    110          * Full size JPEG is available.
    111          * @param jpegData
    112          * @param x
    113          * @param y
    114          */
    115         void jpegAvailable(byte[] jpegData, int x, int y);
    116 
    117         /**
    118          * Metadata from an image frame.
    119          *
    120          * @param info Info string we print just under viewfinder.
    121          *
    122          *             fps, mLastIso, af, ae, awb
    123          * @param faces Face coordinates.
    124          * @param normExposure Exposure value normalized from 0 to 1.
    125          * @param normLensPos Lens position value normalized from 0 to 1.
    126          * @param fps
    127          * @param iso
    128          * @param afState
    129          * @param aeState
    130          * @param awbState
    131          *
    132          */
    133         void frameDataAvailable(NormalizedFace[] faces, float normExposure, float normLensPos, float fps, int iso, int afState, int aeState, int awbState);
    134 
    135         /**
    136          * Misc performance data.
    137          */
    138         void performanceDataAvailable(Integer timeToFirstFrame, Integer halWaitTime, Float droppedFrameCount);
    139 
    140         /**
    141          * Called when camera2 FULL not available.
    142          */
    143         void noCamera2Full();
    144 
    145         /**
    146          * Used to set the preview SurfaceView background color from black to transparent.
    147          */
    148         void receivedFirstFrame();
    149     }
    150 
    151     void setCaptureFlow(Boolean yuv1, Boolean yuv2, Boolean raw10, Boolean nr, Boolean edge, Boolean face);
    152 
    153     void setReprocessingFlow(Boolean nr, Boolean edge);
    154 
    155 }
    156