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 "common/FrameProcessorBase.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 FrameProcessorBase { 41 public: 42 FrameProcessor(wp<CameraDeviceBase> device, sp<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 // Helper for process3aState 65 template<typename Src, typename T> 66 bool get3aResult(const CameraMetadata& result, int32_t tag, T* value, 67 int32_t frameNumber, int cameraId); 68 69 70 struct AlgState { 71 // TODO: also track AE mode 72 camera_metadata_enum_android_control_af_mode afMode; 73 camera_metadata_enum_android_control_awb_mode awbMode; 74 75 camera_metadata_enum_android_control_ae_state aeState; 76 camera_metadata_enum_android_control_af_state afState; 77 camera_metadata_enum_android_control_awb_state awbState; 78 79 int32_t afTriggerId; 80 int32_t aeTriggerId; 81 82 // These defaults need to match those in Parameters.cpp AlgStateAlgState83 AlgState() : 84 afMode(ANDROID_CONTROL_AF_MODE_AUTO), 85 awbMode(ANDROID_CONTROL_AWB_MODE_AUTO), 86 aeState(ANDROID_CONTROL_AE_STATE_INACTIVE), 87 afState(ANDROID_CONTROL_AF_STATE_INACTIVE), 88 awbState(ANDROID_CONTROL_AWB_STATE_INACTIVE), 89 afTriggerId(0), 90 aeTriggerId(0) { 91 } 92 } m3aState; 93 94 // Whether the partial result quirk is enabled for this device 95 bool mUsePartialQuirk; 96 97 // Track most recent frame number for which 3A notifications were sent for. 98 // Used to filter against sending 3A notifications for the same frame 99 // several times. 100 int32_t mLast3AFrameNumber; 101 102 // Emit FaceDetection event to java if faces changed 103 void callbackFaceDetection(sp<Camera2Client> client, 104 const camera_frame_metadata &metadata); 105 }; 106 107 108 }; //namespace camera2 109 }; //namespace android 110 111 #endif 112