blob: 513b695e09f7404bef2984aa90978e0bce2214c3 [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,
Eino-Ville Talvala3d82c0d2015-02-23 15:19:19 -080042 uint32_t width, uint32_t height, int format,
Yin-Chia Yehb97babb2015-03-12 13:42:44 -070043 android_dataspace dataSpace, camera3_stream_rotation_t rotation);
Eino-Ville Talvalafd58f1a2013-03-06 16:20:06 -080044
45 /**
46 * Set up a stream for formats that have a variable buffer size for the same
47 * dimensions, such as compressed JPEG.
48 */
49 Camera3OutputStream(int id, sp<ANativeWindow> consumer,
Eino-Ville Talvala3d82c0d2015-02-23 15:19:19 -080050 uint32_t width, uint32_t height, size_t maxSize, int format,
Yin-Chia Yehb97babb2015-03-12 13:42:44 -070051 android_dataspace dataSpace, camera3_stream_rotation_t rotation);
Eino-Ville Talvalafd58f1a2013-03-06 16:20:06 -080052
53 virtual ~Camera3OutputStream();
54
55 /**
56 * Camera3Stream interface
57 */
58
Eino-Ville Talvalafd58f1a2013-03-06 16:20:06 -080059 virtual void dump(int fd, const Vector<String16> &args) const;
60
61 /**
62 * Set the transform on the output stream; one of the
63 * HAL_TRANSFORM_* / NATIVE_WINDOW_TRANSFORM_* constants.
64 */
65 status_t setTransform(int transform);
66
Igor Murashkine3a9f962013-05-08 18:03:15 -070067 protected:
68 Camera3OutputStream(int id, camera3_stream_type_t type,
Eino-Ville Talvala3d82c0d2015-02-23 15:19:19 -080069 uint32_t width, uint32_t height, int format,
Yin-Chia Yehb97babb2015-03-12 13:42:44 -070070 android_dataspace dataSpace, camera3_stream_rotation_t rotation);
Igor Murashkine3a9f962013-05-08 18:03:15 -070071
Zhijun He124ccf42013-05-22 14:01:30 -070072 /**
73 * Note that we release the lock briefly in this function
74 */
Igor Murashkine3a9f962013-05-08 18:03:15 -070075 virtual status_t returnBufferCheckedLocked(
76 const camera3_stream_buffer &buffer,
77 nsecs_t timestamp,
78 bool output,
79 /*out*/
80 sp<Fence> *releaseFenceOut);
81
Zhijun He0a210512014-07-24 13:45:15 -070082 virtual status_t disconnectLocked();
83
Eino-Ville Talvalafd58f1a2013-03-06 16:20:06 -080084 sp<ANativeWindow> mConsumer;
Igor Murashkine3a9f962013-05-08 18:03:15 -070085 private:
Eino-Ville Talvalafd58f1a2013-03-06 16:20:06 -080086 int mTransform;
Eino-Ville Talvalafd58f1a2013-03-06 16:20:06 -080087
Igor Murashkine3a9f962013-05-08 18:03:15 -070088 virtual status_t setTransformLocked(int transform);
Eino-Ville Talvalafd58f1a2013-03-06 16:20:06 -080089
Ruchit Sharmae0711f22014-08-18 13:48:24 -040090 bool mTraceFirstBuffer;
91
Eino-Ville Talvalafd58f1a2013-03-06 16:20:06 -080092 /**
93 * Internal Camera3Stream interface
94 */
95 virtual status_t getBufferLocked(camera3_stream_buffer *buffer);
96 virtual status_t returnBufferLocked(
97 const camera3_stream_buffer &buffer,
98 nsecs_t timestamp);
Eino-Ville Talvalafd58f1a2013-03-06 16:20:06 -080099
100 virtual status_t configureQueueLocked();
Eino-Ville Talvalab2f5b192013-07-30 14:36:03 -0700101
Eino-Ville Talvala4d44cad2015-04-11 13:15:45 -0700102 virtual status_t getEndpointUsage(uint32_t *usage) const;
Eino-Ville Talvalab2f5b192013-07-30 14:36:03 -0700103
Eino-Ville Talvalafd58f1a2013-03-06 16:20:06 -0800104}; // class Camera3OutputStream
105
106} // namespace camera3
107
108} // namespace android
109
110#endif