-
Notifications
You must be signed in to change notification settings - Fork 0
/
ClariusStreamIoAlgorithm.cpp
58 lines (48 loc) · 1.39 KB
/
ClariusStreamIoAlgorithm.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include "ClariusStreamIoAlgorithm.h"
#include "ClariusStream.h"
#include <ImFusion/Core/Log.h>
#ifdef WIN32
# include "WindowsFirewall.h"
#endif
namespace ImFusion
{
ClariusStreamIoAlgorithm::ClariusStreamIoAlgorithm()
: CreateStreamIoAlgorithm<ClariusStream, false, false>() {
}
/// Returns true if data is empty. If a is not 0, create algorithm with input data.
bool ClariusStreamIoAlgorithm::createCompatible(const DataList& data, Algorithm** a)
{
if (data.size())
return false;
if (a)
*a = new ClariusStreamIoAlgorithm();
return true;
}
void ClariusStreamIoAlgorithm::compute()
{
if (!ClariusStream::canInstantiate())
{
LOG_ERROR("Only one ClariusStream instance allowed at a time!");
return;
}
#ifdef WIN32
if (!WindowsFirewall::checkFirewallRuleExists())
{
LOG_INFO("No firewall exception detected for Clarius streaming. Trying to add one...");
WindowsFirewall::addFirewallRule();
if (WindowsFirewall::checkFirewallRuleExists())
LOG_INFO("Firewall exception added.");
else
LOG_ERROR("Firewall exception could not be added. Please make sure that incoming UDP connections are allowed.");
}
#endif
CreateStreamIoAlgorithm<ClariusStream, false, false>::compute();
if (m_fail || m_stream->p_serverAddress.value().empty())
return; // open needs to be called later when IP is known
if (m_fail)
{
m_stream = nullptr;
return;
}
}
}