Libargus API
Libargus Camera API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
CaptureSession.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016-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: Capture Session API</b>
32  *
33  * @b Description: Defines the CaptureSession object and interface.
34  */
35 
36 #ifndef _ARGUS_CAPTURE_SESSION_H
37 #define _ARGUS_CAPTURE_SESSION_H
38 
39 namespace Argus
40 {
41 
42 /**
43  * Object that controls all operations on a single sensor.
44  *
45  * A capture session is bound to a single sensor (or, in future, a group of synchronized sensors)
46  * and provides methods to perform captures on that sensor (via the ICaptureSession interface).
47  *
48  * @defgroup ArgusCaptureSession CaptureSession
49  * @ingroup ArgusObjects
50  */
52 {
53 protected:
55 };
56 
57 /**
58  * @class ICaptureSession
59  *
60  * Interface to the core CaptureSession methods.
61  *
62  * @ingroup ArgusCaptureSession
63  */
64 DEFINE_UUID(InterfaceID, IID_CAPTURE_SESSION, 813644f5,bc21,4013,af44,dd,da,b5,7a,9d,13);
65 class ICaptureSession : public Interface
66 {
67 public:
68  static const InterfaceID& id() { return IID_CAPTURE_SESSION; }
69 
70  /**
71  * Removes all previously submitted requests from the queue. When all requests
72  * are cancelled, both the FIFO and the streaming requests will be removed.
73  * If repeat captures are enabled, an implicit call to ICaptureSession::stopRepeat()
74  * will be made before cancelling the requests.
75  *
76  * @returns success/status of this call.
77  */
78  virtual Status cancelRequests() = 0;
79 
80  /**
81  * Submits a single capture request.
82  * For blocking capture session (created by ICameraProvider::createBlockingCaptureSession),
83  * it will wait until the request is accepted by lower level driver.
84  * For non-blocking capture session (created by ICameraProvider::createCaptureSession),
85  * it will queue a copy of the request to a queue and return.
86  *
87  * The client can submit the same request instance in a future call.
88  * The request will be copied by the runtime.
89  *
90  * @param[in] request Parameters for the capture.
91  * @param[in] timeout The timeout in nanoseconds. The camera device will
92  * try to issue the request within the timeout period. If it can't it
93  * will return and set @c status to STATUS_UNAVAILABLE.
94  * @param[out] status An optional pointer to return success/status.
95  *
96  * @returns the capture id, a number that uniquely identifies (within this session) the request.
97  * If the submission request failed, zero will be returned.
98  * The request could fail because the timeout is reached,
99  * or because some parameter(s) of the @c request are invalid.
100  */
101  virtual uint32_t capture(const Request* request,
102  uint64_t timeout = TIMEOUT_INFINITE,
103  Status* status = NULL) = 0;
104 
105  /**
106  * Submits a burst of requests.
107  *
108  * For blocking capture session (created by ICameraProvider::createBlockingCaptureSession),
109  * it will wait until the first request is accepted by lower level driver.
110  * For non-blocking capture session (created by ICameraProvider::createCaptureSession),
111  * it will queue a copy of the requests to a queue and return.
112 
113  * The runtime will either accept the entire burst or refuse it completely
114  * (that is, no partial bursts will be accepted).
115  *
116  * @param[in] requestList The list of requests that make up the burst.
117  * @param[in] timeout The timeout in nanoseconds. The camera device will try to issue
118  * the request within the timeout period. If it can't it will return and set
119  * @c status to STATUS_UNAVAILABLE.
120  * @param[out] status An optional pointer to return success/status.
121  *
122  * @returns the capture id of the capture associated with the first request in the burst.
123  * The capture id will increment by one for the captures associated with each successive
124  * request.
125  * If the submission request failed, zero will be returned.
126  * The request could fail because the timeout is reached,
127  * or because some parameter(s) of the @c request are invalid.
128  */
129  virtual uint32_t captureBurst(const std::vector<const Request*>& requestList,
130  uint64_t timeout = TIMEOUT_INFINITE,
131  Status* status = NULL) = 0;
132 
133  /**
134  * Returns the maximum number of capture requests that can be included in a burst capture.
135  */
136  virtual uint32_t maxBurstRequests() const = 0;
137 
138  /**
139  * Creates a request object that can be later used with this CaptureSession.
140  *
141  * @param[in] intent Optional parameter that specifies the intent of the capture request and
142  * instructs the driver to populate the request with recommended settings
143  * for that intent.
144  * @param[out] status An optional pointer to return success/status.
145  *
146  * @see ICaptureMetadata::getClientData()
147  */
148  virtual Request* createRequest(const CaptureIntent& intent = CAPTURE_INTENT_PREVIEW,
149  Status* status = NULL) = 0;
150 
151  /**
152  * Creates an OutputStreamSettings object that is used to configure the creation of
153  * an OutputStream (see createOutputStream). The type of OutputStream that will be
154  * configured and created by these settings are determined by the StreamType.
155  *
156  * @param[in] type The type of the OutputStream to configure/create with these settings.
157  * @param[out] status An optional pointer to return success/status.
158  *
159  * @returns The newly created OutputStreamSettings, or NULL on failure.
160  */
161  virtual OutputStreamSettings* createOutputStreamSettings(const StreamType& type,
162  Status* status = NULL) = 0;
163 
164  /**
165  * Creates an OutputStream object using the settings configured by an OutputStreamSettings
166  * object (see createOutputStreamSettings).
167  *
168  * @param[in] settings The settings to use for the new output stream.
169  * @param[out] status An optional pointer to return success/status.
170  *
171  * @returns The newly created OutputStream, or NULL on failure.
172  */
173  virtual OutputStream* createOutputStream(const OutputStreamSettings* settings,
174  Status* status = NULL) = 0;
175 
176  /**
177  * Returns true if there is a streaming request in place.
178  */
179  virtual bool isRepeating() const = 0;
180 
181  /**
182  * Sets up a repeating request. This is a convenience method that will queue
183  * a request whenever the request queue is empty and the camera is ready to
184  * accept new requests.
185  *
186  * To stop repeating the request, call stopRepeat().
187  *
188  * @param[in] request The request to repeat.
189  *
190  * @returns success/status of the call.
191  */
192  virtual Status repeat(const Request* request) = 0;
193 
194  /**
195  * Sets up a repeating burst request. This is a convenience method that will queue
196  * a request whenever the request queue is empty and the camera is ready to
197  * accept new requests.
198  *
199  * To stop repeating the requests, call stopRepeat().
200  *
201  * @param[in] requestList The list of requests that make up the repeating burst.
202  *
203  * @returns success/status of the call.
204  */
205  virtual Status repeatBurst(const std::vector<const Request*>& requestList) = 0;
206 
207  /**
208  * Shuts down any repeating capture.
209  *
210  * @returns The range of capture ids generated by the most recent repeat() / repeatBurst() call.
211  * Note that some captures within that range may have been generated by explicit capture() calls
212  * made while the repeating capture was in force.
213  * If no captures were generated by the most recent repeat() / repeatBurst() call,
214  * <tt>Range<uint32_t>(0,0)</tt> will be returned.
215  */
216  virtual Range<uint32_t> stopRepeat() = 0;
217 
218  /**
219  * Waits until all pending captures are complete.
220  *
221  * @param[in] timeout The timeout value (in nanoseconds) for this call.
222  * If the pipe has not become idle when the timeout expires,
223  * the call will return STATUS_TIMEOUT.
224  */
225  virtual Status waitForIdle(uint64_t timeout = TIMEOUT_INFINITE) const = 0;
226 
227 protected:
229 };
230 
231 } // namespace Argus
232 
233 #endif // _ARGUS_CAPTURE_SESSION_H