Skip to content

Commit

Permalink
Add 'scIsConnected()' method to API to make application connection wa…
Browse files Browse the repository at this point in the history
…iting more flexible.
  • Loading branch information
Andrey Kalugin committed Jan 15, 2024
1 parent bc03234 commit 419c62c
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/softcam/softcam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,3 +176,8 @@ extern "C" bool scWaitForConnection(scCamera camera, float timeout)
{
return softcam::sender::WaitForConnection(camera, timeout);
}

extern "C" bool scIsConnected(scCamera camera)
{
return softcam::sender::IsConnected(camera);
}
1 change: 1 addition & 0 deletions src/softcam/softcam.def
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ EXPORTS
scDeleteCamera
scSendFrame
scWaitForConnection
scIsConnected
10 changes: 10 additions & 0 deletions src/softcam/softcam.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,14 @@ extern "C"
this function returns `false`.
*/
bool SOFTCAM_API scWaitForConnection(scCamera camera, float timeout = 0.0f);

/*
This function reports if an application is connected to the specified
virtual camera.
This function returns `true` if the virtual camera has ever been
accessed by an application before this function returns. Otherwise,
this function returns `false`.
*/
bool SOFTCAM_API scIsConnected(scCamera camera);
}
10 changes: 10 additions & 0 deletions src/softcamcore/SenderAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,5 +111,15 @@ bool WaitForConnection(CameraHandle camera, float timeout)
return false;
}

bool IsConnected(CameraHandle camera)
{
Camera* target = static_cast<Camera*>(camera);
if (target && s_camera.load() == target)
{
return target->m_frame_buffer.connected();
}
return false;
}

} //namespace sender
} //namespace softcam

0 comments on commit 419c62c

Please sign in to comment.