Eino-Ville Talvala | 8be20f5 | 2013-03-06 16:20:06 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2013 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_CAMERA3_INPUT_STREAM_H |
| 18 | #define ANDROID_SERVERS_CAMERA3_INPUT_STREAM_H |
| 19 | |
| 20 | #include <utils/RefBase.h> |
| 21 | #include <gui/Surface.h> |
| 22 | #include <gui/BufferItemConsumer.h> |
| 23 | |
| 24 | #include "Camera3Stream.h" |
| 25 | |
| 26 | namespace android { |
| 27 | |
| 28 | namespace camera3 { |
| 29 | |
| 30 | /** |
| 31 | * A class for managing a single stream of input data to the camera device. |
Igor Murashkin | 0776a14 | 2013-04-15 14:59:22 -0700 | [diff] [blame] | 32 | * |
| 33 | * This class serves as a consumer adapter for the HAL, and will consume the |
| 34 | * buffers by feeding them into the HAL, as well as releasing the buffers back |
| 35 | * the buffers once the HAL is done with them. |
Eino-Ville Talvala | 8be20f5 | 2013-03-06 16:20:06 -0800 | [diff] [blame] | 36 | */ |
| 37 | class Camera3InputStream : public Camera3Stream { |
| 38 | public: |
| 39 | /** |
| 40 | * Set up a stream for formats that have fixed size, such as RAW and YUV. |
| 41 | */ |
| 42 | Camera3InputStream(int id, uint32_t width, uint32_t height, int format); |
Igor Murashkin | 0776a14 | 2013-04-15 14:59:22 -0700 | [diff] [blame] | 43 | ~Camera3InputStream(); |
Eino-Ville Talvala | 8be20f5 | 2013-03-06 16:20:06 -0800 | [diff] [blame] | 44 | |
| 45 | virtual status_t waitUntilIdle(nsecs_t timeout); |
| 46 | virtual void dump(int fd, const Vector<String16> &args) const; |
| 47 | |
| 48 | /** |
| 49 | * Get the producer interface for this stream, to hand off to a producer. |
| 50 | * The producer must be connected to the provided interface before |
| 51 | * finishConfigure is called on this stream. |
| 52 | */ |
| 53 | sp<IGraphicBufferProducer> getProducerInterface() const; |
| 54 | |
| 55 | private: |
| 56 | |
Igor Murashkin | 0776a14 | 2013-04-15 14:59:22 -0700 | [diff] [blame] | 57 | typedef BufferItemConsumer::BufferItem BufferItem; |
| 58 | |
Eino-Ville Talvala | 8be20f5 | 2013-03-06 16:20:06 -0800 | [diff] [blame] | 59 | sp<BufferItemConsumer> mConsumer; |
Igor Murashkin | 0776a14 | 2013-04-15 14:59:22 -0700 | [diff] [blame] | 60 | Vector<BufferItem> mBuffersInFlight; |
| 61 | size_t mTotalBufferCount; |
| 62 | size_t mDequeuedBufferCount; |
| 63 | Condition mBufferReturnedSignal; |
| 64 | uint32_t mFrameCount; |
| 65 | nsecs_t mLastTimestamp; |
| 66 | |
| 67 | // The merged release fence for all returned buffers |
| 68 | sp<Fence> mCombinedFence; |
Eino-Ville Talvala | 8be20f5 | 2013-03-06 16:20:06 -0800 | [diff] [blame] | 69 | |
| 70 | /** |
| 71 | * Camera3Stream interface |
| 72 | */ |
| 73 | |
Igor Murashkin | 0776a14 | 2013-04-15 14:59:22 -0700 | [diff] [blame] | 74 | virtual status_t getInputBufferLocked(camera3_stream_buffer *buffer); |
| 75 | virtual status_t returnInputBufferLocked( |
| 76 | const camera3_stream_buffer &buffer); |
Eino-Ville Talvala | 8be20f5 | 2013-03-06 16:20:06 -0800 | [diff] [blame] | 77 | virtual bool hasOutstandingBuffersLocked() const; |
| 78 | virtual status_t disconnectLocked(); |
| 79 | |
Igor Murashkin | 0776a14 | 2013-04-15 14:59:22 -0700 | [diff] [blame] | 80 | virtual status_t configureQueueLocked(); |
| 81 | virtual size_t getBufferCountLocked(); |
| 82 | |
Eino-Ville Talvala | 8be20f5 | 2013-03-06 16:20:06 -0800 | [diff] [blame] | 83 | }; // class Camera3InputStream |
| 84 | |
| 85 | }; // namespace camera3 |
| 86 | |
| 87 | }; // namespace android |
| 88 | |
| 89 | #endif |