Ari Hausman-Cohen | 7344215 | 2016-06-08 15:50:49 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 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 | // Modified from hardware/libhardware/modules/camera/Stream.h |
| 18 | |
| 19 | #ifndef STREAM_H_ |
| 20 | #define STREAM_H_ |
| 21 | |
| 22 | #include <hardware/camera3.h> |
| 23 | #include <hardware/gralloc.h> |
| 24 | #include <system/graphics.h> |
| 25 | #include <utils/Mutex.h> |
| 26 | |
| 27 | namespace default_camera_hal { |
| 28 | // Stream represents a single input or output stream for a camera device. |
| 29 | class Stream { |
| 30 | public: |
| 31 | Stream(int id, camera3_stream_t *s); |
| 32 | ~Stream(); |
| 33 | |
| 34 | // validate that astream's parameters match this stream's parameters |
| 35 | bool isValidReuseStream(int id, camera3_stream_t *s); |
| 36 | |
Ari Hausman-Cohen | 7344215 | 2016-06-08 15:50:49 -0700 | [diff] [blame] | 37 | void setUsage(uint32_t usage); |
| 38 | void setMaxBuffers(uint32_t max_buffers); |
Ari Hausman-Cohen | 72fddb3 | 2016-06-30 16:53:31 -0700 | [diff] [blame^] | 39 | void setDataSpace(android_dataspace_t data_space); |
Ari Hausman-Cohen | 7344215 | 2016-06-08 15:50:49 -0700 | [diff] [blame] | 40 | |
Ari Hausman-Cohen | 72fddb3 | 2016-06-30 16:53:31 -0700 | [diff] [blame^] | 41 | inline int getFormat() const { return mFormat; }; |
| 42 | inline int getType() const { return mType; }; |
| 43 | inline uint32_t getWidth() const { return mWidth; }; |
| 44 | inline uint32_t getHeight() const { return mHeight; }; |
| 45 | inline int getRotation() const { return mRotation; }; |
| 46 | |
| 47 | bool isInputType() const; |
| 48 | bool isOutputType() const; |
Ari Hausman-Cohen | 7344215 | 2016-06-08 15:50:49 -0700 | [diff] [blame] | 49 | const char* typeToString(int type); |
| 50 | const char* formatToString(int format); |
| 51 | void dump(int fd); |
| 52 | |
| 53 | // This stream is being reused. Used in stream configuration passes |
| 54 | bool mReuse; |
| 55 | |
| 56 | private: |
Ari Hausman-Cohen | 7344215 | 2016-06-08 15:50:49 -0700 | [diff] [blame] | 57 | |
| 58 | // The camera device id this stream belongs to |
| 59 | const int mId; |
| 60 | // Handle to framework's stream, used as a cookie for buffers |
| 61 | camera3_stream_t *mStream; |
| 62 | // Stream type: CAMERA3_STREAM_* (see <hardware/camera3.h>) |
| 63 | const int mType; |
| 64 | // Width in pixels of the buffers in this stream |
| 65 | const uint32_t mWidth; |
| 66 | // Height in pixels of the buffers in this stream |
| 67 | const uint32_t mHeight; |
| 68 | // Gralloc format: HAL_PIXEL_FORMAT_* (see <system/graphics.h>) |
| 69 | const int mFormat; |
| 70 | // Gralloc usage mask : GRALLOC_USAGE_* (see <hardware/gralloc.h>) |
| 71 | uint32_t mUsage; |
Ari Hausman-Cohen | 72fddb3 | 2016-06-30 16:53:31 -0700 | [diff] [blame^] | 72 | // Output rotation this stream should undergo |
| 73 | const int mRotation; |
| 74 | // Color space of image data. |
| 75 | android_dataspace_t mDataSpace; |
Ari Hausman-Cohen | 7344215 | 2016-06-08 15:50:49 -0700 | [diff] [blame] | 76 | // Max simultaneous in-flight buffers for this stream |
| 77 | uint32_t mMaxBuffers; |
Ari Hausman-Cohen | 7344215 | 2016-06-08 15:50:49 -0700 | [diff] [blame] | 78 | // Lock protecting the Stream object for modifications |
| 79 | android::Mutex mLock; |
| 80 | }; |
| 81 | } // namespace default_camera_hal |
| 82 | |
| 83 | #endif // STREAM_H_ |