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