blob: 8adda887d758c5ca68cb3a7b80d0fbcc86155423 [file] [log] [blame]
Eino-Ville Talvala8be20f52013-03-06 16:20:06 -08001/*
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 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 */
Igor Murashkinae3d0ba2013-05-08 18:03:15 -070037class Camera3InputStream : public Camera3IOStreamBase {
Eino-Ville Talvala8be20f52013-03-06 16:20:06 -080038 public:
39 /**
40 * Set up a stream for formats that have fixed size, such as RAW and YUV.
41 */
42 Camera3InputStream(int id, uint32_t width, uint32_t height, int format);
Igor Murashkin0776a142013-04-15 14:59:22 -070043 ~Camera3InputStream();
Eino-Ville Talvala8be20f52013-03-06 16:20:06 -080044
Eino-Ville Talvala8be20f52013-03-06 16:20:06 -080045 virtual void dump(int fd, const Vector<String16> &args) const;
46
47 /**
48 * Get the producer interface for this stream, to hand off to a producer.
49 * The producer must be connected to the provided interface before
50 * finishConfigure is called on this stream.
51 */
52 sp<IGraphicBufferProducer> getProducerInterface() const;
53
54 private:
55
Igor Murashkin0776a142013-04-15 14:59:22 -070056 typedef BufferItemConsumer::BufferItem BufferItem;
57
Eino-Ville Talvala8be20f52013-03-06 16:20:06 -080058 sp<BufferItemConsumer> mConsumer;
Igor Murashkin0776a142013-04-15 14:59:22 -070059 Vector<BufferItem> mBuffersInFlight;
Igor Murashkin0776a142013-04-15 14:59:22 -070060
Igor Murashkinae3d0ba2013-05-08 18:03:15 -070061 /**
62 * Camera3IOStreamBase
63 */
64 virtual status_t returnBufferCheckedLocked(
65 const camera3_stream_buffer &buffer,
66 nsecs_t timestamp,
67 bool output,
68 /*out*/
69 sp<Fence> *releaseFenceOut);
Eino-Ville Talvala8be20f52013-03-06 16:20:06 -080070
71 /**
72 * Camera3Stream interface
73 */
74
Igor Murashkin0776a142013-04-15 14:59:22 -070075 virtual status_t getInputBufferLocked(camera3_stream_buffer *buffer);
76 virtual status_t returnInputBufferLocked(
77 const camera3_stream_buffer &buffer);
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
Eino-Ville Talvala8be20f52013-03-06 16:20:06 -080082}; // class Camera3InputStream
83
84}; // namespace camera3
85
86}; // namespace android
87
88#endif