Eino-Ville Talvala | 8be20f5 | 2013-03-06 16:20:06 -0800 | [diff] [blame] | 1 | /* |
Shuzhen Wang | c28189a | 2017-11-27 23:05:10 -0800 | [diff] [blame] | 2 | * Copyright (C) 2013-2018 The Android Open Source Project |
Eino-Ville Talvala | 8be20f5 | 2013-03-06 16:20:06 -0800 | [diff] [blame] | 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> |
Carlos Martinez Romero | 8e77610 | 2024-08-21 12:49:10 -0700 | [diff] [blame] | 21 | #include <gui/Flags.h> |
Eino-Ville Talvala | 8be20f5 | 2013-03-06 16:20:06 -0800 | [diff] [blame] | 22 | #include <gui/Surface.h> |
| 23 | #include <gui/BufferItemConsumer.h> |
| 24 | |
Igor Murashkin | ae3d0ba | 2013-05-08 18:03:15 -0700 | [diff] [blame] | 25 | #include "Camera3IOStreamBase.h" |
Eino-Ville Talvala | 8be20f5 | 2013-03-06 16:20:06 -0800 | [diff] [blame] | 26 | |
| 27 | namespace android { |
| 28 | |
| 29 | namespace camera3 { |
| 30 | |
| 31 | /** |
| 32 | * 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] | 33 | * |
| 34 | * This class serves as a consumer adapter for the HAL, and will consume the |
| 35 | * buffers by feeding them into the HAL, as well as releasing the buffers back |
| 36 | * the buffers once the HAL is done with them. |
Eino-Ville Talvala | 8be20f5 | 2013-03-06 16:20:06 -0800 | [diff] [blame] | 37 | */ |
Yin-Chia Yeh | be83fa7 | 2017-03-30 13:35:36 -0700 | [diff] [blame] | 38 | class Camera3InputStream : public Camera3IOStreamBase, |
| 39 | public BufferItemConsumer::BufferFreedListener { |
Eino-Ville Talvala | 8be20f5 | 2013-03-06 16:20:06 -0800 | [diff] [blame] | 40 | public: |
| 41 | /** |
| 42 | * Set up a stream for formats that have fixed size, such as RAW and YUV. |
| 43 | */ |
| 44 | Camera3InputStream(int id, uint32_t width, uint32_t height, int format); |
Igor Murashkin | 0776a14 | 2013-04-15 14:59:22 -0700 | [diff] [blame] | 45 | ~Camera3InputStream(); |
Eino-Ville Talvala | 8be20f5 | 2013-03-06 16:20:06 -0800 | [diff] [blame] | 46 | |
Emilian Peev | 3b93acb | 2024-03-11 21:09:48 +0000 | [diff] [blame] | 47 | virtual void dump(int fd, const Vector<String16> &args); |
Eino-Ville Talvala | 8be20f5 | 2013-03-06 16:20:06 -0800 | [diff] [blame] | 48 | |
Igor Murashkin | 054aab3 | 2013-11-18 11:39:27 -0800 | [diff] [blame] | 49 | // TODO: expose an interface to get the IGraphicBufferProducer |
| 50 | |
Eino-Ville Talvala | 8be20f5 | 2013-03-06 16:20:06 -0800 | [diff] [blame] | 51 | private: |
| 52 | |
| 53 | sp<BufferItemConsumer> mConsumer; |
Carlos Martinez Romero | 8e77610 | 2024-08-21 12:49:10 -0700 | [diff] [blame] | 54 | #if WB_CAMERA3_AND_PROCESSORS_WITH_DEPENDENCIES |
| 55 | sp<Surface> mSurface; |
| 56 | #else |
Chien-Yu Chen | 618ff8a | 2015-03-13 11:27:17 -0700 | [diff] [blame] | 57 | sp<IGraphicBufferProducer> mProducer; |
Carlos Martinez Romero | 8e77610 | 2024-08-21 12:49:10 -0700 | [diff] [blame] | 58 | #endif |
Igor Murashkin | 0776a14 | 2013-04-15 14:59:22 -0700 | [diff] [blame] | 59 | Vector<BufferItem> mBuffersInFlight; |
Igor Murashkin | 0776a14 | 2013-04-15 14:59:22 -0700 | [diff] [blame] | 60 | |
Austin Borger | 1c1bee0 | 2023-06-01 16:51:35 -0700 | [diff] [blame] | 61 | static const std::string FAKE_ID; |
Shuzhen Wang | c28189a | 2017-11-27 23:05:10 -0800 | [diff] [blame] | 62 | |
Igor Murashkin | ae3d0ba | 2013-05-08 18:03:15 -0700 | [diff] [blame] | 63 | /** |
| 64 | * Camera3IOStreamBase |
| 65 | */ |
| 66 | virtual status_t returnBufferCheckedLocked( |
Emilian Peev | f481670 | 2020-04-03 15:44:51 -0700 | [diff] [blame] | 67 | const camera_stream_buffer &buffer, |
Igor Murashkin | ae3d0ba | 2013-05-08 18:03:15 -0700 | [diff] [blame] | 68 | nsecs_t timestamp, |
Shuzhen Wang | 90708ea | 2021-11-04 11:40:49 -0700 | [diff] [blame] | 69 | nsecs_t readoutTimestamp, |
Igor Murashkin | ae3d0ba | 2013-05-08 18:03:15 -0700 | [diff] [blame] | 70 | bool output, |
Emilian Peev | 5104fe9 | 2021-10-21 14:27:09 -0700 | [diff] [blame] | 71 | int32_t transform, |
Yin-Chia Yeh | 58b1b4e | 2018-10-15 12:18:36 -0700 | [diff] [blame] | 72 | const std::vector<size_t>& surface_ids, |
Igor Murashkin | ae3d0ba | 2013-05-08 18:03:15 -0700 | [diff] [blame] | 73 | /*out*/ |
| 74 | sp<Fence> *releaseFenceOut); |
Eino-Ville Talvala | 8be20f5 | 2013-03-06 16:20:06 -0800 | [diff] [blame] | 75 | |
| 76 | /** |
| 77 | * Camera3Stream interface |
| 78 | */ |
| 79 | |
Shuzhen Wang | 83bff12 | 2020-11-20 15:51:39 -0800 | [diff] [blame] | 80 | virtual status_t getInputBufferLocked(camera_stream_buffer *buffer, Size *size); |
Igor Murashkin | 0776a14 | 2013-04-15 14:59:22 -0700 | [diff] [blame] | 81 | virtual status_t returnInputBufferLocked( |
Emilian Peev | f481670 | 2020-04-03 15:44:51 -0700 | [diff] [blame] | 82 | const camera_stream_buffer &buffer); |
Carlos Martinez Romero | 8e77610 | 2024-08-21 12:49:10 -0700 | [diff] [blame] | 83 | #if WB_CAMERA3_AND_PROCESSORS_WITH_DEPENDENCIES |
| 84 | virtual status_t getInputSurfaceLocked(sp<Surface> *surface); |
| 85 | #else |
Chien-Yu Chen | 618ff8a | 2015-03-13 11:27:17 -0700 | [diff] [blame] | 86 | virtual status_t getInputBufferProducerLocked( |
| 87 | sp<IGraphicBufferProducer> *producer); |
Carlos Martinez Romero | 8e77610 | 2024-08-21 12:49:10 -0700 | [diff] [blame] | 88 | #endif |
Eino-Ville Talvala | 8be20f5 | 2013-03-06 16:20:06 -0800 | [diff] [blame] | 89 | virtual status_t disconnectLocked(); |
| 90 | |
Igor Murashkin | 0776a14 | 2013-04-15 14:59:22 -0700 | [diff] [blame] | 91 | virtual status_t configureQueueLocked(); |
Igor Murashkin | 0776a14 | 2013-04-15 14:59:22 -0700 | [diff] [blame] | 92 | |
Emilian Peev | 3b93acb | 2024-03-11 21:09:48 +0000 | [diff] [blame] | 93 | virtual status_t getEndpointUsage(uint64_t *usage); |
Eino-Ville Talvala | b2f5b19 | 2013-07-30 14:36:03 -0700 | [diff] [blame] | 94 | |
Yin-Chia Yeh | be83fa7 | 2017-03-30 13:35:36 -0700 | [diff] [blame] | 95 | /** |
| 96 | * BufferItemConsumer::BufferFreedListener interface |
| 97 | */ |
| 98 | virtual void onBufferFreed(const wp<GraphicBuffer>&) override; |
| 99 | |
Eino-Ville Talvala | 8be20f5 | 2013-03-06 16:20:06 -0800 | [diff] [blame] | 100 | }; // class Camera3InputStream |
| 101 | |
| 102 | }; // namespace camera3 |
| 103 | |
| 104 | }; // namespace android |
| 105 | |
| 106 | #endif |