Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions Record3DUnityStreaming.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
#include <record3d/Record3DStructs.h>
#include <record3d/Record3DStream.h>
#include <cmath>
#include <map>

std::map<int32_t, Record3D::Record3DStream*> streams;


FrameMetadata GetFrameMetadata()
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
}
}
1 change: 1 addition & 0 deletions include/record3d_unity_streaming/Record3DUnityStreaming.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down