From df6db324fab641c91be9025e3d17a4482708afeb Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Mon, 11 May 2020 16:14:26 +0100 Subject: [PATCH] Change the way the timestamp is calculated. --- NXDNGateway/KenwoodNetwork.cpp | 27 ++++++++++++++++++++++++--- NXDNGateway/KenwoodNetwork.h | 2 -- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/NXDNGateway/KenwoodNetwork.cpp b/NXDNGateway/KenwoodNetwork.cpp index 40822c3..bbf9241 100644 --- a/NXDNGateway/KenwoodNetwork.cpp +++ b/NXDNGateway/KenwoodNetwork.cpp @@ -36,7 +36,6 @@ const unsigned int BUFFER_LENGTH = 200U; CKenwoodNetwork::CKenwoodNetwork(unsigned int localPort, const std::string& rptAddress, unsigned int rptPort, bool debug) : m_rtcpSocket(localPort + 1U), m_rtpSocket(localPort + 0U), -m_stopWatch(), m_address(), m_rtcpPort(rptPort + 1U), m_rtpPort(rptPort + 0U), @@ -240,6 +239,30 @@ bool CKenwoodNetwork::writeRTPVoiceHeader(const unsigned char* data) { assert(data != NULL); +#if defined(_WIN32) || defined(_WIN64) + SYSTEMTIME st; + ::GetSystemTime(&st); + + unsigned int hh = st.wHour; + unsigned int mm = st.wMinute; + unsigned int ss = st.wSecond; + unsigned int ms = st.wMilliseconds; + + m_timeStamp = hh * 3600U * 1000U * 80U; + m_timeStamp += mm * 60U * 1000U * 80U; + m_timeStamp += ss * 1000U * 80U; + m_timeStamp += ms * 80U; +#else + struct timeval tod; + ::gettimeofday(&tod, NULL); + + unsigned int ss = tod.tv_sec; + unsigned int ms = tod.tv_usec / 1000U; + + m_timeStamp = ss * 1000U * 80U; + m_timeStamp += ms * 80U; +#endif + unsigned char buffer[50U]; ::memset(buffer, 0x00U, 50U); @@ -250,8 +273,6 @@ bool CKenwoodNetwork::writeRTPVoiceHeader(const unsigned char* data) buffer[2U] = (m_seqNo >> 8) & 0xFFU; buffer[3U] = (m_seqNo >> 0) & 0xFFU; - m_timeStamp = (unsigned long)m_stopWatch.time(); - buffer[4U] = (m_timeStamp >> 24) & 0xFFU; buffer[5U] = (m_timeStamp >> 16) & 0xFFU; buffer[6U] = (m_timeStamp >> 8) & 0xFFU; diff --git a/NXDNGateway/KenwoodNetwork.h b/NXDNGateway/KenwoodNetwork.h index bf59c2f..ac16618 100644 --- a/NXDNGateway/KenwoodNetwork.h +++ b/NXDNGateway/KenwoodNetwork.h @@ -20,7 +20,6 @@ #define KenwoodNetwork_H #include "RptNetwork.h" -#include "StopWatch.h" #include "UDPSocket.h" #include "Timer.h" @@ -45,7 +44,6 @@ public: private: CUDPSocket m_rtpSocket; CUDPSocket m_rtcpSocket; - CStopWatch m_stopWatch; in_addr m_address; unsigned int m_rtcpPort; unsigned int m_rtpPort;