blob: 39d5995e49d2f5fd11435a519a3556990bd8bc8a [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_ZSL_STREAM_H
18#define ANDROID_SERVERS_CAMERA3_ZSL_STREAM_H
19
20#include <utils/RefBase.h>
21#include <gui/Surface.h>
22
23#include "Camera3Stream.h"
24
25namespace android {
26
27namespace camera3 {
28
29/**
30 * A class for managing a single opaque ZSL stream to/from the camera device.
31 * This acts as a bidirectional stream at the HAL layer, caching and discarding
32 * most output buffers, and when directed, pushes a buffer back to the HAL for
33 * processing.
34 */
35class Camera3ZslStream: public Camera3Stream {
36 public:
37 /**
38 * Set up a ZSL stream of a given resolution. Depth is the number of buffers
39 * cached within the stream that can be retrieved for input.
40 */
41 Camera3ZslStream(int id, uint32_t width, uint32_t height, int depth);
42
43 virtual status_t waitUntilIdle(nsecs_t timeout);
44 virtual void dump(int fd, const Vector<String16> &args) const;
45
46 /**
47 * Get an input buffer matching a specific timestamp. If no buffer matching
48 * the timestamp is available, NO_MEMORY is returned.
49 */
50 status_t getInputBuffer(camera3_stream_buffer *buffer, nsecs_t timestamp);
51
52 /**
53 * Return input buffer from HAL. The buffer is then marked as unfilled, and
54 * returned to the output-side stream for refilling.
55 */
56 status_t returnInputBuffer(const camera3_stream_buffer &buffer);
57
58 private:
59
60 int mDepth;
61
62 /**
63 * Camera3Stream interface
64 */
65
66 // getBuffer/returnBuffer operate the output stream side of the ZslStream.
67 virtual status_t getBufferLocked(camera3_stream_buffer *buffer);
68 virtual status_t returnBufferLocked(const camera3_stream_buffer &buffer,
69 nsecs_t timestamp);
70 virtual bool hasOutstandingBuffersLocked() const;
71 virtual status_t disconnectLocked();
72
73}; // class Camera3ZslStream
74
75}; // namespace camera3
76
77}; // namespace android
78
79#endif