Multimedia API Reference

November 16, 2016 | 24.2.1 Release

 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Types.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016, 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 
37 #ifndef _ARGUS_TYPES_H
38 #define _ARGUS_TYPES_H
39 
49 #include <stdint.h>
50 #include <vector>
51 
52 #include <EGL/egl.h>
53 #include <EGL/eglext.h>
54 
55 // Some versions of the Xlib.h header file define 'Status' to 'int'. This collides with the libargus
56 // 'Status' type.
57 // If 'Status' is defined then undefine it and use a typedef instead.
58 #ifdef Status
59 #undef Status
60 typedef int Status;
61 #endif // Status
62 
63 namespace Argus
64 {
65 
66 /*
67  * Forward declaration of standard objects
68  */
69 class CameraDevice;
70 class CameraProvider;
71 class CaptureSession;
72 class CaptureMetadata;
73 class CaptureMetadataContainer;
74 class Event;
75 class EventQueue;
76 class InputStream;
77 class OutputStream;
78 class OutputStreamSettings;
79 class Request;
80 class SensorMode;
81 
82 /*
83  * Forward declaration of standard interfaces
84  */
85 class ICameraProperties;
86 class ICameraProvider;
87 class ICaptureSession;
88 class IAutoControlSettings;
89 class IRequest;
90 class IStream;
91 class IStreamSettings;
92 
96 const uint64_t TIMEOUT_INFINITE = 0xFFFFFFFFFFFFFFFF;
97 
101 class ExtensionName : public NamedUUID
102 {
103 public:
104  ExtensionName(uint32_t time_low_
105  , uint16_t time_mid_
106  , uint16_t time_hi_and_version_
107  , uint16_t clock_seq_
108  , uint8_t c0, uint8_t c1, uint8_t c2, uint8_t c3, uint8_t c4, uint8_t c5
109  , const char* name)
110  : NamedUUID(time_low_, time_mid_, time_hi_and_version_, clock_seq_,
111  c0, c1, c2, c3, c4, c5, name)
112  {}
113 
115  : NamedUUID(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "EXT_UNSPECIFIED")
116  {}
117 };
118 
119 /*
120  * Named UUID classes.
121  */
122 
123 DEFINE_NAMED_UUID_CLASS(AwbMode);
124 DEFINE_NAMED_UUID_CLASS(CaptureIntent);
125 DEFINE_NAMED_UUID_CLASS(DenoiseMode);
126 DEFINE_NAMED_UUID_CLASS(SensorModeType);
127 DEFINE_NAMED_UUID_CLASS(VideoStabilizationMode);
128 
129 /*
130  * Named UUIDs sorted alphabetically.
131  */
132 
133 DEFINE_UUID(AwbMode, AWB_MODE_OFF, FB3F365A,CC62,11E5,9956,62,56,62,87,07,61);
134 DEFINE_UUID(AwbMode, AWB_MODE_AUTO, FB3F365B,CC62,11E5,9956,62,56,62,87,07,61);
135 DEFINE_UUID(AwbMode, AWB_MODE_INCANDESCENT, FB3F365C,CC62,11E5,9956,62,56,62,87,07,61);
136 DEFINE_UUID(AwbMode, AWB_MODE_FLUORESCENT, FB3F365D,CC62,11E5,9956,62,56,62,87,07,61);
137 DEFINE_UUID(AwbMode, AWB_MODE_WARM_FLUORESCENT, FB3F365E,CC62,11E5,9956,62,56,62,87,07,61);
138 DEFINE_UUID(AwbMode, AWB_MODE_DAYLIGHT, FB3F365F,CC62,11E5,9956,62,56,62,87,07,61);
139 DEFINE_UUID(AwbMode, AWB_MODE_CLOUDY_DAYLIGHT, FB3F3660,CC62,11E5,9956,62,56,62,87,07,61);
140 DEFINE_UUID(AwbMode, AWB_MODE_TWILIGHT, FB3F3661,CC62,11E5,9956,62,56,62,87,07,61);
141 DEFINE_UUID(AwbMode, AWB_MODE_SHADE, FB3F3662,CC62,11E5,9956,62,56,62,87,07,61);
142 
143 DEFINE_UUID(CaptureIntent, CAPTURE_INTENT_MANUAL,
144  FB3F3663,CC62,11E5,9956,62,56,62,87,07,61);
145 DEFINE_UUID(CaptureIntent, CAPTURE_INTENT_PREVIEW,
146  FB3F3664,CC62,11E5,9956,62,56,62,87,07,61);
147 DEFINE_UUID(CaptureIntent, CAPTURE_INTENT_STILL_CAPTURE,
148  FB3F3665,CC62,11E5,9956,62,56,62,87,07,61);
149 DEFINE_UUID(CaptureIntent, CAPTURE_INTENT_VIDEO_RECORD,
150  FB3F3666,CC62,11E5,9956,62,56,62,87,07,61);
151 DEFINE_UUID(CaptureIntent, CAPTURE_INTENT_VIDEO_SNAPSHOT,
152  FB3F3667,CC62,11E5,9956,62,56,62,87,07,61);
153 
154 DEFINE_UUID(DenoiseMode, DENOISE_MODE_OFF, FB3F3668,CC62,11E5,9956,62,56,62,87,07,61);
155 DEFINE_UUID(DenoiseMode, DENOISE_MODE_FAST, FB3F3669,CC62,11E5,9956,62,56,62,87,07,61);
156 DEFINE_UUID(DenoiseMode, DENOISE_MODE_HIGH_QUALITY, FB3F366A,CC62,11E5,9956,62,56,62,87,07,61);
157 
158 DEFINE_UUID(SensorModeType, SENSOR_MODE_TYPE_DEPTH,
159  64483464,4b91,11e6,bbbd,40,16,7e,ab,86,92);
160 DEFINE_UUID(SensorModeType, SENSOR_MODE_TYPE_YUV,
161  6453e00c,4b91,11e6,871d,40,16,7e,ab,86,92);
162 DEFINE_UUID(SensorModeType, SENSOR_MODE_TYPE_RGB,
163  6463d4c6,4b91,11e6,88a3,40,16,7e,ab,86,92);
164 DEFINE_UUID(SensorModeType, SENSOR_MODE_TYPE_BAYER,
165  646f04ea,4b91,11e6,9c06,40,16,7e,ab,86,92);
166 
167 DEFINE_UUID(VideoStabilizationMode, VIDEO_STABILIZATION_MODE_OFF,
168  FB3F366E,CC62,11E5,9956,62,56,62,87,07,61);
169 DEFINE_UUID(VideoStabilizationMode, VIDEO_STABILIZATION_MODE_ON,
170  FB3F366F,CC62,11E5,9956,62,56,62,87,07,61);
171 
172 /*
173  * Camera settings constants - sorted alphabetically.
174  */
175 
177 {
182 
184 };
185 
187 {
193 
195 };
196 
198 {
203 
205 };
206 
208 {
213 
215 };
216 
220 enum Status
221 {
224 
227 
230 
233 
236 
239 
242 
245 
248 
249  // Number of elements in this enum.
251 };
252 
254 {
258 
260 };
261 
262 
266 class PixelFormat : public NamedUUID
267 {
268 public:
269  PixelFormat(uint32_t time_low_
270  , uint16_t time_mid_
271  , uint16_t time_hi_and_version_
272  , uint16_t clock_seq_
273  , uint8_t c0, uint8_t c1, uint8_t c2, uint8_t c3, uint8_t c4, uint8_t c5
274  , const char* name)
275  : NamedUUID(time_low_, time_mid_, time_hi_and_version_, clock_seq_,
276  c0, c1, c2, c3, c4, c5, name)
277  {}
278 
279 private:
280  PixelFormat(); // No default c'tor please use PIXEL_FMT_UNKNOWN
281 };
282 
283 DEFINE_UUID(PixelFormat, PIXEL_FMT_UNKNOWN, 00000000,93d5,11e5,0000,1c,b7,2c,ef,d4,1e);
284 DEFINE_UUID(PixelFormat, PIXEL_FMT_Y8, 569be14a,93d5,11e5,91bc,1c,b7,2c,ef,d4,1e);
285 DEFINE_UUID(PixelFormat, PIXEL_FMT_Y16, 56ddb19c,93d5,11e5,8e2c,1c,b7,2c,ef,d4,1e);
286 DEFINE_UUID(PixelFormat, PIXEL_FMT_YCbCr_420_888, 570c10e6,93d5,11e5,8ff3,1c,b7,2c,ef,d4,1e);
287 DEFINE_UUID(PixelFormat, PIXEL_FMT_YCbCr_422_888, 573a7940,93d5,11e5,99c2,1c,b7,2c,ef,d4,1e);
288 DEFINE_UUID(PixelFormat, PIXEL_FMT_YCbCr_444_888, 576043dc,93d5,11e5,8983,1c,b7,2c,ef,d4,1e);
289 DEFINE_UUID(PixelFormat, PIXEL_FMT_JPEG_BLOB, 578b08c4,93d5,11e5,9686,1c,b7,2c,ef,d4,1e);
290 DEFINE_UUID(PixelFormat, PIXEL_FMT_RAW16, 57b484d8,93d5,11e5,aeb6,1c,b7,2c,ef,d4,1e);
291 
296 {
297 protected:
299 
300 private:
301  NonCopyable(NonCopyable& other);
302  NonCopyable& operator=(NonCopyable& other);
303 };
304 
313 {
314 protected:
317 };
318 
322 class InterfaceID : public NamedUUID
323 {
324 public:
325  InterfaceID(uint32_t time_low_
326  , uint16_t time_mid_
327  , uint16_t time_hi_and_version_
328  , uint16_t clock_seq_
329  , uint8_t c0, uint8_t c1, uint8_t c2, uint8_t c3, uint8_t c4, uint8_t c5
330  , const char* name)
331  : NamedUUID(time_low_, time_mid_, time_hi_and_version_, clock_seq_,
332  c0, c1, c2, c3, c4, c5, name)
333  {}
334 
336  : NamedUUID(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "IID_UNSPECIFIED")
337  {}
338 };
339 
344 {
345 public:
346 
352  virtual Interface* getInterface(const InterfaceID& interfaceId) = 0;
353 
354 protected:
356 };
357 
362 template <typename TheInterface>
363 inline TheInterface* interface_cast(InterfaceProvider* obj)
364 {
365  return static_cast<TheInterface*>(obj ? obj->getInterface(TheInterface::id()): 0);
366 }
367 
368 template <typename TheInterface>
369 inline TheInterface* interface_cast(const InterfaceProvider* obj)
370 {
371  return static_cast<TheInterface*>(
372  obj ? const_cast<const Interface*>(
373  const_cast<InterfaceProvider*>(obj)->getInterface(TheInterface::id())): 0);
374 }
375 
381 {
382 public:
383 
388  virtual void destroy() = 0;
389 
390 protected:
392 };
393 
397 template<typename T>
398 class rv : public T
399 {
400  rv();
401  ~rv();
402  rv(const rv&);
403  void operator=(const rv&);
404 };
405 
406 template<typename T>
407  rv<T>& move(T& self)
408 {
409  return *static_cast<rv<T>*>(&self);
410 }
411 
415 template <typename T> struct remove_const;
416 template <typename T> struct remove_const<const T&>{ typedef T& type; };
417 template <typename T> struct remove_const<const T*>{ typedef T* type; };
418 template <typename T> struct remove_const<const T >{ typedef T type; };
419 template <typename T> struct remove_const { typedef T type; };
420 
421 template <typename T>
423 {
424 public:
425  explicit UniqueObj(T* obj=NULL): m_obj(obj) {}
426 
427  void reset(T* obj=NULL)
428  { if (m_obj) const_cast<typename remove_const<T*>::type>(m_obj)->destroy(); m_obj = obj; }
429  T* release()
430  { T* obj = m_obj; m_obj = NULL; return obj; }
431 
432  UniqueObj( rv<UniqueObj>& moved ): m_obj(moved.release()) {}
433  UniqueObj& operator=( rv<UniqueObj>& moved ){ reset( moved.release()); return *this; }
434 
435  ~UniqueObj() { reset(); }
436 
437  T& operator*() const { return *m_obj; }
438  T* get() const { return m_obj; }
439 
440  operator bool() const { return !!m_obj; }
441 
442  operator rv<UniqueObj>&() { return *static_cast< rv<UniqueObj>*>(this); }
443  operator const rv<UniqueObj>&() const { return *static_cast<const rv<UniqueObj>*>(this); }
444 
445 private:
446  T* m_obj;
447 
448  T* operator->() const; // Prevent calling destroy() directly.
449  // Note: For getInterface functionality use interface_cast.
450 };
451 
452 template <typename TheInterface, typename TObject>
453 inline TheInterface* interface_cast(const UniqueObj<TObject>& obj)
454 {
455  return interface_cast<TheInterface>( obj.get());
456 }
457 
461 template <typename T>
462 struct Range
463 {
464  T min;
465  T max;
466 
467  Range(T value) : min( value ), max( value ) {}
468  Range(T min, T max) : min( min ), max( max ) {};
469  bool operator== (const Range<T>& rhs) const
470  {
471  return (min == rhs.min && max == rhs.max);
472  }
473 
474  bool empty() const
475  {
476  return max < min;
477  }
478 };
479 
483 struct Rectangle
484 {
485  uint32_t left;
486  uint32_t top;
487  uint32_t width;
488  uint32_t height;
489 
490  Rectangle() : left(0), top(0), width(0), height(0) {}
491  Rectangle(uint32_t _left, uint32_t _top, uint32_t _width, uint32_t _height)
492  : left(_left), top(_top), width(_width), height(_height)
493  {}
494 
495  bool operator==(const Rectangle& other) const
496  {
497  return (left == other.left) && (top == other.top) &&
498  (width == other.width) && (height == other.height);
499  }
500 };
501 
505 struct Size
506 {
507  uint32_t width;
508  uint32_t height;
509 
510  Size() : width(0), height(0) {}
511 
513  Size(uint32_t w, uint32_t h) : width(w), height(h) {}
514 
515  bool operator==(const Size& a) const
516  {
517  return width == a.width && height == a.height;
518  }
519 };
520 
524 struct Location
525 {
526  uint32_t x;
527  uint32_t y;
528 
529  Location() : x(0), y(0) {}
530 
532  Location(uint32_t a, uint32_t b) : x(a), y(b) {}
533 
534  bool operator==(const Location& other) const
535  {
536  return x == other.x && y == other.y;
537  }
538 };
539 
544 {
545  float left;
546  float top;
547  float right;
548  float bottom;
549 
550  NormalizedRect() : left(0.0f), top(0.0f), right(1.0f), bottom(1.0f) {}
551  NormalizedRect(float l, float t, float r, float b) : left(l), top(t), right(r), bottom(b) {}
552  bool operator==(const NormalizedRect& other) const
553  {
554  return (left == other.left) &&
555  (top == other.top) &&
556  (right == other.right) &&
557  (bottom == other.bottom);
558  }
559 };
560 
565 {
566  float rGain;
567  float grGain;
568  float gbGain;
569  float bGain;
570 
572  : rGain(0.0f)
573  , grGain(0.0f)
574  , gbGain(0.0f)
575  , bGain(0.0f)
576  {}
577 
578  BayerGains(float r, float gr, float gb, float b)
579  : rGain(r)
580  , grGain(gr)
581  , gbGain(gb)
582  , bGain(b)
583  {}
584 
585  bool operator==(const BayerGains& other) const
586  {
587  return (rGain == other.rGain) &&
588  (grGain == other.grGain) &&
589  (gbGain == other.gbGain) &&
590  (bGain == other.bGain);
591  }
592 };
593 
597 struct AcRegion
598 {
600  : rect(0, 0, 0, 0)
601  , weight(1.0f)
602  {}
603 
604  AcRegion(uint32_t _left, uint32_t _top, uint32_t _width, uint32_t _height, float _weight)
605  : rect(_left, _top, _width, _height)
606  , weight(_weight)
607  {}
608 
609  bool operator==(const AcRegion& other) const
610  {
611  return (weight == other.weight) &&
612  (rect == other.rect);
613  }
614 
616  float weight;
617 };
618 
619 typedef uint32_t AutoControlId;
620 
621 } // namespace Argus
623 #endif // _ARGUS_TYPES_H
Extension name UUID.
Definition: Types.h:101
float gbGain
Definition: Types.h:568
Size(uint32_t w, uint32_t h)
Construct size from width and height.
Definition: Types.h:513
The base interface for a class that provides libargus interfaces.
Definition: Types.h:343
T * release()
Definition: Types.h:429
void reset(T *obj=NULL)
Definition: Types.h:427
float grGain
Definition: Types.h:567
The stream or other resource has been disconnected.
Definition: Types.h:247
bool empty() const
Definition: Types.h:474
Location(uint32_t a, uint32_t b)
Construct location from x and y.
Definition: Types.h:532
bool operator==(const Location &other) const
Definition: Types.h:534
Status
Status values returned by API function calls.
Definition: Types.h:220
uint32_t y
Definition: Types.h:527
RGBColorChannel
Definition: Types.h:253
TheInterface * interface_cast(InterfaceProvider *obj)
Interface-casting helper similar to dynamic_cast.
Definition: Types.h:363
The top-level interface class.
Definition: Types.h:312
Function succeeded.
Definition: Types.h:223
Pixel formats.
Definition: Types.h:266
UniqueObj(rv< UniqueObj > &moved)
Definition: Types.h:432
AeState
Definition: Types.h:186
bool operator==(const NormalizedRect &other) const
Definition: Types.h:552
uint32_t width
Definition: Types.h:507
AwbState
Definition: Types.h:197
An operation timed out.
Definition: Types.h:241
Range(T value)
Definition: Types.h:467
Aggregates 2D co-ordinates of a location in a single structure.
Definition: Types.h:524
bool operator==(const Range< T > &rhs) const
Definition: Types.h:469
A templatized class to hold a min/max range of values.
Definition: Types.h:462
Range(T min, T max)
Definition: Types.h:468
uint32_t height
Definition: Types.h:488
Rectangle(uint32_t _left, uint32_t _top, uint32_t _width, uint32_t _height)
Definition: Types.h:491
InterfaceID(uint32_t time_low_, uint16_t time_mid_, uint16_t time_hi_and_version_, uint16_t clock_seq_, uint8_t c0, uint8_t c1, uint8_t c2, uint8_t c3, uint8_t c4, uint8_t c5, const char *name)
Definition: Types.h:325
uint32_t x
Definition: Types.h:526
DEFINE_UUID(ExtensionName, EXT_BAYER_SHARPNESS_MAP, 7d5e0470, 4ea6, 11e6, bdf4, 08, 00, 20, 0c, 9a, 66)
The Ext::BayerSharpnessMap extension adds internally-generated sharpness metrics to CaptureMetadata r...
A unique identifier with a name (primarily for debugging purposes).
Definition: UUID.h:75
virtual void destroy()=0
Destroy this object.
The capture was aborted.
Definition: Types.h:244
uint32_t top
Definition: Types.h:486
Defines gains used for each Bayer channel.
Definition: Types.h:564
Defines a rectangle in pixel space.
Definition: Types.h:483
bool operator==(const Rectangle &other) const
Definition: Types.h:495
AeAntibandingMode
Definition: Types.h:176
const uint64_t TIMEOUT_INFINITE
Constant used for infinite timeouts.
Definition: Types.h:96
uint32_t width
Definition: Types.h:487
DEFINE_NAMED_UUID_CLASS(StreamMode)
The requested settings are invalid.
Definition: Types.h:229
bool operator==(const Size &a) const
Definition: Types.h:515
uint32_t height
Definition: Types.h:508
ExtensionName(uint32_t time_low_, uint16_t time_mid_, uint16_t time_hi_and_version_, uint16_t clock_seq_, uint8_t c0, uint8_t c1, uint8_t c2, uint8_t c3, uint8_t c4, uint8_t c5, const char *name)
Definition: Types.h:104
uint32_t left
Definition: Types.h:485
bool operator==(const AcRegion &other) const
Definition: Types.h:609
A unique identifier for an libargus Interface.
Definition: Types.h:322
Aggregates width and height in a single structure.
Definition: Types.h:505
PixelFormat(uint32_t time_low_, uint16_t time_mid_, uint16_t time_hi_and_version_, uint16_t clock_seq_, uint8_t c0, uint8_t c1, uint8_t c2, uint8_t c3, uint8_t c4, uint8_t c5, const char *name)
Definition: Types.h:269
T * get() const
Definition: Types.h:438
The requested device is unavailable.
Definition: Types.h:232
float weight
Definition: Types.h:616
T & operator*() const
Definition: Types.h:437
A top level object class for libargus objects that are created and owned by the client.
Definition: Types.h:380
AcRegion(uint32_t _left, uint32_t _top, uint32_t _width, uint32_t _height, float _weight)
Definition: Types.h:604
uint32_t AutoControlId
Definition: Types.h:619
The set of parameters passed was invalid.
Definition: Types.h:226
This method has not been implemented.
Definition: Types.h:238
rv< T > & move(T &self)
Definition: Types.h:407
Movable smart pointer mimicking std::unique_ptr.
Definition: Types.h:415
BayerChannel
Definition: Types.h:207
UniqueObj & operator=(rv< UniqueObj > &moved)
Definition: Types.h:433
BayerGains(float r, float gr, float gb, float b)
Definition: Types.h:578
bool operator==(const BayerGains &other) const
Definition: Types.h:585
Template helper emulating C++11 rvalue semantics.
Definition: Types.h:398
virtual Interface * getInterface(const InterfaceID &interfaceId)=0
Acquire the interface specified by interfaceId.
An operation failed because of insufficient mavailable memory.
Definition: Types.h:235
Rectangle rect
Definition: Types.h:615
UniqueObj(T *obj=NULL)
Definition: Types.h:425
Utility class for libargus interfaces.
Definition: Types.h:295
Defines an autocontrol region of interest (in pixel space).
Definition: Types.h:597
NormalizedRect(float l, float t, float r, float b)
Definition: Types.h:551
Defines a normalized rectangle region in [0.0, 1.0].
Definition: Types.h:543