24 v8obj_ = v8::Object::New(v8::Isolate::GetCurrent());
47 Nan::New(value).ToLocalChecked());
56 Nan::New(value.c_str()).ToLocalChecked());
59 template <
typename T,
typename V, u
int32_t len>
61 v8::Local<v8::Array>
array = Nan::New<v8::Array>(
len);
76 return !(v->IsUndefined() || v->IsNull());
88 mutable v8::Local<v8::Object>
v8obj_;
95 ErrorInfo() : is_error_(false), recoverable_(false) {}
101 is_error_ = is_error;
102 recoverable_ = recoverable;
103 description_ = description;
104 native_function_ =
function;
107 void Reset() { Update(
false,
false,
"",
""); }
113 obj.
SetMember(
"description", description_);
114 obj.
SetMember(
"nativeFunction", native_function_);
134 const Nan::FunctionCallbackInfo<v8::Value>&
info) {
135 v8::Local<v8::Context> context = info.GetIsolate()->GetCurrentContext();
137 Nan::Utf8String
value(info[1]->ToString(context).ToLocalChecked());
147 bool recoverable =
false;
166 return Nan::Undefined();
176 Nan::AsyncResource resource(
"js_error_callback_name_");
190 template<
typename R,
typename F,
typename... arguments>
200 template<
typename F,
typename... arguments>
212 pending_infos_.push_back(
this);
215 pending_infos_.erase(
216 std::find(pending_infos_.begin(), pending_infos_.end(),
this));
223 return (
result != pending_infos_.end());
226 while (pending_infos_.size()) {
delete *(pending_infos_.begin()); }
254 singleton_ =
nullptr;
259 uv_close(reinterpret_cast<uv_handle_t*>(async_),
260 [](uv_handle_t* ptr) ->
void {
263 uv_mutex_destroy(&mutex_);
268 if (singleton_->async_->data) {
274 singleton_->async_->data =
static_cast<void*
>(
info);
275 uv_async_send(singleton_->async_);
281 async_ =
static_cast<uv_async_t*
>(malloc(
sizeof(uv_async_t)));
282 async_->data =
nullptr;
283 uv_async_init(uv_default_loop(), async_, AsyncProc);
284 uv_mutex_init(&mutex_);
287 if (singleton_) uv_mutex_lock(&(singleton_->mutex_));
290 if (singleton_) uv_mutex_unlock(&(singleton_->mutex_));
300 async->data =
nullptr;
320 SetMemberArray<v8::Number, float, 9>(
"rotation", extrinsics.
rotation);
321 SetMemberArray<v8::Number, float, 3>(
"translation", extrinsics.
translation);
339 SetMemberArray<v8::Number, float, 5>(
"coeffs", intrinsics.
coeffs);
346 v8::Local<v8::Array> data_array = Nan::New<v8::Array>(3);
351 index++, Nan::New(intri->
data[
i][
j]));
355 SetMemberArray<v8::Number, float, 3>(
"noiseVariances",
357 SetMemberArray<v8::Number, float, 3>(
"biasVariances",
381 SetMember(
"serializedData", serialized_data);
397 static void Init(v8::Local<v8::Object> exports) {
398 v8::Local<v8::FunctionTemplate> tpl = Nan::New<v8::FunctionTemplate>(New);
399 tpl->SetClassName(Nan::New(
"RSStreamProfile").ToLocalChecked());
400 tpl->InstanceTemplate()->SetInternalFieldCount(1);
402 Nan::SetPrototypeMethod(tpl,
"destroy", Destroy);
403 Nan::SetPrototypeMethod(tpl,
"stream", Stream);
404 Nan::SetPrototypeMethod(tpl,
"format", Format);
405 Nan::SetPrototypeMethod(tpl,
"fps", Fps);
406 Nan::SetPrototypeMethod(tpl,
"index",
Index);
407 Nan::SetPrototypeMethod(tpl,
"uniqueID", UniqueID);
408 Nan::SetPrototypeMethod(tpl,
"isDefault", IsDefault);
409 Nan::SetPrototypeMethod(tpl,
"isVideoProfile", IsVideoProfile);
410 Nan::SetPrototypeMethod(tpl,
"isMotionProfile", IsMotionProfile);
411 Nan::SetPrototypeMethod(tpl,
"width", Width);
412 Nan::SetPrototypeMethod(tpl,
"height", Height);
413 Nan::SetPrototypeMethod(tpl,
"getExtrinsicsTo", GetExtrinsicsTo);
414 Nan::SetPrototypeMethod(tpl,
"getVideoStreamIntrinsics",
415 GetVideoStreamIntrinsics);
416 Nan::SetPrototypeMethod(tpl,
"getMotionIntrinsics", GetMotionIntrinsics);
418 v8::Local<v8::Context> context = exports->CreationContext();
420 constructor_.Reset(tpl->GetFunction(context).ToLocalChecked());
421 exports->Set(context, Nan::New(
"RSStreamProfile").ToLocalChecked(),
422 tpl->GetFunction(context).ToLocalChecked());
427 Nan::EscapableHandleScope scope;
429 v8::Local<v8::Function> cons = Nan::New<v8::Function>(constructor_);
432 v8::Local<v8::Object> instance =
433 cons->NewInstance(context, 0,
nullptr).ToLocalChecked();
434 auto me = Nan::ObjectWrap::Unwrap<RSStreamProfile>(instance);
436 me->own_profile_ = own;
438 &me->format_, &me->index_, &me->unique_id_, &me->fps_, &me->error_);
442 me->is_video_ =
true;
444 &me->width_, &me->height_, &me->error_);
447 me->is_motion_ =
true;
450 return scope.Escape(instance);
455 unique_id_(0), fps_(0), format_(static_cast<
rs2_format>(0)),
456 stream_(static_cast<
rs2_stream>(0)), is_video_(false), width_(0),
457 height_(0), is_default_(false), own_profile_(false), is_motion_(false) {}
471 auto me = Nan::ObjectWrap::Unwrap<RSStreamProfile>(
info.Holder());
475 info.GetReturnValue().Set(Nan::Undefined());
478 static void New(
const Nan::FunctionCallbackInfo<v8::Value>&
info) {
479 if (info.IsConstructCall()) {
481 obj->Wrap(info.This());
482 info.GetReturnValue().Set(info.This());
487 auto me = Nan::ObjectWrap::Unwrap<RSStreamProfile>(
info.Holder());
489 info.GetReturnValue().Set(Nan::New(me->stream_));
492 info.GetReturnValue().Set(Nan::Undefined());
495 auto me = Nan::ObjectWrap::Unwrap<RSStreamProfile>(
info.Holder());
497 info.GetReturnValue().Set(Nan::New(me->format_));
500 info.GetReturnValue().Set(Nan::Undefined());
503 auto me = Nan::ObjectWrap::Unwrap<RSStreamProfile>(
info.Holder());
505 info.GetReturnValue().Set(Nan::New(me->fps_));
508 info.GetReturnValue().Set(Nan::Undefined());
511 auto me = Nan::ObjectWrap::Unwrap<RSStreamProfile>(
info.Holder());
513 info.GetReturnValue().Set(Nan::New(me->index_));
516 info.GetReturnValue().Set(Nan::Undefined());
519 auto me = Nan::ObjectWrap::Unwrap<RSStreamProfile>(
info.Holder());
521 info.GetReturnValue().Set(Nan::New(me->unique_id_));
524 info.GetReturnValue().Set(Nan::Undefined());
527 auto me = Nan::ObjectWrap::Unwrap<RSStreamProfile>(
info.Holder());
529 info.GetReturnValue().Set(Nan::New(me->is_default_));
532 info.GetReturnValue().Set(Nan::Undefined());
535 auto me = Nan::ObjectWrap::Unwrap<RSStreamProfile>(
info.Holder());
537 info.GetReturnValue().Set(Nan::New(me->is_video_));
540 info.GetReturnValue().Set(Nan::Undefined());
544 auto me = Nan::ObjectWrap::Unwrap<RSStreamProfile>(
info.Holder());
545 info.GetReturnValue().Set(Nan::Undefined());
548 info.GetReturnValue().Set(Nan::New(me->is_motion_));
552 auto me = Nan::ObjectWrap::Unwrap<RSStreamProfile>(
info.Holder());
554 info.GetReturnValue().Set(Nan::New(me->width_));
557 info.GetReturnValue().Set(Nan::Undefined());
561 auto me = Nan::ObjectWrap::Unwrap<RSStreamProfile>(
info.Holder());
563 info.GetReturnValue().Set(Nan::New(me->height_));
566 info.GetReturnValue().Set(Nan::Undefined());
570 info.GetReturnValue().Set(Nan::Undefined());
571 v8::Local<v8::Context> context =
info.GetIsolate()->GetCurrentContext();
572 auto me = Nan::ObjectWrap::Unwrap<RSStreamProfile>(
info.Holder());
573 auto to = Nan::ObjectWrap::Unwrap<RSStreamProfile>(
info[0]->ToObject(context).ToLocalChecked());
574 if (!me || !to)
return;
579 if (me->error_)
return;
586 info.GetReturnValue().Set(Nan::Undefined());
587 auto me = Nan::ObjectWrap::Unwrap<RSStreamProfile>(
info.Holder());
593 if (me->error_)
return;
600 info.GetReturnValue().Set(Nan::Undefined());
601 auto me = Nan::ObjectWrap::Unwrap<RSStreamProfile>(
info.Holder());
606 &output, &me->error_);
607 if (me->error_)
return;
654 static void Init(v8::Local<v8::Object> exports) {
655 v8::Local<v8::FunctionTemplate> tpl = Nan::New<v8::FunctionTemplate>(New);
656 tpl->SetClassName(Nan::New(
"RSFrame").ToLocalChecked());
657 tpl->InstanceTemplate()->SetInternalFieldCount(1);
659 Nan::SetPrototypeMethod(tpl,
"destroy", Destroy);
660 Nan::SetPrototypeMethod(tpl,
"getStreamProfile", GetStreamProfile);
661 Nan::SetPrototypeMethod(tpl,
"getData", GetData);
662 Nan::SetPrototypeMethod(tpl,
"writeData", WriteData);
663 Nan::SetPrototypeMethod(tpl,
"getWidth", GetWidth);
664 Nan::SetPrototypeMethod(tpl,
"getHeight", GetHeight);
665 Nan::SetPrototypeMethod(tpl,
"getStrideInBytes", GetStrideInBytes);
666 Nan::SetPrototypeMethod(tpl,
"getBitsPerPixel", GetBitsPerPixel);
667 Nan::SetPrototypeMethod(tpl,
"getTimestamp", GetTimestamp);
668 Nan::SetPrototypeMethod(tpl,
"getTimestampDomain", GetTimestampDomain);
669 Nan::SetPrototypeMethod(tpl,
"getFrameNumber", GetFrameNumber);
670 Nan::SetPrototypeMethod(tpl,
"getFrameMetadata", GetFrameMetadata);
671 Nan::SetPrototypeMethod(tpl,
"supportsFrameMetadata",
672 SupportsFrameMetadata);
673 Nan::SetPrototypeMethod(tpl,
"isVideoFrame", IsVideoFrame);
674 Nan::SetPrototypeMethod(tpl,
"isDepthFrame", IsDepthFrame);
675 Nan::SetPrototypeMethod(tpl,
"isDisparityFrame", IsDisparityFrame);
676 Nan::SetPrototypeMethod(tpl,
"isMotionFrame", IsMotionFrame);
677 Nan::SetPrototypeMethod(tpl,
"isPoseFrame", IsPoseFrame);
680 Nan::SetPrototypeMethod(tpl,
"canGetPoints", CanGetPoints);
681 Nan::SetPrototypeMethod(tpl,
"getVertices", GetVertices);
682 Nan::SetPrototypeMethod(tpl,
"getVerticesBufferLen", GetVerticesBufferLen);
683 Nan::SetPrototypeMethod(tpl,
"getTexCoordBufferLen", GetTexCoordBufferLen);
684 Nan::SetPrototypeMethod(tpl,
"writeVertices", WriteVertices);
685 Nan::SetPrototypeMethod(tpl,
"getTextureCoordinates",
686 GetTextureCoordinates);
687 Nan::SetPrototypeMethod(tpl,
"writeTextureCoordinates",
688 WriteTextureCoordinates);
689 Nan::SetPrototypeMethod(tpl,
"getPointsCount", GetPointsCount);
690 Nan::SetPrototypeMethod(tpl,
"exportToPly", ExportToPly);
691 Nan::SetPrototypeMethod(tpl,
"isValid", IsValid);
692 Nan::SetPrototypeMethod(tpl,
"getDistance", GetDistance);
693 Nan::SetPrototypeMethod(tpl,
"getBaseLine", GetBaseLine);
694 Nan::SetPrototypeMethod(tpl,
"keep", Keep);
695 Nan::SetPrototypeMethod(tpl,
"getMotionData", GetMotionData);
696 Nan::SetPrototypeMethod(tpl,
"getPoseData", GetPoseData);
698 v8::Local<v8::Context> context = exports->CreationContext();
700 constructor_.Reset(tpl->GetFunction(context).ToLocalChecked());
701 exports->Set(context, Nan::New(
"RSFrame").ToLocalChecked(),
702 tpl->GetFunction(context).ToLocalChecked());
706 Nan::EscapableHandleScope scope;
708 v8::Local<v8::Function> cons = Nan::New<v8::Function>(constructor_);
711 v8::Local<v8::Object> instance =
712 cons->NewInstance(context, 0,
nullptr).ToLocalChecked();
714 auto me = Nan::ObjectWrap::Unwrap<RSFrame>(instance);
717 return scope.Escape(instance);
724 Nan::AsyncResource resource(
"_internalResetBuffer");
725 resource.runInAsyncScope(
handle(),
"_internalResetBuffer", 0,
nullptr);
730 RSFrame() : frame_(nullptr), error_(nullptr) {}
745 const char*
names[4] = {
"x",
"y",
"z",
"w"};
746 v8::Local<v8::String>
name = Nan::New(names[index]).ToLocalChecked();
747 Nan::Set(obj, name, Nan::New(value));
752 SetAFloatInVectorObject(obj, 0, vec.
x);
753 SetAFloatInVectorObject(obj, 1, vec.
y);
754 SetAFloatInVectorObject(obj, 2, vec.
z);
759 SetAFloatInVectorObject(obj, 0, quaternion.
x);
760 SetAFloatInVectorObject(obj, 1, quaternion.
y);
761 SetAFloatInVectorObject(obj, 2, quaternion.
z);
762 SetAFloatInVectorObject(obj, 3, quaternion.
w);
767 auto translation_name = Nan::New(
"translation").ToLocalChecked();
768 auto velocity_name = Nan::New(
"velocity").ToLocalChecked();
769 auto acceleration_name = Nan::New(
"acceleration").ToLocalChecked();
770 auto rotation_name = Nan::New(
"rotation").ToLocalChecked();
771 auto angular_velocity_name = Nan::New(
"angularVelocity").ToLocalChecked();
772 auto angular_acceleration_name =
773 Nan::New(
"angularAcceleration").ToLocalChecked();
774 auto tracker_confidence_name =
775 Nan::New(
"trackerConfidence").ToLocalChecked();
776 auto mapper_confidence_name = Nan::New(
"mapperConfidence").ToLocalChecked();
778 auto translation_obj = Nan::GetRealNamedProperty(
780 auto velocity_obj = Nan::GetRealNamedProperty(
782 auto acceleration_obj = Nan::GetRealNamedProperty(
784 auto rotation_obj = Nan::GetRealNamedProperty(
786 auto angular_velocity_obj = Nan::GetRealNamedProperty(
788 auto angular_acceleration_obj = Nan::GetRealNamedProperty(
791 FillAFloatVector(translation_obj.ToLocalChecked(), pose.
translation);
792 FillAFloatVector(velocity_obj.ToLocalChecked(), pose.
velocity);
793 FillAFloatVector(acceleration_obj.ToLocalChecked(), pose.
acceleration);
794 FillAFloatQuaternion(rotation_obj.ToLocalChecked(), pose.
rotation);
795 FillAFloatVector(angular_velocity_obj.ToLocalChecked(), pose.
angular_velocity);
802 static void New(
const Nan::FunctionCallbackInfo<v8::Value>&
info) {
803 if (info.IsConstructCall()) {
805 obj->Wrap(info.This());
806 info.GetReturnValue().Set(info.This());
811 info.GetReturnValue().Set(Nan::Undefined());
812 auto me = Nan::ObjectWrap::Unwrap<RSFrame>(
info.Holder());
813 if (!me || !me->frame_)
return;
822 &me->error_, me->frame_, &me->error_);
824 &stream, &format, &index, &unique_id, &fps, &me->error_);
825 if (me->error_)
return;
830 if (!profile)
return;
836 info.GetReturnValue().Set(Nan::Undefined());
837 auto me = Nan::ObjectWrap::Unwrap<RSFrame>(
info.Holder());
841 me->frame_, &me->error_);
845 &me->error_, me->frame_, &me->error_);
847 me->frame_, &me->error_);
849 auto array_buffer = v8::ArrayBuffer::New(
850 v8::Isolate::GetCurrent(),
851 static_cast<uint8_t*>(const_cast<void*>(
buffer)), length,
852 v8::ArrayBufferCreationMode::kExternalized);
853 info.GetReturnValue().Set(array_buffer);
857 info.GetReturnValue().Set(Nan::Undefined());
858 auto array_buffer = v8::Local<v8::ArrayBuffer>::Cast(
info[0]);
859 auto me = Nan::ObjectWrap::Unwrap<RSFrame>(
info.Holder());
863 &me->error_, me->frame_, &me->error_);
865 &me->error_, me->frame_, &me->error_);
867 me->frame_, &me->error_);
870 auto contents = array_buffer->GetContents();
876 info.GetReturnValue().Set(Nan::Undefined());
877 auto me = Nan::ObjectWrap::Unwrap<RSFrame>(
info.Holder());
881 me->frame_, &me->error_);
882 info.GetReturnValue().Set(Nan::New(
value));
886 info.GetReturnValue().Set(Nan::Undefined());
887 auto me = Nan::ObjectWrap::Unwrap<RSFrame>(
info.Holder());
891 me->frame_, &me->error_);
892 info.GetReturnValue().Set(Nan::New(
value));
896 info.GetReturnValue().Set(Nan::Undefined());
897 auto me = Nan::ObjectWrap::Unwrap<RSFrame>(
info.Holder());
901 &me->error_, me->frame_, &me->error_);
902 info.GetReturnValue().Set(Nan::New(
value));
906 info.GetReturnValue().Set(Nan::Undefined());
907 auto me = Nan::ObjectWrap::Unwrap<RSFrame>(
info.Holder());
911 me->frame_, &me->error_);
912 info.GetReturnValue().Set(Nan::New(
value));
916 info.GetReturnValue().Set(Nan::Undefined());
917 auto me = Nan::ObjectWrap::Unwrap<RSFrame>(
info.Holder());
921 me->frame_, &me->error_);
922 info.GetReturnValue().Set(Nan::New(
value));
926 info.GetReturnValue().Set(Nan::Undefined());
927 auto me = Nan::ObjectWrap::Unwrap<RSFrame>(
info.Holder());
930 auto value = GetNativeResult<rs2_timestamp_domain>(
932 info.GetReturnValue().Set(Nan::New(
value));
936 info.GetReturnValue().Set(Nan::Undefined());
937 auto me = Nan::ObjectWrap::Unwrap<RSFrame>(
info.Holder());
941 &me->error_, me->frame_, &me->error_);
942 info.GetReturnValue().Set(Nan::New(value));
946 info.GetReturnValue().Set(Nan::Undefined());
947 auto me = Nan::ObjectWrap::Unwrap<RSFrame>(
info.Holder());
950 bool isVideo =
false;
954 info.GetReturnValue().Set(Nan::New(isVideo));
958 info.GetReturnValue().Set(Nan::Undefined());
959 auto me = Nan::ObjectWrap::Unwrap<RSFrame>(
info.Holder());
962 bool isDepth =
false;
966 info.GetReturnValue().Set(Nan::New(isDepth));
970 auto me = Nan::ObjectWrap::Unwrap<RSFrame>(
info.Holder());
971 info.GetReturnValue().Set(Nan::Undefined());
976 info.GetReturnValue().Set(Nan::New(is_disparity ?
true :
false));
980 auto me = Nan::ObjectWrap::Unwrap<RSFrame>(
info.Holder());
981 info.GetReturnValue().Set(Nan::Undefined());
986 info.GetReturnValue().Set(Nan::New(
val ?
true :
false));
990 auto me = Nan::ObjectWrap::Unwrap<RSFrame>(
info.Holder());
991 info.GetReturnValue().Set(Nan::Undefined());
996 info.GetReturnValue().Set(Nan::New(
val ?
true :
false));
1000 info.GetReturnValue().Set(Nan::New(
false));
1001 auto me = Nan::ObjectWrap::Unwrap<RSFrame>(
info.Holder());
1004 Nan::TypedArrayContents<unsigned char> content(
info[1]);
1005 unsigned char* internal_data = *content;
1006 if (!me || !internal_data)
return;
1010 unsigned char* out_ptr =
reinterpret_cast<unsigned char*
>(&output);
1012 unsigned char* val_ptr =
reinterpret_cast<unsigned char*
>(&
val);
1014 if (*val_ptr == 0) {
1016 memcpy(internal_data, out_ptr, 8);
1020 internal_data[
i] = out_ptr[7-
i];
1023 info.GetReturnValue().Set(Nan::New(
true));
1027 info.GetReturnValue().Set(Nan::Undefined());
1028 auto me = Nan::ObjectWrap::Unwrap<RSFrame>(
info.Holder());
1034 me->frame_,
metadata, &me->error_);
1035 info.GetReturnValue().Set(Nan::New(result ?
true :
false));
1039 auto me = Nan::ObjectWrap::Unwrap<RSFrame>(
info.Holder());
1043 info.GetReturnValue().Set(Nan::Undefined());
1047 info.GetReturnValue().Set(Nan::Undefined());
1048 auto me = Nan::ObjectWrap::Unwrap<RSFrame>(
info.Holder());
1055 info.GetReturnValue().Set(Nan::New(result));
1059 info.GetReturnValue().Set(Nan::Undefined());
1060 auto me = Nan::ObjectWrap::Unwrap<RSFrame>(
info.Holder());
1064 &me->error_, me->frame_, &me->error_);
1066 &me->error_, me->frame_, &me->error_);
1067 if (!vertices || !count)
return;
1071 auto vertex_buf =
static_cast<uint8_t*
>(malloc(len));
1073 for (
size_t i = 0;
i <
count;
i++) {
1074 memcpy(vertex_buf+
i*step, vertices[
i].
xyz, step);
1076 auto array_buffer = v8::ArrayBuffer::New(
1077 v8::Isolate::GetCurrent(), vertex_buf, len,
1078 v8::ArrayBufferCreationMode::kInternalized);
1080 info.GetReturnValue().Set(v8::Float32Array::New(array_buffer, 0, 3*count));
1084 info.GetReturnValue().Set(Nan::Undefined());
1085 auto me = Nan::ObjectWrap::Unwrap<RSFrame>(
info.Holder());
1089 &me->error_, me->frame_, &me->error_);
1090 const uint32_t step = 3 *
sizeof(float);
1092 info.GetReturnValue().Set(Nan::New(length));
1096 info.GetReturnValue().Set(Nan::Undefined());
1097 auto me = Nan::ObjectWrap::Unwrap<RSFrame>(
info.Holder());
1101 &me->error_, me->frame_, &me->error_);
1102 const uint32_t step = 2 *
sizeof(int);
1104 info.GetReturnValue().Set(Nan::New(length));
1108 info.GetReturnValue().Set(Nan::False());
1109 auto me = Nan::ObjectWrap::Unwrap<RSFrame>(
info.Holder());
1110 auto array_buffer = v8::Local<v8::ArrayBuffer>::Cast(
info[0]);
1113 const rs2_vertex* vertBuf = GetNativeResult<rs2_vertex*>(
1116 &me->error_, me->frame_, &me->error_);
1117 if (!vertBuf || !count)
return;
1119 const uint32_t step = 3 *
sizeof(float);
1121 if (array_buffer->ByteLength() <
length)
return;
1123 auto contents = array_buffer->GetContents();
1125 for (
size_t i = 0;
i <
count;
i++) {
1126 memcpy(vertex_buf+
i*step, vertBuf[
i].
xyz, step);
1128 info.GetReturnValue().Set(Nan::True());
1132 info.GetReturnValue().Set(Nan::Undefined());
1133 auto me = Nan::ObjectWrap::Unwrap<RSFrame>(
info.Holder());
1140 &me->error_, me->frame_, &me->error_);
1141 if (!coords || !count)
return;
1145 auto texcoord_buf =
static_cast<uint8_t*
>(malloc(len));
1147 for (
size_t i = 0;
i <
count; ++
i) {
1148 memcpy(texcoord_buf +
i * step, coords[
i].ij, step);
1150 auto array_buffer = v8::ArrayBuffer::New(
1151 v8::Isolate::GetCurrent(), texcoord_buf, len,
1152 v8::ArrayBufferCreationMode::kInternalized);
1154 info.GetReturnValue().Set(v8::Int32Array::New(array_buffer, 0, 2*count));
1158 info.GetReturnValue().Set(Nan::False());
1159 auto me = Nan::ObjectWrap::Unwrap<RSFrame>(
info.Holder());
1160 auto array_buffer = v8::Local<v8::ArrayBuffer>::Cast(
info[0]);
1166 &me->error_, me->frame_, &me->error_);
1167 if (!coords || !count)
return;
1169 const uint32_t step = 2 *
sizeof(int);
1171 if (array_buffer->ByteLength() <
length)
return;
1173 auto contents = array_buffer->GetContents();
1175 for (
size_t i = 0;
i <
count; ++
i) {
1176 memcpy(texcoord_buf +
i * step, coords[
i].ij, step);
1178 info.GetReturnValue().Set(Nan::True());
1182 info.GetReturnValue().Set(Nan::Undefined());
1183 auto me = Nan::ObjectWrap::Unwrap<RSFrame>(
info.Holder());
1187 &me->error_, me->frame_, &me->error_);
1188 info.GetReturnValue().Set(Nan::New(count));
1192 auto me = Nan::ObjectWrap::Unwrap<RSFrame>(
info.Holder());
1196 v8::Local<v8::Context> context =
info.GetIsolate()->GetCurrentContext();
1197 auto texture = Nan::ObjectWrap::Unwrap<RSFrame>(
1198 info[1]->ToObject(context).ToLocalChecked());
1199 info.GetReturnValue().Set(Nan::Undefined());
1209 auto me = Nan::ObjectWrap::Unwrap<RSFrame>(
info.Holder());
1212 info.GetReturnValue().Set(Nan::True());
1216 info.GetReturnValue().Set(Nan::False());
1220 info.GetReturnValue().Set(Nan::Undefined());
1221 auto me = Nan::ObjectWrap::Unwrap<RSFrame>(
info.Holder());
1222 auto x = Nan::To<int64_t>(
info[0]).FromJust();
1223 auto y = Nan::To<int64_t>(
info[1]).FromJust();
1227 me->frame_,
x,
y, &me->error_);
1228 info.GetReturnValue().Set(Nan::New(
val));
1232 auto me = Nan::ObjectWrap::Unwrap<RSFrame>(
info.Holder());
1233 info.GetReturnValue().Set(Nan::Undefined());
1237 &me->error_, me->frame_, &me->error_);
1238 info.GetReturnValue().Set(Nan::New(
val));
1242 auto me = Nan::ObjectWrap::Unwrap<RSFrame>(
info.Holder());
1243 info.GetReturnValue().Set(Nan::Undefined());
1244 if (!me || !me->frame_)
return;
1250 auto me = Nan::ObjectWrap::Unwrap<RSFrame>(
info.Holder());
1251 info.GetReturnValue().Set(Nan::Undefined());
1253 v8::Local<v8::Context> context =
info.GetIsolate()->GetCurrentContext();
1254 auto obj =
info[0]->ToObject(context).ToLocalChecked();
1255 auto frame_data =
static_cast<const float*
>(GetNativeResult<const void*>(
1263 auto me = Nan::ObjectWrap::Unwrap<RSFrame>(
info.Holder());
1264 info.GetReturnValue().Set(Nan::False());
1269 &pose_data, &me->error_);
1270 if (me->error_)
return;
1271 v8::Local<v8::Context> context =
info.GetIsolate()->GetCurrentContext();
1272 AssemblePoseData(
info[0]->ToObject(context).ToLocalChecked(), pose_data);
1273 info.GetReturnValue().Set(Nan::True());
1310 static void Init(v8::Local<v8::Object> exports) {
1311 v8::Local<v8::FunctionTemplate> tpl = Nan::New<v8::FunctionTemplate>(New);
1312 tpl->SetClassName(Nan::New(
"RSFrameQueue").ToLocalChecked());
1313 tpl->InstanceTemplate()->SetInternalFieldCount(1);
1315 Nan::SetPrototypeMethod(tpl,
"create", Create);
1316 Nan::SetPrototypeMethod(tpl,
"destroy", Destroy);
1317 Nan::SetPrototypeMethod(tpl,
"waitForFrame", WaitForFrame);
1318 Nan::SetPrototypeMethod(tpl,
"pollForFrame", PollForFrame);
1319 Nan::SetPrototypeMethod(tpl,
"enqueueFrame", EnqueueFrame);
1320 v8::Local<v8::Context> context = exports->CreationContext();
1321 constructor_.Reset(tpl->GetFunction(context).ToLocalChecked());
1322 exports->Set(context, Nan::New(
"RSFrameQueue").ToLocalChecked(),
1323 tpl->GetFunction(context).ToLocalChecked());
1327 Nan::EscapableHandleScope scope;
1329 v8::Local<v8::Function> cons = Nan::New<v8::Function>(constructor_);
1332 v8::Local<v8::Object> instance =
1333 cons->NewInstance(context, 0,
nullptr).ToLocalChecked();
1335 return scope.Escape(instance);
1349 frame_queue_ =
nullptr;
1352 static void New(
const Nan::FunctionCallbackInfo<v8::Value>&
info) {
1353 if (info.IsConstructCall()) {
1355 obj->Wrap(info.This());
1356 info.GetReturnValue().Set(info.This());
1361 info.GetReturnValue().Set(Nan::Undefined());
1363 auto me = Nan::ObjectWrap::Unwrap<RSFrameQueue>(
info.Holder());
1367 me->frame_queue_,
timeout, &me->error_);
1374 info.GetReturnValue().Set(Nan::Undefined());
1375 int32_t capacity = Nan::To<int32_t>(
info[0]).FromJust();
1376 auto me = Nan::ObjectWrap::Unwrap<RSFrameQueue>(
info.Holder());
1380 &me->error_, capacity, &me->error_);
1384 auto me = Nan::ObjectWrap::Unwrap<RSFrameQueue>(
info.Holder());
1388 info.GetReturnValue().Set(Nan::Undefined());
1392 info.GetReturnValue().Set(Nan::Undefined());
1393 auto me = Nan::ObjectWrap::Unwrap<RSFrameQueue>(
info.Holder());
1398 me->frame_queue_, &frame, &me->error_);
1405 v8::Local<v8::Context> context =
info.GetIsolate()->GetCurrentContext();
1406 auto me = Nan::ObjectWrap::Unwrap<RSFrameQueue>(
info.Holder());
1407 auto frame = Nan::ObjectWrap::Unwrap<RSFrame>(
info[0]->ToObject(context).ToLocalChecked());
1411 frame->frame_ =
nullptr;
1413 info.GetReturnValue().Set(Nan::Undefined());
1430 frame_(frame), sensor_(static_cast<
RSSensor*>(data)) {}
1453 desc_(desc), time_(time), severity_(severity),
1454 category_(category), serialized_data_(serialized_data),
1474 const char* desc = GetNativeResult<const char*>(
1476 rs2_time_t time = GetNativeResult<rs2_time_t>(
1481 GetNativeResult<rs2_notification_category>(
1483 std::string serialized_data = GetNativeResult<std::string>(
1486 time, severity, category, serialized_data, sensor_));
1497 : frame_queue_(queue) {}
1499 if (frame && frame_queue_)
1520 block_(block_ptr), error_(nullptr) {}
1535 status_(status), dev_(dev), error_(nullptr) {}
1563 &unique_id_, &fps_, &error_);
1576 static void Init(v8::Local<v8::Object> exports) {
1577 v8::Local<v8::FunctionTemplate> tpl = Nan::New<v8::FunctionTemplate>(New);
1578 tpl->SetClassName(Nan::New(
"RSFrameSet").ToLocalChecked());
1579 tpl->InstanceTemplate()->SetInternalFieldCount(1);
1581 Nan::SetPrototypeMethod(tpl,
"destroy", Destroy);
1582 Nan::SetPrototypeMethod(tpl,
"getSize", GetSize);
1583 Nan::SetPrototypeMethod(tpl,
"getFrame", GetFrame);
1584 Nan::SetPrototypeMethod(tpl,
"replaceFrame", ReplaceFrame);
1585 Nan::SetPrototypeMethod(tpl,
"indexToStream", IndexToStream);
1586 Nan::SetPrototypeMethod(tpl,
"indexToStreamIndex", IndexToStreamIndex);
1587 v8::Local<v8::Context> context = exports->CreationContext();
1588 constructor_.Reset(tpl->GetFunction(context).ToLocalChecked());
1589 exports->Set(context, Nan::New(
"RSFrameSet").ToLocalChecked(),
1590 tpl->GetFunction(context).ToLocalChecked());
1594 Nan::EscapableHandleScope scope;
1596 v8::Local<v8::Function> cons = Nan::New<v8::Function>(constructor_);
1599 v8::Local<v8::Object> instance =
1600 cons->NewInstance(context, 0,
nullptr).ToLocalChecked();
1601 auto me = Nan::ObjectWrap::Unwrap<RSFrameSet>(instance);
1602 me->SetFrame(frame);
1604 return scope.Escape(instance);
1643 auto me = Nan::ObjectWrap::Unwrap<RSFrameSet>(
info.Holder());
1647 info.GetReturnValue().Set(Nan::Undefined());
1650 static void New(
const Nan::FunctionCallbackInfo<v8::Value>&
info) {
1651 if (info.IsConstructCall()) {
1653 obj->Wrap(info.This());
1654 info.GetReturnValue().Set(info.This());
1659 auto me = Nan::ObjectWrap::Unwrap<RSFrameSet>(
info.Holder());
1660 if (me && me->frames_) {
1661 info.GetReturnValue().Set(Nan::New(me->frame_count_));
1664 info.GetReturnValue().Set(Nan::New(0));
1668 info.GetReturnValue().Set(Nan::Undefined());
1669 auto me = Nan::ObjectWrap::Unwrap<RSFrameSet>(
info.Holder());
1670 if (!me || !me->frames_)
return;
1673 auto stream_index = Nan::To<int64_t>(
info[1]).FromJust();
1677 &me->error_, me->frames_, 0, &me->error_);
1686 &me->error_, me->frames_,
i, &me->error_);
1687 if (!frame)
continue;
1690 GetNativeResult<const rs2_stream_profile*>(
1694 if (extrator.
stream_ == stream && (!stream_index ||
1695 (stream_index && stream_index == extrator.
index_))) {
1705 info.GetReturnValue().Set(Nan::False());
1706 auto me = Nan::ObjectWrap::Unwrap<RSFrameSet>(
info.Holder());
1708 auto stream_index = Nan::To<int64_t>(
info[1]).FromJust();
1709 auto target_frame = Nan::ObjectWrap::Unwrap<RSFrame>(Nan::To<v8::Object>(
info[2]).ToLocalChecked());
1711 if (!me || !me->frames_)
return;
1715 &me->error_, me->frames_,
i, &me->error_);
1716 if (!frame)
continue;
1719 GetNativeResult<const rs2_stream_profile*>(
1723 if (extrator.
stream_ == stream && (!stream_index ||
1724 (stream_index && stream_index == extrator.
index_))) {
1725 target_frame->Replace(frame);
1726 info.GetReturnValue().Set(Nan::True());
1735 info.GetReturnValue().Set(Nan::Undefined());
1736 auto me = Nan::ObjectWrap::Unwrap<RSFrameSet>(
info.Holder());
1737 if (!me || !me->frames_)
return;
1741 &me->error_, me->frames_,
index, &me->error_);
1746 &me->error_, frame, &me->error_);
1758 &format, &idx, &unique_id, &fps, &me->error_);
1760 if (me->error_)
return;
1762 info.GetReturnValue().Set(Nan::New(stream));
1766 auto me = Nan::ObjectWrap::Unwrap<RSFrameSet>(
info.Holder());
1767 info.GetReturnValue().Set(Nan::Undefined());
1768 if (!me || !me->frames_)
return;
1772 &me->error_, me->frames_,
index, &me->error_);
1777 &me->error_, frame, &me->error_);
1788 &format, &idx, &unique_id, &fps, &me->error_);
1790 if (me->error_)
return;
1792 info.GetReturnValue().Set(Nan::New(idx));
1826 static void Init(v8::Local<v8::Object> exports) {
1827 v8::Local<v8::FunctionTemplate> tpl = Nan::New<v8::FunctionTemplate>(New);
1828 tpl->SetClassName(Nan::New(
"RSSyncer").ToLocalChecked());
1829 tpl->InstanceTemplate()->SetInternalFieldCount(1);
1831 Nan::SetPrototypeMethod(tpl,
"destroy", Destroy);
1832 Nan::SetPrototypeMethod(tpl,
"waitForFrames", WaitForFrames);
1833 Nan::SetPrototypeMethod(tpl,
"pollForFrames", PollForFrames);
1835 v8::Local<v8::Context> context = exports->CreationContext();
1836 constructor_.Reset(tpl->GetFunction(context).ToLocalChecked());
1837 exports->Set(context, Nan::New(
"RSSyncer").ToLocalChecked(),
1838 tpl->GetFunction(context).ToLocalChecked());
1842 Nan::EscapableHandleScope scope;
1844 v8::Local<v8::Function> cons = Nan::New<v8::Function>(constructor_);
1847 v8::Local<v8::Object> instance =
1848 cons->NewInstance(context, 0,
nullptr).ToLocalChecked();
1850 return scope.Escape(instance);
1854 RSSyncer() : syncer_(nullptr), frame_queue_(nullptr), error_(nullptr) {}
1866 frame_queue_ =
nullptr;
1869 static void New(
const Nan::FunctionCallbackInfo<v8::Value>&
info) {
1870 if (info.IsConstructCall()) {
1872 obj->
syncer_ = GetNativeResult<rs2_processing_block*>(
1879 obj->Wrap(info.This());
1880 info.GetReturnValue().Set(info.This());
1885 info.GetReturnValue().Set(Nan::False());
1886 auto me = Nan::ObjectWrap::Unwrap<RSSyncer>(
info.Holder());
1887 auto frameset = Nan::ObjectWrap::Unwrap<RSFrameSet>(Nan::To<v8::Object>(
info[0]).ToLocalChecked());
1888 auto timeout = Nan::To<int64_t>(
info[1]).FromJust();
1889 if (!me || !frameset)
return;
1892 &me->error_, me->frame_queue_,
timeout, &me->error_);
1893 if (!frames)
return;
1895 frameset->Replace(frames);
1896 info.GetReturnValue().Set(Nan::True());
1900 auto me = Nan::ObjectWrap::Unwrap<RSSyncer>(
info.Holder());
1904 info.GetReturnValue().Set(Nan::Undefined());
1908 info.GetReturnValue().Set(Nan::False());
1909 auto me = Nan::ObjectWrap::Unwrap<RSSyncer>(
info.Holder());
1910 auto frameset = Nan::ObjectWrap::Unwrap<RSFrameSet>(Nan::To<v8::Object>(
info[0]).ToLocalChecked());
1911 if (!me || !frameset)
return;
1915 me->frame_queue_, &frame_ref, &me->error_);
1918 frameset->Replace(frame_ref);
1919 info.GetReturnValue().Set(Nan::True());
1943 const Nan::FunctionCallbackInfo<v8::Value>&
info) {
1947 info.GetReturnValue().Set(Nan::New(on ?
true :
false));
1955 info.GetReturnValue().Set(Nan::New(
value));
1959 const Nan::FunctionCallbackInfo<v8::Value>&
info) {
1964 info.GetReturnValue().Set(Nan::New(desc).ToLocalChecked());
1966 info.GetReturnValue().Set(Nan::Undefined());
1970 const Nan::FunctionCallbackInfo<v8::Value>&
info) {
1972 auto val = Nan::To<double>(info[1]).FromJust();
1977 info.GetReturnValue().Set(Nan::New(desc).ToLocalChecked());
1979 info.GetReturnValue().Set(Nan::Undefined());
1984 auto val = Nan::To<double>(info[1]).FromJust();
1986 static_cast<rs2_option>(option),
val, &error_);
1987 info.GetReturnValue().Set(Nan::Undefined());
1991 const Nan::FunctionCallbackInfo<v8::Value>&
info) {
1998 static_cast<rs2_option>(option), &min, &max, &step, &def, &error_);
2003 const Nan::FunctionCallbackInfo<v8::Value>&
info) {
2007 info.GetReturnValue().Set(Nan::New((
val) ?
true :
false));
2016 static void Init(v8::Local<v8::Object> exports) {
2017 v8::Local<v8::FunctionTemplate> tpl = Nan::New<v8::FunctionTemplate>(New);
2018 tpl->SetClassName(Nan::New(
"RSSensor").ToLocalChecked());
2019 tpl->InstanceTemplate()->SetInternalFieldCount(1);
2021 Nan::SetPrototypeMethod(tpl,
"destroy", Destroy);
2022 Nan::SetPrototypeMethod(tpl,
"openStream", OpenStream);
2023 Nan::SetPrototypeMethod(tpl,
"openMultipleStream", OpenMultipleStream);
2024 Nan::SetPrototypeMethod(tpl,
"getCameraInfo", GetCameraInfo);
2025 Nan::SetPrototypeMethod(tpl,
"startWithSyncer", StartWithSyncer);
2026 Nan::SetPrototypeMethod(tpl,
"startWithCallback", StartWithCallback);
2027 Nan::SetPrototypeMethod(tpl,
"supportsOption", SupportsOption);
2028 Nan::SetPrototypeMethod(tpl,
"getOption", GetOption);
2029 Nan::SetPrototypeMethod(tpl,
"setOption", SetOption);
2030 Nan::SetPrototypeMethod(tpl,
"getOptionRange", GetOptionRange);
2031 Nan::SetPrototypeMethod(tpl,
"isOptionReadonly", IsOptionReadonly);
2032 Nan::SetPrototypeMethod(tpl,
"getOptionDescription", GetOptionDescription);
2033 Nan::SetPrototypeMethod(tpl,
"getOptionValueDescription",
2034 GetOptionValueDescription);
2035 Nan::SetPrototypeMethod(tpl,
"stop", Stop);
2036 Nan::SetPrototypeMethod(tpl,
"supportsCameraInfo", SupportsCameraInfo);
2037 Nan::SetPrototypeMethod(tpl,
"getStreamProfiles", GetStreamProfiles);
2038 Nan::SetPrototypeMethod(tpl,
"close", Close);
2039 Nan::SetPrototypeMethod(tpl,
"setNotificationCallback",
2040 SetNotificationCallback);
2041 Nan::SetPrototypeMethod(tpl,
"setRegionOfInterest", SetRegionOfInterest);
2042 Nan::SetPrototypeMethod(tpl,
"getRegionOfInterest", GetRegionOfInterest);
2043 Nan::SetPrototypeMethod(tpl,
"getDepthScale",
GetDepthScale);
2044 Nan::SetPrototypeMethod(tpl,
"isROISensor", IsROISensor);
2045 Nan::SetPrototypeMethod(tpl,
"is",
Is);
2047 v8::Local<v8::Context> context = exports->CreationContext();
2048 constructor_.Reset(tpl->GetFunction(context).ToLocalChecked());
2049 exports->Set(context, Nan::New(
"RSSensor").ToLocalChecked(),
2050 tpl->GetFunction(context).ToLocalChecked());
2054 Nan::EscapableHandleScope scope;
2056 v8::Local<v8::Function> cons = Nan::New<v8::Function>(constructor_);
2059 v8::Local<v8::Object> instance =
2060 cons->NewInstance(context, 0,
nullptr).ToLocalChecked();
2062 auto me = Nan::ObjectWrap::Unwrap<RSSensor>(instance);
2064 return scope.Escape(instance);
2075 frame_->Replace(
nullptr);
2076 video_frame_->Replace(
nullptr);
2077 depth_frame_->Replace(
nullptr);
2078 disparity_frame_->Replace(
nullptr);
2079 motion_frame_->Replace(
nullptr);
2080 pose_frame_->Replace(
nullptr);
2084 disparity_frame_->Replace(raw_frame);
2087 depth_frame_->Replace(raw_frame);
2090 video_frame_->Replace(raw_frame);
2093 motion_frame_->Replace(raw_frame);
2096 pose_frame_->Replace(raw_frame);
2098 frame_->Replace(raw_frame);
2103 RSSensor() : sensor_(nullptr), error_(nullptr), profile_list_(nullptr),
2104 frame_(nullptr), video_frame_(nullptr), depth_frame_(nullptr),
2105 disparity_frame_(nullptr), motion_frame_(nullptr), pose_frame_(nullptr) {}
2111 void RegisterNotificationCallbackMethod();
2119 profile_list_ =
nullptr;
2122 static void New(
const Nan::FunctionCallbackInfo<v8::Value>&
info) {
2123 if (info.IsConstructCall()) {
2125 obj->Wrap(info.This());
2126 info.GetReturnValue().Set(info.This());
2131 auto me = Nan::ObjectWrap::Unwrap<RSSensor>(
info.Holder());
2132 if (me)
return me->SupportsOptionInternal(
info);
2134 info.GetReturnValue().Set(Nan::False());
2138 auto me = Nan::ObjectWrap::Unwrap<RSSensor>(
info.Holder());
2139 if (me)
return me->GetOptionInternal(
info);
2141 info.GetReturnValue().Set(Nan::Undefined());
2145 auto me = Nan::ObjectWrap::Unwrap<RSSensor>(
info.Holder());
2146 if (me)
return me->GetOptionDescriptionInternal(
info);
2148 info.GetReturnValue().Set(Nan::Undefined());
2152 auto me = Nan::ObjectWrap::Unwrap<RSSensor>(
info.Holder());
2153 if (me)
return me->GetOptionValueDescriptionInternal(
info);
2155 info.GetReturnValue().Set(Nan::Undefined());
2159 auto me = Nan::ObjectWrap::Unwrap<RSSensor>(
info.Holder());
2160 if (me)
return me->SetOptionInternal(
info);
2162 info.GetReturnValue().Set(Nan::Undefined());
2166 auto me = Nan::ObjectWrap::Unwrap<RSSensor>(
info.Holder());
2167 if (me)
return me->GetOptionRangeInternal(
info);
2169 info.GetReturnValue().Set(Nan::Undefined());
2173 auto me = Nan::ObjectWrap::Unwrap<RSSensor>(
info.Holder());
2174 if (me)
return me->IsOptionReadonlyInternal(
info);
2176 info.GetReturnValue().Set(Nan::False());
2180 info.GetReturnValue().Set(Nan::Undefined());
2181 int32_t camera_info = Nan::To<int32_t>(
info[0]).FromJust();
2182 auto me = Nan::ObjectWrap::Unwrap<RSSensor>(
info.Holder());
2188 if (me->error_)
return;
2190 info.GetReturnValue().Set(Nan::New(
value).ToLocalChecked());
2194 info.GetReturnValue().Set(Nan::Undefined());
2195 auto syncer = Nan::ObjectWrap::Unwrap<RSSyncer>(Nan::To<v8::Object>(
info[0]).ToLocalChecked());
2196 auto me = Nan::ObjectWrap::Unwrap<RSSensor>(
info.Holder());
2197 if (!me || !syncer)
return;
2204 auto frame = Nan::ObjectWrap::Unwrap<RSFrame>(Nan::To<v8::Object>(
info[1]).ToLocalChecked());
2205 auto depth_frame = Nan::ObjectWrap::Unwrap<RSFrame>(Nan::To<v8::Object>(
info[2]).ToLocalChecked());
2206 auto video_frame = Nan::ObjectWrap::Unwrap<RSFrame>(Nan::To<v8::Object>(
info[3]).ToLocalChecked());
2207 auto disparity_frame = Nan::ObjectWrap::Unwrap<RSFrame>(Nan::To<v8::Object>(
info[4]).ToLocalChecked());
2208 auto motion_frame = Nan::ObjectWrap::Unwrap<RSFrame>(Nan::To<v8::Object>(
info[5]).ToLocalChecked());
2209 auto pose_frame = Nan::ObjectWrap::Unwrap<RSFrame>(Nan::To<v8::Object>(
info[6]).ToLocalChecked());
2210 auto me = Nan::ObjectWrap::Unwrap<RSSensor>(
info.Holder());
2211 if (me && frame && depth_frame && video_frame && disparity_frame &&
2212 motion_frame && pose_frame) {
2215 me->video_frame_ = video_frame;
2216 me->disparity_frame_ = disparity_frame;
2217 me->motion_frame_ = motion_frame;
2218 me->pose_frame_ = pose_frame;
2224 info.GetReturnValue().Set(Nan::Undefined());
2228 auto me = Nan::ObjectWrap::Unwrap<RSSensor>(
info.Holder());
2232 info.GetReturnValue().Set(Nan::Undefined());
2236 info.GetReturnValue().Set(Nan::Undefined());
2237 auto me = Nan::ObjectWrap::Unwrap<RSSensor>(
info.Holder());
2239 Nan::ObjectWrap::Unwrap<RSStreamProfile>(Nan::To<v8::Object>(
info[0]).ToLocalChecked());
2240 if (!me || !profile)
return;
2247 info.GetReturnValue().Set(Nan::Undefined());
2248 auto me = Nan::ObjectWrap::Unwrap<RSSensor>(
info.Holder());
2251 auto array = v8::Local<v8::Array>::Cast(
info[0]);
2253 std::vector<const rs2_stream_profile*> profs;
2254 v8::Local<v8::Context> context =
info.GetIsolate()->GetCurrentContext();
2257 Nan::ObjectWrap::Unwrap<RSStreamProfile>(Nan::To<v8::Object>(
array->Get(context,
i).ToLocalChecked()).ToLocalChecked());
2258 profs.push_back(
profile->profile_);
2265 auto me = Nan::ObjectWrap::Unwrap<RSSensor>(
info.Holder());
2272 info.GetReturnValue().Set(Nan::Undefined());
2273 auto me = Nan::ObjectWrap::Unwrap<RSSensor>(
info.Holder());
2279 &me->error_, me->sensor_, &me->error_);
2280 me->profile_list_ = list;
2285 &me->error_, list, &me->error_);
2287 v8::Local<v8::Context> context =
info.GetIsolate()->GetCurrentContext();
2288 v8::Local<v8::Array>
array = Nan::New<v8::Array>(
size);
2294 info.GetReturnValue().Set(array);
2298 info.GetReturnValue().Set(Nan::False());
2299 int32_t camera_info = Nan::To<int32_t>(
info[0]).FromJust();
2300 auto me = Nan::ObjectWrap::Unwrap<RSSensor>(
info.Holder());
2305 info.GetReturnValue().Set(Nan::New(on ?
true :
false));
2309 auto me = Nan::ObjectWrap::Unwrap<RSSensor>(
info.Holder());
2316 auto me = Nan::ObjectWrap::Unwrap<RSSensor>(
info.Holder());
2319 Nan::Utf8String
value(Nan::To<v8::String>(
info[0]).ToLocalChecked());
2320 me->notification_callback_name_ =
std::string(*value);
2321 me->RegisterNotificationCallbackMethod();
2325 info.GetReturnValue().Set(Nan::Undefined());
2326 int32_t minx = Nan::To<int32_t>(
info[0]).FromJust();
2327 int32_t miny = Nan::To<int32_t>(
info[1]).FromJust();
2328 int32_t maxx = Nan::To<int32_t>(
info[2]).FromJust();
2329 int32_t maxy = Nan::To<int32_t>(
info[3]).FromJust();
2330 auto me = Nan::ObjectWrap::Unwrap<RSSensor>(
info.Holder());
2334 miny, maxx, maxy, &me->error_);
2338 info.GetReturnValue().Set(Nan::Undefined());
2343 auto me = Nan::ObjectWrap::Unwrap<RSSensor>(
info.Holder());
2347 &miny, &maxx, &maxy, &me->error_);
2348 if (me->error_)
return;
2349 info.GetReturnValue().Set(
2354 info.GetReturnValue().Set(Nan::Undefined());
2355 auto me = Nan::ObjectWrap::Unwrap<RSSensor>(
info.Holder());
2359 me->sensor_, &me->error_);
2360 if (me->error_)
return;
2362 info.GetReturnValue().Set(Nan::New(
scale));
2366 info.GetReturnValue().Set(Nan::Undefined());
2367 int32_t stype = Nan::To<int32_t>(
info[0]).FromJust();
2369 auto me = Nan::ObjectWrap::Unwrap<RSSensor>(
info.Holder());
2373 &me->error_, me->sensor_,
static_cast<rs2_extension>(stype), &me->error_);
2374 if (me->error_)
return;
2376 info.GetReturnValue().Set(Nan::New(is_ok));
2380 info.GetReturnValue().Set(Nan::Undefined());
2381 auto me = Nan::ObjectWrap::Unwrap<RSSensor>(
info.Holder());
2386 if (me->error_)
return;
2388 info.GetReturnValue().Set(Nan::New(is_roi));
2441 static void Init(v8::Local<v8::Object> exports) {
2442 v8::Local<v8::FunctionTemplate> tpl = Nan::New<v8::FunctionTemplate>(New);
2443 tpl->SetClassName(Nan::New(
"RSDevice").ToLocalChecked());
2444 tpl->InstanceTemplate()->SetInternalFieldCount(1);
2446 Nan::SetPrototypeMethod(tpl,
"destroy", Destroy);
2447 Nan::SetPrototypeMethod(tpl,
"getCameraInfo", GetCameraInfo);
2448 Nan::SetPrototypeMethod(tpl,
"supportsCameraInfo", SupportsCameraInfo);
2449 Nan::SetPrototypeMethod(tpl,
"reset", Reset);
2450 Nan::SetPrototypeMethod(tpl,
"querySensors", QuerySensors);
2451 Nan::SetPrototypeMethod(tpl,
"triggerErrorForTest", TriggerErrorForTest);
2452 Nan::SetPrototypeMethod(tpl,
"spawnRecorderDevice", SpawnRecorderDevice);
2455 Nan::SetPrototypeMethod(tpl,
"pauseRecord", PauseRecord);
2456 Nan::SetPrototypeMethod(tpl,
"resumeRecord", ResumeRecord);
2457 Nan::SetPrototypeMethod(tpl,
"getFileName", GetFileName);
2458 Nan::SetPrototypeMethod(tpl,
"pausePlayback", PausePlayback);
2459 Nan::SetPrototypeMethod(tpl,
"resumePlayback", ResumePlayback);
2460 Nan::SetPrototypeMethod(tpl,
"stopPlayback", StopPlayback);
2461 Nan::SetPrototypeMethod(tpl,
"getPosition", GetPosition);
2462 Nan::SetPrototypeMethod(tpl,
"getDuration", GetDuration);
2463 Nan::SetPrototypeMethod(tpl,
"seek", Seek);
2464 Nan::SetPrototypeMethod(tpl,
"isRealTime", IsRealTime);
2465 Nan::SetPrototypeMethod(tpl,
"setIsRealTime", SetIsRealTime);
2466 Nan::SetPrototypeMethod(tpl,
"setPlaybackSpeed", SetPlaybackSpeed);
2467 Nan::SetPrototypeMethod(tpl,
"getCurrentStatus", GetCurrentStatus);
2468 Nan::SetPrototypeMethod(tpl,
"setStatusChangedCallbackMethodName",
2469 SetStatusChangedCallbackMethodName);
2470 Nan::SetPrototypeMethod(tpl,
"isTm2", IsTm2);
2471 Nan::SetPrototypeMethod(tpl,
"isPlayback", IsPlayback);
2472 Nan::SetPrototypeMethod(tpl,
"isRecorder", IsRecorder);
2475 Nan::SetPrototypeMethod(tpl,
"enableLoopback", EnableLoopback);
2476 Nan::SetPrototypeMethod(tpl,
"disableLoopback", DisableLoopback);
2477 Nan::SetPrototypeMethod(tpl,
"isLoopbackEnabled", IsLoopbackEnabled);
2479 v8::Local<v8::Context> context = exports->CreationContext();
2480 constructor_.Reset(tpl->GetFunction(context).ToLocalChecked());
2481 exports->Set(context, Nan::New(
"RSDevice").ToLocalChecked(),
2482 tpl->GetFunction(context).ToLocalChecked());
2487 Nan::EscapableHandleScope scope;
2489 v8::Local<v8::Function> cons = Nan::New<v8::Function>(constructor_);
2492 v8::Local<v8::Object> instance =
2493 cons->NewInstance(context, 0,
nullptr).ToLocalChecked();
2495 auto me = Nan::ObjectWrap::Unwrap<RSDevice>(instance);
2499 return scope.Escape(instance);
2504 error_(nullptr), type_(
type) {}
2517 static void New(
const Nan::FunctionCallbackInfo<v8::Value>&
info) {
2518 if (info.IsConstructCall()) {
2520 obj->Wrap(info.This());
2521 info.GetReturnValue().Set(info.This());
2526 info.GetReturnValue().Set(Nan::Undefined());
2527 int32_t camera_info = Nan::To<int32_t>(
info[0]).FromJust();
2528 auto me = Nan::ObjectWrap::Unwrap<RSDevice>(
info.Holder());
2534 if (me->error_)
return;
2536 info.GetReturnValue().Set(Nan::New(
value).ToLocalChecked());
2540 auto me = Nan::ObjectWrap::Unwrap<RSDevice>(
info.Holder());
2544 info.GetReturnValue().Set(Nan::Undefined());
2549 info.GetReturnValue().Set(Nan::False());
2550 int32_t camera_info = Nan::To<int32_t>(
info[0]).FromJust();
2551 auto me = Nan::ObjectWrap::Unwrap<RSDevice>(
info.Holder());
2556 if (me->error_)
return;
2557 info.GetReturnValue().Set(Nan::New(on ?
true :
false));
2561 auto me = Nan::ObjectWrap::Unwrap<RSDevice>(
info.Holder());
2568 info.GetReturnValue().Set(Nan::Undefined());
2569 auto me = Nan::ObjectWrap::Unwrap<RSDevice>(
info.Holder());
2572 std::shared_ptr<rs2_sensor_list> list(
2578 list.get(), &me->error_);
2581 v8::Local<v8::Array>
array = Nan::New<v8::Array>();
2582 v8::Local<v8::Context> context =
info.GetIsolate()->GetCurrentContext();
2585 &me->error_, list.get(),
i, &me->error_);
2588 info.GetReturnValue().Set(array);
2592 info.GetReturnValue().Set(Nan::Undefined());
2593 auto me = Nan::ObjectWrap::Unwrap<RSDevice>(
info.Holder());
2603 static_cast<void*>(raw_data), 24, &me->error_);
2607 auto me = Nan::ObjectWrap::Unwrap<RSDevice>(
info.Holder());
2608 info.GetReturnValue().Set(Nan::Undefined());
2611 Nan::Utf8String file(Nan::To<v8::String>(
info[0]).ToLocalChecked());
2613 &me->error_, me->dev_, *file, &me->error_);
2614 if (me->error_)
return;
2617 info.GetReturnValue().Set(
obj);
2621 info.GetReturnValue().Set(Nan::Undefined());
2622 auto me = Nan::ObjectWrap::Unwrap<RSDevice>(
info.Holder());
2630 info.GetReturnValue().Set(Nan::Undefined());
2631 auto me = Nan::ObjectWrap::Unwrap<RSDevice>(
info.Holder());
2639 auto me = Nan::ObjectWrap::Unwrap<RSDevice>(
info.Holder());
2640 info.GetReturnValue().Set(Nan::Undefined());
2643 const char* file =
nullptr;
2644 if (me->IsPlaybackInternal()) {
2646 &me->error_, me->dev_, &me->error_);
2647 }
else if (me->IsRecorderInternal()) {
2649 &me->error_, me->dev_, &me->error_);
2653 if (me->error_)
return;
2655 info.GetReturnValue().Set(Nan::New(file).ToLocalChecked());
2659 info.GetReturnValue().Set(Nan::Undefined());
2660 auto me = Nan::ObjectWrap::Unwrap<RSDevice>(
info.Holder());
2668 info.GetReturnValue().Set(Nan::Undefined());
2669 auto me = Nan::ObjectWrap::Unwrap<RSDevice>(
info.Holder());
2677 info.GetReturnValue().Set(Nan::Undefined());
2678 auto me = Nan::ObjectWrap::Unwrap<RSDevice>(
info.Holder());
2686 auto me = Nan::ObjectWrap::Unwrap<RSDevice>(
info.Holder());
2687 info.GetReturnValue().Set(Nan::Undefined());
2690 auto pos =
static_cast<uint32_t>(GetNativeResult<uint32_t>(
2692 info.GetReturnValue().Set(Nan::New(
pos));
2696 auto me = Nan::ObjectWrap::Unwrap<RSDevice>(
info.Holder());
2697 info.GetReturnValue().Set(Nan::Undefined());
2700 auto duration =
static_cast<uint32_t>(
2702 me->dev_, &me->error_)/1000000);
2703 info.GetReturnValue().Set(Nan::New(duration));
2707 auto me = Nan::ObjectWrap::Unwrap<RSDevice>(
info.Holder());
2708 info.GetReturnValue().Set(Nan::Undefined());
2717 auto me = Nan::ObjectWrap::Unwrap<RSDevice>(
info.Holder());
2718 info.GetReturnValue().Set(Nan::Undefined());
2722 &me->error_, me->dev_, &me->error_);
2723 if (me->error_)
return;
2725 info.GetReturnValue().Set(
val ? Nan::True() : Nan::False());
2729 auto me = Nan::ObjectWrap::Unwrap<RSDevice>(
info.Holder());
2730 info.GetReturnValue().Set(Nan::Undefined());
2733 auto val = Nan::To<bool>(
info[0]).FromJust();
2735 me->dev_,
val, &me->error_);
2739 auto me = Nan::ObjectWrap::Unwrap<RSDevice>(
info.Holder());
2740 info.GetReturnValue().Set(Nan::Undefined());
2743 auto speed = Nan::To<double>(
info[0]).FromJust();
2745 me->dev_, speed, &me->error_);
2749 auto me = Nan::ObjectWrap::Unwrap<RSDevice>(
info.Holder());
2750 info.GetReturnValue().Set(Nan::Undefined());
2753 auto val = me->IsPlaybackInternal();
2754 info.GetReturnValue().Set(
val ? Nan::True() : Nan::False());
2758 auto me = Nan::ObjectWrap::Unwrap<RSDevice>(
info.Holder());
2759 info.GetReturnValue().Set(Nan::Undefined());
2762 auto val = me->IsRecorderInternal();
2763 info.GetReturnValue().Set(
val ? Nan::True() : Nan::False());
2767 auto me = Nan::ObjectWrap::Unwrap<RSDevice>(
info.Holder());
2768 info.GetReturnValue().Set(Nan::Undefined());
2771 auto status = GetNativeResult<rs2_playback_status>(
2773 me->dev_, &me->error_);
2774 if (me->error_)
return;
2780 auto me = Nan::ObjectWrap::Unwrap<RSDevice>(
info.Holder());
2781 info.GetReturnValue().Set(Nan::Undefined());
2784 Nan::Utf8String method(Nan::To<v8::String>(
info[0]).ToLocalChecked());
2785 me->status_changed_callback_method_name_ =
std::string(*method);
2791 auto me = Nan::ObjectWrap::Unwrap<RSDevice>(
info.Holder());
2792 info.GetReturnValue().Set(Nan::Undefined());
2797 info.GetReturnValue().Set(
val ? Nan::True() : Nan::False());
2801 auto me = Nan::ObjectWrap::Unwrap<RSDevice>(
info.Holder());
2802 info.GetReturnValue().Set(Nan::Undefined());
2805 Nan::Utf8String file(Nan::To<v8::String>(
info[0]).ToLocalChecked());
2811 auto me = Nan::ObjectWrap::Unwrap<RSDevice>(
info.Holder());
2812 info.GetReturnValue().Set(Nan::Undefined());
2820 auto me = Nan::ObjectWrap::Unwrap<RSDevice>(
info.Holder());
2821 info.GetReturnValue().Set(Nan::Undefined());
2825 me->dev_, &me->error_);
2826 info.GetReturnValue().Set(
val ? Nan::True() : Nan::False());
2834 return (error_ || !
val) ?
false :
true;
2841 return (error_ || !
val) ?
false :
true;
2861 Nan::HandleScope scope;
2863 sensor_->ReplaceFrame(frame_);
2865 Nan::AsyncResource resource(
"frame_callback_name_");
2866 resource.runInAsyncScope(sensor_->handle(), sensor_->frame_callback_name_.c_str(), 0,
nullptr);
2873 Nan::HandleScope scope;
2874 v8::Local<v8::Value>
args[1] = {
2876 desc_, time_, severity_, category_, serialized_data_).
GetObject()
2879 Nan::AsyncResource resource(
"notification_callback_name_");
2880 resource.runInAsyncScope(sensor_->handle(), sensor_->notification_callback_name_.c_str(), 1,
args);
2887 Nan::HandleScope scope;
2888 v8::Local<v8::Value>
args[1] = { Nan::New(
status_) };
2889 Nan::AsyncResource resource(
"status_changed_callback_method_name_");
2897 static void Init(v8::Local<v8::Object> exports) {
2898 v8::Local<v8::FunctionTemplate> tpl = Nan::New<v8::FunctionTemplate>(New);
2899 tpl->SetClassName(Nan::New(
"RSPointCloud").ToLocalChecked());
2900 tpl->InstanceTemplate()->SetInternalFieldCount(1);
2902 Nan::SetPrototypeMethod(tpl,
"destroy", Destroy);
2903 Nan::SetPrototypeMethod(tpl,
"calculate", Calculate);
2904 Nan::SetPrototypeMethod(tpl,
"mapTo", MapTo);
2907 Nan::SetPrototypeMethod(tpl,
"supportsOption", SupportsOption);
2908 Nan::SetPrototypeMethod(tpl,
"getOption", GetOption);
2909 Nan::SetPrototypeMethod(tpl,
"setOption", SetOption);
2910 Nan::SetPrototypeMethod(tpl,
"getOptionRange", GetOptionRange);
2911 Nan::SetPrototypeMethod(tpl,
"isOptionReadonly", IsOptionReadonly);
2912 Nan::SetPrototypeMethod(tpl,
"getOptionDescription", GetOptionDescription);
2913 Nan::SetPrototypeMethod(tpl,
"getOptionValueDescription",
2914 GetOptionValueDescription);
2916 v8::Local<v8::Context> context = exports->CreationContext();
2917 constructor_.Reset(tpl->GetFunction(context).ToLocalChecked());
2918 exports->Set(context, Nan::New(
"RSPointCloud").ToLocalChecked(),
2919 tpl->GetFunction(context).ToLocalChecked());
2924 return reinterpret_cast<rs2_options*
>(processing_block_);
2940 processing_block_ =
nullptr;
2942 frame_queue_ =
nullptr;
2946 auto me = Nan::ObjectWrap::Unwrap<RSPointCloud>(
info.Holder());
2950 info.GetReturnValue().Set(Nan::Undefined());
2953 static void New(
const Nan::FunctionCallbackInfo<v8::Value>&
info) {
2954 if (info.IsConstructCall()) {
2962 obj->Wrap(info.This());
2963 info.GetReturnValue().Set(info.This());
2968 info.GetReturnValue().Set(Nan::False());
2969 auto me = Nan::ObjectWrap::Unwrap<RSPointCloud>(
info.Holder());
2970 auto frame = Nan::ObjectWrap::Unwrap<RSFrame>(Nan::To<v8::Object>(
info[0]).ToLocalChecked());
2971 auto target_frame = Nan::ObjectWrap::Unwrap<RSFrame>(Nan::To<v8::Object>(
info[1]).ToLocalChecked());
2972 if (!me || !frame || !frame->frame_ || !target_frame)
return;
2976 if (me->error_)
return;
2979 frame->frame_, &me->error_);
2980 if (me->error_)
return;
2983 &me->error_, me->frame_queue_, 5000, &me->error_);
2984 if (!new_frame)
return;
2986 target_frame->Replace(new_frame);
2987 info.GetReturnValue().Set(Nan::True());
2991 auto me = Nan::ObjectWrap::Unwrap<RSPointCloud>(
info.Holder());
2992 auto frame = Nan::ObjectWrap::Unwrap<RSFrame>(Nan::To<v8::Object>(
info[0]).ToLocalChecked());
2993 info.GetReturnValue().Set(Nan::Undefined());
2994 if (!me || !frame)
return;
2998 &me->error_, frame->frame_, &me->error_);
2999 if (!profile)
return;
3003 reinterpret_cast<rs2_options*>(me->processing_block_),
3005 static_cast<float>(extrator.
stream_),
3009 reinterpret_cast<rs2_options*>(me->processing_block_),
3011 static_cast<float>(extrator.
format_),
3015 reinterpret_cast<rs2_options*>(me->processing_block_),
3017 static_cast<float>(extrator.
index_),
3024 if (me->error_)
return;
3027 frame->frame_, &me->error_);
3031 auto me = Nan::ObjectWrap::Unwrap<RSPointCloud>(
info.Holder());
3032 if (me)
return me->SupportsOptionInternal(
info);
3034 info.GetReturnValue().Set(Nan::False());
3038 auto me = Nan::ObjectWrap::Unwrap<RSPointCloud>(
info.Holder());
3039 if (me)
return me->GetOptionInternal(
info);
3041 info.GetReturnValue().Set(Nan::Undefined());
3045 auto me = Nan::ObjectWrap::Unwrap<RSPointCloud>(
info.Holder());
3046 if (me)
return me->GetOptionDescriptionInternal(
info);
3048 info.GetReturnValue().Set(Nan::Undefined());
3052 auto me = Nan::ObjectWrap::Unwrap<RSPointCloud>(
info.Holder());
3053 if (me)
return me->GetOptionValueDescriptionInternal(
info);
3055 info.GetReturnValue().Set(Nan::Undefined());
3059 auto me = Nan::ObjectWrap::Unwrap<RSPointCloud>(
info.Holder());
3060 if (me)
return me->SetOptionInternal(
info);
3062 info.GetReturnValue().Set(Nan::Undefined());
3066 auto me = Nan::ObjectWrap::Unwrap<RSPointCloud>(
info.Holder());
3067 if (me)
return me->GetOptionRangeInternal(
info);
3069 info.GetReturnValue().Set(Nan::Undefined());
3073 auto me = Nan::ObjectWrap::Unwrap<RSPointCloud>(
info.Holder());
3074 if (me)
return me->IsOptionReadonlyInternal(
info);
3076 info.GetReturnValue().Set(Nan::False());
3091 static void Init(v8::Local<v8::Object> exports) {
3092 v8::Local<v8::FunctionTemplate> tpl = Nan::New<v8::FunctionTemplate>(New);
3093 tpl->SetClassName(Nan::New(
"RSDeviceList").ToLocalChecked());
3094 tpl->InstanceTemplate()->SetInternalFieldCount(1);
3096 Nan::SetPrototypeMethod(tpl,
"destroy", Destroy);
3097 Nan::SetPrototypeMethod(tpl,
"contains",
Contains);
3098 Nan::SetPrototypeMethod(tpl,
"size", Size);
3099 Nan::SetPrototypeMethod(tpl,
"getDevice", GetDevice);
3101 v8::Local<v8::Context> context = exports->CreationContext();
3102 constructor_.Reset(tpl->GetFunction(context).ToLocalChecked());
3103 exports->Set(context, Nan::New(
"RSDeviceList").ToLocalChecked(),
3104 tpl->GetFunction(context).ToLocalChecked());
3108 Nan::EscapableHandleScope scope;
3109 v8::Local<v8::Function> cons = Nan::New<v8::Function>(constructor_);
3111 v8::Local<v8::Object> instance =
3112 cons->NewInstance(context, 0,
nullptr).ToLocalChecked();
3113 auto me = Nan::ObjectWrap::Unwrap<RSDeviceList>(instance);
3115 return scope.Escape(instance);
3132 static void New(
const Nan::FunctionCallbackInfo<v8::Value>&
info) {
3133 if (info.IsConstructCall()) {
3135 obj->Wrap(info.This());
3136 info.GetReturnValue().Set(info.This());
3141 auto me = Nan::ObjectWrap::Unwrap<RSDeviceList>(
info.Holder());
3142 if (me) me->DestroyMe();
3144 info.GetReturnValue().Set(Nan::Undefined());
3148 info.GetReturnValue().Set(Nan::Undefined());
3149 auto me = Nan::ObjectWrap::Unwrap<RSDeviceList>(
info.Holder());
3150 auto dev = Nan::ObjectWrap::Unwrap<RSDevice>(Nan::To<v8::Object>(
info[0]).ToLocalChecked());
3151 if (!me && dev)
return;
3154 me->list_, dev->dev_, &me->error_);
3155 if (me->error_)
return;
3157 info.GetReturnValue().Set(Nan::New(contains));
3161 info.GetReturnValue().Set(Nan::Undefined());
3162 auto me = Nan::ObjectWrap::Unwrap<RSDeviceList>(
info.Holder());
3166 me->list_, &me->error_);
3167 if (me->error_)
return;
3169 info.GetReturnValue().Set(Nan::New(cnt));
3173 info.GetReturnValue().Set(Nan::Undefined());
3174 auto me = Nan::ObjectWrap::Unwrap<RSDeviceList>(
info.Holder());
3175 auto index = Nan::To<int64_t>(
info[0]).FromJust();
3179 me->list_,
index, &me->error_);
3217 static void Init(v8::Local<v8::Object> exports) {
3218 v8::Local<v8::FunctionTemplate> tpl = Nan::New<v8::FunctionTemplate>(New);
3219 tpl->SetClassName(Nan::New(
"RSContext").ToLocalChecked());
3220 tpl->InstanceTemplate()->SetInternalFieldCount(1);
3222 Nan::SetPrototypeMethod(tpl,
"destroy", Destroy);
3223 Nan::SetPrototypeMethod(tpl,
"create", Create);
3224 Nan::SetPrototypeMethod(tpl,
"queryDevices", QueryDevices);
3225 Nan::SetPrototypeMethod(tpl,
"setDevicesChangedCallback",
3226 SetDevicesChangedCallback);
3227 Nan::SetPrototypeMethod(tpl,
"loadDeviceFile", LoadDeviceFile);
3228 Nan::SetPrototypeMethod(tpl,
"unloadDeviceFile", UnloadDeviceFile);
3229 Nan::SetPrototypeMethod(tpl,
"createDeviceFromSensor",
3230 CreateDeviceFromSensor);
3232 v8::Local<v8::Context> context = exports->CreationContext();
3233 constructor_.Reset(tpl->GetFunction(context).ToLocalChecked());
3234 exports->Set(context, Nan::New(
"RSContext").ToLocalChecked(),
3235 tpl->GetFunction(context).ToLocalChecked());
3239 Nan::EscapableHandleScope scope;
3241 v8::Local<v8::Function> cons = Nan::New<v8::Function>(constructor_);
3244 v8::Local<v8::Object> instance =
3245 cons->NewInstance(context, 0,
nullptr).ToLocalChecked();
3249 auto me = Nan::ObjectWrap::Unwrap<RSContext>(instance);
3252 return scope.Escape(instance);
3263 void RegisterDevicesChangedCallbackMethod();
3272 static void New(
const Nan::FunctionCallbackInfo<v8::Value>&
info) {
3273 if (!info.IsConstructCall())
return;
3276 if (info.Length()) {
3277 Nan::Utf8String type_str(Nan::To<v8::String>(info[0]).ToLocalChecked());
3279 if (!std_type_str.compare(
"recording"))
3281 else if (!std_type_str.compare(
"playback"))
3285 if (type == kRecording || type == kPlayback) {
3286 Nan::Utf8String file(Nan::To<v8::String>(info[1]).ToLocalChecked());
3287 Nan::Utf8String
section(Nan::To<v8::String>(info[2]).ToLocalChecked());
3291 if (type == kRecording)
3293 obj->Wrap(info.This());
3294 info.GetReturnValue().Set(info.This());
3299 info.GetReturnValue().Set(Nan::Undefined());
3300 auto me = Nan::ObjectWrap::Unwrap<RSContext>(
info.Holder());
3303 switch (me->type_) {
3307 me->section_.c_str(), me->mode_, &me->error_);
3312 me->section_.c_str(), &me->error_);
3322 auto me = Nan::ObjectWrap::Unwrap<RSContext>(
info.Holder());
3326 info.GetReturnValue().Set(Nan::Undefined());
3330 auto me = Nan::ObjectWrap::Unwrap<RSContext>(
info.Holder());
3332 Nan::Utf8String
value(Nan::To<v8::String>(
info[0]).ToLocalChecked());
3333 me->device_changed_callback_name_ =
std::string(*value);
3334 me->RegisterDevicesChangedCallbackMethod();
3336 info.GetReturnValue().Set(Nan::Undefined());
3340 info.GetReturnValue().Set(Nan::Undefined());
3341 auto me = Nan::ObjectWrap::Unwrap<RSContext>(
info.Holder());
3344 Nan::Utf8String
value(Nan::To<v8::String>(
info[0]).ToLocalChecked());
3346 me->ctx_, *
value, &me->error_);
3350 info.GetReturnValue().Set(jsobj);
3354 auto me = Nan::ObjectWrap::Unwrap<RSContext>(
info.Holder());
3355 info.GetReturnValue().Set(Nan::Undefined());
3358 Nan::Utf8String
value(Nan::To<v8::String>(
info[0]).ToLocalChecked());
3364 info.GetReturnValue().Set(Nan::Undefined());
3365 auto sensor = Nan::ObjectWrap::Unwrap<RSSensor>(Nan::To<v8::Object>(
info[0]).ToLocalChecked());
3374 info.GetReturnValue().Set(jsobj);
3378 info.GetReturnValue().Set(Nan::Undefined());
3379 auto me = Nan::ObjectWrap::Unwrap<RSContext>(
info.Holder());
3383 &me->error_, me->ctx_, &me->error_);
3384 if (!dev_list)
return;
3387 info.GetReturnValue().Set(jsobj);
3411 removed_(r), added_(a), ctx_(ctx) {}
3415 Nan::HandleScope scope;
3416 v8::Local<v8::Value> rmlist;
3417 v8::Local<v8::Value> addlist;
3421 rmlist = Nan::Undefined();
3426 addlist = Nan::Undefined();
3428 v8::Local<v8::Value>
args[2] = {rmlist, addlist};
3430 Nan::AsyncResource resource(
"device_changed_callback_name_");
3431 resource.runInAsyncScope(ctx_->handle(), ctx_->device_changed_callback_name_.c_str(), 2,
args);
3477 static void Init(v8::Local<v8::Object> exports) {
3478 v8::Local<v8::FunctionTemplate> tpl = Nan::New<v8::FunctionTemplate>(New);
3479 tpl->SetClassName(Nan::New(
"RSDeviceHub").ToLocalChecked());
3480 tpl->InstanceTemplate()->SetInternalFieldCount(1);
3482 Nan::SetPrototypeMethod(tpl,
"waitForDevice", WaitForDevice);
3483 Nan::SetPrototypeMethod(tpl,
"isConnected", IsConnected);
3484 Nan::SetPrototypeMethod(tpl,
"destroy", Destroy);
3486 v8::Local<v8::Context> context = exports->CreationContext();
3487 constructor_.Reset(tpl->GetFunction(context).ToLocalChecked());
3488 exports->Set(context, Nan::New(
"RSDeviceHub").ToLocalChecked(),
3489 tpl->GetFunction(context).ToLocalChecked());
3493 Nan::EscapableHandleScope scope;
3495 v8::Local<v8::Function> cons = Nan::New<v8::Function>(constructor_);
3498 v8::Local<v8::Object> instance =
3499 cons->NewInstance(context, 0,
nullptr).ToLocalChecked();
3501 return scope.Escape(instance);
3521 auto me = Nan::ObjectWrap::Unwrap<RSDeviceHub>(
info.Holder());
3522 if (me) me->DestroyMe();
3523 info.GetReturnValue().Set(Nan::Undefined());
3526 static void New(
const Nan::FunctionCallbackInfo<v8::Value>&
info) {
3527 if (info.IsConstructCall()) {
3530 Nan::ObjectWrap::Unwrap<RSContext>(Nan::To<v8::Object>(info[0]).ToLocalChecked());
3534 obj->Wrap(info.This());
3535 info.GetReturnValue().Set(info.This());
3540 info.GetReturnValue().Set(Nan::Undefined());
3541 auto me = Nan::ObjectWrap::Unwrap<RSDeviceHub>(
info.Holder());
3545 &me->error_, me->hub_, &me->error_);
3552 info.GetReturnValue().Set(Nan::Undefined());
3553 auto me = Nan::ObjectWrap::Unwrap<RSDeviceHub>(
info.Holder());
3554 auto dev = Nan::ObjectWrap::Unwrap<RSDevice>(Nan::To<v8::Object>(
info[0]).ToLocalChecked());
3555 if (!me || !dev)
return;
3558 &me->error_, me->hub_, dev->dev_, &me->error_);
3559 if (me->error_)
return;
3561 info.GetReturnValue().Set(Nan::New(
res ?
true :
false));
3576 static void Init(v8::Local<v8::Object> exports) {
3577 v8::Local<v8::FunctionTemplate> tpl = Nan::New<v8::FunctionTemplate>(New);
3578 tpl->SetClassName(Nan::New(
"RSPipelineProfile").ToLocalChecked());
3579 tpl->InstanceTemplate()->SetInternalFieldCount(1);
3581 Nan::SetPrototypeMethod(tpl,
"getStreams", GetStreams);
3582 Nan::SetPrototypeMethod(tpl,
"getDevice", GetDevice);
3583 Nan::SetPrototypeMethod(tpl,
"destroy", Destroy);
3585 v8::Local<v8::Context> context = exports->CreationContext();
3586 constructor_.Reset(tpl->GetFunction(context).ToLocalChecked());
3587 exports->Set(context, Nan::New(
"RSPipelineProfile").ToLocalChecked(),
3588 tpl->GetFunction(context).ToLocalChecked());
3592 Nan::EscapableHandleScope scope;
3594 v8::Local<v8::Function> cons = Nan::New<v8::Function>(constructor_);
3597 v8::Local<v8::Object> instance =
3598 cons->NewInstance(context, 0,
nullptr).ToLocalChecked();
3600 auto me = Nan::ObjectWrap::Unwrap<RSPipelineProfile>(instance);
3601 me->pipeline_profile_ =
profile;
3602 return scope.Escape(instance);
3617 pipeline_profile_ =
nullptr;
3621 auto me = Nan::ObjectWrap::Unwrap<RSPipelineProfile>(
info.Holder());
3622 if (me) me->DestroyMe();
3623 info.GetReturnValue().Set(Nan::Undefined());
3626 static void New(
const Nan::FunctionCallbackInfo<v8::Value>&
info) {
3627 if (info.IsConstructCall()) {
3629 obj->Wrap(info.This());
3630 info.GetReturnValue().Set(info.This());
3635 info.GetReturnValue().Set(Nan::Undefined());
3636 auto me = Nan::ObjectWrap::Unwrap<RSPipelineProfile>(
info.Holder());
3645 &me->error_, list, &me->error_);
3646 if (me->error_)
return;
3648 v8::Local<v8::Array>
array = Nan::New<v8::Array>(
size);
3649 v8::Local<v8::Context> context =
info.GetIsolate()->GetCurrentContext();
3653 &me->error_, list,
i, &me->error_));
3656 info.GetReturnValue().Set(array);
3660 info.GetReturnValue().Set(Nan::Undefined());
3661 auto me = Nan::ObjectWrap::Unwrap<RSPipelineProfile>(
info.Holder());
3684 static void Init(v8::Local<v8::Object> exports) {
3685 v8::Local<v8::FunctionTemplate> tpl = Nan::New<v8::FunctionTemplate>(New);
3686 tpl->SetClassName(Nan::New(
"RSConfig").ToLocalChecked());
3687 tpl->InstanceTemplate()->SetInternalFieldCount(1);
3689 Nan::SetPrototypeMethod(tpl,
"destroy", Destroy);
3690 Nan::SetPrototypeMethod(tpl,
"enableStream", EnableStream);
3691 Nan::SetPrototypeMethod(tpl,
"enableAllStreams", EnableAllStreams);
3692 Nan::SetPrototypeMethod(tpl,
"enableDevice", EnableDevice);
3693 Nan::SetPrototypeMethod(tpl,
"enableDeviceFromFile", EnableDeviceFromFile);
3694 Nan::SetPrototypeMethod(tpl,
"enableRecordToFile", EnableRecordToFile);
3695 Nan::SetPrototypeMethod(tpl,
"disableStream", DisableStream);
3696 Nan::SetPrototypeMethod(tpl,
"disableAllStreams", DisableAllStreams);
3697 Nan::SetPrototypeMethod(tpl,
"resolve", Resolve);
3698 Nan::SetPrototypeMethod(tpl,
"canResolve", CanResolve);
3699 Nan::SetPrototypeMethod(tpl,
"enableDeviceFromFileRepeatOption",
3700 EnableDeviceFromFileRepeatOption);
3702 v8::Local<v8::Context> context = exports->CreationContext();
3703 constructor_.Reset(tpl->GetFunction(context).ToLocalChecked());
3704 exports->Set(context, Nan::New(
"RSConfig").ToLocalChecked(),
3705 tpl->GetFunction(context).ToLocalChecked());
3709 Nan::EscapableHandleScope scope;
3711 v8::Local<v8::Function> cons = Nan::New<v8::Function>(constructor_);
3714 v8::Local<v8::Object> instance =
3715 cons->NewInstance(context, 0,
nullptr).ToLocalChecked();
3717 return scope.Escape(instance);
3735 auto me = Nan::ObjectWrap::Unwrap<RSConfig>(
info.Holder());
3736 if (me) me->DestroyMe();
3737 info.GetReturnValue().Set(Nan::Undefined());
3740 static void New(
const Nan::FunctionCallbackInfo<v8::Value>&
info) {
3741 if (info.IsConstructCall()) {
3744 obj->Wrap(info.This());
3745 info.GetReturnValue().Set(info.This());
3751 info.GetReturnValue().Set(Nan::Undefined());
3752 auto me = Nan::ObjectWrap::Unwrap<RSConfig>(
info.Holder());
3753 auto stream = Nan::To<int64_t>(
info[0]).FromJust();
3754 auto index = Nan::To<int64_t>(
info[1]).FromJust();
3755 auto width = Nan::To<int64_t>(
info[2]).FromJust();
3756 auto height = Nan::To<int64_t>(
info[3]).FromJust();
3757 auto format = Nan::To<int64_t>(
info[4]).FromJust();
3758 auto framerate = Nan::To<int64_t>(
info[5]).FromJust();
3759 if (!me || !me->config_)
return;
3772 info.GetReturnValue().Set(Nan::Undefined());
3773 auto me = Nan::ObjectWrap::Unwrap<RSConfig>(
info.Holder());
3781 info.GetReturnValue().Set(Nan::Undefined());
3782 auto me = Nan::ObjectWrap::Unwrap<RSConfig>(
info.Holder());
3785 Nan::Utf8String
value(Nan::To<v8::String>(
info[0]).ToLocalChecked());
3791 info.GetReturnValue().Set(Nan::Undefined());
3792 auto me = Nan::ObjectWrap::Unwrap<RSConfig>(
info.Holder());
3795 Nan::Utf8String
value(Nan::To<v8::String>(
info[0]).ToLocalChecked());
3797 *value, &me->error_);
3801 info.GetReturnValue().Set(Nan::Undefined());
3802 auto me = Nan::ObjectWrap::Unwrap<RSConfig>(
info.Holder());
3805 auto repeat = Nan::To<bool>(
info[1]).FromJust();
3806 Nan::Utf8String
value(Nan::To<v8::String>(
info[0]).ToLocalChecked());
3808 &me->error_, me->config_, *value,
repeat, &me->error_);
3812 info.GetReturnValue().Set(Nan::Undefined());
3813 auto me = Nan::ObjectWrap::Unwrap<RSConfig>(
info.Holder());
3816 Nan::Utf8String
value(Nan::To<v8::String>(
info[0]).ToLocalChecked());
3818 *value, &me->error_);
3822 info.GetReturnValue().Set(Nan::Undefined());
3823 auto me = Nan::ObjectWrap::Unwrap<RSConfig>(
info.Holder());
3826 auto stream = Nan::To<int64_t>(
info[0]).FromJust();
3832 info.GetReturnValue().Set(Nan::Undefined());
3833 auto me = Nan::ObjectWrap::Unwrap<RSConfig>(
info.Holder());
3854 static void Init(v8::Local<v8::Object> exports) {
3855 v8::Local<v8::FunctionTemplate> tpl = Nan::New<v8::FunctionTemplate>(New);
3856 tpl->SetClassName(Nan::New(
"RSPipeline").ToLocalChecked());
3857 tpl->InstanceTemplate()->SetInternalFieldCount(1);
3859 Nan::SetPrototypeMethod(tpl,
"start", Start);
3860 Nan::SetPrototypeMethod(tpl,
"startWithConfig", StartWithConfig);
3861 Nan::SetPrototypeMethod(tpl,
"stop", Stop);
3862 Nan::SetPrototypeMethod(tpl,
"waitForFrames", WaitForFrames);
3863 Nan::SetPrototypeMethod(tpl,
"pollForFrames", PollForFrames);
3864 Nan::SetPrototypeMethod(tpl,
"getActiveProfile", GetActiveProfile);
3865 Nan::SetPrototypeMethod(tpl,
"create", Create);
3866 Nan::SetPrototypeMethod(tpl,
"destroy", Destroy);
3868 v8::Local<v8::Context> context = exports->CreationContext();
3869 constructor_.Reset(tpl->GetFunction(context).ToLocalChecked());
3870 exports->Set(context, Nan::New(
"RSPipeline").ToLocalChecked(),
3871 tpl->GetFunction(context).ToLocalChecked());
3875 Nan::EscapableHandleScope scope;
3877 v8::Local<v8::Function> cons = Nan::New<v8::Function>(constructor_);
3880 v8::Local<v8::Object> instance =
3881 cons->NewInstance(context, 0,
nullptr).ToLocalChecked();
3882 return scope.Escape(instance);
3898 pipeline_ =
nullptr;
3902 auto me = Nan::ObjectWrap::Unwrap<RSPipeline>(
info.Holder());
3903 if (me) me->DestroyMe();
3904 info.GetReturnValue().Set(Nan::Undefined());
3907 static void New(
const Nan::FunctionCallbackInfo<v8::Value>&
info) {
3908 if (info.IsConstructCall()) {
3910 obj->Wrap(info.This());
3911 info.GetReturnValue().Set(info.This());
3916 info.GetReturnValue().Set(Nan::Undefined());
3917 auto me = Nan::ObjectWrap::Unwrap<RSPipeline>(
info.Holder());
3918 auto rsctx = Nan::ObjectWrap::Unwrap<RSContext>(Nan::To<v8::Object>(
info[0]).ToLocalChecked());
3919 if (!me || !rsctx)
return;
3922 &me->error_, rsctx->ctx_, &me->error_);
3926 info.GetReturnValue().Set(Nan::Undefined());
3927 auto me = Nan::ObjectWrap::Unwrap<RSPipeline>(
info.Holder());
3928 if (!me || !me->pipeline_)
return;
3930 RSConfig*
config = Nan::ObjectWrap::Unwrap<RSConfig>(Nan::To<v8::Object>(
info[0]).ToLocalChecked());
3933 config->
config_, &me->error_);
3940 info.GetReturnValue().Set(Nan::Undefined());
3941 auto me = Nan::ObjectWrap::Unwrap<RSPipeline>(
info.Holder());
3942 if (!me || !me->pipeline_)
return;
3952 info.GetReturnValue().Set(Nan::Undefined());
3953 auto me = Nan::ObjectWrap::Unwrap<RSPipeline>(
info.Holder());
3954 if (!me || !me->pipeline_)
return;
3960 info.GetReturnValue().Set(Nan::False());
3961 auto me = Nan::ObjectWrap::Unwrap<RSPipeline>(
info.Holder());
3962 auto frameset = Nan::ObjectWrap::Unwrap<RSFrameSet>(Nan::To<v8::Object>(
info[0]).ToLocalChecked());
3963 if (!me || !frameset)
return;
3965 auto timeout = Nan::To<int64_t>(
info[1]).FromJust();
3969 if (!frames)
return;
3971 frameset->Replace(frames);
3972 info.GetReturnValue().Set(Nan::True());
3976 info.GetReturnValue().Set(Nan::False());
3977 auto me = Nan::ObjectWrap::Unwrap<RSPipeline>(
info.Holder());
3978 auto frameset = Nan::ObjectWrap::Unwrap<RSFrameSet>(Nan::To<v8::Object>(
info[0]).ToLocalChecked());
3979 if (!me || !frameset)
return;
3983 me->pipeline_, &
frames, &me->error_);
3986 frameset->Replace(frames);
3987 info.GetReturnValue().Set(Nan::True());
3991 info.GetReturnValue().Set(Nan::Undefined());
3992 auto me = Nan::ObjectWrap::Unwrap<RSPipeline>(
info.Holder());
4013 info.GetReturnValue().Set(Nan::Undefined());
4014 auto me = Nan::ObjectWrap::Unwrap<RSConfig>(
info.Holder());
4017 RSPipeline*
pipe = Nan::ObjectWrap::Unwrap<RSPipeline>(Nan::To<v8::Object>(
info[0]).ToLocalChecked());
4021 if (!pipeline_profile)
return;
4027 info.GetReturnValue().Set(Nan::Undefined());
4028 auto me = Nan::ObjectWrap::Unwrap<RSConfig>(
info.Holder());
4031 RSPipeline*
pipe = Nan::ObjectWrap::Unwrap<RSPipeline>(Nan::To<v8::Object>(
info[0]).ToLocalChecked());
4033 me->config_, pipe->
pipeline_, &me->error_);
4034 if (me->error_)
return;
4036 info.GetReturnValue().Set(Nan::New(can_resolve ?
true :
false));
4041 static void Init(v8::Local<v8::Object> exports) {
4042 v8::Local<v8::FunctionTemplate> tpl = Nan::New<v8::FunctionTemplate>(New);
4043 tpl->SetClassName(Nan::New(
"RSColorizer").ToLocalChecked());
4044 tpl->InstanceTemplate()->SetInternalFieldCount(1);
4046 Nan::SetPrototypeMethod(tpl,
"destroy", Destroy);
4047 Nan::SetPrototypeMethod(tpl,
"create", Create);
4048 Nan::SetPrototypeMethod(tpl,
"colorize", Colorize);
4049 Nan::SetPrototypeMethod(tpl,
"supportsOption", SupportsOption);
4050 Nan::SetPrototypeMethod(tpl,
"getOption", GetOption);
4051 Nan::SetPrototypeMethod(tpl,
"setOption", SetOption);
4052 Nan::SetPrototypeMethod(tpl,
"getOptionRange", GetOptionRange);
4053 Nan::SetPrototypeMethod(tpl,
"isOptionReadonly", IsOptionReadonly);
4054 Nan::SetPrototypeMethod(tpl,
"getOptionDescription", GetOptionDescription);
4055 Nan::SetPrototypeMethod(tpl,
"getOptionValueDescription",
4056 GetOptionValueDescription);
4058 v8::Local<v8::Context> context = exports->CreationContext();
4059 constructor_.Reset(tpl->GetFunction(context).ToLocalChecked());
4060 exports->Set(context, Nan::New(
"RSColorizer").ToLocalChecked(),
4061 tpl->GetFunction(context).ToLocalChecked());
4065 Nan::EscapableHandleScope scope;
4067 v8::Local<v8::Function> cons = Nan::New<v8::Function>(constructor_);
4070 v8::Local<v8::Object> instance =
4071 cons->NewInstance(context, 0,
nullptr).ToLocalChecked();
4073 return scope.Escape(instance);
4079 return reinterpret_cast<rs2_options*
>(colorizer_);
4083 RSColorizer() : colorizer_(nullptr), frame_queue_(nullptr), error_(nullptr) {}
4093 colorizer_ =
nullptr;
4095 frame_queue_ =
nullptr;
4099 auto me = Nan::ObjectWrap::Unwrap<RSColorizer>(
info.Holder());
4103 info.GetReturnValue().Set(Nan::Undefined());
4106 static void New(
const Nan::FunctionCallbackInfo<v8::Value>&
info) {
4107 if (info.IsConstructCall()) {
4109 obj->Wrap(info.This());
4110 info.GetReturnValue().Set(info.This());
4115 info.GetReturnValue().Set(Nan::Undefined());
4116 auto me = Nan::ObjectWrap::Unwrap<RSColorizer>(
info.Holder());
4119 me->colorizer_ = GetNativeResult<rs2_processing_block*>(
4121 if (!me->colorizer_)
return;
4123 me->frame_queue_ = GetNativeResult<rs2_frame_queue*>(
4125 if (!me->frame_queue_)
return;
4133 info.GetReturnValue().Set(Nan::False());
4134 auto me = Nan::ObjectWrap::Unwrap<RSColorizer>(
info.Holder());
4135 RSFrame*
depth = Nan::ObjectWrap::Unwrap<RSFrame>(Nan::To<v8::Object>(
info[0]).ToLocalChecked());
4136 RSFrame*
target = Nan::ObjectWrap::Unwrap<RSFrame>(Nan::To<v8::Object>(
info[1]).ToLocalChecked());
4137 if (!me || !depth || !depth->frame_ || !target)
return;
4141 if (me->error_)
return;
4144 depth->frame_, &me->error_);
4145 if (me->error_)
return;
4148 &me->error_, me->frame_queue_, 5000, &me->error_);
4149 target->DestroyMe();
4150 if (!result)
return;
4152 target->Replace(result);
4153 info.GetReturnValue().Set(Nan::True());
4157 auto me = Nan::ObjectWrap::Unwrap<RSColorizer>(
info.Holder());
4158 if (me)
return me->SupportsOptionInternal(
info);
4160 info.GetReturnValue().Set(Nan::False());
4164 auto me = Nan::ObjectWrap::Unwrap<RSColorizer>(
info.Holder());
4165 if (me)
return me->GetOptionInternal(
info);
4167 info.GetReturnValue().Set(Nan::Undefined());
4171 auto me = Nan::ObjectWrap::Unwrap<RSColorizer>(
info.Holder());
4172 if (me)
return me->GetOptionDescriptionInternal(
info);
4174 info.GetReturnValue().Set(Nan::Undefined());
4178 auto me = Nan::ObjectWrap::Unwrap<RSColorizer>(
info.Holder());
4179 if (me)
return me->GetOptionValueDescriptionInternal(
info);
4181 info.GetReturnValue().Set(Nan::Undefined());
4185 auto me = Nan::ObjectWrap::Unwrap<RSColorizer>(
info.Holder());
4186 if (me)
return me->SetOptionInternal(
info);
4188 info.GetReturnValue().Set(Nan::Undefined());
4192 auto me = Nan::ObjectWrap::Unwrap<RSColorizer>(
info.Holder());
4193 if (me)
return me->GetOptionRangeInternal(
info);
4195 info.GetReturnValue().Set(Nan::Undefined());
4199 auto me = Nan::ObjectWrap::Unwrap<RSColorizer>(
info.Holder());
4200 if (me)
return me->IsOptionReadonlyInternal(
info);
4202 info.GetReturnValue().Set(Nan::False());
4217 static void Init(v8::Local<v8::Object> exports) {
4218 v8::Local<v8::FunctionTemplate> tpl = Nan::New<v8::FunctionTemplate>(New);
4219 tpl->SetClassName(Nan::New(
"RSAlign").ToLocalChecked());
4220 tpl->InstanceTemplate()->SetInternalFieldCount(1);
4222 Nan::SetPrototypeMethod(tpl,
"destroy", Destroy);
4223 Nan::SetPrototypeMethod(tpl,
"waitForFrames", WaitForFrames);
4224 Nan::SetPrototypeMethod(tpl,
"process", Process);
4226 v8::Local<v8::Context> context = exports->CreationContext();
4227 constructor_.Reset(tpl->GetFunction(context).ToLocalChecked());
4228 exports->Set(context, Nan::New(
"RSAlign").ToLocalChecked(),
4229 tpl->GetFunction(context).ToLocalChecked());
4233 RSAlign() : align_(nullptr), frame_queue_(nullptr), error_(nullptr) {}
4245 frame_queue_ =
nullptr;
4249 auto me = Nan::ObjectWrap::Unwrap<RSAlign>(
info.Holder());
4250 if (me) me->DestroyMe();
4252 info.GetReturnValue().Set(Nan::Undefined());
4255 static void New(
const Nan::FunctionCallbackInfo<v8::Value>&
info) {
4256 if (!info.IsConstructCall())
return;
4259 auto stream =
static_cast<rs2_stream>(Nan::To<int64_t>(info[0]).FromJust());
4262 if (!obj->
align_)
return;
4272 obj->Wrap(info.This());
4273 info.GetReturnValue().Set(info.This());
4277 info.GetReturnValue().Set(Nan::Undefined());
4278 auto me = Nan::ObjectWrap::Unwrap<RSAlign>(
info.Holder());
4282 &me->error_, me->frame_queue_, 5000, &me->error_);
4283 if (!result)
return;
4289 info.GetReturnValue().Set(Nan::False());
4290 auto me = Nan::ObjectWrap::Unwrap<RSAlign>(
info.Holder());
4291 auto frameset = Nan::ObjectWrap::Unwrap<RSFrameSet>(Nan::To<v8::Object>(
info[0]).ToLocalChecked());
4292 auto target_fs = Nan::ObjectWrap::Unwrap<RSFrameSet>(Nan::To<v8::Object>(
info[1]).ToLocalChecked());
4293 if (!me || !frameset || !target_fs)
return;
4298 if (me->error_)
return;
4301 frameset->GetFrames(), &me->error_);
4302 if (me->error_)
return;
4306 me->frame_queue_, &frame, &me->error_);
4307 if (!ret_code)
return;
4309 target_fs->Replace(frame);
4310 info.GetReturnValue().Set(Nan::True());
4327 kFilterDecimation = 0,
4332 kFilterDepth2Disparity
4334 static void Init(v8::Local<v8::Object> exports) {
4335 v8::Local<v8::FunctionTemplate> tpl = Nan::New<v8::FunctionTemplate>(New);
4336 tpl->SetClassName(Nan::New(
"RSFilter").ToLocalChecked());
4337 tpl->InstanceTemplate()->SetInternalFieldCount(1);
4339 Nan::SetPrototypeMethod(tpl,
"destroy", Destroy);
4340 Nan::SetPrototypeMethod(tpl,
"process", Process);
4341 Nan::SetPrototypeMethod(tpl,
"supportsOption", SupportsOption);
4342 Nan::SetPrototypeMethod(tpl,
"getOption", GetOption);
4343 Nan::SetPrototypeMethod(tpl,
"setOption", SetOption);
4344 Nan::SetPrototypeMethod(tpl,
"getOptionRange", GetOptionRange);
4345 Nan::SetPrototypeMethod(tpl,
"isOptionReadonly", IsOptionReadonly);
4346 Nan::SetPrototypeMethod(tpl,
"getOptionDescription", GetOptionDescription);
4347 Nan::SetPrototypeMethod(tpl,
"getOptionValueDescription",
4348 GetOptionValueDescription);
4350 v8::Local<v8::Context> context = exports->CreationContext();
4351 constructor_.Reset(tpl->GetFunction(context).ToLocalChecked());
4352 exports->Set(context, Nan::New(
"RSFilter").ToLocalChecked(),
4353 tpl->GetFunction(context).ToLocalChecked());
4361 RSFilter() : block_(nullptr), frame_queue_(nullptr), error_(nullptr),
4362 type_(kFilterDecimation) {}
4374 frame_queue_ =
nullptr;
4378 auto me = Nan::ObjectWrap::Unwrap<RSFilter>(
info.Holder());
4379 if (me) me->DestroyMe();
4381 info.GetReturnValue().Set(Nan::Undefined());
4384 static void New(
const Nan::FunctionCallbackInfo<v8::Value>&
info) {
4385 if (!info.IsConstructCall())
return;
4387 Nan::Utf8String type_str(Nan::To<v8::String>(info[0]).ToLocalChecked());
4390 if (!(type.compare(
"decimation"))) {
4391 obj->
type_ = kFilterDecimation;
4392 obj->
block_ = GetNativeResult<rs2_processing_block*>(
4394 }
else if (!(type.compare(
"temporal"))) {
4395 obj->
type_ = kFilterTemporal;
4396 obj->
block_ = GetNativeResult<rs2_processing_block*>(
4398 }
else if (!(type.compare(
"spatial"))) {
4399 obj->
type_ = kFilterSpatial;
4400 obj->
block_ = GetNativeResult<rs2_processing_block*>(
4402 }
else if (!(type.compare(
"hole-filling"))) {
4403 obj->
type_ = kFilterHoleFilling;
4404 obj->
block_ = GetNativeResult<rs2_processing_block*>(
4406 }
else if (!(type.compare(
"disparity-to-depth"))) {
4407 obj->
type_ = kFilterDisparity2Depth;
4408 obj->
block_ = GetNativeResult<rs2_processing_block*>(
4410 }
else if (!(type.compare(
"depth-to-disparity"))) {
4411 obj->
type_ = kFilterDepth2Disparity;
4412 obj->
block_ = GetNativeResult<rs2_processing_block*>(
4415 if (!obj->
block_)
return;
4426 obj->Wrap(info.This());
4427 info.GetReturnValue().Set(info.This());
4431 auto me = Nan::ObjectWrap::Unwrap<RSFilter>(
info.Holder());
4432 auto input_frame = Nan::ObjectWrap::Unwrap<RSFrame>(Nan::To<v8::Object>(
info[0]).ToLocalChecked());
4433 auto out_frame = Nan::ObjectWrap::Unwrap<RSFrame>(Nan::To<v8::Object>(
info[1]).ToLocalChecked());
4434 info.GetReturnValue().Set(Nan::False());
4435 if (!me || !input_frame || !out_frame)
return;
4440 if (me->error_)
return;
4443 input_frame->frame_, &me->error_);
4444 if (me->error_)
return;
4448 me->frame_queue_, &frame, &me->error_);
4449 if (!ret_code)
return;
4451 out_frame->Replace(frame);
4452 info.GetReturnValue().Set(Nan::True());
4456 auto me = Nan::ObjectWrap::Unwrap<RSFilter>(
info.Holder());
4457 if (me)
return me->SupportsOptionInternal(
info);
4459 info.GetReturnValue().Set(Nan::False());
4463 auto me = Nan::ObjectWrap::Unwrap<RSFilter>(
info.Holder());
4464 if (me)
return me->GetOptionInternal(
info);
4466 info.GetReturnValue().Set(Nan::Undefined());
4470 auto me = Nan::ObjectWrap::Unwrap<RSFilter>(
info.Holder());
4471 if (me)
return me->GetOptionDescriptionInternal(
info);
4473 info.GetReturnValue().Set(Nan::Undefined());
4477 auto me = Nan::ObjectWrap::Unwrap<RSFilter>(
info.Holder());
4478 if (me)
return me->GetOptionValueDescriptionInternal(
info);
4480 info.GetReturnValue().Set(Nan::Undefined());
4484 auto me = Nan::ObjectWrap::Unwrap<RSFilter>(
info.Holder());
4485 if (me)
return me->SetOptionInternal(
info);
4487 info.GetReturnValue().Set(Nan::Undefined());
4491 auto me = Nan::ObjectWrap::Unwrap<RSFilter>(
info.Holder());
4492 if (me)
return me->GetOptionRangeInternal(
info);
4494 info.GetReturnValue().Set(Nan::Undefined());
4498 auto me = Nan::ObjectWrap::Unwrap<RSFilter>(
info.Holder());
4499 if (me)
return me->IsOptionReadonlyInternal(
info);
4501 info.GetReturnValue().Set(Nan::False());
4534 info.GetReturnValue().Set(Nan::Undefined());
4540 info.GetReturnValue().Set(Nan::New(time));
4552 #define _FORCE_SET_ENUM(name) \ 4553 Nan::DefineOwnProperty(exports, \ 4554 Nan::New(#name).ToLocalChecked(), \ 4555 Nan::New(static_cast<int>((name))), \ 4556 static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete)); 4559 v8::Local<v8::Context> context = exports->CreationContext();
4561 exports->Set(context, Nan::New(
"globalCleanup").ToLocalChecked(),
4562 Nan::New<v8::FunctionTemplate>(GlobalCleanup)->GetFunction(context).ToLocalChecked());
4563 exports->Set(context, Nan::New(
"getTime").ToLocalChecked(),
4564 Nan::New<v8::FunctionTemplate>(
GetTime)->GetFunction(context).ToLocalChecked());
4565 exports->Set(context, Nan::New(
"registerErrorCallback").ToLocalChecked(),
4566 Nan::New<v8::FunctionTemplate>(RegisterErrorCallback)->GetFunction(context).ToLocalChecked());
4567 exports->Set(context, Nan::New(
"getError").ToLocalChecked(),
4568 Nan::New<v8::FunctionTemplate>(GetError)->GetFunction(context).ToLocalChecked());
static void New(const Nan::FunctionCallbackInfo< v8::Value > &info)
static void FillAFloatVector(v8::Local< v8::Object > obj, const rs2_vector &vec)
const char * rs2_playback_device_get_file_path(const rs2_device *device, rs2_error **error)
rs2_processing_block * rs2_create_decimation_filter_block(rs2_error **error)
static v8::Local< v8::Object > NewInstance()
int rs2_get_sensors_count(const rs2_sensor_list *info_list, rs2_error **error)
rs2_camera_info
Read-only strings that can be queried from the device. Not all information attributes are available o...
void InitModule(v8::Local< v8::Object > exports)
RSDevice(DeviceType type=kNormalDevice)
int rs2_pipeline_poll_for_frames(rs2_pipeline *pipe, rs2_frame **output_frame, 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)
void on_notification(rs2_notification *notification) override
void rs2_export_to_ply(const rs2_frame *frame, const char *fname, rs2_frame *texture, rs2_error **error)
static NAN_METHOD(IsOptionReadonly)
void GetOptionInternal(const Nan::FunctionCallbackInfo< v8::Value > &info)
static NAN_METHOD(EnableDevice)
float rs2_get_option(const rs2_options *options, rs2_option option, rs2_error **error)
DevicesChangedCallbackInfo(rs2_device_list *r, rs2_device_list *a, RSContext *ctx)
static NAN_METHOD(GetStreamProfile)
static v8::Local< v8::Object > NewInstance()
int rs2_device_list_contains(const rs2_device_list *info_list, const rs2_device *device, rs2_error **error)
rs2_processing_block * processing_block_
Exposes RealSense processing-block functionality for C compilers.
void SetMemberArray(const char *name, V value[len])
float rs2_get_depth_scale(rs2_sensor *sensor, rs2_error **error)
int rs2_loopback_is_enabled(const rs2_device *device, rs2_error **error)
static NAN_METHOD(GetOptionRange)
static NAN_METHOD(GetOptionValueDescription)
::realsense_legacy_msgs::extrinsics_< std::allocator< void > > extrinsics
GLenum GLuint GLenum severity
int rs2_get_frame_points_count(const rs2_frame *frame, rs2_error **error)
const rs2_stream_profile * rs2_get_frame_stream_profile(const rs2_frame *frame, rs2_error **error)
void on_frame(rs2_frame *frame) override
void rs2_free_error(rs2_error *error)
GLuint const GLchar * name
static v8::Local< v8::Object > NewInstance()
static NAN_METHOD(GetPosition)
rs2_vector angular_acceleration
rs2_pipeline_profile * rs2_config_resolve(rs2_config *config, rs2_pipeline *pipe, rs2_error **error)
rs2_device_list * rs2_query_devices(const rs2_context *context, rs2_error **error)
static NAN_METHOD(Create)
static NAN_METHOD(DisableLoopback)
static MainThreadCallback * singleton_
void rs2_playback_seek(const rs2_device *device, long long int time, rs2_error **error)
rs2_option
Defines general configuration controls. These can generally be mapped to camera UVC controls...
void SetFrame(rs2_frame *frame)
static NAN_METHOD(WriteTextureCoordinates)
static Nan::Persistent< v8::Function > constructor_
unsigned int tracker_confidence
static void New(const Nan::FunctionCallbackInfo< v8::Value > &info)
virtual ~FrameCallbackForProcessingBlock()
static NAN_METHOD(SetDevicesChangedCallback)
static NAN_METHOD(GetWidth)
int rs2_is_frame_extendable_to(const rs2_frame *frame, rs2_extension extension_type, rs2_error **error)
static NAN_METHOD(GetSize)
void rs2_start_processing(rs2_processing_block *block, rs2_frame_callback *on_frame, rs2_error **error)
static void Init(v8::Local< v8::Object > exports)
rs2_pipeline_profile * rs2_pipeline_start(rs2_pipeline *pipe, rs2_error **error)
void rs2_get_video_stream_resolution(const rs2_stream_profile *mode, int *width, int *height, rs2_error **error)
static v8::Local< v8::Object > NewInstance(rs2_device_list *list)
rs2_sensor * rs2_create_sensor(const rs2_sensor_list *list, int index, rs2_error **error)
rs2_device_hub * rs2_create_device_hub(const rs2_context *context, rs2_error **error)
Creates RealSense device_hub .
int rs2_poll_for_frame(rs2_frame_queue *queue, rs2_frame **output_frame, rs2_error **error)
static NAN_METHOD(GetDistance)
GLenum GLenum GLenum GLenum GLenum scale
Nan::Persistent< v8::Object > js_error_container_
rs2_frame_queue * frame_queue_
bool IsMemberPresent(const std::string &name) const
void rs2_keep_frame(rs2_frame *frame)
void SetMemberUndefined(const char *name)
static NAN_METHOD(Destroy)
static NAN_METHOD(PollForFrames)
static NAN_METHOD(GetFrameNumber)
FrameCallbackInfo(rs2_frame *frame, void *data)
static NAN_METHOD(GetMotionData)
void rs2_get_extrinsics(const rs2_stream_profile *from, const rs2_stream_profile *to, rs2_extrinsics *extrin, rs2_error **error)
static NAN_METHOD(IsConnected)
rs2_device * rs2_create_device_from_sensor(const rs2_sensor *sensor, rs2_error **error)
GLuint64 GLenum void * handle
static Nan::Persistent< v8::Function > constructor_
static NAN_METHOD(WaitForFrames)
static NAN_METHOD(GetBitsPerPixel)
void rs2_delete_device(rs2_device *device)
rs2_context * rs2_create_context(int api_version, rs2_error **error)
Creates RealSense context that is required for the rest of the API.
rs2_processing_block * rs2_create_hole_filling_filter_block(rs2_error **error)
static NAN_METHOD(GetData)
static NAN_METHOD(GetHeight)
rs2_processing_block * rs2_create_sync_processing_block(rs2_error **error)
static Nan::Persistent< v8::Function > constructor_
void rs2_set_region_of_interest(const rs2_sensor *sensor, int min_x, int min_y, int max_x, int max_y, rs2_error **error)
sets the active region of interest to be used by auto-exposure algorithm
rs2_config * rs2_create_config(rs2_error **error)
void rs2_delete_context(rs2_context *context)
Frees the relevant context object.
static void New(const Nan::FunctionCallbackInfo< v8::Value > &info)
static NAN_METHOD(Colorize)
static NAN_METHOD(IsVideoFrame)
rs2_device * rs2_context_add_device(rs2_context *ctx, const char *file, rs2_error **error)
static const textual_icon repeat
static Nan::Persistent< v8::Function > constructor_
static void Init(v8::Local< v8::Object > exports)
void rs2_playback_device_set_status_changed_callback(const rs2_device *device, rs2_playback_status_changed_callback *callback, rs2_error **error)
rs2_pipeline * rs2_create_pipeline(rs2_context *ctx, rs2_error **error)
static NAN_METHOD(DisableAllStreams)
v8::Local< v8::Value > GetMember(const std::string &name) const
void rs2_config_enable_record_to_file(rs2_config *config, const char *file, rs2_error **error)
rs2_device * rs2_create_device(const rs2_device_list *info_list, int index, rs2_error **error)
static NAN_METHOD(IsMotionFrame)
static NAN_METHOD(IsLoopbackEnabled)
void rs2_stop(const rs2_sensor *sensor, rs2_error **error)
static NAN_METHOD(SetOption)
static void FillAFloatQuaternion(v8::Local< v8::Object > obj, const rs2_quaternion &quaternion)
void rs2_record_device_pause(const rs2_device *device, rs2_error **error)
int rs2_playback_device_is_real_time(const rs2_device *device, rs2_error **error)
GLint GLint GLsizei GLsizei GLsizei depth
void rs2_playback_device_pause(const rs2_device *device, rs2_error **error)
void rs2_delete_frame_queue(rs2_frame_queue *queue)
static NAN_METHOD(GetCameraInfo)
RSIntrinsics(rs2_intrinsics intrinsics)
static NAN_METHOD(GetFrameMetadata)
static NAN_METHOD(PauseRecord)
static void Init(v8::Local< v8::Object > exports)
rs2_time_t rs2_get_frame_timestamp(const rs2_frame *frame, rs2_error **error)
int rs2_stream_profile_is(const rs2_stream_profile *mode, rs2_extension type, rs2_error **error)
const char * rs2_get_notification_serialized_data(rs2_notification *notification, rs2_error **error)
rs2_pixel * rs2_get_frame_texture_coordinates(const rs2_frame *frame, rs2_error **error)
GLsizei const GLchar *const * string
Exposes RealSense internal functionality for C compilers.
static void New(const Nan::FunctionCallbackInfo< v8::Value > &info)
virtual ~DevicesChangedCallbackInfo()
3D coordinates with origin at topmost left corner of the lense, with positive Z pointing away from th...
static v8::Local< v8::Object > NewInstance(rs2_pipeline_profile *profile)
RSMotionIntrinsics(rs2_motion_device_intrinsic *intri)
rs2_log_severity rs2_get_notification_severity(rs2_notification *notification, rs2_error **error)
static NAN_METHOD(WaitForFrame)
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)
#define _FORCE_SET_ENUM(name)
void SetOptionInternal(const Nan::FunctionCallbackInfo< v8::Value > &info)
static NAN_METHOD(GetDevice)
bool Is(std::shared_ptr< P > ptr)
rs2_pipeline_profile * rs2_pipeline_get_active_profile(rs2_pipeline *pipe, rs2_error **error)
static NAN_METHOD(TriggerErrorForTest)
float GetDepthScale(rs2::device dev)
static NAN_METHOD(PollForFrame)
static NAN_METHOD(QueryDevices)
int rs2_supports_frame_metadata(const rs2_frame *frame, rs2_frame_metadata_value frame_metadata, rs2_error **error)
void SetMemberT(const char *name, const T &value)
rs2_vector angular_velocity
rs2_processing_block * colorizer_
RSOptionRange(float min, float max, float step, float def)
static NAN_METHOD(Process)
static NAN_METHOD(GetOptionDescription)
rs2_stream_profile * rs2_clone_stream_profile(const rs2_stream_profile *mode, rs2_stream stream, int index, rs2_format format, rs2_error **error)
void rs2_config_enable_all_stream(rs2_config *config, rs2_error **error)
static NAN_METHOD(IsValid)
rs2_device * rs2_pipeline_profile_get_device(rs2_pipeline_profile *profile, rs2_error **error)
RSRegionOfInterest(int32_t minx, int32_t miny, int32_t maxx, int32_t maxy)
Exposes librealsense functionality for C compilers.
static void Init(v8::Local< v8::Object > exports)
NAN_METHOD(RSConfig::Resolve)
::realsense_legacy_msgs::pose_< std::allocator< void > > pose
v8::Local< v8::Object > GetObject() const
status
Defines return codes that SDK interfaces use. Negative values indicate errors, a zero value indicates...
virtual void on_devices_changed(rs2_device_list *removed, rs2_device_list *added)
rs2_stream_profile_list * rs2_get_stream_profiles(rs2_sensor *sensor, rs2_error **error)
static void AnalyzeError(rs2_error *err)
static NAN_METHOD(Create)
int rs2_get_frame_height(const rs2_frame *frame, rs2_error **error)
GLboolean GLboolean GLboolean GLboolean a
static NAN_METHOD(UnloadDeviceFile)
void rs2_open(rs2_sensor *device, const rs2_stream_profile *profile, rs2_error **error)
rs2_frame_queue * frame_queue_
static void Init(v8::Local< v8::Object > exports)
static NAN_METHOD(Calculate)
rs2_context * rs2_create_recording_context(int api_version, const char *filename, const char *section, rs2_recording_mode mode, rs2_error **error)
def info(name, value, persistent=False)
static NAN_METHOD(GetTimestampDomain)
PlaybackStatusCallbackInfo(rs2_playback_status status, RSDevice *dev)
unsigned int mapper_confidence
Quaternion used to represent rotation.
static void New(const Nan::FunctionCallbackInfo< v8::Value > &info)
void rs2_loopback_enable(const rs2_device *device, const char *from_file, rs2_error **error)
int rs2_get_frame_stride_in_bytes(const rs2_frame *frame, rs2_error **error)
void RegisterDevicesChangedCallbackMethod()
static NAN_METHOD(IsOptionReadonly)
static v8::Local< v8::Object > NewInstance()
int rs2_supports_option(const rs2_options *options, rs2_option option, rs2_error **error)
static NAN_METHOD(EnableDeviceFromFile)
rs2_processing_block * rs2_create_align(rs2_stream align_to, rs2_error **error)
NotificationCallback(RSSensor *s)
static NAN_METHOD(GetTimestamp)
rs2_processing_block * block_
static NAN_METHOD(DisableStream)
rs2_frame_queue * frame_queue_
rs2_stream_profile_list * rs2_pipeline_profile_get_streams(rs2_pipeline_profile *profile, rs2_error **error)
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)
StdString::ContainsMatcher Contains(std::string const &str, CaseSensitive::Choice caseSensitivity=CaseSensitive::Yes)
void rs2_playback_device_stop(const rs2_device *device, rs2_error **error)
bool contains(const std::shared_ptr< librealsense::device_info > &first, const std::shared_ptr< librealsense::device_info > &second)
unsigned long long int rs2_playback_get_position(const rs2_device *device, rs2_error **error)
static Nan::Persistent< v8::Function > constructor_
static void Init(v8::Local< v8::Object > exports)
rs2_time_t rs2_get_time(rs2_error **error)
rs2_options * GetOptionsPointer() override
static NAN_METHOD(GetTexCoordBufferLen)
void rs2_config_disable_all_streams(rs2_config *config, rs2_error **error)
v8::Local< v8::Object > v8obj_
static NAN_METHOD(IsRecorder)
void rs2_record_device_resume(const rs2_device *device, rs2_error **error)
void rs2_config_enable_device_from_file(rs2_config *config, const char *file, rs2_error **error)
int rs2_embedded_frames_count(rs2_frame *composite, rs2_error **error)
rs2_processing_block * rs2_create_pointcloud(rs2_error **error)
static NAN_METHOD(Process)
static bool InfoExist(MainThreadCallbackInfo *info)
int rs2_is_stream_profile_default(const rs2_stream_profile *mode, rs2_error **error)
static NAN_METHOD(Destroy)
rs2_pipeline_profile * pipeline_profile_
rs2_log_severity severity_
void rs2_enqueue_frame(rs2_frame *frame, void *queue)
static NAN_METHOD(WaitForFrames)
static NAN_METHOD(GetVertices)
rs2_frame_queue * frame_queue_
int rs2_supports_device_info(const rs2_device *device, rs2_camera_info info, rs2_error **error)
static void AssemblePoseData(v8::Local< v8::Object > obj, const rs2_pose &pose)
const char * rs2_get_option_value_description(const rs2_options *options, rs2_option option, float value, rs2_error **error)
static NAN_METHOD(Destroy)
static void Init(v8::Local< v8::Object > exports)
static v8::Local< v8::Object > NewInstance()
void GetOptionDescriptionInternal(const Nan::FunctionCallbackInfo< v8::Value > &info)
static NAN_METHOD(EnableStream)
static v8::Local< v8::Object > NewInstance(rs2_context *ctx_ptr=nullptr)
int rs2_get_frame_width(const rs2_frame *frame, rs2_error **error)
static void Init(v8::Local< v8::Object > exports)
std::string serialized_data_
static NAN_METHOD(Create)
void rs2_delete_sensor(rs2_sensor *sensor)
float rs2_depth_frame_get_distance(const rs2_frame *frame_ref, int x, int y, rs2_error **error)
static v8::Local< v8::Object > NewInstance(rs2_frame *frame)
static NAN_METHOD(IsOptionReadonly)
void rs2_get_region_of_interest(const rs2_sensor *sensor, int *min_x, int *min_y, int *max_x, int *max_y, rs2_error **error)
gets the active region of interest to be used by auto-exposure algorithm
const char * rs2_get_error_message(const rs2_error *error)
int rs2_device_hub_is_device_connected(const rs2_device_hub *hub, const rs2_device *device, rs2_error **error)
void IsOptionReadonlyInternal(const Nan::FunctionCallbackInfo< v8::Value > &info)
rs2_time_t rs2_get_notification_timestamp(rs2_notification *notification, rs2_error **error)
int rs2_is_device_extendable_to(const rs2_device *device, rs2_extension extension, rs2_error **error)
static NAN_METHOD(GetStrideInBytes)
static NAN_METHOD(Contains)
bool IsRecorderInternal()
void CallNativeFunc(F func, rs2_error **error, arguments...params)
static NAN_METHOD(EnqueueFrame)
static NAN_METHOD(CanGetPoints)
static NAN_METHOD(SupportsOption)
v8::Local< v8::Value > GetMember(const char *name) const
static NAN_METHOD(GetActiveProfile)
rs2_timestamp_domain rs2_get_frame_timestamp_domain(const rs2_frame *frameset, rs2_error **error)
void rs2_delete_stream_profile(rs2_stream_profile *mode)
static NAN_METHOD(Destroy)
GLint GLsizei GLsizei height
static NAN_METHOD(SetOption)
static NAN_METHOD(GetTextureCoordinates)
int rs2_config_can_resolve(rs2_config *config, rs2_pipeline *pipe, rs2_error **error)
void rs2_delete_device_hub(const rs2_device_hub *hub)
Frees the relevant device hub object.
static NAN_METHOD(QuerySensors)
virtual ~PlaybackStatusCallbackInfo()
static NAN_METHOD(ResumeRecord)
static NAN_METHOD(GetOption)
static void New(const Nan::FunctionCallbackInfo< v8::Value > &info)
GLint GLint GLsizei GLint GLenum format
const rs2_stream_profile * rs2_get_stream_profile(const rs2_stream_profile_list *list, int index, rs2_error **error)
static Nan::Persistent< v8::Function > constructor_
static NAN_METHOD(SupportsOption)
void Replace(rs2_frame *value)
void rs2_set_notifications_callback_cpp(const rs2_sensor *sensor, rs2_notifications_callback *callback, rs2_error **error)
static NAN_METHOD(Destroy)
IMGUI_API float GetTime()
static NAN_METHOD(Destroy)
static v8::Local< v8::Object > NewInstance(rs2_frame *frame)
IMGUI_API ImGuiContext * GetCurrentContext()
void SupportsOptionInternal(const Nan::FunctionCallbackInfo< v8::Value > &info)
static void New(const Nan::FunctionCallbackInfo< v8::Value > &info)
static NAN_METHOD(WriteVertices)
static NAN_METHOD(Destroy)
void rs2_hardware_reset(const rs2_device *device, rs2_error **error)
unsigned __int64 uint64_t
static NAN_METHOD(GetPoseData)
static NAN_METHOD(SetIsRealTime)
std::string js_error_callback_name_
R GetNativeResult(F func, rs2_error **error, arguments...params)
static void UpdateJSErrorCallback(const Nan::FunctionCallbackInfo< v8::Value > &info)
static NAN_METHOD(GetOptionValueDescription)
GLdouble GLdouble GLint stride
void DeleteMember(const char *name)
rs2_sensor_list * rs2_query_sensors(const rs2_device *device, rs2_error **error)
static NAN_METHOD(SetPlaybackSpeed)
void rs2_delete_processing_block(rs2_processing_block *block)
void Replace(rs2_frame *frame)
static NAN_METHOD(GetDevice)
rs2_format
A stream's format identifies how binary data is encoded within a frame.
GLenum const GLfloat * params
void rs2_get_option_range(const rs2_options *sensor, rs2_option option, float *min, float *max, float *step, float *def, rs2_error **error)
int rs2_supports_sensor_info(const rs2_sensor *sensor, rs2_camera_info info, rs2_error **error)
rs2_processing_block * rs2_create_temporal_filter_block(rs2_error **error)
rs2_exception_type rs2_get_librealsense_exception_type(const rs2_error *error)
static Nan::Persistent< v8::Function > constructor_
static NAN_METHOD(GetFrame)
static NAN_METHOD(Create)
void MarkError(bool recoverable, std::string description, std::string native_function)
static NAN_METHOD(StartWithConfig)
static v8::Local< v8::Object > NewInstance(rs2_device *dev, DeviceType type=kNormalDevice)
static NAN_METHOD(GetBaseLine)
unsigned long long rs2_get_frame_number(const rs2_frame *frame, rs2_error **error)
static NAN_METHOD(GetCurrentStatus)
void rs2_config_enable_device_from_file_repeat_option(rs2_config *config, const char *file, int repeat_playback, rs2_error **error)
rs2_processing_block * block_
NODE_MODULE(node_librealsense, InitModule)
static void Init(v8::Local< v8::Object > exports)
DevicesChangedCallback(RSContext *context)
void swap(nlohmann::json &j1, nlohmann::json &j2) noexcept(is_nothrow_move_constructible< nlohmann::json >::value andis_nothrow_move_assignable< nlohmann::json >::value)
exchanges the values of two JSON objects
unsigned long long int rs2_playback_get_duration(const rs2_device *device, rs2_error **error)
static NAN_METHOD(SupportsOption)
static NAN_METHOD(GetOptionRange)
rs2_processing_block * rs2_create_disparity_transform_block(unsigned char transform_to_disparity, rs2_error **error)
static void Init(v8::Local< v8::Object > exports)
rs2_context * rs2_create_mock_context(int api_version, const char *filename, const char *section, rs2_error **error)
rs2_processing_block * rs2_create_colorizer(rs2_error **error)
RSContext(ContextType type=kNormal)
rs2_stream
Streams are different types of data provided by RealSense devices.
FrameCallbackForFrameQueue(rs2_frame_queue *queue)
bool IsPlaybackInternal()
rs2_pipeline_profile * rs2_pipeline_start_with_config(rs2_pipeline *pipe, rs2_config *config, rs2_error **error)
static NAN_METHOD(LoadDeviceFile)
v8::Local< v8::Object > GetJSObject()
DictBase(v8::Local< v8::Object > source)
static NAN_METHOD(IndexToStreamIndex)
static void New(const Nan::FunctionCallbackInfo< v8::Value > &info)
static NAN_METHOD(GetOptionRange)
std::string device_changed_callback_name_
virtual ~MainThreadCallbackInfo()
rs2_frame_queue * frame_queue_
FrameCallbackForProc(void *data)
static std::list< MainThreadCallbackInfo * > pending_infos_
void rs2_get_video_stream_intrinsics(const rs2_stream_profile *mode, rs2_intrinsics *intrinsics, rs2_error **error)
static NAN_METHOD(IsDepthFrame)
static void SetAFloatInVectorObject(v8::Local< v8::Object > obj, uint32_t index, float value)
static NAN_METHOD(GetFileName)
Cross-stream extrinsics: encodes the topology describing how the different devices are oriented...
const rs2_raw_data_buffer * rs2_send_and_receive_raw_data(rs2_device *device, void *raw_data_to_send, unsigned size_of_raw_data_to_send, rs2_error **error)
static NAN_METHOD(GetOption)
static NAN_METHOD(SetOption)
static void Init(v8::Local< v8::Object > exports)
int rs2_is_sensor_extendable_to(const rs2_sensor *sensor, rs2_extension extension, rs2_error **error)
3D vector in Euclidean coordinate space
static void ReleasePendingInfos()
static void New(const Nan::FunctionCallbackInfo< v8::Value > &info)
static NAN_METHOD(IsPlayback)
RSNotification(const std::string &des, rs2_time_t time, rs2_log_severity severity, rs2_notification_category category, const std::string &serialized_data)
static const struct @18 vertices[3]
rs2_extension
Specifies advanced interfaces (capabilities) objects may implement.
static NAN_METHOD(CreateDeviceFromSensor)
rs2_notification_category
Category of the librealsense notification.
rs2_frame_queue * frame_queue_
GLbitfield GLuint64 timeout
::realsense_legacy_msgs::metadata_< std::allocator< void > > metadata
rs2_device_list * removed_
static NAN_METHOD(EnableAllStreams)
long long rs2_metadata_type
static NAN_METHOD(GetDuration)
static NAN_METHOD(PausePlayback)
rs2_playback_status status_
void rs2_delete_stream_profiles_list(rs2_stream_profile_list *list)
static NAN_METHOD(Destroy)
void rs2_pipeline_stop(rs2_pipeline *pipe, rs2_error **error)
static NAN_METHOD(IndexToStream)
void rs2_close(const rs2_sensor *sensor, rs2_error **error)
static NAN_METHOD(IsPoseFrame)
static void Init(v8::Local< v8::Object > exports)
void on_playback_status_changed(rs2_playback_status status) override
rs2_processing_block * rs2_create_spatial_filter_block(rs2_error **error)
static NAN_METHOD(GetPointsCount)
rs2_vertex * rs2_get_frame_vertices(const rs2_frame *frame, rs2_error **error)
static NAN_METHOD(StopPlayback)
rs2_device * rs2_create_record_device(const rs2_device *device, const char *file, rs2_error **error)
static NAN_METHOD(SetStatusChangedCallbackMethodName)
static NAN_METHOD(GetVerticesBufferLen)
virtual ~DevicesChangedCallback()
void rs2_frame_add_ref(rs2_frame *frame, rs2_error **error)
static void AsyncProc(uv_async_t *async)
const char * rs2_get_option_description(const rs2_options *options, rs2_option option, rs2_error **error)
void SetMember(const char *name, v8::Local< v8::Value > value)
static NAN_METHOD(ResumePlayback)
int rs2_is_option_read_only(const rs2_options *options, rs2_option option, rs2_error **error)
void rs2_delete_config(rs2_config *config)
void rs2_open_multiple(rs2_sensor *device, const rs2_stream_profile **profiles, int count, rs2_error **error)
void rs2_start_cpp(const rs2_sensor *sensor, rs2_frame_callback *callback, rs2_error **error)
GLsizei GLsizei GLchar * source
rs2_options * GetOptionsPointer() override
void rs2_set_devices_changed_callback_cpp(rs2_context *context, rs2_devices_changed_callback *callback, rs2_error **error)
rs2_notification_category rs2_get_notification_category(rs2_notification *notification, rs2_error **error)
static NAN_METHOD(WaitForDevice)
void SetMember(const char *name, const std::string &value)
static void NotifyMainThread(MainThreadCallbackInfo *info)
rs2_playback_status rs2_playback_device_get_current_status(const rs2_device *device, rs2_error **error)
static NAN_METHOD(IsDisparityFrame)
Motion device intrinsics: scale, bias, and variances.
static NAN_METHOD(IsRealTime)
static Nan::Persistent< v8::Function > constructor_
void rs2_delete_sensor_list(rs2_sensor_list *info_list)
void rs2_config_enable_device(rs2_config *config, const char *serial, rs2_error **error)
static void New(const Nan::FunctionCallbackInfo< v8::Value > &info)
void Update(bool is_error, bool recoverable, std::string description, std::string function)
GLenum GLuint GLenum GLsizei length
float rs2_depth_stereo_frame_get_baseline(const rs2_frame *frame_ref, rs2_error **error)
void rs2_context_remove_device(rs2_context *ctx, const char *file, rs2_error **error)
static NAN_METHOD(EnableRecordToFile)
std::string status_changed_callback_method_name_
static NAN_METHOD(Destroy)
static NAN_METHOD(GetStreams)
void rs2_release_frame(rs2_frame *frame)
const char * rs2_get_sensor_info(const rs2_sensor *sensor, rs2_camera_info info, rs2_error **error)
static void Init(v8::Local< v8::Object > exports)
static v8::Local< v8::Value > GetJSErrorObject()
void on_frame(rs2_frame *frame) override
const char * rs2_get_notification_description(rs2_notification *notification, rs2_error **error)
static void Init(v8::Local< v8::Object > exports)
std::string native_function_
rs2_frame * rs2_extract_frame(rs2_frame *composite, int index, rs2_error **error)
bool IsMemberPresent(const char *name) const
int rs2_get_stream_profiles_count(const rs2_stream_profile_list *list, rs2_error **error)
void GetOptionRangeInternal(const Nan::FunctionCallbackInfo< v8::Value > &info)
rs2_metadata_type rs2_get_frame_metadata(const rs2_frame *frame, rs2_frame_metadata_value frame_metadata, rs2_error **error)
static NAN_METHOD(SupportsCameraInfo)
void rs2_set_option(const rs2_options *options, rs2_option option, float value, rs2_error **error)
static Nan::Persistent< v8::Function > constructor_
static NAN_METHOD(Destroy)
static void New(const Nan::FunctionCallbackInfo< v8::Value > &info)
static NAN_METHOD(GetOptionValueDescription)
PlaybackStatusCallback(RSDevice *dev)
rs2_notification_category category_
static NAN_METHOD(EnableLoopback)
rs2_options * GetOptionsPointer() override
static NAN_METHOD(SpawnRecorderDevice)
virtual ~FrameCallbackInfo()
FrameCallbackForProcessingBlock(rs2_processing_block *block_ptr)
rs2_log_severity
Severity of the librealsense logger.
void rs2_loopback_disable(const rs2_device *device, rs2_error **error)
void rs2_delete_device_list(rs2_device_list *info_list)
static NAN_METHOD(Destroy)
rs2_device * rs2_device_hub_wait_for_device(const rs2_device_hub *hub, rs2_error **error)
static Nan::Persistent< v8::Function > constructor_
static ErrorUtil * singleton_
NotificationCallbackInfo(const char *desc, rs2_time_t time, rs2_log_severity severity, rs2_notification_category category, std::string serialized_data, RSSensor *s)
static NAN_METHOD(GetOption)
static Nan::Persistent< v8::Function > constructor_
void on_frame(rs2_frame *frame) override
static NAN_METHOD(SupportsFrameMetadata)
static NAN_METHOD(Destroy)
rs2_processing_block * align_
RSExtrinsics(rs2_extrinsics extrinsics)
void rs2_get_motion_intrinsics(const rs2_stream_profile *mode, rs2_motion_device_intrinsic *intrinsics, rs2_error **error)
void rs2_delete_pipeline_profile(rs2_pipeline_profile *profile)
static Nan::Persistent< v8::Function > constructor_
const char * rs2_get_failed_function(const rs2_error *error)
int rs2_get_device_count(const rs2_device_list *info_list, rs2_error **error)
static void New(const Nan::FunctionCallbackInfo< v8::Value > &info)
static void New(const Nan::FunctionCallbackInfo< v8::Value > &info)
static NAN_METHOD(Destroy)
static NAN_METHOD(ExportToPly)
void GetOptionValueDescriptionInternal(const Nan::FunctionCallbackInfo< v8::Value > &info)
void rs2_pose_frame_get_pose_data(const rs2_frame *frame, rs2_pose *pose, rs2_error **error)
static Nan::Persistent< v8::Function > constructor_
const char * rs2_record_device_filename(const rs2_device *device, rs2_error **error)
void SetMember(const char *name, const char *value)
static NAN_METHOD(Destroy)
static NAN_METHOD(ReplaceFrame)
int rs2_get_frame_bits_per_pixel(const rs2_frame *frame, rs2_error **error)
rs2_frame_metadata_value
Per-Frame-Metadata is the set of read-only properties that might be exposed for each individual frame...
void rs2_delete_pipeline(rs2_pipeline *pipe)
struct rs2_frame rs2_frame
static NAN_METHOD(WriteData)
static NAN_METHOD(GetOptionDescription)
const void * rs2_get_frame_data(const rs2_frame *frame, rs2_error **error)
static void New(const Nan::FunctionCallbackInfo< v8::Value > &info)
void rs2_playback_device_resume(const rs2_device *device, rs2_error **error)
virtual ~NotificationCallbackInfo()
static NAN_METHOD(EnableDeviceFromFileRepeatOption)
void rs2_playback_device_set_real_time(const rs2_device *device, int real_time, rs2_error **error)
Pixel location within 2D image. (0,0) is the topmost, left corner. Positive X is right, positive Y is down.
static Nan::Persistent< v8::Function > constructor_
void rs2_playback_device_set_playback_speed(const rs2_device *device, float speed, rs2_error **error)
void rs2_config_disable_stream(rs2_config *config, rs2_stream stream, rs2_error **error)
const char * rs2_get_device_info(const rs2_device *device, rs2_camera_info info, rs2_error **error)
static NAN_METHOD(GetOptionDescription)