Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5a30eae9 authored by android-build-team Robot's avatar android-build-team Robot Committed by Android (Google) Code Review
Browse files

Merge "DvrTrackingSensors related functionality in DVR."

parents 159742d2 3cf66ee2
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -12,7 +12,6 @@
#include <dvr/dvr_display_manager.h>
#include <dvr/dvr_performance.h>
#include <dvr/dvr_surface.h>
#include <dvr/dvr_tracking.h>
#include <dvr/dvr_vsync.h>

// Headers not yet moved into libdvr.
+20 −0
Original line number Diff line number Diff line
@@ -29,6 +29,26 @@ int dvrTrackingCameraStop(DvrTrackingCamera*) {
  return -ENOSYS;
}

int dvrTrackingSensorsCreate(DvrTrackingSensors**, const char*) {
  ALOGE("dvrTrackingSensorsCreate is not implemented.");
  return -ENOSYS;
}

void dvrTrackingSensorsDestroy(DvrTrackingSensors*) {
  ALOGE("dvrTrackingSensorsDestroy is not implemented.");
}

int dvrTrackingSensorsStart(DvrTrackingSensors*,
                            DvrTrackingSensorEventCallback) {
  ALOGE("dvrTrackingStart is not implemented.");
  return -ENOSYS;
}

int dvrTrackingSensorsStop(DvrTrackingSensors*) {
  ALOGE("dvrTrackingStop is not implemented.");
  return -ENOSYS;
}

}  // extern "C"

#endif  // DVR_TRACKING_IMPLEMENTED
+8 −2
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@
#include <dvr/dvr_display_types.h>
#include <dvr/dvr_hardware_composer_types.h>
#include <dvr/dvr_pose.h>
#include <dvr/dvr_tracking.h>

#ifdef __cplusplus
extern "C" {
@@ -50,8 +51,6 @@ typedef int32_t DvrGlobalBufferKey;
typedef struct DvrSurfaceAttributeValue DvrSurfaceAttributeValue;
typedef struct DvrSurfaceAttribute DvrSurfaceAttribute;

typedef struct DvrTrackingCamera DvrTrackingCamera;

// Note: To avoid breaking others during active development, only modify this
// struct by appending elements to the end.
// If you do feel we should to re-arrange or remove elements, please make a
@@ -376,6 +375,13 @@ typedef int (*DvrTrackingCameraStartPtr)(DvrTrackingCamera* camera,
                                         DvrWriteBufferQueue* write_queue);
typedef int (*DvrTrackingCameraStopPtr)(DvrTrackingCamera* camera);

typedef int (*DvrTrackingSensorsCreatePtr)(DvrTrackingSensors** out_sensors,
                                           const char* mode);
typedef void (*DvrTrackingSensorsDestroyPtr)(DvrTrackingSensors* sensors);
typedef int (*DvrTrackingSensorsStartPtr)(
    DvrTrackingSensors* sensors, DvrTrackingSensorEventCallback callback);
typedef int (*DvrTrackingSensorsStopPtr)(DvrTrackingSensors* sensors);

// The buffer metadata that an Android Surface (a.k.a. ANativeWindow)
// will populate. A DvrWriteBufferQueue must be created with this metadata iff
// ANativeWindow access is needed. Please do not remove, modify, or reorder
+4 −0
Original line number Diff line number Diff line
@@ -187,3 +187,7 @@ DVR_V1_API_ENTRY(TrackingCameraCreate);
DVR_V1_API_ENTRY(TrackingCameraDestroy);
DVR_V1_API_ENTRY(TrackingCameraStart);
DVR_V1_API_ENTRY(TrackingCameraStop);
DVR_V1_API_ENTRY(TrackingSensorsCreate);
DVR_V1_API_ENTRY(TrackingSensorsDestroy);
DVR_V1_API_ENTRY(TrackingSensorsStart);
DVR_V1_API_ENTRY(TrackingSensorsStop);
+65 −0
Original line number Diff line number Diff line
#ifndef ANDROID_DVR_TRACKING_H_
#define ANDROID_DVR_TRACKING_H_

#include <stdint.h>
#include <sys/cdefs.h>

__BEGIN_DECLS

// Represents a sensor event.
typedef struct DvrTrackingSensorEvent {
  // The sensor type.
  int32_t sensor;

  // Event type.
  int32_t type;

  // This is the timestamp recorded from the device. Taken in the middle
  // of the integration interval and adjusted for any low pass filtering.
  int64_t timestamp_ns;

  // The event data.
  float x;
  float y;
  float z;
} DvrTrackingSensorEvent;

typedef struct DvrTrackingSensors DvrTrackingSensors;
typedef struct DvrTrackingCamera DvrTrackingCamera;
typedef struct DvrWriteBufferQueue DvrWriteBufferQueue;

// The callback for DvrTrackingSensors session that will deliver the events.
// This callback is passed to dvrTrackingSensorsStart.
typedef void (*DvrTrackingSensorEventCallback)(DvrTrackingSensorEvent* event);

// Creates a DvrTrackingCamera session.
//
// On creation, the session is not in operating mode. Client code must call
@@ -56,6 +80,47 @@ int dvrTrackingCameraStart(DvrTrackingCamera* camera,
// @return Zero on success, or negative error code.
int dvrTrackingCameraStop(DvrTrackingCamera* camera);

// Creates a DvrTrackingSensors session.
//
// This will initialize but not start device sensors (gyro / accel). Upon
// successfull creation, the clients can call dvrTrackingSensorsStart to start
// receiving sensor events.
//
// @param out_sensors The pointer of a DvrTrackingSensors will be filled here if
//     the method call succeeds.
// @param mode The sensor mode.
//        mode="ndk": Use the Android NDK.
//        mode="direct": Use direct mode sensors (lower latency).
// @return Zero on success, or negative error code.
int dvrTrackingSensorsCreate(DvrTrackingSensors** out_sensors,
                             const char* mode);

// Destroy a DvrTrackingSensors session.
//
// @param sensors The DvrTrackingSensors struct to destroy.
void dvrTrackingSensorsDestroy(DvrTrackingSensors* sensors);

// Start the tracking.
//
// This will start the device sensors and start pumping the feature and sensor
// events as they arrive.
//
// @param client A tracking client created by dvrTrackingSensorsCreate.
// @param callback A callback that will receive the sensor events on an
// arbitrary thread.
// @return Zero on success, or negative error code.
int dvrTrackingSensorsStart(DvrTrackingSensors* sensors,
                            DvrTrackingSensorEventCallback callback);

// Stop the tracking.
//
// This will stop the device sensors. dvrTrackingSensorsStart can be called to
// restart them again.
//
// @param client A tracking client created by dvrTrackingClientCreate.
// @return Zero on success, or negative error code.
int dvrTrackingSensorsStop(DvrTrackingSensors* sensors);

__END_DECLS

#endif  // ANDROID_DVR_TRACKING_H_
Loading