21 #ifndef ONIDRIVERAPI_H 22 #define ONIDRIVERAPI_H 30 namespace oni {
namespace driver {
46 return OniStreamServices::getDefaultRequiredFrameSize(
streamServices);
68 StreamBase() : m_newFrameCallback(NULL), m_propertyChangedCallback(NULL) {}
82 virtual void stop() = 0;
95 void raiseNewFrame(OniFrame* pFrame) { (*m_newFrameCallback)(
this, pFrame, m_newFrameCallbackCookie); }
96 void raisePropertyChanged(
int propertyId,
const void* data,
int dataSize) { (*m_propertyChangedCallback)(
this, propertyId, data, dataSize, m_propertyChangedCookie); }
117 virtual void destroyStream(
StreamBase* pStream) = 0;
132 void raisePropertyChanged(
int propertyId,
const void* data,
int dataSize) { (*m_propertyChangedCallback)(
this, propertyId, data, dataSize, m_propertyChangedCookie); }
147 va_start(args, format);
148 m_pDriverServices->errorLoggerAppend(m_pDriverServices->driverServices, format, args);
154 m_pDriverServices->errorLoggerClear(m_pDriverServices->driverServices);
157 void log(
int severity,
const char* file,
int line,
const char* mask,
const char* message)
159 m_pDriverServices->log(m_pDriverServices->driverServices, severity, file, line, mask, message);
176 m_deviceConnectedEvent = connectedCallback;
177 m_deviceDisconnectedEvent = disconnectedCallback;
178 m_deviceStateChangedEvent = deviceStateChangedCallback;
183 virtual DeviceBase* deviceOpen(
const char* uri,
const char* mode) = 0;
184 virtual void deviceClose(
DeviceBase* pDevice) = 0;
186 virtual void shutdown() = 0;
194 void deviceConnected(
const OniDeviceInfo* pInfo) { (m_deviceConnectedEvent)(pInfo, m_pCookie); }
195 void deviceDisconnected(
const OniDeviceInfo* pInfo) { (m_deviceDisconnectedEvent)(pInfo, m_pCookie); }
196 void deviceStateChanged(
const OniDeviceInfo* pInfo,
int errorState) { (m_deviceStateChangedEvent)(pInfo, errorState, m_pCookie); }
211 #define ONI_EXPORT_DRIVER(DriverClass) \ 213 oni::driver::DriverBase* g_pDriver = NULL; \ 216 ONI_C_API_EXPORT void oniDriverCreate(OniDriverServices* driverServices) { \ 217 g_pDriver = XN_NEW(DriverClass, driverServices); \ 219 ONI_C_API_EXPORT void oniDriverDestroy() \ 221 g_pDriver->shutdown(); \ 222 XN_DELETE(g_pDriver); g_pDriver = NULL; \ 224 ONI_C_API_EXPORT OniStatus oniDriverInitialize(oni::driver::DeviceConnectedCallback deviceConnectedCallback, \ 225 oni::driver::DeviceDisconnectedCallback deviceDisconnectedCallback, \ 226 oni::driver::DeviceStateChangedCallback deviceStateChangedCallback, \ 229 return g_pDriver->initialize(deviceConnectedCallback, deviceDisconnectedCallback, deviceStateChangedCallback, pCookie); \ 232 ONI_C_API_EXPORT OniStatus oniDriverTryDevice(const char* uri) \ 234 return g_pDriver->tryDevice(uri); \ 238 ONI_C_API_EXPORT oni::driver::DeviceBase* oniDriverDeviceOpen(const char* uri, const char* mode) \ 240 return g_pDriver->deviceOpen(uri, mode); \ 242 ONI_C_API_EXPORT void oniDriverDeviceClose(oni::driver::DeviceBase* pDevice) \ 244 g_pDriver->deviceClose(pDevice); \ 247 ONI_C_API_EXPORT OniStatus oniDriverDeviceGetSensorInfoList(oni::driver::DeviceBase* pDevice, OniSensorInfo** pSensorInfos, \ 250 return pDevice->getSensorInfoList(pSensorInfos, numSensors); \ 253 ONI_C_API_EXPORT oni::driver::StreamBase* oniDriverDeviceCreateStream(oni::driver::DeviceBase* pDevice, \ 254 OniSensorType sensorType) \ 256 return pDevice->createStream(sensorType); \ 259 ONI_C_API_EXPORT void oniDriverDeviceDestroyStream(oni::driver::DeviceBase* pDevice, oni::driver::StreamBase* pStream) \ 261 return pDevice->destroyStream(pStream); \ 264 ONI_C_API_EXPORT OniStatus oniDriverDeviceSetProperty(oni::driver::DeviceBase* pDevice, int propertyId, \ 265 const void* data, int dataSize) \ 267 return pDevice->setProperty(propertyId, data, dataSize); \ 269 ONI_C_API_EXPORT OniStatus oniDriverDeviceGetProperty(oni::driver::DeviceBase* pDevice, int propertyId, \ 270 void* data, int* pDataSize) \ 272 return pDevice->getProperty(propertyId, data, pDataSize); \ 274 ONI_C_API_EXPORT OniBool oniDriverDeviceIsPropertySupported(oni::driver::DeviceBase* pDevice, int propertyId) \ 276 return pDevice->isPropertySupported(propertyId); \ 278 ONI_C_API_EXPORT void oniDriverDeviceSetPropertyChangedCallback(oni::driver::DeviceBase* pDevice, \ 279 oni::driver::PropertyChangedCallback handler, void* pCookie) \ 281 pDevice->setPropertyChangedCallback(handler, pCookie); \ 283 ONI_C_API_EXPORT void oniDriverDeviceNotifyAllProperties(oni::driver::DeviceBase* pDevice) \ 285 pDevice->notifyAllProperties(); \ 287 ONI_C_API_EXPORT OniStatus oniDriverDeviceInvoke(oni::driver::DeviceBase* pDevice, int commandId, \ 288 void* data, int dataSize) \ 290 return pDevice->invoke(commandId, data, dataSize); \ 292 ONI_C_API_EXPORT OniBool oniDriverDeviceIsCommandSupported(oni::driver::DeviceBase* pDevice, int commandId) \ 294 return pDevice->isCommandSupported(commandId); \ 296 ONI_C_API_EXPORT OniStatus oniDriverDeviceTryManualTrigger(oni::driver::DeviceBase* pDevice) \ 298 return pDevice->tryManualTrigger(); \ 300 ONI_C_API_EXPORT OniBool oniDriverDeviceIsImageRegistrationModeSupported(oni::driver::DeviceBase* pDevice, \ 301 OniImageRegistrationMode mode) \ 303 return pDevice->isImageRegistrationModeSupported(mode); \ 307 ONI_C_API_EXPORT void oniDriverStreamSetServices(oni::driver::StreamBase* pStream, OniStreamServices* pServices) \ 309 pStream->setServices((oni::driver::StreamServices*)pServices); \ 312 ONI_C_API_EXPORT OniStatus oniDriverStreamSetProperty(oni::driver::StreamBase* pStream, int propertyId, \ 313 const void* data, int dataSize) \ 315 return pStream->setProperty(propertyId, data, dataSize); \ 317 ONI_C_API_EXPORT OniStatus oniDriverStreamGetProperty(oni::driver::StreamBase* pStream, int propertyId, void* data, \ 320 return pStream->getProperty(propertyId, data, pDataSize); \ 322 ONI_C_API_EXPORT OniBool oniDriverStreamIsPropertySupported(oni::driver::StreamBase* pStream, int propertyId) \ 324 return pStream->isPropertySupported(propertyId); \ 326 ONI_C_API_EXPORT void oniDriverStreamSetPropertyChangedCallback(oni::driver::StreamBase* pStream, \ 327 oni::driver::PropertyChangedCallback handler, void* pCookie) \ 329 pStream->setPropertyChangedCallback(handler, pCookie); \ 331 ONI_C_API_EXPORT void oniDriverStreamNotifyAllProperties(oni::driver::StreamBase* pStream) \ 333 pStream->notifyAllProperties(); \ 335 ONI_C_API_EXPORT OniStatus oniDriverStreamInvoke(oni::driver::StreamBase* pStream, int commandId, \ 336 void* data, int dataSize) \ 338 return pStream->invoke(commandId, data, dataSize); \ 340 ONI_C_API_EXPORT OniBool oniDriverStreamIsCommandSupported(oni::driver::StreamBase* pStream, int commandId) \ 342 return pStream->isCommandSupported(commandId); \ 345 ONI_C_API_EXPORT OniStatus oniDriverStreamStart(oni::driver::StreamBase* pStream) \ 347 return pStream->start(); \ 349 ONI_C_API_EXPORT void oniDriverStreamStop(oni::driver::StreamBase* pStream) \ 354 ONI_C_API_EXPORT int oniDriverStreamGetRequiredFrameSize(oni::driver::StreamBase* pStream) \ 356 return pStream->getRequiredFrameSize(); \ 359 ONI_C_API_EXPORT void oniDriverStreamSetNewFrameCallback(oni::driver::StreamBase* pStream, \ 360 oni::driver::NewFrameCallback handler, void* pCookie) \ 362 pStream->setNewFrameCallback(handler, pCookie); \ 365 ONI_C_API_EXPORT OniStatus oniDriverStreamConvertDepthToColorCoordinates(oni::driver::StreamBase* pDepthStream, \ 366 oni::driver::StreamBase* pColorStream, int depthX, int depthY, OniDepthPixel depthZ, int* pColorX, int* pColorY) \ 368 return pDepthStream->convertDepthToColorCoordinates(pColorStream, depthX, depthY, depthZ, pColorX, pColorY); \ 371 ONI_C_API_EXPORT OniStatus oniDriverStreamConvertC2DCoordinates(oni::driver::StreamBase* pDepthStream, \ 372 int colorX, int colorY, OniDepthPixel depthZ, int* pDepthX, int* pDepthY) \ 374 return pDepthStream->convertC2DCoordinates(colorX, colorY, depthZ, pDepthX, pDepthY); \ 377 ONI_C_API_EXPORT OniStatus oniDriverStreamConvertD2CCoordinates(oni::driver::StreamBase* pDepthStream, \ 378 int colorX, int colorY, OniDepthPixel depthZ, int* pDepthX, int* pDepthY) \ 380 return pDepthStream->convertD2CCoordinates(colorX, colorY, depthZ, pDepthX, pDepthY); \ 383 ONI_C_API_EXPORT void* oniDriverEnableFrameSync(oni::driver::StreamBase** pStreams, int streamCount) \ 385 return g_pDriver->enableFrameSync(pStreams, streamCount); \ 388 ONI_C_API_EXPORT void oniDriverDisableFrameSync(void* frameSyncGroup) \ 390 return g_pDriver->disableFrameSync(frameSyncGroup); \ 393 #endif // ONIDRIVERAPI_H NewFrameCallback m_newFrameCallback
virtual OniBool isCommandSupported(int)
virtual OniStatus getProperty(int, void *, int *)
PropertyChangedCallback m_propertyChangedCallback
void errorLoggerAppend(const char *format,...)
void log(int severity, const char *file, int line, const char *mask, const char *message)
DriverServices(OniDriverServices *pDriverServices)
void raiseNewFrame(OniFrame *pFrame)
void * m_propertyChangedCookie
void deviceStateChanged(const OniDeviceInfo *pInfo, int errorState)
DeviceStateChangedCallback m_deviceStateChangedEvent
virtual OniStatus convertC2DCoordinates(int, int, OniDepthPixel, int *, int *)
virtual void * enableFrameSync(StreamBase **, int)
void addFrameRef(OniFrame *pFrame)
StreamServices * m_pServices
virtual void setPropertyChangedCallback(PropertyChangedCallback handler, void *pCookie)
virtual OniStatus invoke(int, void *, int)
virtual OniBool isPropertySupported(int)
OniDriverServices * m_pDriverServices
virtual OniStatus tryDevice(const char *)
DriverServices & getServices()
StreamServices & getServices()
virtual OniStatus setProperty(int, const void *, int)
void * m_propertyChangedCookie
virtual int getRequiredFrameSize()
virtual OniStatus convertDepthToColorCoordinates(StreamBase *, int, int, OniDepthPixel, int *, int *)
DeviceConnectedCallback m_deviceConnectedEvent
virtual void setServices(StreamServices *pStreamServices)
virtual OniBool isImageRegistrationModeSupported(OniImageRegistrationMode mode)
virtual OniBool isCommandSupported(int)
DriverBase(OniDriverServices *pDriverServices)
virtual OniStatus getProperty(int, void *, int *)
int getDefaultRequiredFrameSize()
void(ONI_CALLBACK_TYPE * PropertyChangedCallback)(void *sender, int propertyId, const void *data, int dataSize, void *pCookie)
virtual void notifyAllProperties()
void raisePropertyChanged(int propertyId, const void *data, int dataSize)
PropertyChangedCallback m_propertyChangedCallback
void(ONI_CALLBACK_TYPE * NewFrameCallback)(StreamBase *streamId, OniFrame *, void *pCookie)
void deviceDisconnected(const OniDeviceInfo *pInfo)
void deviceConnected(const OniDeviceInfo *pInfo)
virtual OniStatus initialize(DeviceConnectedCallback connectedCallback, DeviceDisconnectedCallback disconnectedCallback, DeviceStateChangedCallback deviceStateChangedCallback, void *pCookie)
virtual void disableFrameSync(void *)
DriverServices m_services
virtual OniStatus tryManualTrigger()
virtual void setNewFrameCallback(NewFrameCallback handler, void *pCookie)
virtual OniStatus convertD2CCoordinates(int, int, OniDepthPixel, int *, int *)
typedef void(ONI_CALLBACK_TYPE *DeviceConnectedCallback)(const OniDeviceInfo *
virtual void setPropertyChangedCallback(PropertyChangedCallback handler, void *pCookie)
virtual OniStatus invoke(int, void *, int)
OniFrame * acquireFrame()
DeviceDisconnectedCallback m_deviceDisconnectedEvent
virtual void notifyAllProperties()
virtual OniStatus setProperty(int, const void *, int)
void * m_newFrameCallbackCookie
void raisePropertyChanged(int propertyId, const void *data, int dataSize)
OniFrame *ONI_CALLBACK_TYPE * acquireFrame(void *streamServices)
void(ONI_CALLBACK_TYPE * DeviceStateChangedCallback)(const OniDeviceInfo *deviceId, int errorState, void *pCookie)
void releaseFrame(OniFrame *pFrame)
virtual OniBool isPropertySupported(int)
void(ONI_CALLBACK_TYPE * DeviceDisconnectedCallback)(const OniDeviceInfo *, void *pCookie)