Home | History | Annotate | Download | only in camera2
      1 /*
      2  * Copyright (C) 2012 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 #ifndef ANDROID_SERVERS_CAMERA_CAMERA2_FRAMEPROCESSOR_H
     18 #define ANDROID_SERVERS_CAMERA_CAMERA2_FRAMEPROCESSOR_H
     19 
     20 #include <utils/Thread.h>
     21 #include <utils/String16.h>
     22 #include <utils/Vector.h>
     23 #include <utils/KeyedVector.h>
     24 #include <utils/List.h>
     25 #include <camera/CameraMetadata.h>
     26 
     27 #include "ProFrameProcessor.h"
     28 
     29 struct camera_frame_metadata;
     30 
     31 namespace android {
     32 
     33 class Camera2Client;
     34 
     35 namespace camera2 {
     36 
     37 /* Output frame metadata processing thread.  This thread waits for new
     38  * frames from the device, and analyzes them as necessary.
     39  */
     40 class FrameProcessor : public ProFrameProcessor {
     41   public:
     42     FrameProcessor(wp<CameraDeviceBase> device, wp<Camera2Client> client);
     43     ~FrameProcessor();
     44 
     45   private:
     46     wp<Camera2Client> mClient;
     47 
     48     bool mSynthesize3ANotify;
     49 
     50     int mLastFrameNumberOfFaces;
     51 
     52     void processNewFrames(const sp<Camera2Client> &client);
     53 
     54     virtual bool processSingleFrame(CameraMetadata &frame,
     55                                     const sp<CameraDeviceBase> &device);
     56 
     57     status_t processFaceDetect(const CameraMetadata &frame,
     58             const sp<Camera2Client> &client);
     59 
     60     // Send 3A state change notifications to client based on frame metadata
     61     status_t process3aState(const CameraMetadata &frame,
     62             const sp<Camera2Client> &client);
     63 
     64     struct AlgState {
     65         camera_metadata_enum_android_control_ae_state  aeState;
     66         camera_metadata_enum_android_control_af_state  afState;
     67         camera_metadata_enum_android_control_awb_state awbState;
     68 
     69         AlgState() :
     70                 aeState(ANDROID_CONTROL_AE_STATE_INACTIVE),
     71                 afState(ANDROID_CONTROL_AF_STATE_INACTIVE),
     72                 awbState(ANDROID_CONTROL_AWB_STATE_INACTIVE) {
     73         }
     74     } m3aState;
     75 
     76     // Emit FaceDetection event to java if faces changed
     77     void callbackFaceDetection(sp<Camera2Client> client,
     78                                const camera_frame_metadata &metadata);
     79 };
     80 
     81 
     82 }; //namespace camera2
     83 }; //namespace android
     84 
     85 #endif
     86