CaptureSession.h 11 KB

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