Commit a9bec01e authored by Jussi Lindgren's avatar Jussi Lindgren

Server: TCP Tagging clients now stamp with client-side time by default

- In addition, the TCP Tagging timestamp is now required to be relative
to the computer boot time and hence requires AS and Designer to be on the
same host. If not, server-side stamping should be used.
parent f3e08aa0
......@@ -42,7 +42,7 @@ void CPluginTCPTagging::startHook(const std::vector<OpenViBE::CString>& vSelecte
}
// Initialize time counters.
m_previousClockTime = System::Time::zgetTime();
m_previousClockTime = System::Time::zgetTimeRaw(false);
m_previousSampleTime = 0;
m_bWarningPrinted = false;
}
......@@ -56,9 +56,13 @@ void CPluginTCPTagging::stopHook()
void CPluginTCPTagging::loopHook(std::deque < std::vector < OpenViBE::float32 > >& /*vPendingBuffer*/,
OpenViBE::CStimulationSet& stimulationSet, uint64 /* start */, uint64 /* end */, uint64 lastSampleTime)
{
const uint64 clockTime = System::Time::zgetTime();
const uint64 clockTime = System::Time::zgetTimeRaw(false);
Tag tag;
// n.b. the last chunk received but not yet sent is between timestamps [previousClockTime,clockTime]. Note
// that more stims may be arriving in the loop meaning that they are newer than 'clockTime'. This is not an issue,
// they will be scheduled with future samples.
// Collect tags from the stream until exhaustion.
while(m_scopedTagStream.get() && m_scopedTagStream->pop(tag)) {
......
......@@ -58,12 +58,12 @@ void CTagSession::handleRead(const boost::system::error_code &error)
if(m_tag.timestamp == 0 || (m_tag.flags & TCP_Tagging_Flags::FLAG_AUTOSTAMP_SERVERSIDE))
{
// Client didn't provide timestamp or asked the server to do it. Stamp current time.
m_tag.timestamp = System::Time::zgetTime();
m_tag.timestamp = System::Time::zgetTimeRaw(false);
}
else if(!(m_tag.flags & TCP_Tagging_Flags::FLAG_FPTIME))
{
// Client provided stamp but not in FPTIME
m_tag.timestamp = System::Time::zgetTime();
m_tag.timestamp = System::Time::zgetTimeRaw(false);
if(!(m_errorState & (1LL<<1)))
{
// @fixme not appropriate to print errors from a thread, but better than silent fail
......@@ -71,16 +71,6 @@ void CTagSession::handleRead(const boost::system::error_code &error)
m_errorState |= (1LL<<1);
}
}
else if(m_tag.flags & TCP_Tagging_Flags::FLAG_AUTOSTAMP_CLIENTSIDE)
{
// @FIXME remove this branch after zgetTimeRaw(false) becomes available in SDK; fix CStimulusSender.cpp and all refs to zgetTime() in tagging context to use the raw version.
m_tag.timestamp = System::Time::zgetTime();
if(!(m_errorState & (1LL<<2)))
{
std::cout << "[WARNING] TCP Tagging: Client side stamping not currently supported. Using server receiving time for tags.\n";
m_errorState |= (1LL<<2);
}
}
// Push tag to the queue.
m_queuePtr->push(m_tag);
......
......@@ -65,8 +65,7 @@ boolean CStimulusSender::sendStimulation(uint64_t ui64Stimulation, uint64_t ui64
if(ui64Flags & IStimulusSender::TCP_Tagging_Flags::FLAG_AUTOSTAMP_CLIENTSIDE)
{
// @FIXME change to getter that has same starting point as the corresponding server getter
ui64Timestamp = System::Time::zgetTime();
ui64Timestamp = System::Time::zgetTimeRaw(false);
ui64Flags |= IStimulusSender::TCP_Tagging_Flags::FLAG_FPTIME;
}
......@@ -84,3 +83,4 @@ boolean CStimulusSender::sendStimulation(uint64_t ui64Stimulation, uint64_t ui64
return true;
}
......@@ -540,9 +540,8 @@ namespace OpenViBEPlugins
// Note that we don't need concurrency control here as gtk callbacks run in the main thread
void CDisplayCueImage::flushQueue(void)
{
for (size_t i = 0; i<m_vStimuliQueue.size(); i++)
for(size_t i=0;i<m_vStimuliQueue.size();i++)
{
// Timestamp is not used on purpose as we do not have the same clock scheme with AS
m_pStimulusSender->sendStimulation(m_vStimuliQueue[i]);
}
m_vStimuliQueue.clear();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment