blob: d331a94e809b634c5c474bfb0355bd002381f95c [file] [log] [blame]
Eino-Ville Talvalafd58f1a2013-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_OUTPUT_STREAM_H
18#define ANDROID_SERVERS_CAMERA3_OUTPUT_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 stream of output data from the camera device.
31 */
32class Camera3OutputStream : public Camera3Stream {
33 public:
34 /**
35 * Set up a stream for formats that have 2 dimensions, such as RAW and YUV.
36 */
37 Camera3OutputStream(int id, sp<ANativeWindow> consumer,
38 uint32_t width, uint32_t height, int format);
39
40 /**
41 * Set up a stream for formats that have a variable buffer size for the same
42 * dimensions, such as compressed JPEG.
43 */
44 Camera3OutputStream(int id, sp<ANativeWindow> consumer,
45 uint32_t width, uint32_t height, size_t maxSize, int format);
46
47 virtual ~Camera3OutputStream();
48
49 /**
50 * Camera3Stream interface
51 */
52
53 virtual status_t waitUntilIdle(nsecs_t timeout);
54 virtual void dump(int fd, const Vector<String16> &args) const;
55
56 /**
57 * Set the transform on the output stream; one of the
58 * HAL_TRANSFORM_* / NATIVE_WINDOW_TRANSFORM_* constants.
59 */
60 status_t setTransform(int transform);
61
62 private:
63 sp<ANativeWindow> mConsumer;
64 int mTransform;
65 size_t mTotalBufferCount;
66 size_t mDequeuedBufferCount;
67 Condition mBufferReturnedSignal;
68 uint32_t mFrameCount;
69 nsecs_t mLastTimestamp;
70
71 // The merged release fence for all returned buffers
72 sp<Fence> mCombinedFence;
73
74 status_t setTransformLocked(int transform);
75
76 /**
77 * Internal Camera3Stream interface
78 */
79 virtual status_t getBufferLocked(camera3_stream_buffer *buffer);
80 virtual status_t returnBufferLocked(
81 const camera3_stream_buffer &buffer,
82 nsecs_t timestamp);
83 virtual bool hasOutstandingBuffersLocked() const;
84
85 virtual status_t configureQueueLocked();
86 virtual size_t getBufferCountLocked();
87 virtual status_t disconnectLocked();
88
89}; // class Camera3OutputStream
90
91} // namespace camera3
92
93} // namespace android
94
95#endif