21 #ifndef _ONI_DRIVER_API_H_ 22 #define _ONI_DRIVER_API_H_ 30 namespace oni {
namespace driver {
46 return OniStreamServices::getDefaultRequiredFrameSize(
streamServices);
68 StreamBase() : m_newFrameCallback(NULL), m_propertyChangedCallback(NULL) {}
82 virtual void stop() = 0;
92 void raiseNewFrame(OniFrame* pFrame) { (*m_newFrameCallback)(
this, pFrame, m_newFrameCallbackCookie); }
93 void raisePropertyChanged(
int propertyId,
const void* data,
int dataSize) { (*m_propertyChangedCallback)(
this, propertyId, data, dataSize, m_propertyChangedCookie); }
114 virtual void destroyStream(
StreamBase* pStream) = 0;
129 void raisePropertyChanged(
int propertyId,
const void* data,
int dataSize) { (*m_propertyChangedCallback)(
this, propertyId, data, dataSize, m_propertyChangedCookie); }
144 va_start(args, format);
145 m_pDriverServices->errorLoggerAppend(m_pDriverServices->driverServices, format, args);
151 m_pDriverServices->errorLoggerClear(m_pDriverServices->driverServices);
154 void log(
int severity,
const char* file,
int line,
const char* mask,
const char* message)
156 m_pDriverServices->log(m_pDriverServices->driverServices, severity, file, line, mask, message);
173 m_deviceConnectedEvent = connectedCallback;
174 m_deviceDisconnectedEvent = disconnectedCallback;
175 m_deviceStateChangedEvent = deviceStateChangedCallback;
180 virtual DeviceBase* deviceOpen(
const char* uri,
const char* mode) = 0;
181 virtual void deviceClose(
DeviceBase* pDevice) = 0;
183 virtual void shutdown() = 0;
191 void deviceConnected(
const OniDeviceInfo* pInfo) { (m_deviceConnectedEvent)(pInfo, m_pCookie); }
192 void deviceDisconnected(
const OniDeviceInfo* pInfo) { (m_deviceDisconnectedEvent)(pInfo, m_pCookie); }
193 void deviceStateChanged(
const OniDeviceInfo* pInfo,
int errorState) { (m_deviceStateChangedEvent)(pInfo, errorState, m_pCookie); }
208 #define ONI_EXPORT_DRIVER(DriverClass) \ 210 oni::driver::DriverBase* g_pDriver = NULL; \ 213 ONI_C_API_EXPORT void oniDriverCreate(OniDriverServices* driverServices) { \ 214 g_pDriver = XN_NEW(DriverClass, driverServices); \ 216 ONI_C_API_EXPORT void oniDriverDestroy() \ 218 g_pDriver->shutdown(); \ 219 XN_DELETE(g_pDriver); g_pDriver = NULL; \ 221 ONI_C_API_EXPORT OniStatus oniDriverInitialize(oni::driver::DeviceConnectedCallback deviceConnectedCallback, \ 222 oni::driver::DeviceDisconnectedCallback deviceDisconnectedCallback, \ 223 oni::driver::DeviceStateChangedCallback deviceStateChangedCallback, \ 226 return g_pDriver->initialize(deviceConnectedCallback, deviceDisconnectedCallback, deviceStateChangedCallback, pCookie); \ 229 ONI_C_API_EXPORT OniStatus oniDriverTryDevice(const char* uri) \ 231 return g_pDriver->tryDevice(uri); \ 235 ONI_C_API_EXPORT oni::driver::DeviceBase* oniDriverDeviceOpen(const char* uri, const char* mode) \ 237 return g_pDriver->deviceOpen(uri, mode); \ 239 ONI_C_API_EXPORT void oniDriverDeviceClose(oni::driver::DeviceBase* pDevice) \ 241 g_pDriver->deviceClose(pDevice); \ 244 ONI_C_API_EXPORT OniStatus oniDriverDeviceGetSensorInfoList(oni::driver::DeviceBase* pDevice, OniSensorInfo** pSensorInfos, \ 247 return pDevice->getSensorInfoList(pSensorInfos, numSensors); \ 250 ONI_C_API_EXPORT oni::driver::StreamBase* oniDriverDeviceCreateStream(oni::driver::DeviceBase* pDevice, \ 251 OniSensorType sensorType) \ 253 return pDevice->createStream(sensorType); \ 256 ONI_C_API_EXPORT void oniDriverDeviceDestroyStream(oni::driver::DeviceBase* pDevice, oni::driver::StreamBase* pStream) \ 258 return pDevice->destroyStream(pStream); \ 261 ONI_C_API_EXPORT OniStatus oniDriverDeviceSetProperty(oni::driver::DeviceBase* pDevice, int propertyId, \ 262 const void* data, int dataSize) \ 264 return pDevice->setProperty(propertyId, data, dataSize); \ 266 ONI_C_API_EXPORT OniStatus oniDriverDeviceGetProperty(oni::driver::DeviceBase* pDevice, int propertyId, \ 267 void* data, int* pDataSize) \ 269 return pDevice->getProperty(propertyId, data, pDataSize); \ 271 ONI_C_API_EXPORT OniBool oniDriverDeviceIsPropertySupported(oni::driver::DeviceBase* pDevice, int propertyId) \ 273 return pDevice->isPropertySupported(propertyId); \ 275 ONI_C_API_EXPORT void oniDriverDeviceSetPropertyChangedCallback(oni::driver::DeviceBase* pDevice, \ 276 oni::driver::PropertyChangedCallback handler, void* pCookie) \ 278 pDevice->setPropertyChangedCallback(handler, pCookie); \ 280 ONI_C_API_EXPORT void oniDriverDeviceNotifyAllProperties(oni::driver::DeviceBase* pDevice) \ 282 pDevice->notifyAllProperties(); \ 284 ONI_C_API_EXPORT OniStatus oniDriverDeviceInvoke(oni::driver::DeviceBase* pDevice, int commandId, \ 285 void* data, int dataSize) \ 287 return pDevice->invoke(commandId, data, dataSize); \ 289 ONI_C_API_EXPORT OniBool oniDriverDeviceIsCommandSupported(oni::driver::DeviceBase* pDevice, int commandId) \ 291 return pDevice->isCommandSupported(commandId); \ 293 ONI_C_API_EXPORT OniStatus oniDriverDeviceTryManualTrigger(oni::driver::DeviceBase* pDevice) \ 295 return pDevice->tryManualTrigger(); \ 297 ONI_C_API_EXPORT OniBool oniDriverDeviceIsImageRegistrationModeSupported(oni::driver::DeviceBase* pDevice, \ 298 OniImageRegistrationMode mode) \ 300 return pDevice->isImageRegistrationModeSupported(mode); \ 304 ONI_C_API_EXPORT void oniDriverStreamSetServices(oni::driver::StreamBase* pStream, OniStreamServices* pServices) \ 306 pStream->setServices((oni::driver::StreamServices*)pServices); \ 309 ONI_C_API_EXPORT OniStatus oniDriverStreamSetProperty(oni::driver::StreamBase* pStream, int propertyId, \ 310 const void* data, int dataSize) \ 312 return pStream->setProperty(propertyId, data, dataSize); \ 314 ONI_C_API_EXPORT OniStatus oniDriverStreamGetProperty(oni::driver::StreamBase* pStream, int propertyId, void* data, \ 317 return pStream->getProperty(propertyId, data, pDataSize); \ 319 ONI_C_API_EXPORT OniBool oniDriverStreamIsPropertySupported(oni::driver::StreamBase* pStream, int propertyId) \ 321 return pStream->isPropertySupported(propertyId); \ 323 ONI_C_API_EXPORT void oniDriverStreamSetPropertyChangedCallback(oni::driver::StreamBase* pStream, \ 324 oni::driver::PropertyChangedCallback handler, void* pCookie) \ 326 pStream->setPropertyChangedCallback(handler, pCookie); \ 328 ONI_C_API_EXPORT void oniDriverStreamNotifyAllProperties(oni::driver::StreamBase* pStream) \ 330 pStream->notifyAllProperties(); \ 332 ONI_C_API_EXPORT OniStatus oniDriverStreamInvoke(oni::driver::StreamBase* pStream, int commandId, \ 333 void* data, int dataSize) \ 335 return pStream->invoke(commandId, data, dataSize); \ 337 ONI_C_API_EXPORT OniBool oniDriverStreamIsCommandSupported(oni::driver::StreamBase* pStream, int commandId) \ 339 return pStream->isCommandSupported(commandId); \ 342 ONI_C_API_EXPORT OniStatus oniDriverStreamStart(oni::driver::StreamBase* pStream) \ 344 return pStream->start(); \ 346 ONI_C_API_EXPORT void oniDriverStreamStop(oni::driver::StreamBase* pStream) \ 351 ONI_C_API_EXPORT int oniDriverStreamGetRequiredFrameSize(oni::driver::StreamBase* pStream) \ 353 return pStream->getRequiredFrameSize(); \ 356 ONI_C_API_EXPORT void oniDriverStreamSetNewFrameCallback(oni::driver::StreamBase* pStream, \ 357 oni::driver::NewFrameCallback handler, void* pCookie) \ 359 pStream->setNewFrameCallback(handler, pCookie); \ 362 ONI_C_API_EXPORT OniStatus oniDriverStreamConvertDepthToColorCoordinates(oni::driver::StreamBase* pDepthStream, \ 363 oni::driver::StreamBase* pColorStream, int depthX, int depthY, OniDepthPixel depthZ, int* pColorX, int* pColorY) \ 365 return pDepthStream->convertDepthToColorCoordinates(pColorStream, depthX, depthY, depthZ, pColorX, pColorY); \ 368 ONI_C_API_EXPORT void* oniDriverEnableFrameSync(oni::driver::StreamBase** pStreams, int streamCount) \ 370 return g_pDriver->enableFrameSync(pStreams, streamCount); \ 373 ONI_C_API_EXPORT void oniDriverDisableFrameSync(void* frameSyncGroup) \ 375 return g_pDriver->disableFrameSync(frameSyncGroup); \ 378 #endif // _ONI_DRIVER_API_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 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)
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)
def handler(signum, frame)
virtual OniBool isPropertySupported(int)
void(ONI_CALLBACK_TYPE * DeviceDisconnectedCallback)(const OniDeviceInfo *, void *pCookie)