• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef ANDROID_DVR_API_H_
2 #define ANDROID_DVR_API_H_
3 
4 #include <stdbool.h>
5 #include <stddef.h>
6 #include <stdint.h>
7 #include <unistd.h>
8 #include <cstdio>
9 
10 #include <dvr/dvr_display_types.h>
11 #include <dvr/dvr_hardware_composer_types.h>
12 #include <dvr/dvr_pose.h>
13 #include <dvr/dvr_tracking_types.h>
14 
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
19 #ifdef __GNUC__
20 #define ALIGNED_DVR_STRUCT(x) __attribute__((packed, aligned(x)))
21 #else
22 #define ALIGNED_DVR_STRUCT(x)
23 #endif
24 
25 typedef struct ANativeWindow ANativeWindow;
26 
27 typedef struct DvrPoseAsync DvrPoseAsync;
28 
29 typedef uint64_t DvrSurfaceUpdateFlags;
30 typedef struct DvrDisplayManager DvrDisplayManager;
31 typedef struct DvrSurfaceState DvrSurfaceState;
32 typedef struct DvrPoseClient DvrPoseClient;
33 typedef struct DvrPoseDataCaptureRequest DvrPoseDataCaptureRequest;
34 typedef struct DvrVSyncClient DvrVSyncClient;
35 typedef struct DvrVirtualTouchpad DvrVirtualTouchpad;
36 
37 typedef struct DvrBuffer DvrBuffer;
38 typedef struct DvrWriteBuffer DvrWriteBuffer;
39 typedef struct DvrReadBuffer DvrReadBuffer;
40 typedef struct AHardwareBuffer AHardwareBuffer;
41 
42 typedef struct DvrReadBufferQueue DvrReadBufferQueue;
43 typedef struct DvrWriteBufferQueue DvrWriteBufferQueue;
44 typedef struct DvrNativeBufferMetadata DvrNativeBufferMetadata;
45 
46 typedef struct DvrSurface DvrSurface;
47 typedef uint64_t DvrSurfaceAttributeType;
48 typedef int32_t DvrSurfaceAttributeKey;
49 typedef int32_t DvrGlobalBufferKey;
50 
51 typedef struct DvrSurfaceAttributeValue DvrSurfaceAttributeValue;
52 typedef struct DvrSurfaceAttribute DvrSurfaceAttribute;
53 
54 typedef struct DvrReadBuffer DvrReadBuffer;
55 typedef struct DvrTrackingCamera DvrTrackingCamera;
56 typedef struct DvrTrackingFeatureExtractor DvrTrackingFeatureExtractor;
57 typedef struct DvrTrackingSensors DvrTrackingSensors;
58 typedef struct DvrWriteBufferQueue DvrWriteBufferQueue;
59 
60 // Note: To avoid breaking others during active development, only modify this
61 // struct by appending elements to the end.
62 // If you do feel we should to re-arrange or remove elements, please make a
63 // note of it, and wait until we're about to finalize for an API release to do
64 // so.
65 typedef struct DvrNativeDisplayMetrics {
66   uint32_t display_width;
67   uint32_t display_height;
68   uint32_t display_x_dpi;
69   uint32_t display_y_dpi;
70   uint32_t vsync_period_ns;
71 } DvrNativeDisplayMetrics;
72 
73 // native_handle contains the fds for the underlying ION allocations inside
74 // the gralloc buffer. This is needed temporarily while GPU vendors work on
75 // better support for AHardwareBuffer via glBindSharedBuffer APIs. See
76 // b/37207909. For now we can declare the native_handle struct where it is
77 // used for GPU late latching. See cutils/native_handle.h for the struct layout.
78 struct native_handle;
79 
80 // Device metrics data type enums.
81 enum {
82   // Request the device lens metrics protobuf. This matches cardboard protos.
83   DVR_CONFIGURATION_DATA_LENS_METRICS = 0,
84   // Request the device metrics protobuf.
85   DVR_CONFIGURATION_DATA_DEVICE_METRICS = 1,
86   // Request the per device configuration data file.
87   DVR_CONFIGURATION_DATA_DEVICE_CONFIG = 2,
88   // Request the edid data for the display.
89   DVR_CONFIGURATION_DATA_DEVICE_EDID = 3,
90 };
91 
92 // dvr_display_manager.h
93 typedef int (*DvrDisplayManagerCreatePtr)(DvrDisplayManager** client_out);
94 typedef void (*DvrDisplayManagerDestroyPtr)(DvrDisplayManager* client);
95 typedef int (*DvrDisplayManagerGetEventFdPtr)(DvrDisplayManager* client);
96 typedef int (*DvrDisplayManagerTranslateEpollEventMaskPtr)(
97     DvrDisplayManager* client, int in_events, int* out_events);
98 typedef int (*DvrDisplayManagerGetSurfaceStatePtr)(
99     DvrDisplayManager* client, DvrSurfaceState* surface_state);
100 typedef int (*DvrDisplayManagerGetReadBufferQueuePtr)(
101     DvrDisplayManager* client, int surface_id, int queue_id,
102     DvrReadBufferQueue** queue_out);
103 typedef int (*DvrConfigurationDataGetPtr)(int config_type, uint8_t** data,
104                                           size_t* data_size);
105 typedef void (*DvrConfigurationDataDestroyPtr)(uint8_t* data);
106 typedef int (*DvrSurfaceStateCreatePtr)(DvrSurfaceState** surface_state);
107 typedef void (*DvrSurfaceStateDestroyPtr)(DvrSurfaceState* surface_state);
108 typedef int (*DvrSurfaceStateGetSurfaceCountPtr)(DvrSurfaceState* surface_state,
109                                                  size_t* count_out);
110 typedef int (*DvrSurfaceStateGetUpdateFlagsPtr)(
111     DvrSurfaceState* surface_state, size_t surface_index,
112     DvrSurfaceUpdateFlags* flags_out);
113 typedef int (*DvrSurfaceStateGetSurfaceIdPtr)(DvrSurfaceState* surface_state,
114                                               size_t surface_index,
115                                               int* surface_id_out);
116 typedef int (*DvrSurfaceStateGetProcessIdPtr)(DvrSurfaceState* surface_state,
117                                               size_t surface_index,
118                                               int* process_id_out);
119 typedef int (*DvrSurfaceStateGetQueueCountPtr)(DvrSurfaceState* surface_state,
120                                                size_t surface_index,
121                                                size_t* count_out);
122 typedef ssize_t (*DvrSurfaceStateGetQueueIdsPtr)(DvrSurfaceState* surface_state,
123                                                  size_t surface_index,
124                                                  int* queue_ids,
125                                                  size_t max_count);
126 typedef int (*DvrSurfaceStateGetZOrderPtr)(DvrSurfaceState* surface_state,
127                                            size_t surface_index,
128                                            int* z_order_out);
129 typedef int (*DvrSurfaceStateGetVisiblePtr)(DvrSurfaceState* surface_state,
130                                             size_t surface_index,
131                                             bool* visible_out);
132 typedef int (*DvrSurfaceStateGetAttributeCountPtr)(
133     DvrSurfaceState* surface_state, size_t surface_index, size_t* count_out);
134 typedef ssize_t (*DvrSurfaceStateGetAttributesPtr)(
135     DvrSurfaceState* surface_state, size_t surface_index,
136     DvrSurfaceAttribute* attributes, size_t max_attribute_count);
137 
138 // dvr_buffer.h
139 typedef void (*DvrWriteBufferCreateEmptyPtr)(DvrWriteBuffer** write_buffer_out);
140 typedef void (*DvrWriteBufferDestroyPtr)(DvrWriteBuffer* write_buffer);
141 typedef int (*DvrWriteBufferIsValidPtr)(DvrWriteBuffer* write_buffer);
142 typedef int (*DvrWriteBufferClearPtr)(DvrWriteBuffer* write_buffer);
143 typedef int (*DvrWriteBufferGetIdPtr)(DvrWriteBuffer* write_buffer);
144 typedef int (*DvrWriteBufferGetAHardwareBufferPtr)(
145     DvrWriteBuffer* write_buffer, AHardwareBuffer** hardware_buffer);
146 typedef int (*DvrWriteBufferPostPtr)(DvrWriteBuffer* write_buffer,
147                                      int ready_fence_fd, const void* meta,
148                                      size_t meta_size_bytes);
149 typedef int (*DvrWriteBufferGainPtr)(DvrWriteBuffer* write_buffer,
150                                      int* release_fence_fd);
151 typedef int (*DvrWriteBufferGainAsyncPtr)(DvrWriteBuffer* write_buffer);
152 typedef const struct native_handle* (*DvrWriteBufferGetNativeHandlePtr)(
153     DvrWriteBuffer* write_buffer);
154 
155 typedef void (*DvrReadBufferCreateEmptyPtr)(DvrReadBuffer** read_buffer_out);
156 typedef void (*DvrReadBufferDestroyPtr)(DvrReadBuffer* read_buffer);
157 typedef int (*DvrReadBufferIsValidPtr)(DvrReadBuffer* read_buffer);
158 typedef int (*DvrReadBufferClearPtr)(DvrReadBuffer* read_buffer);
159 typedef int (*DvrReadBufferGetIdPtr)(DvrReadBuffer* read_buffer);
160 typedef int (*DvrReadBufferGetAHardwareBufferPtr)(
161     DvrReadBuffer* read_buffer, AHardwareBuffer** hardware_buffer);
162 typedef int (*DvrReadBufferAcquirePtr)(DvrReadBuffer* read_buffer,
163                                        int* ready_fence_fd, void* meta,
164                                        size_t meta_size_bytes);
165 typedef int (*DvrReadBufferReleasePtr)(DvrReadBuffer* read_buffer,
166                                        int release_fence_fd);
167 typedef int (*DvrReadBufferReleaseAsyncPtr)(DvrReadBuffer* read_buffer);
168 typedef const struct native_handle* (*DvrReadBufferGetNativeHandlePtr)(
169     DvrReadBuffer* read_buffer);
170 
171 typedef void (*DvrBufferDestroyPtr)(DvrBuffer* buffer);
172 typedef int (*DvrBufferGetAHardwareBufferPtr)(
173     DvrBuffer* buffer, AHardwareBuffer** hardware_buffer);
174 typedef int (*DvrBufferGlobalLayoutVersionGetPtr)();
175 typedef const struct native_handle* (*DvrBufferGetNativeHandlePtr)(
176     DvrBuffer* buffer);
177 
178 // dvr_buffer_queue.h
179 typedef int (*DvrWriteBufferQueueCreatePtr)(uint32_t width, uint32_t height,
180                                             uint32_t format,
181                                             uint32_t layer_count,
182                                             uint64_t usage, size_t capacity,
183                                             size_t metadata_size,
184                                             DvrWriteBufferQueue** queue_out);
185 typedef void (*DvrWriteBufferQueueDestroyPtr)(DvrWriteBufferQueue* write_queue);
186 typedef ssize_t (*DvrWriteBufferQueueGetCapacityPtr)(
187     DvrWriteBufferQueue* write_queue);
188 typedef int (*DvrWriteBufferQueueGetIdPtr)(DvrWriteBufferQueue* write_queue);
189 typedef int (*DvrWriteBufferQueueGetExternalSurfacePtr)(
190     DvrWriteBufferQueue* write_queue, ANativeWindow** out_window);
191 typedef int (*DvrWriteBufferQueueGetANativeWindowPtr)(
192     DvrWriteBufferQueue* write_queue, ANativeWindow** out_window);
193 typedef int (*DvrWriteBufferQueueCreateReadQueuePtr)(
194     DvrWriteBufferQueue* write_queue, DvrReadBufferQueue** out_read_queue);
195 typedef int (*DvrWriteBufferQueueDequeuePtr)(DvrWriteBufferQueue* write_queue,
196                                              int timeout,
197                                              DvrWriteBuffer* out_buffer,
198                                              int* out_fence_fd);
199 typedef int (*DvrWriteBufferQueueGainBufferPtr)(
200     DvrWriteBufferQueue* write_queue, int timeout,
201     DvrWriteBuffer** out_write_buffer, DvrNativeBufferMetadata* out_meta,
202     int* out_fence_fd);
203 typedef int (*DvrWriteBufferQueuePostBufferPtr)(
204     DvrWriteBufferQueue* write_queue, DvrWriteBuffer* write_buffer,
205     const DvrNativeBufferMetadata* meta, int ready_fence_fd);
206 typedef int (*DvrWriteBufferQueueResizeBufferPtr)(
207     DvrWriteBufferQueue* write_queue, uint32_t width, uint32_t height);
208 typedef void (*DvrReadBufferQueueDestroyPtr)(DvrReadBufferQueue* read_queue);
209 typedef ssize_t (*DvrReadBufferQueueGetCapacityPtr)(
210     DvrReadBufferQueue* read_queue);
211 typedef int (*DvrReadBufferQueueGetIdPtr)(DvrReadBufferQueue* read_queue);
212 typedef int (*DvrReadBufferQueueGetEventFdPtr)(DvrReadBufferQueue* read_queue);
213 typedef int (*DvrReadBufferQueueCreateReadQueuePtr)(
214     DvrReadBufferQueue* read_queue, DvrReadBufferQueue** out_read_queue);
215 typedef int (*DvrReadBufferQueueDequeuePtr)(DvrReadBufferQueue* read_queue,
216                                             int timeout,
217                                             DvrReadBuffer* out_buffer,
218                                             int* out_fence_fd, void* out_meta,
219                                             size_t meta_size_bytes);
220 typedef int (*DvrReadBufferQueueAcquireBufferPtr)(
221     DvrReadBufferQueue* read_queue, int timeout,
222     DvrReadBuffer** out_read_buffer, DvrNativeBufferMetadata* out_meta,
223     int* out_fence_fd);
224 typedef int (*DvrReadBufferQueueReleaseBufferPtr)(
225     DvrReadBufferQueue* read_queue, DvrReadBuffer* read_buffer,
226     const DvrNativeBufferMetadata* meta, int release_fence_fd);
227 typedef void (*DvrReadBufferQueueBufferAvailableCallback)(void* context);
228 typedef int (*DvrReadBufferQueueSetBufferAvailableCallbackPtr)(
229     DvrReadBufferQueue* read_queue,
230     DvrReadBufferQueueBufferAvailableCallback callback, void* context);
231 typedef void (*DvrReadBufferQueueBufferRemovedCallback)(DvrReadBuffer* buffer,
232                                                         void* context);
233 typedef int (*DvrReadBufferQueueSetBufferRemovedCallbackPtr)(
234     DvrReadBufferQueue* read_queue,
235     DvrReadBufferQueueBufferRemovedCallback callback, void* context);
236 typedef int (*DvrReadBufferQueueHandleEventsPtr)(
237     DvrReadBufferQueue* read_queue);
238 
239 // dvr_surface.h
240 typedef int (*DvrSetupGlobalBufferPtr)(DvrGlobalBufferKey key, size_t size,
241                                        uint64_t usage, DvrBuffer** buffer_out);
242 typedef int (*DvrDeleteGlobalBufferPtr)(DvrGlobalBufferKey key);
243 typedef int (*DvrGetGlobalBufferPtr)(DvrGlobalBufferKey key,
244                                      DvrBuffer** out_buffer);
245 typedef int (*DvrSurfaceCreatePtr)(const DvrSurfaceAttribute* attributes,
246                                    size_t attribute_count,
247                                    DvrSurface** surface_out);
248 typedef void (*DvrSurfaceDestroyPtr)(DvrSurface* surface);
249 typedef int (*DvrSurfaceGetIdPtr)(DvrSurface* surface);
250 typedef int (*DvrSurfaceSetAttributesPtr)(DvrSurface* surface,
251                                           const DvrSurfaceAttribute* attributes,
252                                           size_t attribute_count);
253 typedef int (*DvrSurfaceCreateWriteBufferQueuePtr)(
254     DvrSurface* surface, uint32_t width, uint32_t height, uint32_t format,
255     uint32_t layer_count, uint64_t usage, size_t capacity, size_t metadata_size,
256     DvrWriteBufferQueue** queue_out);
257 typedef int (*DvrGetNativeDisplayMetricsPtr)(size_t sizeof_metrics,
258                                              DvrNativeDisplayMetrics* metrics);
259 
260 // dvr_vsync.h
261 typedef int (*DvrVSyncClientCreatePtr)(DvrVSyncClient** client_out);
262 typedef void (*DvrVSyncClientDestroyPtr)(DvrVSyncClient* client);
263 typedef int (*DvrVSyncClientGetSchedInfoPtr)(DvrVSyncClient* client,
264                                              int64_t* vsync_period_ns,
265                                              int64_t* next_timestamp_ns,
266                                              uint32_t* next_vsync_count);
267 
268 // libs/vr/libvrsensor/include/dvr/pose_client.h
269 typedef DvrPoseClient* (*DvrPoseClientCreatePtr)();
270 typedef void (*DvrPoseClientDestroyPtr)(DvrPoseClient* client);
271 typedef int (*DvrPoseClientGetPtr)(DvrPoseClient* client, uint32_t vsync_count,
272                                    DvrPoseAsync* out_pose);
273 typedef uint32_t (*DvrPoseClientGetVsyncCountPtr)(DvrPoseClient* client);
274 typedef int (*DvrPoseClientGetControllerPtr)(DvrPoseClient* client,
275                                              int32_t controller_id,
276                                              uint32_t vsync_count,
277                                              DvrPoseAsync* out_pose);
278 typedef int (*DvrPoseClientSensorsEnablePtr)(DvrPoseClient* client,
279                                              bool enabled);
280 typedef int (*DvrPoseClientDataCapturePtr)(DvrPoseClient* client,
281     const DvrPoseDataCaptureRequest* request);
282 typedef int (*DvrPoseClientDataReaderDestroyPtr)(DvrPoseClient* client,
283                                                  uint64_t data_type);
284 
285 // dvr_pose.h
286 typedef int (*DvrPoseClientGetDataReaderPtr)(DvrPoseClient* client,
287                                              uint64_t data_type,
288                                              DvrReadBufferQueue** read_queue);
289 
290 // services/vr/virtual_touchpad/include/dvr/virtual_touchpad_client.h
291 
292 // Touchpad IDs for *Touch*() and *ButtonState*() calls.
293 enum {
294   DVR_VIRTUAL_TOUCHPAD_PRIMARY = 0,
295   DVR_VIRTUAL_TOUCHPAD_VIRTUAL = 1,
296 };
297 typedef DvrVirtualTouchpad* (*DvrVirtualTouchpadCreatePtr)();
298 typedef void (*DvrVirtualTouchpadDestroyPtr)(DvrVirtualTouchpad* client);
299 typedef int (*DvrVirtualTouchpadAttachPtr)(DvrVirtualTouchpad* client);
300 typedef int (*DvrVirtualTouchpadDetachPtr)(DvrVirtualTouchpad* client);
301 typedef int (*DvrVirtualTouchpadTouchPtr)(DvrVirtualTouchpad* client,
302                                           int touchpad, float x, float y,
303                                           float pressure);
304 typedef int (*DvrVirtualTouchpadButtonStatePtr)(DvrVirtualTouchpad* client,
305                                                 int touchpad, int buttons);
306 typedef int (*DvrVirtualTouchpadScrollPtr)(DvrVirtualTouchpad* client,
307                                            int touchpad, float x, float y);
308 
309 // dvr_hardware_composer_client.h
310 typedef struct DvrHwcClient DvrHwcClient;
311 typedef struct DvrHwcFrame DvrHwcFrame;
312 typedef int (*DvrHwcOnFrameCallback)(void* client_state, DvrHwcFrame* frame);
313 typedef DvrHwcClient* (*DvrHwcClientCreatePtr)(DvrHwcOnFrameCallback callback,
314                                                void* client_state);
315 typedef void (*DvrHwcClientDestroyPtr)(DvrHwcClient* client);
316 typedef void (*DvrHwcFrameDestroyPtr)(DvrHwcFrame* frame);
317 typedef DvrHwcDisplay (*DvrHwcFrameGetDisplayIdPtr)(DvrHwcFrame* frame);
318 typedef int32_t (*DvrHwcFrameGetDisplayWidthPtr)(DvrHwcFrame* frame);
319 typedef int32_t (*DvrHwcFrameGetDisplayHeightPtr)(DvrHwcFrame* frame);
320 typedef bool (*DvrHwcFrameGetDisplayRemovedPtr)(DvrHwcFrame* frame);
321 typedef size_t (*DvrHwcFrameGetLayerCountPtr)(DvrHwcFrame* frame);
322 typedef DvrHwcLayer (*DvrHwcFrameGetLayerIdPtr)(DvrHwcFrame* frame,
323                                                 size_t layer_index);
324 typedef uint32_t (*DvrHwcFrameGetActiveConfigPtr)(DvrHwcFrame* frame);
325 typedef uint32_t (*DvrHwcFrameGetColorModePtr)(DvrHwcFrame* frame);
326 typedef void (*DvrHwcFrameGetColorTransformPtr)(DvrHwcFrame* frame,
327                                                 float* out_matrix,
328                                                 int32_t* out_hint);
329 typedef uint32_t (*DvrHwcFrameGetPowerModePtr)(DvrHwcFrame* frame);
330 typedef uint32_t (*DvrHwcFrameGetVsyncEnabledPtr)(DvrHwcFrame* frame);
331 typedef AHardwareBuffer* (*DvrHwcFrameGetLayerBufferPtr)(DvrHwcFrame* frame,
332                                                          size_t layer_index);
333 typedef int (*DvrHwcFrameGetLayerFencePtr)(DvrHwcFrame* frame,
334                                            size_t layer_index);
335 typedef DvrHwcRecti (*DvrHwcFrameGetLayerDisplayFramePtr)(DvrHwcFrame* frame,
336                                                           size_t layer_index);
337 typedef DvrHwcRectf (*DvrHwcFrameGetLayerCropPtr)(DvrHwcFrame* frame,
338                                                   size_t layer_index);
339 typedef DvrHwcBlendMode (*DvrHwcFrameGetLayerBlendModePtr)(DvrHwcFrame* frame,
340                                                            size_t layer_index);
341 typedef float (*DvrHwcFrameGetLayerAlphaPtr)(DvrHwcFrame* frame,
342                                              size_t layer_index);
343 typedef uint32_t (*DvrHwcFrameGetLayerTypePtr)(DvrHwcFrame* frame,
344                                                size_t layer_index);
345 typedef uint32_t (*DvrHwcFrameGetLayerApplicationIdPtr)(DvrHwcFrame* frame,
346                                                         size_t layer_index);
347 typedef uint32_t (*DvrHwcFrameGetLayerZOrderPtr)(DvrHwcFrame* frame,
348                                                  size_t layer_index);
349 
350 typedef void (*DvrHwcFrameGetLayerCursorPtr)(DvrHwcFrame* frame,
351                                              size_t layer_index, int32_t* out_x,
352                                              int32_t* out_y);
353 
354 typedef uint32_t (*DvrHwcFrameGetLayerTransformPtr)(DvrHwcFrame* frame,
355                                                     size_t layer_index);
356 
357 typedef uint32_t (*DvrHwcFrameGetLayerDataspacePtr)(DvrHwcFrame* frame,
358                                                     size_t layer_index);
359 
360 typedef uint32_t (*DvrHwcFrameGetLayerColorPtr)(DvrHwcFrame* frame,
361                                                 size_t layer_index);
362 
363 typedef uint32_t (*DvrHwcFrameGetLayerNumVisibleRegionsPtr)(DvrHwcFrame* frame,
364                                                             size_t layer_index);
365 typedef DvrHwcRecti (*DvrHwcFrameGetLayerVisibleRegionPtr)(DvrHwcFrame* frame,
366                                                            size_t layer_index,
367                                                            size_t index);
368 
369 typedef uint32_t (*DvrHwcFrameGetLayerNumDamagedRegionsPtr)(DvrHwcFrame* frame,
370                                                             size_t layer_index);
371 typedef DvrHwcRecti (*DvrHwcFrameGetLayerDamagedRegionPtr)(DvrHwcFrame* frame,
372                                                            size_t layer_index,
373                                                            size_t index);
374 
375 // dvr_performance.h
376 typedef int (*DvrPerformanceSetSchedulerPolicyPtr)(
377     pid_t task_id, const char* scheduler_policy);
378 
379 // dvr_tracking.h
380 typedef int (*DvrTrackingCameraCreatePtr)(DvrTrackingCamera** out_camera);
381 typedef void (*DvrTrackingCameraDestroyPtr)(DvrTrackingCamera* camera);
382 typedef int (*DvrTrackingCameraStartPtr)(DvrTrackingCamera* camera,
383                                          DvrWriteBufferQueue* write_queue);
384 typedef int (*DvrTrackingCameraStopPtr)(DvrTrackingCamera* camera);
385 
386 typedef int (*DvrTrackingFeatureExtractorCreatePtr)(
387     DvrTrackingFeatureExtractor** out_extractor);
388 typedef void (*DvrTrackingFeatureExtractorDestroyPtr)(
389     DvrTrackingFeatureExtractor* extractor);
390 typedef void (*DvrTrackingFeatureCallback)(void* context,
391                                            const DvrTrackingFeatures* event);
392 typedef int (*DvrTrackingFeatureExtractorStartPtr)(
393     DvrTrackingFeatureExtractor* extractor,
394     DvrTrackingFeatureCallback callback, void* context);
395 typedef int (*DvrTrackingFeatureExtractorStopPtr)(
396     DvrTrackingFeatureExtractor* extractor);
397 typedef int (*DvrTrackingFeatureExtractorProcessBufferPtr)(
398     DvrTrackingFeatureExtractor* extractor, DvrReadBuffer* buffer,
399     const DvrTrackingBufferMetadata* metadata, bool* out_skipped);
400 
401 typedef void (*DvrTrackingSensorEventCallback)(void* context,
402                                                DvrTrackingSensorEvent* event);
403 typedef int (*DvrTrackingSensorsCreatePtr)(DvrTrackingSensors** out_sensors,
404                                            const char* mode);
405 typedef void (*DvrTrackingSensorsDestroyPtr)(DvrTrackingSensors* sensors);
406 typedef int (*DvrTrackingSensorsStartPtr)(
407     DvrTrackingSensors* sensors, DvrTrackingSensorEventCallback callback,
408     void* context);
409 typedef int (*DvrTrackingSensorsStopPtr)(DvrTrackingSensors* sensors);
410 
411 // The buffer metadata that an Android Surface (a.k.a. ANativeWindow)
412 // will populate. A DvrWriteBufferQueue must be created with this metadata iff
413 // ANativeWindow access is needed. Please do not remove, modify, or reorder
414 // existing data members. If new fields need to be added, please take extra care
415 // to make sure that new data field is padded properly the size of the struct
416 // stays same.
417 // TODO(b/118893702): move the definition to libnativewindow or libui
418 struct ALIGNED_DVR_STRUCT(8) DvrNativeBufferMetadata {
419 #ifdef __cplusplus
DvrNativeBufferMetadataDvrNativeBufferMetadata420   DvrNativeBufferMetadata()
421       : timestamp(0),
422         is_auto_timestamp(0),
423         dataspace(0),
424         crop_left(0),
425         crop_top(0),
426         crop_right(0),
427         crop_bottom(0),
428         scaling_mode(0),
429         transform(0),
430         index(0),
431         user_metadata_size(0),
432         user_metadata_ptr(0),
433         release_fence_mask(0),
434         reserved{0} {}
435 #endif
436   // Timestamp of the frame.
437   int64_t timestamp;
438 
439   // Whether the buffer is using auto timestamp.
440   int32_t is_auto_timestamp;
441 
442   // Must be one of the HAL_DATASPACE_XXX value defined in system/graphics.h
443   int32_t dataspace;
444 
445   // Crop extracted from an ACrop or android::Crop object.
446   int32_t crop_left;
447   int32_t crop_top;
448   int32_t crop_right;
449   int32_t crop_bottom;
450 
451   // Must be one of the NATIVE_WINDOW_SCALING_MODE_XXX value defined in
452   // system/window.h.
453   int32_t scaling_mode;
454 
455   // Must be one of the ANATIVEWINDOW_TRANSFORM_XXX value defined in
456   // android/native_window.h
457   int32_t transform;
458 
459   // The index of the frame.
460   int64_t index;
461 
462   // Size of additional metadata requested by user.
463   uint64_t user_metadata_size;
464 
465   // Raw memory address of the additional user defined metadata. Only valid when
466   // user_metadata_size is non-zero.
467   uint64_t user_metadata_ptr;
468 
469   // Only applicable for metadata retrieved from GainAsync. This indicates which
470   // consumer has pending fence that producer should epoll on.
471   uint32_t release_fence_mask;
472 
473   // Reserved bytes for so that the struct is forward compatible and padding to
474   // 104 bytes so the size is a multiple of 8.
475   int32_t reserved[9];
476 };
477 
478 #ifdef __cplusplus
479 // Warning: DvrNativeBufferMetadata is part of the DVR API and changing its size
480 // will cause compatiblity issues between different DVR API releases.
481 static_assert(sizeof(DvrNativeBufferMetadata) == 104,
482               "Unexpected size for DvrNativeBufferMetadata");
483 #endif
484 
485 struct DvrApi_v1 {
486 // Defines an API entry for V1 (no version suffix).
487 #define DVR_V1_API_ENTRY(name) Dvr##name##Ptr name
488 #define DVR_V1_API_ENTRY_DEPRECATED(name) Dvr##name##Ptr name
489 
490 #include "dvr_api_entries.h"
491 
492 // Undefine macro definitions to play nice with Google3 style rules.
493 #undef DVR_V1_API_ENTRY
494 #undef DVR_V1_API_ENTRY_DEPRECATED
495 };
496 
497 int dvrGetApi(void* api, size_t struct_size, int version);
498 
499 #ifdef __cplusplus
500 }  // extern "C"
501 #endif
502 
503 #endif  // ANDROID_DVR_API_H_
504