blob: b1603e57726a0cae5d96c9a62662601ec69ca682 [file] [log] [blame]
Eino-Ville Talvala8be20f52013-03-06 16:20:06 -08001/*
Shuzhen Wangc28189a2017-11-27 23:05:10 -08002 * Copyright (C) 2013-2018 The Android Open Source Project
Eino-Ville Talvala8be20f52013-03-06 16:20:06 -08003 *
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 Romero8e776102024-08-21 12:49:10 -070021#include <gui/Flags.h>
Eino-Ville Talvala8be20f52013-03-06 16:20:06 -080022#include <gui/Surface.h>
23#include <gui/BufferItemConsumer.h>
24
Igor Murashkinae3d0ba2013-05-08 18:03:15 -070025#include "Camera3IOStreamBase.h"
Eino-Ville Talvala8be20f52013-03-06 16:20:06 -080026
27namespace android {
28
29namespace camera3 {
30
31/**
32 * A class for managing a single stream of input data to the camera device.
Igor Murashkin0776a142013-04-15 14:59:22 -070033 *
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 Talvala8be20f52013-03-06 16:20:06 -080037 */
Yin-Chia Yehbe83fa72017-03-30 13:35:36 -070038class Camera3InputStream : public Camera3IOStreamBase,
39 public BufferItemConsumer::BufferFreedListener {
Eino-Ville Talvala8be20f52013-03-06 16:20:06 -080040 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 Murashkin0776a142013-04-15 14:59:22 -070045 ~Camera3InputStream();
Eino-Ville Talvala8be20f52013-03-06 16:20:06 -080046
Emilian Peev3b93acb2024-03-11 21:09:48 +000047 virtual void dump(int fd, const Vector<String16> &args);
Eino-Ville Talvala8be20f52013-03-06 16:20:06 -080048
Igor Murashkin054aab32013-11-18 11:39:27 -080049 // TODO: expose an interface to get the IGraphicBufferProducer
50
Eino-Ville Talvala8be20f52013-03-06 16:20:06 -080051 private:
52
53 sp<BufferItemConsumer> mConsumer;
Carlos Martinez Romero8e776102024-08-21 12:49:10 -070054#if WB_CAMERA3_AND_PROCESSORS_WITH_DEPENDENCIES
55 sp<Surface> mSurface;
56#else
Chien-Yu Chen618ff8a2015-03-13 11:27:17 -070057 sp<IGraphicBufferProducer> mProducer;
Carlos Martinez Romero8e776102024-08-21 12:49:10 -070058#endif
Igor Murashkin0776a142013-04-15 14:59:22 -070059 Vector<BufferItem> mBuffersInFlight;
Igor Murashkin0776a142013-04-15 14:59:22 -070060
Austin Borger1c1bee02023-06-01 16:51:35 -070061 static const std::string FAKE_ID;
Shuzhen Wangc28189a2017-11-27 23:05:10 -080062
Igor Murashkinae3d0ba2013-05-08 18:03:15 -070063 /**
64 * Camera3IOStreamBase
65 */
66 virtual status_t returnBufferCheckedLocked(
Emilian Peevf4816702020-04-03 15:44:51 -070067 const camera_stream_buffer &buffer,
Igor Murashkinae3d0ba2013-05-08 18:03:15 -070068 nsecs_t timestamp,
Shuzhen Wang90708ea2021-11-04 11:40:49 -070069 nsecs_t readoutTimestamp,
Igor Murashkinae3d0ba2013-05-08 18:03:15 -070070 bool output,
Emilian Peev5104fe92021-10-21 14:27:09 -070071 int32_t transform,
Yin-Chia Yeh58b1b4e2018-10-15 12:18:36 -070072 const std::vector<size_t>& surface_ids,
Igor Murashkinae3d0ba2013-05-08 18:03:15 -070073 /*out*/
74 sp<Fence> *releaseFenceOut);
Eino-Ville Talvala8be20f52013-03-06 16:20:06 -080075
76 /**
77 * Camera3Stream interface
78 */
79
Shuzhen Wang83bff122020-11-20 15:51:39 -080080 virtual status_t getInputBufferLocked(camera_stream_buffer *buffer, Size *size);
Igor Murashkin0776a142013-04-15 14:59:22 -070081 virtual status_t returnInputBufferLocked(
Emilian Peevf4816702020-04-03 15:44:51 -070082 const camera_stream_buffer &buffer);
Carlos Martinez Romero8e776102024-08-21 12:49:10 -070083#if WB_CAMERA3_AND_PROCESSORS_WITH_DEPENDENCIES
84 virtual status_t getInputSurfaceLocked(sp<Surface> *surface);
85#else
Chien-Yu Chen618ff8a2015-03-13 11:27:17 -070086 virtual status_t getInputBufferProducerLocked(
87 sp<IGraphicBufferProducer> *producer);
Carlos Martinez Romero8e776102024-08-21 12:49:10 -070088#endif
Eino-Ville Talvala8be20f52013-03-06 16:20:06 -080089 virtual status_t disconnectLocked();
90
Igor Murashkin0776a142013-04-15 14:59:22 -070091 virtual status_t configureQueueLocked();
Igor Murashkin0776a142013-04-15 14:59:22 -070092
Emilian Peev3b93acb2024-03-11 21:09:48 +000093 virtual status_t getEndpointUsage(uint64_t *usage);
Eino-Ville Talvalab2f5b192013-07-30 14:36:03 -070094
Yin-Chia Yehbe83fa72017-03-30 13:35:36 -070095 /**
96 * BufferItemConsumer::BufferFreedListener interface
97 */
98 virtual void onBufferFreed(const wp<GraphicBuffer>&) override;
99
Eino-Ville Talvala8be20f52013-03-06 16:20:06 -0800100}; // class Camera3InputStream
101
102}; // namespace camera3
103
104}; // namespace android
105
106#endif