Eino-Ville Talvala | 16a2ada | 2014-08-27 14:41:33 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 27 | namespace android { |
| 28 | namespace 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 | */ |
| 36 | class 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 Hsieh | 8b0b971 | 2016-08-09 14:25:53 -0700 | [diff] [blame] | 45 | explicit Camera3DummyStream(int id); |
Eino-Ville Talvala | 16a2ada | 2014-08-27 14:41:33 -0700 | [diff] [blame] | 46 | |
| 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 Talvala | 77c1a35 | 2016-06-13 12:32:43 -0700 | [diff] [blame] | 57 | virtual status_t detachBuffer(sp<GraphicBuffer>* buffer, int* fenceFd); |
| 58 | |
Chien-Yu Chen | 85a6455 | 2015-08-28 15:46:12 -0700 | [diff] [blame] | 59 | /** |
| 60 | * Return if this output stream is for video encoding. |
| 61 | */ |
| 62 | bool isVideoStream() const; |
| 63 | |
Zhijun He | 5d677d1 | 2016-05-29 16:52:39 -0700 | [diff] [blame] | 64 | /** |
| 65 | * Return if the consumer configuration of this stream is deferred. |
| 66 | */ |
Shuzhen Wang | 0129d52 | 2016-10-30 22:43:41 -0700 | [diff] [blame] | 67 | virtual bool isConsumerConfigurationDeferred(size_t surface_id) const; |
Zhijun He | 5d677d1 | 2016-05-29 16:52:39 -0700 | [diff] [blame] | 68 | |
| 69 | /** |
Shuzhen Wang | 758c215 | 2017-01-10 18:26:18 -0800 | [diff] [blame] | 70 | * Set the consumer surfaces to the output stream. |
Zhijun He | 5d677d1 | 2016-05-29 16:52:39 -0700 | [diff] [blame] | 71 | */ |
Shuzhen Wang | 758c215 | 2017-01-10 18:26:18 -0800 | [diff] [blame] | 72 | virtual status_t setConsumers(const std::vector<sp<Surface>>& consumers); |
Zhijun He | 5d677d1 | 2016-05-29 16:52:39 -0700 | [diff] [blame] | 73 | |
Eino-Ville Talvala | 16a2ada | 2014-08-27 14:41:33 -0700 | [diff] [blame] | 74 | protected: |
| 75 | |
| 76 | /** |
| 77 | * Note that we release the lock briefly in this function |
| 78 | */ |
| 79 | virtual status_t returnBufferCheckedLocked( |
| 80 | const camera3_stream_buffer &buffer, |
| 81 | nsecs_t timestamp, |
| 82 | bool output, |
| 83 | /*out*/ |
| 84 | sp<Fence> *releaseFenceOut); |
| 85 | |
| 86 | virtual status_t disconnectLocked(); |
| 87 | |
| 88 | private: |
| 89 | |
| 90 | // Default dummy parameters; 320x240 is a required size for all devices, |
| 91 | // otherwise act like a SurfaceView would. |
| 92 | static const int DUMMY_WIDTH = 320; |
| 93 | static const int DUMMY_HEIGHT = 240; |
| 94 | static const int DUMMY_FORMAT = HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED; |
Eino-Ville Talvala | 3d82c0d | 2015-02-23 15:19:19 -0800 | [diff] [blame] | 95 | static const android_dataspace DUMMY_DATASPACE = HAL_DATASPACE_UNKNOWN; |
Yin-Chia Yeh | b97babb | 2015-03-12 13:42:44 -0700 | [diff] [blame] | 96 | static const camera3_stream_rotation_t DUMMY_ROTATION = CAMERA3_STREAM_ROTATION_0; |
Eino-Ville Talvala | 16a2ada | 2014-08-27 14:41:33 -0700 | [diff] [blame] | 97 | static const uint32_t DUMMY_USAGE = GRALLOC_USAGE_HW_COMPOSER; |
| 98 | |
| 99 | /** |
| 100 | * Internal Camera3Stream interface |
| 101 | */ |
Shuzhen Wang | bee0f0a | 2017-01-24 14:51:37 -0800 | [diff] [blame^] | 102 | virtual status_t getBufferLocked(camera3_stream_buffer *buffer, |
| 103 | const std::vector<size_t>& surface_ids = std::vector<size_t>()); |
Eino-Ville Talvala | 16a2ada | 2014-08-27 14:41:33 -0700 | [diff] [blame] | 104 | virtual status_t returnBufferLocked( |
| 105 | const camera3_stream_buffer &buffer, |
| 106 | nsecs_t timestamp); |
| 107 | |
| 108 | virtual status_t configureQueueLocked(); |
| 109 | |
Eino-Ville Talvala | 4d44cad | 2015-04-11 13:15:45 -0700 | [diff] [blame] | 110 | virtual status_t getEndpointUsage(uint32_t *usage) const; |
Eino-Ville Talvala | 16a2ada | 2014-08-27 14:41:33 -0700 | [diff] [blame] | 111 | |
| 112 | }; // class Camera3DummyStream |
| 113 | |
| 114 | } // namespace camera3 |
| 115 | |
| 116 | } // namespace android |
| 117 | |
| 118 | #endif |