diff --git a/server/streamtiming.cpp b/server/streamtiming.cpp index 529b329..d8a0641 100644 --- a/server/streamtiming.cpp +++ b/server/streamtiming.cpp @@ -19,7 +19,6 @@ along with this program. If not, see #include "streamtiming.h" -#include "../common/debugdefs.h" #include "timestamp.h" #include @@ -63,78 +62,6 @@ void StreamTiming::stop(uint portId) } } -bool StreamTiming::recordTxTime(uint portId, uint guid, uint ttagId, - const struct timespec ×tamp) -{ - TxRxKey key = makeKey(guid, ttagId); - TtagData value = { .timeStamp = timestamp, .portId = portId}; - - timingDebug("[%d TX] %ld:%ld ttag %u guid %u", portId, - timestamp.tv_sec, long(timestamp.tv_nsec), ttagId, guid); - - QMutexLocker locker(&txHashLock_); - txHash_.insert(key, value); - - return true; -} - -bool StreamTiming::recordRxTime(uint portId, uint guid, uint ttagId, - const struct timespec ×tamp) -{ - TxRxKey key = makeKey(guid, ttagId); - TtagData value = { .timeStamp = timestamp, .portId = portId}; - - timingDebug("[%d RX] %ld:%ld ttag %u guid %u", portId, - timestamp.tv_sec, long(timestamp.tv_nsec), ttagId, guid); - - QMutexLocker locker(&rxHashLock_); - rxHash_.insert(key, value); - - return true; -} - -bool StreamTiming::recordTxTime(uint portId, uint guid, uint ttagId, - const struct timeval ×tamp) -{ - struct timespec ts; - ts.tv_sec = timestamp.tv_sec; - ts.tv_nsec = timestamp.tv_usec*1000; - - return recordTxTime(portId, guid, ttagId, ts); -} - -bool StreamTiming::recordRxTime(uint portId, uint guid, uint ttagId, - const struct timeval ×tamp) -{ - struct timespec ts; - ts.tv_sec = timestamp.tv_sec; - ts.tv_nsec = timestamp.tv_usec*1000; - - return recordRxTime(portId, guid, ttagId, ts); -} - -// TTagList contains 32-bit ttags formatted as ttagId (8msb) + guid (24lsb) -bool StreamTiming::recordTxTime(uint portId, uint *ttagList, int count, - const struct timespec ×tamp) -{ - TtagData value = { .timeStamp = timestamp, .portId = portId}; - QMutexLocker locker(&txHashLock_); - - // FIXME: Change TxRxKey to match the format passed to this function - for (int i = 0; i < count; i++) { - uint guid = ttagList[i] & 0x00FFFFFF; - uint ttagId = ttagList[i] >> 24; - TxRxKey key = makeKey(guid, ttagId); - - timingDebug("[%d TX] %ld:%ld ttag %u guid %u", portId, - timestamp.tv_sec, long(timestamp.tv_nsec), ttagId, guid); - - txHash_.insert(key, value); - } - - return true; -} - quint64 StreamTiming::delay(uint portId, uint guid) { Q_ASSERT(guid <= SignProtocol::kMaxGuid); diff --git a/server/streamtiming.h b/server/streamtiming.h index 8c2dab8..6e9c264 100644 --- a/server/streamtiming.h +++ b/server/streamtiming.h @@ -20,6 +20,7 @@ along with this program. If not, see #ifndef _STREAM_TIMING #define _STREAM_TIMING +#include "../common/debugdefs.h" #include "../common/sign.h" #include @@ -100,4 +101,81 @@ private: QTimer *gcTimer_; // Garbage collection for stale tx records }; +inline +bool StreamTiming::recordTxTime(uint portId, uint guid, uint ttagId, + const struct timespec ×tamp) +{ + TxRxKey key = makeKey(guid, ttagId); + TtagData value = { .timeStamp = timestamp, .portId = portId}; + + timingDebug("[%d TX] %ld:%ld ttag %u guid %u", portId, + timestamp.tv_sec, long(timestamp.tv_nsec), ttagId, guid); + + QMutexLocker locker(&txHashLock_); + txHash_.insert(key, value); + + return true; +} + +inline +bool StreamTiming::recordRxTime(uint portId, uint guid, uint ttagId, + const struct timespec ×tamp) +{ + TxRxKey key = makeKey(guid, ttagId); + TtagData value = { .timeStamp = timestamp, .portId = portId}; + + timingDebug("[%d RX] %ld:%ld ttag %u guid %u", portId, + timestamp.tv_sec, long(timestamp.tv_nsec), ttagId, guid); + + QMutexLocker locker(&rxHashLock_); + rxHash_.insert(key, value); + + return true; +} + +inline +bool StreamTiming::recordTxTime(uint portId, uint guid, uint ttagId, + const struct timeval ×tamp) +{ + struct timespec ts; + ts.tv_sec = timestamp.tv_sec; + ts.tv_nsec = timestamp.tv_usec*1000; + + return recordTxTime(portId, guid, ttagId, ts); +} + +inline +bool StreamTiming::recordRxTime(uint portId, uint guid, uint ttagId, + const struct timeval ×tamp) +{ + struct timespec ts; + ts.tv_sec = timestamp.tv_sec; + ts.tv_nsec = timestamp.tv_usec*1000; + + return recordRxTime(portId, guid, ttagId, ts); +} + +// TTagList contains 32-bit ttags formatted as ttagId (8msb) + guid (24lsb) +inline +bool StreamTiming::recordTxTime(uint portId, uint *ttagList, int count, + const struct timespec ×tamp) +{ + TtagData value = { .timeStamp = timestamp, .portId = portId}; + QMutexLocker locker(&txHashLock_); + + // FIXME: Change TxRxKey to match the format passed to this function + for (int i = 0; i < count; i++) { + uint guid = ttagList[i] & 0x00FFFFFF; + uint ttagId = ttagList[i] >> 24; + TxRxKey key = makeKey(guid, ttagId); + + timingDebug("[%d TX] %ld:%ld ttag %u guid %u", portId, + timestamp.tv_sec, long(timestamp.tv_nsec), ttagId, guid); + + txHash_.insert(key, value); + } + + return true; +} + #endif