blob: 9710765c2a17853142331019d03adb370db29cc1 [file] [log] [blame]
Eino-Ville Talvala16a2ada2014-08-27 14:41:33 -07001/*
2 * Copyright (C) 2014 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_DUMMY_STREAM_H
18#define ANDROID_SERVERS_CAMERA3_DUMMY_STREAM_H
19
20#include <utils/RefBase.h>
21#include <gui/Surface.h>
22
23#include "Camera3Stream.h"
24#include "Camera3IOStreamBase.h"
25#include "Camera3OutputStreamInterface.h"
26
27namespace android {
28namespace camera3 {
29
30/**
31 * A dummy output stream class, to be used as a placeholder when no valid
32 * streams are configured by the client.
33 * This is necessary because camera HAL v3.2 or older disallow configuring
34 * 0 output streams, while the public camera2 API allows for it.
35 */
36class Camera3DummyStream :
37 public Camera3IOStreamBase,
38 public Camera3OutputStreamInterface {
39
40 public:
41 /**
42 * Set up a dummy stream; doesn't actually connect to anything, and uses
43 * a default dummy format and size.
44 */
Chih-Hung Hsieh8b0b9712016-08-09 14:25:53 -070045 explicit Camera3DummyStream(int id);
Eino-Ville Talvala16a2ada2014-08-27 14:41:33 -070046
47 virtual ~Camera3DummyStream();
48
49 /**
50 * Camera3Stream interface
51 */
52
53 virtual void dump(int fd, const Vector<String16> &args) const;
54
55 status_t setTransform(int transform);
56
Eino-Ville Talvala77c1a352016-06-13 12:32:43 -070057 virtual status_t detachBuffer(sp<GraphicBuffer>* buffer, int* fenceFd);
58
Chien-Yu Chen85a64552015-08-28 15:46:12 -070059 /**
Chien-Yu Chen63068522017-10-23 15:59:49 -070060 * Drop buffers for stream of streamId if dropping is true. If dropping is false, do not
61 * drop buffers for stream of streamId.
62 */
63 virtual status_t dropBuffers(bool /*dropping*/) override;
64
65 /**
Chien-Yu Chen85a64552015-08-28 15:46:12 -070066 * Return if this output stream is for video encoding.
67 */
68 bool isVideoStream() const;
69
Zhijun He5d677d12016-05-29 16:52:39 -070070 /**
71 * Return if the consumer configuration of this stream is deferred.
72 */
Shuzhen Wang0129d522016-10-30 22:43:41 -070073 virtual bool isConsumerConfigurationDeferred(size_t surface_id) const;
Zhijun He5d677d12016-05-29 16:52:39 -070074
75 /**
Shuzhen Wang758c2152017-01-10 18:26:18 -080076 * Set the consumer surfaces to the output stream.
Zhijun He5d677d12016-05-29 16:52:39 -070077 */
Shuzhen Wang758c2152017-01-10 18:26:18 -080078 virtual status_t setConsumers(const std::vector<sp<Surface>>& consumers);
Zhijun He5d677d12016-05-29 16:52:39 -070079
Eino-Ville Talvala16a2ada2014-08-27 14:41:33 -070080 protected:
81
82 /**
83 * Note that we release the lock briefly in this function
84 */
85 virtual status_t returnBufferCheckedLocked(
86 const camera3_stream_buffer &buffer,
87 nsecs_t timestamp,
88 bool output,
89 /*out*/
90 sp<Fence> *releaseFenceOut);
91
92 virtual status_t disconnectLocked();
93
94 private:
95
96 // Default dummy parameters; 320x240 is a required size for all devices,
97 // otherwise act like a SurfaceView would.
98 static const int DUMMY_WIDTH = 320;
99 static const int DUMMY_HEIGHT = 240;
100 static const int DUMMY_FORMAT = HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED;
Eino-Ville Talvala3d82c0d2015-02-23 15:19:19 -0800101 static const android_dataspace DUMMY_DATASPACE = HAL_DATASPACE_UNKNOWN;
Yin-Chia Yehb97babb2015-03-12 13:42:44 -0700102 static const camera3_stream_rotation_t DUMMY_ROTATION = CAMERA3_STREAM_ROTATION_0;
Emilian Peev050f5dc2017-05-18 14:43:56 +0100103 static const uint64_t DUMMY_USAGE = GRALLOC_USAGE_HW_COMPOSER;
Eino-Ville Talvala16a2ada2014-08-27 14:41:33 -0700104
105 /**
106 * Internal Camera3Stream interface
107 */
Shuzhen Wangbee0f0a2017-01-24 14:51:37 -0800108 virtual status_t getBufferLocked(camera3_stream_buffer *buffer,
109 const std::vector<size_t>& surface_ids = std::vector<size_t>());
Eino-Ville Talvala16a2ada2014-08-27 14:41:33 -0700110 virtual status_t returnBufferLocked(
111 const camera3_stream_buffer &buffer,
112 nsecs_t timestamp);
113
114 virtual status_t configureQueueLocked();
115
Emilian Peev050f5dc2017-05-18 14:43:56 +0100116 virtual status_t getEndpointUsage(uint64_t *usage) const;
Eino-Ville Talvala16a2ada2014-08-27 14:41:33 -0700117
118}; // class Camera3DummyStream
119
120} // namespace camera3
121
122} // namespace android
123
124#endif