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_CALLBACKPROCESSOR_H 18 #define ANDROID_SERVERS_CAMERA_CAMERA2_CALLBACKPROCESSOR_H 19 20 #include <utils/Thread.h> 21 #include <utils/String16.h> 22 #include <utils/Vector.h> 23 #include <utils/Mutex.h> 24 #include <utils/Condition.h> 25 #include <gui/CpuConsumer.h> 26 #include "Parameters.h" 27 #include "CameraMetadata.h" 28 #include "Camera2Heap.h" 29 30 namespace android { 31 32 class Camera2Client; 33 34 namespace camera2 { 35 36 /*** 37 * Still image capture output image processing 38 */ 39 class CallbackProcessor: 40 public Thread, public CpuConsumer::FrameAvailableListener { 41 public: 42 CallbackProcessor(wp<Camera2Client> client); 43 ~CallbackProcessor(); 44 45 void onFrameAvailable(); 46 47 status_t updateStream(const Parameters ¶ms); 48 status_t deleteStream(); 49 int getStreamId() const; 50 51 void dump(int fd, const Vector<String16>& args) const; 52 private: 53 static const nsecs_t kWaitDuration = 10000000; // 10 ms 54 wp<Camera2Client> mClient; 55 56 mutable Mutex mInputMutex; 57 bool mCallbackAvailable; 58 Condition mCallbackAvailableSignal; 59 60 enum { 61 NO_STREAM = -1 62 }; 63 64 int mCallbackStreamId; 65 static const size_t kCallbackHeapCount = 6; 66 sp<CpuConsumer> mCallbackConsumer; 67 sp<ANativeWindow> mCallbackWindow; 68 sp<Camera2Heap> mCallbackHeap; 69 int mCallbackHeapId; 70 size_t mCallbackHeapHead, mCallbackHeapFree; 71 72 virtual bool threadLoop(); 73 74 status_t processNewCallback(sp<Camera2Client> &client); 75 76 }; 77 78 79 }; //namespace camera2 80 }; //namespace android 81 82 #endif 83