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