Eino-Ville Talvala | d86a688 | 2012-08-28 11:34:14 -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 | |
| 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" |
Igor Murashkin | 7efa520 | 2013-02-13 15:53:56 -0800 | [diff] [blame] | 27 | #include "camera/CameraMetadata.h" |
Eino-Ville Talvala | d86a688 | 2012-08-28 11:34:14 -0700 | [diff] [blame] | 28 | #include "Camera2Heap.h" |
| 29 | |
| 30 | namespace android { |
| 31 | |
| 32 | class Camera2Client; |
Eino-Ville Talvala | d09801b | 2013-04-23 15:16:57 -0700 | [diff] [blame^] | 33 | class CameraDeviceBase; |
Eino-Ville Talvala | d86a688 | 2012-08-28 11:34:14 -0700 | [diff] [blame] | 34 | |
| 35 | namespace camera2 { |
| 36 | |
| 37 | /*** |
| 38 | * Still image capture output image processing |
| 39 | */ |
| 40 | class CallbackProcessor: |
| 41 | public Thread, public CpuConsumer::FrameAvailableListener { |
| 42 | public: |
Eino-Ville Talvala | d09801b | 2013-04-23 15:16:57 -0700 | [diff] [blame^] | 43 | CallbackProcessor(sp<Camera2Client> client); |
Eino-Ville Talvala | d86a688 | 2012-08-28 11:34:14 -0700 | [diff] [blame] | 44 | ~CallbackProcessor(); |
| 45 | |
| 46 | void onFrameAvailable(); |
| 47 | |
| 48 | status_t updateStream(const Parameters ¶ms); |
| 49 | status_t deleteStream(); |
| 50 | int getStreamId() const; |
| 51 | |
Eino-Ville Talvala | da6665c | 2012-08-29 17:37:16 -0700 | [diff] [blame] | 52 | void dump(int fd, const Vector<String16>& args) const; |
Eino-Ville Talvala | d86a688 | 2012-08-28 11:34:14 -0700 | [diff] [blame] | 53 | private: |
| 54 | static const nsecs_t kWaitDuration = 10000000; // 10 ms |
| 55 | wp<Camera2Client> mClient; |
Eino-Ville Talvala | d09801b | 2013-04-23 15:16:57 -0700 | [diff] [blame^] | 56 | wp<CameraDeviceBase> mDevice; |
| 57 | int mId; |
Eino-Ville Talvala | d86a688 | 2012-08-28 11:34:14 -0700 | [diff] [blame] | 58 | |
| 59 | mutable Mutex mInputMutex; |
| 60 | bool mCallbackAvailable; |
| 61 | Condition mCallbackAvailableSignal; |
| 62 | |
| 63 | enum { |
| 64 | NO_STREAM = -1 |
| 65 | }; |
| 66 | |
| 67 | int mCallbackStreamId; |
| 68 | static const size_t kCallbackHeapCount = 6; |
| 69 | sp<CpuConsumer> mCallbackConsumer; |
| 70 | sp<ANativeWindow> mCallbackWindow; |
| 71 | sp<Camera2Heap> mCallbackHeap; |
| 72 | int mCallbackHeapId; |
| 73 | size_t mCallbackHeapHead, mCallbackHeapFree; |
| 74 | |
| 75 | virtual bool threadLoop(); |
| 76 | |
| 77 | status_t processNewCallback(sp<Camera2Client> &client); |
Eino-Ville Talvala | d09801b | 2013-04-23 15:16:57 -0700 | [diff] [blame^] | 78 | // Used when shutting down |
| 79 | status_t discardNewCallback(); |
Eino-Ville Talvala | d86a688 | 2012-08-28 11:34:14 -0700 | [diff] [blame] | 80 | }; |
| 81 | |
| 82 | |
| 83 | }; //namespace camera2 |
| 84 | }; //namespace android |
| 85 | |
| 86 | #endif |