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_JPEGPROCESSOR_H 18 #define ANDROID_SERVERS_CAMERA_CAMERA2_JPEGPROCESSOR_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 27 #include "camera/CameraMetadata.h" 28 #include "device3/Camera3StreamBufferListener.h" 29 30 namespace android { 31 32 class Camera2Client; 33 class CameraDeviceBase; 34 class MemoryHeapBase; 35 36 namespace camera2 { 37 38 class CaptureSequencer; 39 struct Parameters; 40 41 /*** 42 * Still image capture output image processing 43 */ 44 class JpegProcessor: 45 public Thread, public CpuConsumer::FrameAvailableListener { 46 public: 47 JpegProcessor(sp<Camera2Client> client, wp<CaptureSequencer> sequencer); 48 ~JpegProcessor(); 49 50 // CpuConsumer listener implementation 51 void onFrameAvailable(const BufferItem& item); 52 53 status_t updateStream(const Parameters ¶ms); 54 status_t deleteStream(); 55 int getStreamId() const; 56 57 void dump(int fd, const Vector<String16>& args) const; 58 59 static size_t findJpegSize(uint8_t* jpegBuffer, size_t maxSize); 60 61 private: 62 static const nsecs_t kWaitDuration = 10000000; // 10 ms 63 wp<CameraDeviceBase> mDevice; 64 wp<CaptureSequencer> mSequencer; 65 int mId; 66 67 mutable Mutex mInputMutex; 68 bool mCaptureDone; 69 bool mCaptureSuccess; 70 Condition mCaptureDoneSignal; 71 72 enum { 73 NO_STREAM = -1 74 }; 75 76 int mCaptureStreamId; 77 sp<CpuConsumer> mCaptureConsumer; 78 sp<Surface> mCaptureWindow; 79 sp<MemoryHeapBase> mCaptureHeap; 80 81 virtual bool threadLoop(); 82 83 status_t processNewCapture(bool captureSuccess); 84 85 }; 86 87 88 }; //namespace camera2 89 }; //namespace android 90 91 #endif 92