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