Eino-Ville Talvala | ea0d51b | 2012-08-28 01:25:43 -0700 | [diff] [blame] | 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 | |
Eino-Ville Talvala | da6665c | 2012-08-29 17:37:16 -0700 | [diff] [blame] | 17 | #ifndef ANDROID_SERVERS_CAMERA_CAMERA2_JPEGPROCESSOR_H |
| 18 | #define ANDROID_SERVERS_CAMERA_CAMERA2_JPEGPROCESSOR_H |
Eino-Ville Talvala | ea0d51b | 2012-08-28 01:25:43 -0700 | [diff] [blame] | 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" |
Igor Murashkin | 7efa520 | 2013-02-13 15:53:56 -0800 | [diff] [blame] | 27 | #include "camera/CameraMetadata.h" |
Eino-Ville Talvala | ea0d51b | 2012-08-28 01:25:43 -0700 | [diff] [blame] | 28 | |
| 29 | namespace android { |
| 30 | |
| 31 | class Camera2Client; |
Eino-Ville Talvala | 73bbd1f | 2012-09-26 10:45:47 -0700 | [diff] [blame] | 32 | class MemoryHeapBase; |
Eino-Ville Talvala | ea0d51b | 2012-08-28 01:25:43 -0700 | [diff] [blame] | 33 | |
| 34 | namespace camera2 { |
| 35 | |
Eino-Ville Talvala | da6665c | 2012-08-29 17:37:16 -0700 | [diff] [blame] | 36 | class CaptureSequencer; |
| 37 | |
Eino-Ville Talvala | ea0d51b | 2012-08-28 01:25:43 -0700 | [diff] [blame] | 38 | /*** |
| 39 | * Still image capture output image processing |
| 40 | */ |
Eino-Ville Talvala | da6665c | 2012-08-29 17:37:16 -0700 | [diff] [blame] | 41 | class JpegProcessor: |
Eino-Ville Talvala | ea0d51b | 2012-08-28 01:25:43 -0700 | [diff] [blame] | 42 | public Thread, public CpuConsumer::FrameAvailableListener { |
| 43 | public: |
Eino-Ville Talvala | da6665c | 2012-08-29 17:37:16 -0700 | [diff] [blame] | 44 | JpegProcessor(wp<Camera2Client> client, wp<CaptureSequencer> sequencer); |
| 45 | ~JpegProcessor(); |
Eino-Ville Talvala | ea0d51b | 2012-08-28 01:25:43 -0700 | [diff] [blame] | 46 | |
| 47 | void onFrameAvailable(); |
| 48 | |
| 49 | status_t updateStream(const Parameters ¶ms); |
| 50 | status_t deleteStream(); |
| 51 | int getStreamId() const; |
| 52 | |
Eino-Ville Talvala | da6665c | 2012-08-29 17:37:16 -0700 | [diff] [blame] | 53 | void dump(int fd, const Vector<String16>& args) const; |
Eino-Ville Talvala | ea0d51b | 2012-08-28 01:25:43 -0700 | [diff] [blame] | 54 | private: |
| 55 | static const nsecs_t kWaitDuration = 10000000; // 10 ms |
| 56 | wp<Camera2Client> mClient; |
Eino-Ville Talvala | da6665c | 2012-08-29 17:37:16 -0700 | [diff] [blame] | 57 | wp<CaptureSequencer> mSequencer; |
Eino-Ville Talvala | ea0d51b | 2012-08-28 01:25:43 -0700 | [diff] [blame] | 58 | |
| 59 | mutable Mutex mInputMutex; |
| 60 | bool mCaptureAvailable; |
| 61 | Condition mCaptureAvailableSignal; |
| 62 | |
| 63 | enum { |
| 64 | NO_STREAM = -1 |
| 65 | }; |
| 66 | |
| 67 | int mCaptureStreamId; |
| 68 | sp<CpuConsumer> mCaptureConsumer; |
| 69 | sp<ANativeWindow> mCaptureWindow; |
Alex Ray | a6b4c40 | 2012-09-21 00:58:03 -0700 | [diff] [blame] | 70 | sp<MemoryHeapBase> mCaptureHeap; |
Eino-Ville Talvala | ea0d51b | 2012-08-28 01:25:43 -0700 | [diff] [blame] | 71 | |
| 72 | virtual bool threadLoop(); |
| 73 | |
| 74 | status_t processNewCapture(sp<Camera2Client> &client); |
Alex Ray | 0fa1e76 | 2012-09-27 16:06:48 -0700 | [diff] [blame] | 75 | size_t findJpegSize(uint8_t* jpegBuffer, size_t maxSize); |
Eino-Ville Talvala | ea0d51b | 2012-08-28 01:25:43 -0700 | [diff] [blame] | 76 | |
| 77 | }; |
| 78 | |
| 79 | |
| 80 | }; //namespace camera2 |
| 81 | }; //namespace android |
| 82 | |
| 83 | #endif |