InternalFrameCount.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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. * @file
  30. * <b>Libargus Extension: Internal Frame Count</b>
  31. *
  32. * @b Description: This file defines the InternalFrameCount extension.
  33. * @ingroup ArgusExtInternalFrameCount
  34. */
  35. #ifndef _ARGUS_INTERNAL_FRAME_COUNT_H
  36. #define _ARGUS_INTERNAL_FRAME_COUNT_H
  37. namespace Argus
  38. {
  39. /**
  40. * Adds accessors for an internal frame count performance metric.
  41. * The "internal frame count" is an implementation-dependent metric that may be
  42. * used to detect performance issues and producer frame drops for libargus
  43. * implementations that make use of internal captures.
  44. *
  45. * When a device is opened by a CaptureSession, the libargus implementation may
  46. * begin to immediately capture and process frames from the device in order to
  47. * initialize the camera subsystem even before a client request has been
  48. * submitted. Similarly, frames may be captured and processed by the
  49. * implementation when the client is idle or not ready for output in order to
  50. * maintain the driver subsystem and/or auto-control state (exposure, white
  51. * balance, etc). These captures are started and processed entirely within the
  52. * libargus implementation, with no inputs from or outputs to the client
  53. * application, and so are referred to as "internal" captures. These internal
  54. * captures are typically submitted when there are no client requests in the
  55. * capture queue or no stream buffers available for output within a sensor
  56. * frame period, and so knowing when an internal capture has been submitted can
  57. * be used to detect application or performance issues in cases where these
  58. * conditions are not expected to occur. This extension provides this
  59. * information in the form of an "internal frame count", which is the total
  60. * number of captures submitted by the session including both the internal
  61. * captures as well as client-submitted requests. If an internal frame count
  62. * gap appears between two client-submitted captures, this means that one or
  63. * more internal captures have been performed.
  64. *
  65. * When an application is saturating the capture queue to maintain driver
  66. * efficiency, either manually or by using repeat capture requests, the
  67. * internal frame count can be used to detect when internal captures are
  68. * submitted due to a lack of available output stream buffers. This situation
  69. * leads to sensor frames that are not output to the client's output stream,
  70. * which is usually an undesirable behavior that is referred to as "producer
  71. * frame drop". This is generally caused by a high consumer processing time,
  72. * which starves the stream’s available buffer pool, and can often be resolved
  73. * by decreasing the consumer processing time (reducing the time a buffer is
  74. * acquired, decreasing system load, increasing hardware clocks, etc.)
  75. *
  76. * @defgroup ArgusExtInternalFrameCount Ext::InternalFrameCount
  77. * @ingroup ArgusExtensions
  78. */
  79. DEFINE_UUID(ExtensionName, EXT_INTERNAL_FRAME_COUNT, 37afdbda,0020,4f91,957b,46,ea,eb,79,80,c7);
  80. namespace Ext
  81. {
  82. /**
  83. * @class IInternalFrameCount
  84. *
  85. * Interface used to query the internal frame count for a request.
  86. *
  87. * Since internal captures do not generate events, detecting internal captures
  88. * must be done by comparing the internal capture count of successive client-
  89. * submitted capture requests.
  90. *
  91. * This interface is available from:
  92. * - CaptureMetadata objects.
  93. * - Event objects of type EVENT_TYPE_CAPTURE_STARTED.
  94. *
  95. * @ingroup ArgusCaptureMetadata ArgusEventCaptureStarted ArgusExtInternalFrameCount
  96. */
  97. DEFINE_UUID(InterfaceID, IID_INTERNAL_FRAME_COUNT, c21a7ba2,2b3f,4275,8469,a2,56,34,93,53,93);
  98. class IInternalFrameCount : public Interface
  99. {
  100. public:
  101. static const InterfaceID& id() { return IID_INTERNAL_FRAME_COUNT; }
  102. /**
  103. * Returns the internal frame count for the request.
  104. */
  105. virtual uint64_t getInternalFrameCount() const = 0;
  106. protected:
  107. ~IInternalFrameCount() {}
  108. };
  109. } // namespace Ext
  110. } // namespace Argus
  111. #endif