blob: 22697b76a44a6f7efae326042b81f94b97481b30 [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>
21#include <gui/Surface.h>
22#include <gui/BufferItemConsumer.h>
23
Igor Murashkinae3d0ba2013-05-08 18:03:15 -070024#include "Camera3IOStreamBase.h"
Eino-Ville Talvala8be20f52013-03-06 16:20:06 -080025
26namespace android {
27
28namespace camera3 {
29
30/**
31 * A class for managing a single stream of input data to the camera device.
Igor Murashkin0776a142013-04-15 14:59:22 -070032 *
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 Talvala8be20f52013-03-06 16:20:06 -080036 */
Yin-Chia Yehbe83fa72017-03-30 13:35:36 -070037class Camera3InputStream : public Camera3IOStreamBase,
38 public BufferItemConsumer::BufferFreedListener {
Eino-Ville Talvala8be20f52013-03-06 16:20:06 -080039 public:
40 /**
41 * Set up a stream for formats that have fixed size, such as RAW and YUV.
42 */
43 Camera3InputStream(int id, uint32_t width, uint32_t height, int format);
Igor Murashkin0776a142013-04-15 14:59:22 -070044 ~Camera3InputStream();
Eino-Ville Talvala8be20f52013-03-06 16:20:06 -080045
Eino-Ville Talvala8be20f52013-03-06 16:20:06 -080046 virtual void dump(int fd, const Vector<String16> &args) const;
47
Igor Murashkin054aab32013-11-18 11:39:27 -080048 // TODO: expose an interface to get the IGraphicBufferProducer
49
Eino-Ville Talvala8be20f52013-03-06 16:20:06 -080050 private:
51
52 sp<BufferItemConsumer> mConsumer;
Chien-Yu Chen618ff8a2015-03-13 11:27:17 -070053 sp<IGraphicBufferProducer> mProducer;
Igor Murashkin0776a142013-04-15 14:59:22 -070054 Vector<BufferItem> mBuffersInFlight;
Igor Murashkin0776a142013-04-15 14:59:22 -070055
Ivan Lozanoc0ad82f2020-07-30 09:32:57 -040056 static const String8 FAKE_ID;
Shuzhen Wangc28189a2017-11-27 23:05:10 -080057
Igor Murashkinae3d0ba2013-05-08 18:03:15 -070058 /**
59 * Camera3IOStreamBase
60 */
61 virtual status_t returnBufferCheckedLocked(
62 const camera3_stream_buffer &buffer,
63 nsecs_t timestamp,
64 bool output,
Yin-Chia Yeh58b1b4e2018-10-15 12:18:36 -070065 const std::vector<size_t>& surface_ids,
Igor Murashkinae3d0ba2013-05-08 18:03:15 -070066 /*out*/
67 sp<Fence> *releaseFenceOut);
Eino-Ville Talvala8be20f52013-03-06 16:20:06 -080068
69 /**
70 * Camera3Stream interface
71 */
72
Igor Murashkin0776a142013-04-15 14:59:22 -070073 virtual status_t getInputBufferLocked(camera3_stream_buffer *buffer);
74 virtual status_t returnInputBufferLocked(
75 const camera3_stream_buffer &buffer);
Chien-Yu Chen618ff8a2015-03-13 11:27:17 -070076 virtual status_t getInputBufferProducerLocked(
77 sp<IGraphicBufferProducer> *producer);
Eino-Ville Talvala8be20f52013-03-06 16:20:06 -080078 virtual status_t disconnectLocked();
79
Igor Murashkin0776a142013-04-15 14:59:22 -070080 virtual status_t configureQueueLocked();
Igor Murashkin0776a142013-04-15 14:59:22 -070081
Emilian Peev050f5dc2017-05-18 14:43:56 +010082 virtual status_t getEndpointUsage(uint64_t *usage) const;
Eino-Ville Talvalab2f5b192013-07-30 14:36:03 -070083
Yin-Chia Yehbe83fa72017-03-30 13:35:36 -070084 /**
85 * BufferItemConsumer::BufferFreedListener interface
86 */
87 virtual void onBufferFreed(const wp<GraphicBuffer>&) override;
88
Eino-Ville Talvala8be20f52013-03-06 16:20:06 -080089}; // class Camera3InputStream
90
91}; // namespace camera3
92
93}; // namespace android
94
95#endif