Alex Ray | bcaf788 | 2013-02-28 16:04:35 -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 STREAM_H_ |
| 18 | #define STREAM_H_ |
| 19 | |
| 20 | #include <hardware/camera3.h> |
| 21 | #include <hardware/gralloc.h> |
| 22 | #include <system/graphics.h> |
| 23 | |
| 24 | namespace default_camera_hal { |
| 25 | // Stream represents a single input or output stream for a camera device. |
| 26 | class Stream { |
| 27 | public: |
| 28 | Stream(int id, camera3_stream_t *s); |
| 29 | ~Stream(); |
| 30 | |
| 31 | // validate that astream's parameters match this stream's parameters |
| 32 | bool isValidReuseStream(int id, camera3_stream_t *s); |
| 33 | |
| 34 | void setUsage(uint32_t usage); |
| 35 | void setMaxBuffers(uint32_t max_buffers); |
| 36 | |
| 37 | int getType(); |
| 38 | bool isInputType(); |
| 39 | bool isOutputType(); |
| 40 | bool getRegistered(); |
| 41 | |
| 42 | // This stream is being reused. Used in stream configuration passes |
| 43 | bool mReuse; |
| 44 | |
| 45 | private: |
| 46 | // The camera device id this stream belongs to |
| 47 | const int mId; |
| 48 | // Handle to framework's stream, used as a cookie for buffers |
| 49 | const camera3_stream_t *mStream; |
| 50 | // Stream type: CAMERA3_STREAM_* (see <hardware/camera3.h>) |
| 51 | const int mType; |
| 52 | // Width in pixels of the buffers in this stream |
| 53 | const uint32_t mWidth; |
| 54 | // Height in pixels of the buffers in this stream |
| 55 | const uint32_t mHeight; |
| 56 | // Gralloc format: HAL_PIXEL_FORMAT_* (see <system/graphics.h>) |
| 57 | const int mFormat; |
| 58 | // Gralloc usage mask : GRALLOC_USAGE_* (see <hardware/gralloc.h>) |
| 59 | uint32_t mUsage; |
| 60 | // Max simultaneous in-flight buffers for this stream |
| 61 | uint32_t mMaxBuffers; |
| 62 | // Buffers have been registered for this stream and are ready |
| 63 | bool mRegistered; |
| 64 | // Lock protecting the Stream object for modifications |
| 65 | pthread_mutex_t mMutex; |
| 66 | }; |
| 67 | } // namespace default_camera_hal |
| 68 | |
| 69 | #endif // STREAM_H_ |