CaptureSession.h 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  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. * @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. * Submits a single capture request.
  75. * For blocking capture session (created by ICameraProvider::createBlockingCaptureSession),
  76. * it will wait until the request is accepted by lower level driver.
  77. * For non-blocking capture session (created by ICameraProvider::createCaptureSession),
  78. * it will queue a copy of the request to a queue and return.
  79. *
  80. * The client can submit the same request instance in a future call.
  81. * The request will be copied by the runtime.
  82. *
  83. * @param[in] request Parameters for the capture.
  84. * @param[in] timeout The timeout in nanoseconds. The camera device will
  85. * try to issue the request within the timeout period. If it can't it
  86. * will return and set @c status to STATUS_UNAVAILABLE.
  87. * @param[out] status An optional pointer to return success/status.
  88. *
  89. * @returns the capture id, a number that uniquely identifies (within this session) the request.
  90. * If the submission request failed, zero will be returned.
  91. * The request could fail because the timeout is reached,
  92. * or because some parameter(s) of the @c request are invalid.
  93. */
  94. virtual uint32_t capture(const Request* request,
  95. uint64_t timeout = TIMEOUT_INFINITE,
  96. Status* status = NULL) = 0;
  97. /**
  98. * Submits a burst of requests.
  99. *
  100. * For blocking capture session (created by ICameraProvider::createBlockingCaptureSession),
  101. * it will wait until the first request is accepted by lower level driver.
  102. * For non-blocking capture session (created by ICameraProvider::createCaptureSession),
  103. * it will queue a copy of the requests to a queue and return.
  104. * The runtime will either accept the entire burst or refuse it completely
  105. * (that is, no partial bursts will be accepted).
  106. *
  107. * @param[in] requestList The list of requests that make up the burst.
  108. * @param[in] timeout The timeout in nanoseconds. The camera device will try to issue
  109. * the request within the timeout period. If it can't it will return and set
  110. * @c status to STATUS_UNAVAILABLE.
  111. * @param[out] status An optional pointer to return success/status.
  112. *
  113. * @returns the capture id of the capture associated with the first request in the burst.
  114. * The capture id will increment by one for the captures associated with each successive
  115. * request.
  116. * If the submission request failed, zero will be returned.
  117. * The request could fail because the timeout is reached,
  118. * or because some parameter(s) of the @c request are invalid.
  119. */
  120. virtual uint32_t captureBurst(const std::vector<const Request*>& requestList,
  121. uint64_t timeout = TIMEOUT_INFINITE,
  122. Status* status = NULL) = 0;
  123. /**
  124. * Returns the maximum number of capture requests that can be included in a burst capture.
  125. */
  126. virtual uint32_t maxBurstRequests() const = 0;
  127. /**
  128. * Creates a request object that can be later used with this CaptureSession.
  129. *
  130. * @param[in] intent Optional parameter that specifies the intent of the capture request and
  131. * instructs the driver to populate the request with recommended settings
  132. * for that intent.
  133. * @param[out] status An optional pointer to return success/status.
  134. *
  135. * @see ICaptureMetadata::getClientData()
  136. */
  137. virtual Request* createRequest(const CaptureIntent& intent = CAPTURE_INTENT_PREVIEW,
  138. Status* status = NULL) = 0;
  139. /**
  140. * Creates an OutputStreamSettings object that is used to configure the creation of
  141. * an OutputStream (see createOutputStream). The type of OutputStream that will be
  142. * configured and created by these settings are determined by the StreamType.
  143. *
  144. * @param[in] type The type of the OutputStream to configure/create with these settings.
  145. * @param[out] status An optional pointer to return success/status.
  146. *
  147. * @returns The newly created OutputStreamSettings, or NULL on failure.
  148. */
  149. virtual OutputStreamSettings* createOutputStreamSettings(const StreamType& type,
  150. Status* status = NULL) = 0;
  151. /**
  152. * Creates an OutputStream object using the settings configured by an OutputStreamSettings
  153. * object (see createOutputStreamSettings).
  154. *
  155. * @param[in] settings The settings to use for the new output stream.
  156. * @param[out] status An optional pointer to return success/status.
  157. *
  158. * @returns The newly created OutputStream, or NULL on failure.
  159. */
  160. virtual OutputStream* createOutputStream(const OutputStreamSettings* settings,
  161. Status* status = NULL) = 0;
  162. /**
  163. * Returns true if there is a streaming request in place.
  164. */
  165. virtual bool isRepeating() const = 0;
  166. /**
  167. * Sets up a repeating request. This is a convenience method that will queue
  168. * a request whenever the request queue is empty and the camera is ready to
  169. * accept new requests.
  170. *
  171. * To stop repeating the request, call stopRepeat().
  172. *
  173. * @param[in] request The request to repeat.
  174. *
  175. * @returns success/status of the call.
  176. */
  177. virtual Status repeat(const Request* request) = 0;
  178. /**
  179. * Sets up a repeating burst request. This is a convenience method that will queue
  180. * a request whenever the request queue is empty and the camera is ready to
  181. * accept new requests.
  182. *
  183. * To stop repeating the requests, call stopRepeat().
  184. *
  185. * @param[in] requestList The list of requests that make up the repeating burst.
  186. *
  187. * @returns success/status of the call.
  188. */
  189. virtual Status repeatBurst(const std::vector<const Request*>& requestList) = 0;
  190. /**
  191. * Shuts down any repeating capture.
  192. *
  193. * @returns The range of capture ids generated by the most recent repeat() / repeatBurst() call.
  194. * Note that some captures within that range may have been generated by explicit capture() calls
  195. * made while the repeating capture was in force.
  196. * If no captures were generated by the most recent repeat() / repeatBurst() call,
  197. * <tt>Range<uint32_t>(0,0)</tt> will be returned.
  198. */
  199. virtual Range<uint32_t> stopRepeat() = 0;
  200. /**
  201. * Waits until all pending captures are complete.
  202. *
  203. * @param[in] timeout The timeout value (in nanoseconds) for this call.
  204. * If the pipe has not become idle when the timeout expires,
  205. * the call will return STATUS_TIMEOUT.
  206. */
  207. virtual Status waitForIdle(uint64_t timeout = TIMEOUT_INFINITE) const = 0;
  208. protected:
  209. ~ICaptureSession() {}
  210. };
  211. } // namespace Argus
  212. #endif // _ARGUS_CAPTURE_SESSION_H