Libargus API
Libargus Camera API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Event.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: Event API</b>
32  *
33  * @b Description: Defines the Event objects and interfaces.
34  */
35 
36 #ifndef _ARGUS_EVENT_H
37 #define _ARGUS_EVENT_H
38 
39 namespace Argus
40 {
41 
42 /**
43  * Container representing a single event.
44  *
45  * Every Event will have a single EventType and will expose one or more
46  * interfaces, with the core IEvent interface being mandatory.
47  *
48  * @defgroup ArgusEvent Event
49  * @ingroup ArgusObjects
50  */
51 class Event : public InterfaceProvider
52 {
53 protected:
54  ~Event() {}
55 };
56 
57 /**
58  * A unique identifier for a particular type of Event.
59  *
60  * @ingroup ArgusEvent
61  */
62 class EventType : public NamedUUID
63 {
64 public:
65  EventType(uint32_t time_low_
66  , uint16_t time_mid_
67  , uint16_t time_hi_and_version_
68  , uint16_t clock_seq_
69  , uint8_t c0, uint8_t c1, uint8_t c2, uint8_t c3, uint8_t c4, uint8_t c5
70  , const char* name)
71  : NamedUUID(time_low_, time_mid_, time_hi_and_version_, clock_seq_,
72  c0, c1, c2, c3, c4, c5, name)
73  {}
74 
76  : NamedUUID(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "EVENT_TYPE_UNSPECIFIED")
77  {}
78 };
79 
80 
81 /*
82  * Core Event types
83  */
84 
85 /**
86  * Event type used to report an error.
87  *
88  * @defgroup ArgusEventError Error Event
89  * @ingroup ArgusEvent
90  */
91 DEFINE_UUID(EventType, EVENT_TYPE_ERROR, 2c80d8b0,2bfd,11e5,a2cb,08,00,20,0c,9a,66);
92 
93 /**
94  * Event type used to report when a capture starts.
95  *
96  * @defgroup ArgusEventCaptureStarted CaptureStarted Event
97  * @ingroup ArgusEvent
98  */
99 DEFINE_UUID(EventType, EVENT_TYPE_CAPTURE_STARTED, 2c80d8b1,2bfd,11e5,a2cb,08,00,20,0c,9a,66);
100 
101 /**
102  * Event type used to report when all capture processing has completed.
103  *
104  * @defgroup ArgusEventCaptureComplete CaptureComplete Event
105  * @ingroup ArgusEvent
106  */
107 DEFINE_UUID(EventType, EVENT_TYPE_CAPTURE_COMPLETE, 2c80d8b2,2bfd,11e5,a2cb,08,00,20,0c,9a,66);
108 
109 
110 /**
111  * @class IEvent
112  *
113  * Interface to the common Event properties.
114  *
115  * @ingroup ArgusEvent
116  */
117 DEFINE_UUID(InterfaceID, IID_EVENT, 98bcb49e,fd7d,11e4,a322,16,97,f9,25,ec,7b);
118 class IEvent : public Interface
119 {
120 public:
121  static const InterfaceID& id() { return IID_EVENT; }
122 
123  /**
124  * Returns the event type.
125  * On receiving EVENT_TYPE_CAPTURE_COMPLETE the client can proceed to consume
126  * the acquired frame, and continue to wait on the subsequent frame.
127  * On receiving EVENT_TYPE_ERROR, the client should assume that the error is fatal
128  * and should stop submitting more requests to this session and resume session
129  * shutdown. The specifics of error encounterred by the camera driver can be found
130  * in nvargus-daemon logs.
131  */
132  virtual EventType getEventType() const = 0;
133 
134  /**
135  * Returns the time of the event, in nanoseconds.
136  */
137  virtual uint64_t getTime() const = 0;
138 
139  /**
140  * Returns the capture id for the event.
141  */
142  virtual uint32_t getCaptureId() const = 0;
143 
144 protected:
145  ~IEvent() {}
146 };
147 
148 /**
149  * @class IEventError
150  *
151  * Interface exposed by Events having type EVENT_TYPE_ERROR.
152  *
153  * @ingroup ArgusEventError
154  */
155 DEFINE_UUID(InterfaceID, IID_EVENT_ERROR, 13e0fc70,1ab6,11e5,b939,08,00,20,0c,9a,66);
156 class IEventError : public Interface
157 {
158 public:
159  static const InterfaceID& id() { return IID_EVENT_ERROR; }
160 
161  /**
162  * Returns the Status value describing the error.
163  */
164  virtual Status getStatus() const = 0;
165 
166 protected:
168 };
169 
170 /**
171  * @class IEventCaptureComplete
172  *
173  * Interface exposed by Events having type EVENT_TYPE_CAPTURE_COMPLETE
174  *
175  * @ingroup ArgusEventCaptureComplete
176  */
177 DEFINE_UUID(InterfaceID, IID_EVENT_CAPTURE_COMPLETE, 8b2b40b5,f1e4,4c4d,ae1c,f3,93,f6,54,06,d5);
179 {
180 public:
181  static const InterfaceID& id() { return IID_EVENT_CAPTURE_COMPLETE; }
182 
183  /**
184  * Returns all dynamic metadata associated with this capture.
185  * The lifetime of the returned pointer is equivalent to the lifetime of this event.
186  * NULL may be returned if no metadata is available because the
187  * capture failed or was aborted.
188  */
189  virtual const CaptureMetadata* getMetadata() const = 0;
190 
191  /**
192  * Returns the error status of the metadata event.
193  * If this value is not STATUS_OK, getMetadata() will return NULL.
194  */
195  virtual Status getStatus() const = 0;
196 
197 protected:
199 };
200 
201 } // namespace Argus
202 
203 #endif // _ARGUS_EVENT_H