5 #define WORKER_THREAD_IDLE_MS 500 6 #define WORKER_THREAD_STOP_TIMEOUT_MS 5000 7 #define WAIT_FRAMESET_TIMEOUT_MS 2000 8 #define WAIT_ALIGNED_DEPTH_TIMEOUT_MS 100 10 namespace oni {
namespace driver {
16 m_registrationMode(ONI_IMAGE_REGISTRATION_OFF),
19 m_pipelineProfile(nullptr),
20 m_alignQueue(nullptr),
21 m_alignProcessor(nullptr),
72 catch (std::exception& ex) {
81 return ONI_STATUS_ERROR;
103 for (
auto iter =
m_streams.begin(); iter !=
m_streams.end(); ++iter) {
delete(*iter); }
107 for (
auto iter =
m_sensorInfo.begin(); iter !=
m_sensorInfo.end(); ++iter) {
delete[](iter->pSupportedVideoModes); }
124 if (!e.
success())
return ONI_STATUS_ERROR;
127 if (!e.
success())
return ONI_STATUS_ERROR;
129 strncpy(deviceInfo->uri, serial,
sizeof(deviceInfo->uri) - 1);
131 #ifdef RS2_EMULATE_PRIMESENSE_HARDWARE 132 strncpy(deviceInfo->name,
"PS1080",
sizeof(deviceInfo->name) - 1);
133 strncpy(deviceInfo->vendor,
"PrimeSense",
sizeof(deviceInfo->vendor) - 1);
134 deviceInfo->usbVendorId = 7463;
135 deviceInfo->usbProductId = 1537;
137 strncpy(deviceInfo->name, name,
sizeof(deviceInfo->name) - 1);
138 strncpy(deviceInfo->vendor,
"",
sizeof(deviceInfo->vendor) - 1);
139 deviceInfo->usbVendorId = 0;
140 deviceInfo->usbProductId = 0;
143 rsLogDebug(
"DEVICE serial=%s name=%s", serial, name);
145 return ONI_STATUS_OK;
159 *sensors = ((*numSensors > 0) ? &
m_sensorInfo[0] :
nullptr);
161 return ONI_STATUS_OK;
211 return ONI_STATUS_OK;
214 return ONI_STATUS_NO_DEVICE;
217 #if defined(RS2_TRACE_NOT_SUPPORTED_CMDS) 220 return ONI_STATUS_NOT_SUPPORTED;
235 return ONI_STATUS_OK;
278 bool enableStreamError =
false;
290 rsLogDebug(
"ENABLE STREAM type=%d sensorId=%d streamId=%d %dx%d @%d",
300 enableStreamError =
true;
309 if (enableStreamError)
371 return ONI_STATUS_OK;
375 return ONI_STATUS_ERROR;
451 if (configId != curConfigId)
453 configId = curConfigId;
514 for (
int i = 0;
i < nframes; ++
i)
569 for (
int i = 0;
i < nframes; ++
i)
595 if (!frame || !stream || !stream->
isEnabled() || !spi)
604 oniFrame = stream->getServices().acquireFrame();
619 const size_t frameSize = oniFrame->stride * oniFrame->height;
623 mode.resolutionX = oniFrame->width;
624 mode.resolutionY = oniFrame->height;
627 oniFrame->videoMode =
mode;
628 oniFrame->croppingEnabled =
false;
629 oniFrame->cropOriginX = 0;
630 oniFrame->cropOriginY = 0;
632 if (frameSize != oniFrame->dataSize)
634 rsTraceError(
"invalid frame: rsSize=%u oniSize=%u", (
unsigned int)frameSize, (
unsigned int)oniFrame->dataSize);
635 stream->getServices().releaseFrame(oniFrame);
643 stream->getServices().releaseFrame(oniFrame);
649 memcpy(oniFrame->data, frameData, frameSize);
663 for (
int i = 0;
i < oniFrame->width * oniFrame->height; ++
i)
671 stream->raiseNewFrame(oniFrame);
675 stream->getServices().releaseFrame(oniFrame);
715 std::map<int, rs2_stream> sensorStreams;
722 for (
int sensorId = 0; sensorId < nsensors; sensorId++)
729 sensorStreams.clear();
735 for (
int profileId = 0; profileId < nprofiles; profileId++)
751 rsLogDebug(
"\ttype=%d sensorId=%d streamId=%d profileId=%d format=%d width=%d height=%d framerate=%d",
764 for (
auto iter = sensorStreams.begin(); iter != sensorStreams.end(); ++iter)
766 rsLogDebug(
"UNIQ streamId (%d) -> type (%d)", iter->first, (
int)iter->second);
769 for (
auto iter = sensorStreams.begin(); iter != sensorStreams.end(); ++iter)
773 std::vector<Rs2StreamProfileInfo>
profiles;
776 if (
addStream(sensor, oniType, sensorId, iter->first, &profiles) == ONI_STATUS_OK)
796 std::vector<Rs2StreamProfileInfo>
profiles;
801 info.numSupportedVideoModes = (int)profiles.size();
802 info.pSupportedVideoModes =
nullptr;
804 if (info.numSupportedVideoModes > 0)
806 info.pSupportedVideoModes =
new OniVideoMode[info.numSupportedVideoModes];
809 for (
auto p = profiles.begin();
p != profiles.end(); ++
p)
811 OniVideoMode&
mode = info.pSupportedVideoModes[modeId];
813 mode.resolutionX =
p->width;
814 mode.resolutionY =
p->height;
815 mode.fps =
p->framerate;
819 rsLogDebug(
"\ttype=%d sensorId=%d streamId=%d profileId=%d format=%d width=%d height=%d framerate=%d",
820 (
int)
p->streamType, (
int)
p->sensorId, (
int)
p->streamId, (
int)
p->profileId, (
int)
p->format, (
int)
p->width, (
int)
p->height, (
int)
p->framerate);
828 return ONI_STATUS_OK;
845 return ONI_STATUS_ERROR;
849 if (streamObj->
initialize(
this, sensor, sensorId, streamId, profiles) != ONI_STATUS_OK)
853 return ONI_STATUS_ERROR;
857 return ONI_STATUS_OK;
static const textual_icon lock
int rs2_get_sensors_count(const rs2_sensor_list *info_list, rs2_error **error)
void rs2_config_enable_stream(rs2_config *config, rs2_stream stream, int index, int width, int height, rs2_format format, int framerate, rs2_error **error)
#define RS2_PROJECT_POINT_TO_PIXEL
const rs2_stream_profile * rs2_get_frame_stream_profile(const rs2_frame *frame, rs2_error **error)
GLuint const GLchar * name
rs2_processing_block * m_alignProcessor
rs2_context * getRsContext()
rs2_frame_queue * m_alignQueue
void findStreamProfiles(std::vector< Rs2StreamProfileInfo > *dst, OniSensorType sensorType, int streamId)
virtual OniBool isCommandSupported(int commandId)
virtual OniStatus invoke(int commandId, void *data, int dataSize)
static OniStatus queryDeviceInfo(rs2_device *device, OniDeviceInfo *deviceInfo)
Rs2Device(class Rs2Driver *driver, rs2_device *device)
void rs2_get_video_stream_resolution(const rs2_stream_profile *mode, int *width, int *height, rs2_error **error)
rs2_sensor * rs2_create_sensor(const rs2_sensor_list *list, int index, rs2_error **error)
OniStatus startPipeline()
void updateConfiguration()
OniSensorType convertStreamType(rs2_stream type)
std::list< class Rs2Stream * > m_createdStreams
void rs2_delete_device(rs2_device *device)
rs2_config * rs2_create_config(rs2_error **error)
rs2_pipeline * rs2_create_pipeline(rs2_context *ctx, rs2_error **error)
GLint GLint GLsizei GLsizei GLsizei depth
void rs2_delete_frame_queue(rs2_frame_queue *queue)
bool isSupportedPixelFormat(rs2_format type)
rs2_time_t rs2_get_frame_timestamp(const rs2_frame *frame, rs2_error **error)
OniFrame * createOniFrame(rs2_frame *frame, Rs2Stream *stream, Rs2StreamProfileInfo *spi)
rs2_frame_queue * rs2_create_frame_queue(int capacity, rs2_error **error)
rs2_frame * rs2_wait_for_frame(rs2_frame_queue *queue, unsigned int timeout_ms, rs2_error **error)
void rs2_process_frame(rs2_processing_block *block, rs2_frame *frame, rs2_error **error)
bool isSupportedStreamType(rs2_stream type)
#define rsTraceError(format,...)
rs2_stream_profile_list * rs2_get_stream_profiles(rs2_sensor *sensor, rs2_error **error)
rs2_pipeline * m_pipeline
int rs2_get_frame_height(const rs2_frame *frame, rs2_error **error)
Rs2Stream * getFrameStream(rs2_frame *frame, Rs2StreamProfileInfo *spi)
def info(name, value, persistent=False)
virtual void destroyStream(StreamBase *streamBase)
int rs2_get_frame_stride_in_bytes(const rs2_frame *frame, rs2_error **error)
rs2_processing_block * rs2_create_align(rs2_stream align_to, rs2_error **error)
#define WAIT_FRAMESET_TIMEOUT_MS
rs2_frame * rs2_pipeline_wait_for_frames(rs2_pipeline *pipe, unsigned int timeout_ms, rs2_error **error)
void rs2_get_stream_profile_data(const rs2_stream_profile *mode, rs2_stream *stream, rs2_format *format, int *index, int *unique_id, int *framerate, rs2_error **error)
std::vector< Rs2StreamProfileInfo > m_profiles
void rs2_config_disable_all_streams(rs2_config *config, rs2_error **error)
int rs2_embedded_frames_count(rs2_frame *composite, rs2_error **error)
void submitOniFrame(OniFrame *oniFrame, Rs2Stream *stream)
int rs2_get_frame_width(const rs2_frame *frame, rs2_error **error)
void processFrame(rs2_frame *frame)
virtual OniStatus getSensorInfoList(OniSensorInfo **sensors, int *numSensors)
void rs2_delete_sensor(rs2_sensor *sensor)
const rs2_stream_profile * rs2_get_stream_profile(const rs2_stream_profile_list *list, int index, rs2_error **error)
#define WORKER_THREAD_IDLE_MS
unsigned __int64 uint64_t
#define NAMED_PROFILER(name)
rs2_sensor_list * rs2_query_sensors(const rs2_device *device, rs2_error **error)
void rs2_delete_processing_block(rs2_processing_block *block)
void releaseFrame(rs2_frame *frame)
const char * get_message() const
virtual StreamBase * createStream(OniSensorType sensorType)
unsigned long long rs2_get_frame_number(const rs2_frame *frame, rs2_error **error)
rs2_stream
Streams are different types of data provided by RealSense devices.
rs2_pipeline_profile * rs2_pipeline_start_with_config(rs2_pipeline *pipe, rs2_config *config, rs2_error **error)
#define rsLogDebug(format,...)
std::vector< OniSensorInfo > m_sensorInfo
#define rsTraceFunc(format,...)
static void rs2_project_point_to_pixel(float pixel[2], const struct rs2_intrinsics *intrin, const float point[3])
std::lock_guard< std::mutex > Rs2ScopedMutex
void rs2_delete_stream_profiles_list(rs2_stream_profile_list *list)
void rs2_pipeline_stop(rs2_pipeline *pipe, rs2_error **error)
void rs2_frame_add_ref(rs2_frame *frame, rs2_error **error)
class Rs2Driver * getDriver()
OniImageRegistrationMode m_registrationMode
void rs2_delete_config(rs2_config *config)
rs2_intrinsics m_intrinsics
OniSensorType getOniType() const
void rs2_delete_sensor_list(rs2_sensor_list *info_list)
void rs2_config_enable_device(rs2_config *config, const char *serial, rs2_error **error)
OniStatus initialize(class Rs2Device *device, rs2_sensor *sensor, int sensorId, int streamId, std::vector< Rs2StreamProfileInfo > *profiles)
const rs2_stream_profile * profile
OniStatus addStream(rs2_sensor *sensor, OniSensorType sensorType, int sensorId, int streamId, std::vector< Rs2StreamProfileInfo > *profiles)
std::list< class Rs2Stream * > m_streams
void rs2_release_frame(rs2_frame *frame)
rs2_frame * rs2_extract_frame(rs2_frame *composite, int index, rs2_error **error)
int rs2_get_stream_profiles_count(const rs2_stream_profile_list *list, rs2_error **error)
OniPixelFormat convertPixelFormat(rs2_format type)
virtual OniStatus tryManualTrigger()
void rs2_start_processing_queue(rs2_processing_block *block, rs2_frame_queue *queue, rs2_error **error)
void rs2_delete_pipeline_profile(rs2_pipeline_profile *profile)
OniStatus initializeStreams()
void rs2_delete_pipeline(rs2_pipeline *pipe)
rs2_pipeline_profile * m_pipelineProfile
struct rs2_frame rs2_frame
const void * rs2_get_frame_data(const rs2_frame *frame, rs2_error **error)
#define WAIT_ALIGNED_DEPTH_TIMEOUT_MS
rs2_stream getRsType() const
const OniVideoMode & getVideoMode() const
std::unique_ptr< std::thread > m_thread
Rs2Stream * findStream(OniSensorType sensorType, int streamId)
virtual OniBool isImageRegistrationModeSupported(OniImageRegistrationMode mode)
const char * rs2_get_device_info(const rs2_device *device, rs2_camera_info info, rs2_error **error)