diff --git a/Record3DUnityStreaming.cpp b/Record3DUnityStreaming.cpp index 1779c29..d840216 100755 --- a/Record3DUnityStreaming.cpp +++ b/Record3DUnityStreaming.cpp @@ -3,6 +3,9 @@ #include #include #include +#include + +std::map streams; FrameMetadata GetFrameMetadata() @@ -60,6 +63,8 @@ static float InterpolateDepth(const float* $depthData, float $x, float $y, int $ bool StartStreaming(Record3DDevice $deviceHandle, OnNewFrameCallback $newFrameCallback, OnStreamStoppedCallback $streamStoppedCallback) { auto* stream = new Record3D::Record3DStream{}; + streams[$deviceHandle.handle] = stream; + constexpr int numComponentsPerPointPosition = 4; size_t positionsBufferSize = 0; @@ -144,4 +149,17 @@ bool StartStreaming(Record3DDevice $deviceHandle, OnNewFrameCallback $newFrameCa bool connectionEstablished = stream->ConnectToDevice(dev); return connectionEstablished; +} + +void StopStreaming(Record3DDevice $deviceHandle) +{ + if (streams.count($deviceHandle.handle) > 0) + { + Record3D::Record3DStream* stream = streams[$deviceHandle.handle]; + + if (stream != NULL) + { + stream->Disconnect(); + } + } } \ No newline at end of file diff --git a/include/record3d_unity_streaming/Record3DUnityStreaming.h b/include/record3d_unity_streaming/Record3DUnityStreaming.h index 14dcc44..1189415 100755 --- a/include/record3d_unity_streaming/Record3DUnityStreaming.h +++ b/include/record3d_unity_streaming/Record3DUnityStreaming.h @@ -53,6 +53,7 @@ extern "C" typedef void (*OnNewFrameCallback)(FrameInfo); typedef void (*OnStreamStoppedCallback)(); EXPORT_DLL bool StartStreaming(Record3DDevice $deviceHandle, OnNewFrameCallback $newFrameCallback, OnStreamStoppedCallback $streamStoppedCallback); + EXPORT_DLL void StopStreaming(Record3DDevice $deviceHandle); #ifdef __cplusplus }