Libargus API Libargus Camera API

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
EGLStream.h
Go to the documentation of this file.
1 /*
2 * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of NVIDIA CORPORATION nor the names of its
13 * contributors may be used to endorse or promote products derived
14 * from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
24 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29 /**
30 * @file
31 * <b>Libargus API: EGLStream API</b>
32 *
33 * @b Description: This file defines an EGLStream-linked OutputStream type.
34 */
35
36 #ifndef _ARGUS_EGL_STREAM_H
37 #define _ARGUS_EGL_STREAM_H
38
39 namespace Argus
40 {
41
42 /**
43 * @defgroup ArgusEGLOutputStream EGLOutputStream
44 * @ingroup ArgusOutputStream
45 * @ref ArgusOutputStream type that generates frames as an EGLStream producer (STREAM_TYPE_EGL).
46 *
47 * EGLStream-linked OutputStream objects maintain a connection to an EGLStream
48 * as the producer endpoint. The EGLStream implementation is responsible for
49 * buffer allocation, management, and synchronization as frames are presented
50 * to the EGLStream from libargus and then consumed using an EGLStream consumer.
51 */
52 /**
53 * @defgroup ArgusEGLOutputStreamSettings EGLOutputStreamSettings
54 * @ingroup ArgusOutputStreamSettings
55 * Settings type used to configure/create @ref ArgusEGLOutputStream streams (STREAM_TYPE_EGL).
56 */
57
58 /**
59 * @ref ArgusOutputStream type that generates frames as an EGLStream producer (STREAM_TYPE_EGL).
60 * @ingroup ArgusOutputStream ArgusOutputStreamSettings
61 */
62 DEFINE_UUID(StreamType, STREAM_TYPE_EGL, 3a659360,5231,11e7,9598,18,00,20,0c,9a,66);
63
64 /**
65 * Defines the EGLStream queue mode of operation (see IEGLOutputStreamSettings::setMode).
66 */
67 DEFINE_NAMED_UUID_CLASS(EGLStreamMode);
68 DEFINE_UUID(EGLStreamMode, EGL_STREAM_MODE_MAILBOX, 33661d40,3ee2,11e6,bdf4,08,00,20,0c,9a,66);
69 DEFINE_UUID(EGLStreamMode, EGL_STREAM_MODE_FIFO, 33661d41,3ee2,11e6,bdf4,08,00,20,0c,9a,66);
70
71 /**
72 * @class IEGLOutputStreamSettings
73 *
74 * Interface that exposes the settings used for EGLStream-linked OutputStream creation.
75 *
76 * @ingroup ArgusEGLOutputStreamSettings
77 */
78 DEFINE_UUID(InterfaceID, IID_EGL_OUTPUT_STREAM_SETTINGS, 3a659361,5231,11e7,9598,18,00,20,0c,9a,66);
79 class IEGLOutputStreamSettings : public Interface
80 {
81 public:
82 static const InterfaceID& id() { return IID_EGL_OUTPUT_STREAM_SETTINGS; }
83
84 /**
85 * Set the format of the stream.
86 * Default value: PIXEL_FMT_UNKNOWN
87 */
88 virtual Status setPixelFormat(const PixelFormat& format) = 0;
89 virtual PixelFormat getPixelFormat() const = 0;
90
91 /**
92 * Set the resolution of the stream.
93 * Default value: (0, 0)
94 */
95 virtual Status setResolution(const Size2D<uint32_t>& resolution) = 0;
96 virtual Size2D<uint32_t> getResolution() const = 0;
97
98 /**
99 * Set the number of exposures per stream frame.
100 * This number should match the number of exposures that are going to be provided
101 * with each stream frame when capturing from multi-exposure WDR sources.
102 * Note that the EGLStream consumer must support consuming multi-exposure/buffer
103 * EGLStreams. In the case of the EGLStream::FrameConsumer consumer, the multiple
104 * exposures are treated as separate buffers in the acquired Image and may be
105 * accessed using any Image interface which supports multi-buffer/plane image access
106 * (see EGLStream::IImage::getBufferCount()).
107 * Default value: 1
108 */
109 virtual Status setExposureCount(uint32_t exposureCount) = 0;
110 virtual uint32_t getExposureCount() const = 0;
111
112 /**
113 * Set the EGLDisplay the created stream must belong to.
114 * Default value: EGL_NO_DISPLAY - stream is display-agnostic.
115 */
116 virtual Status setEGLDisplay(EGLDisplay eglDisplay) = 0;
117 virtual EGLDisplay getEGLDisplay() const = 0;
118
119 /**
120 * Sets the mode of the OutputStream. Available options are:
121 *
122 * MAILBOX:
123 * In this mode, only the newest frame is made available to the consumer. When Argus
124 * completes a frame it empties the mailbox and inserts the new frame into the mailbox.
125 * The consumer then retrieves the frame from the mailbox and processes it; when
126 * finished, the frame is either placed back into the mailbox (if the mailbox is empty)
127 * or discarded (if the mailbox is not empty). This mode implies 2 things:
128 *
129 * - If the consumer consumes frames slower than Argus produces frames, then some
130 * frames may be lost (never seen by the consumer).
131 *
132 * - If the consumer consumes frames faster than Argus produces frames, then the
133 * consumer may see some frames more than once.
134 *
135 * FIFO:
136 * When using this mode, every producer frame is made available to the consumer through
137 * the use of a fifo queue for the frames. When using this mode, the fifo queue length
138 * must be specified using setFifoLength. When Argus completes a frame it inserts it to
139 * the head of the fifo queue. If the fifo is full (already contains the number of frames
140 * equal to the fifo queue length), Argus will stall until the fifo is no longer
141 * full. The consumer consumes frames from the tail of the queue; however, if the
142 * consumer releases a frame while the queue is empty, the frame is set aside and will
143 * be returned again the next time the consumer requests a frame if another new frame
144 * has not been inserted into the fifo queue before then. Once a new frame is inserted
145 * into the fifo queue, any previously released frame will be permanently discarded.
146 * This mode implies:
147 *
148 * - Frames are never discarded until the consumer has processed them.
149 *
150 * - If the consumer consumes frames slower than Argus produces them, Argus will stall.
151 *
152 * - If the consumer consumes frames faster than Argus produces them, then the
153 * consumer may see some frames more than once.
154 *
155 * Default value: STREAM_MODE_MAILBOX
156 */
157 virtual Status setMode(const EGLStreamMode& mode) = 0;
158 virtual EGLStreamMode getMode() const = 0;
159
160 /**
161 * Sets the FIFO queue length of the stream. This value is only used if the stream is using
162 * the FIFO mode (@see OutputStreamSettings::setMode). Value must be > 0.
163 * Default value: 1
164 */
165 virtual Status setFifoLength(uint32_t fifoLength) = 0;
166 virtual uint32_t getFifoLength() const = 0;
167
168 /**
169 * Enables or disables embedding Argus CaptureMetadata within frames written to the EGLStream.
170 * Enabling this will allow an EGLStream::MetadataContainer to be created from frames acquired
171 * on the consumer side of the EGLStream that will expose the EGLStream::IArgusCaptureMetadata
172 * interface, which in turn provides access to the CaptureMetadata corresponding to that frame.
173 * This will also enable the IArgusCaptureMetadata interface directly on EGLStream::Frames
174 * acquired by an EGLStream::FrameConsumer.
175 * Default value: disabled.
176 */
177 virtual Status setMetadataEnable(bool metadataEnable) = 0;
178 virtual bool getMetadataEnable() const = 0;
179
180 /**
181 * @returns True if the output pixel format is supported by the CaptureSession for the
182 * queried sensor mode. Otherwise, returns false.
183 *
184 * @param[in] sensorMode The sensor mode being queried for the output pixel type.
185 * @param[in] outputFormat The output pixel format being queried for support.
186 */
187 virtual bool supportsOutputStreamFormat(const SensorMode* sensorMode,
188 const PixelFormat& outputFormat) const = 0;
189
190 protected:
191 ~IEGLOutputStreamSettings() {}
192 };
193
194 /**
195 * @class IEGLOutputStream
196 *
197 * Interface that exposes the methods available to an EGLStream-linked OutputStream.
198 *
199 * @ingroup ArgusEGLOutputStream
200 */
201 DEFINE_UUID(InterfaceID, IID_EGL_OUTPUT_STREAM, 3a659362,5231,11e7,9598,18,00,20,0c,9a,66);
202 class IEGLOutputStream : public Interface
203 {
204 public:
205 static const InterfaceID& id() { return IID_EGL_OUTPUT_STREAM; }
206
207 /**
208 * Waits until both the producer and consumer endpoints of the stream are connected.
209 *
210 * @param[in] timeout The timeout in nanoseconds.
211 *
212 * @returns success/status of this call.
213 */
214 virtual Status waitUntilConnected(uint64_t timeout = TIMEOUT_INFINITE) const = 0;
215
216 /**
217 * Disconnects the stream from the underlying EGLStream.
218 */
219 virtual void disconnect() = 0;
220
221 /**
222 * Returns the format of the stream.
223 */
224 virtual PixelFormat getPixelFormat() const = 0;
225
226 /**
227 * Returns the image resolution of the stream, in pixels.
228 */
229 virtual Size2D<uint32_t> getResolution() const = 0;
230
231 /**
232 * Returns the EGLDisplay the stream's EGLStream belongs to.
233 */
234 virtual EGLDisplay getEGLDisplay() const = 0;
235
236 /**
237 * Returns the EGLStream backing the stream.
238 */
239 virtual EGLStreamKHR getEGLStream() const = 0;
240
241 protected:
242 ~IEGLOutputStream() {}
243 };
244
245 } // namespace Argus
246
247 #endif // _ARGUS_EGL_STREAM_H