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