blob: ce317f9aa6df371b647ddbf7c9f5459eb6485fc5 [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 Murashkine3a9f962013-05-08 18:03:15 -070024#include "Camera3IOStreamBase.h"
Igor Murashkin2fba5842013-04-22 14:03:54 -070025#include "Camera3OutputStreamInterface.h"
Eino-Ville Talvalafd58f1a2013-03-06 16:20:06 -080026
27namespace android {
28
29namespace camera3 {
30
31/**
32 * A class for managing a single stream of output data from the camera device.
33 */
Igor Murashkin2fba5842013-04-22 14:03:54 -070034class Camera3OutputStream :
Igor Murashkine3a9f962013-05-08 18:03:15 -070035 public Camera3IOStreamBase,
Igor Murashkin2fba5842013-04-22 14:03:54 -070036 public Camera3OutputStreamInterface {
Eino-Ville Talvalafd58f1a2013-03-06 16:20:06 -080037 public:
38 /**
39 * Set up a stream for formats that have 2 dimensions, such as RAW and YUV.
40 */
41 Camera3OutputStream(int id, sp<ANativeWindow> consumer,
42 uint32_t width, uint32_t height, int format);
43
44 /**
45 * Set up a stream for formats that have a variable buffer size for the same
46 * dimensions, such as compressed JPEG.
47 */
48 Camera3OutputStream(int id, sp<ANativeWindow> consumer,
49 uint32_t width, uint32_t height, size_t maxSize, int format);
50
51 virtual ~Camera3OutputStream();
52
53 /**
54 * Camera3Stream interface
55 */
56
Eino-Ville Talvalafd58f1a2013-03-06 16:20:06 -080057 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
Igor Murashkine3a9f962013-05-08 18:03:15 -070065 protected:
66 Camera3OutputStream(int id, camera3_stream_type_t type,
67 uint32_t width, uint32_t height, int format);
68
69 virtual status_t returnBufferCheckedLocked(
70 const camera3_stream_buffer &buffer,
71 nsecs_t timestamp,
72 bool output,
73 /*out*/
74 sp<Fence> *releaseFenceOut);
75
Eino-Ville Talvalafd58f1a2013-03-06 16:20:06 -080076 sp<ANativeWindow> mConsumer;
Igor Murashkine3a9f962013-05-08 18:03:15 -070077 private:
Eino-Ville Talvalafd58f1a2013-03-06 16:20:06 -080078 int mTransform;
Eino-Ville Talvalafd58f1a2013-03-06 16:20:06 -080079
Igor Murashkine3a9f962013-05-08 18:03:15 -070080 virtual status_t setTransformLocked(int transform);
Eino-Ville Talvalafd58f1a2013-03-06 16:20:06 -080081
82 /**
83 * Internal Camera3Stream interface
84 */
85 virtual status_t getBufferLocked(camera3_stream_buffer *buffer);
86 virtual status_t returnBufferLocked(
87 const camera3_stream_buffer &buffer,
88 nsecs_t timestamp);
Eino-Ville Talvalafd58f1a2013-03-06 16:20:06 -080089
90 virtual status_t configureQueueLocked();
Eino-Ville Talvalafd58f1a2013-03-06 16:20:06 -080091 virtual status_t disconnectLocked();
Eino-Ville Talvalafd58f1a2013-03-06 16:20:06 -080092}; // class Camera3OutputStream
93
94} // namespace camera3
95
96} // namespace android
97
98#endif