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