Hi,

Last month, I sent a bug report and received no answers :
http://lists.live555.com/pipermail/live-devel/2009-July/010939.html
http://lists.live555.com/pipermail/live-devel/2009-July/010966.html

The issue is : if you change your system time while you receive a stream, then
the library may make your cpu very busy.

So I patched the library myself : I replaced gettimeofday by a monotonic clock.
This has only been tested with linux. In case someone else is looking for a
solution to this bug, I attached my patch.

Regards,

Seb.
From a37614941ca9dd4fa571a33a65d2937c186dcd19 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?S=C3=A9bastien=20Escudier?= <sebastien-de...@celeos.eu>
Date: Mon, 17 Aug 2009 06:55:40 +0200
Subject: [PATCH] Use a monotonic clock

---
 BasicUsageEnvironment/DelayQueue.cpp               |    2 +-
 .../WindowsAudioInputDevice_common.cpp             |    2 +-
 config.linux                                       |    2 +-
 config.linux-gdb                                   |    2 +-
 groupsock/GroupsockHelper.cpp                      |   15 ++++++++++++---
 groupsock/include/GroupsockHelper.hh               |    5 +----
 liveMedia/AC3AudioStreamFramer.cpp                 |    2 +-
 liveMedia/ADTSAudioFileSource.cpp                  |    2 +-
 liveMedia/AMRAudioFileSource.cpp                   |    2 +-
 liveMedia/AVIFileSink.cpp                          |    2 +-
 liveMedia/BasicUDPSink.cpp                         |    4 ++--
 liveMedia/ByteStreamFileSource.cpp                 |    4 ++--
 liveMedia/DigestAuthentication.cpp                 |    2 +-
 liveMedia/H263plusVideoStreamFramer.cpp            |    2 +-
 liveMedia/MP3StreamState.cpp                       |    2 +-
 liveMedia/MPEG1or2AudioStreamFramer.cpp            |    2 +-
 liveMedia/MPEG2TransportStreamFramer.cpp           |    2 +-
 liveMedia/MPEGVideoStreamFramer.cpp                |    2 +-
 liveMedia/MultiFramedRTPSink.cpp                   |    4 ++--
 liveMedia/MultiFramedRTPSource.cpp                 |    4 ++--
 liveMedia/QuickTimeFileSink.cpp                    |    4 ++--
 liveMedia/RTCP.cpp                                 |    6 +++---
 liveMedia/RTPSink.cpp                              |   10 +++++-----
 liveMedia/RTPSource.cpp                            |    4 ++--
 liveMedia/RTSPClient.cpp                           |    2 +-
 liveMedia/ServerMediaSession.cpp                   |    2 +-
 liveMedia/WAVAudioFileSource.cpp                   |    2 +-
 testProgs/playCommon.cpp                           |   16 ++++++++--------
 28 files changed, 58 insertions(+), 52 deletions(-)

diff --git a/BasicUsageEnvironment/DelayQueue.cpp b/BasicUsageEnvironment/DelayQueue.cpp
index 64c6c25..929ce35 100644
--- a/BasicUsageEnvironment/DelayQueue.cpp
+++ b/BasicUsageEnvironment/DelayQueue.cpp
@@ -212,7 +212,7 @@ void DelayQueue::synchronize() {
 EventTime TimeNow() {
   struct timeval tvNow;
 
-  gettimeofday(&tvNow, NULL);
+  mgettimeofday(&tvNow, NULL);
 
   return EventTime(tvNow.tv_sec, tvNow.tv_usec);
 }
diff --git a/WindowsAudioInputDevice/WindowsAudioInputDevice_common.cpp b/WindowsAudioInputDevice/WindowsAudioInputDevice_common.cpp
index 4671eee..f7f6759 100644
--- a/WindowsAudioInputDevice/WindowsAudioInputDevice_common.cpp
+++ b/WindowsAudioInputDevice/WindowsAudioInputDevice_common.cpp
@@ -288,7 +288,7 @@ void WindowsAudioInputDevice_common::waveInProc(WAVEHDR* hdr) {
 
   // Record the time that the data arrived:
   int dontCare;
-  gettimeofday(&readTimes[hdrIndex], &dontCare);
+  mgettimeofday(&readTimes[hdrIndex], &dontCare);
 
   // Add the block to the tail of the queue:
   hdr->lpNext = NULL;
diff --git a/config.linux b/config.linux
index e111780..cbb6954 100644
--- a/config.linux
+++ b/config.linux
@@ -8,7 +8,7 @@ CPLUSPLUS_FLAGS =	$(COMPILE_OPTS) -Wall -DBSD=1
 OBJ =			o
 LINK =			c++ -o
 LINK_OPTS =		-L.
-CONSOLE_LINK_OPTS =	$(LINK_OPTS)
+CONSOLE_LINK_OPTS =	$(LINK_OPTS) -lrt
 LIBRARY_LINK =		ld -o
 LIBRARY_LINK_OPTS =	$(LINK_OPTS) -r -Bstatic
 LIB_SUFFIX =			a
diff --git a/config.linux-gdb b/config.linux-gdb
index 4c64030..b00976b 100644
--- a/config.linux-gdb
+++ b/config.linux-gdb
@@ -8,7 +8,7 @@ CPLUSPLUS_FLAGS =	$(COMPILE_OPTS) -Wall -DBSD=1
 OBJ =			o
 LINK =			c++ -o
 LINK_OPTS =		-L.
-CONSOLE_LINK_OPTS =	$(LINK_OPTS)
+CONSOLE_LINK_OPTS =	$(LINK_OPTS) -lrt
 LIBRARY_LINK =		ld -o
 LIBRARY_LINK_OPTS =	$(LINK_OPTS) -r -Bstatic
 LIB_SUFFIX =			a
diff --git a/groupsock/GroupsockHelper.cpp b/groupsock/GroupsockHelper.cpp
index 09e127d..a61b4d6 100644
--- a/groupsock/GroupsockHelper.cpp
+++ b/groupsock/GroupsockHelper.cpp
@@ -676,7 +676,7 @@ netAddressBits ourIPAddress(UsageEnvironment& env) {
     // Use our newly-discovered IP address, and the current time,
     // to initialize the random number generator's seed:
     struct timeval timeNow;
-    gettimeofday(&timeNow, NULL);
+    mgettimeofday(&timeNow, NULL);
     unsigned seed = ourAddress^timeNow.tv_sec^timeNow.tv_usec;
     our_srandom(seed);
   }
@@ -697,7 +697,7 @@ netAddressBits chooseRandomIPv4SSMAddress(UsageEnvironment& env) {
 
 char const* timestampString() {
   struct timeval tvNow;
-  gettimeofday(&tvNow, NULL);
+  mgettimeofday(&tvNow, NULL);
 
 #if !defined(_WIN32_WCE)
   static char timeString[9]; // holds hh:mm:ss plus trailing '\0'
@@ -725,7 +725,7 @@ char const* timestampString() {
 #include <sys/timeb.h>
 #endif
 
-int gettimeofday(struct timeval* tp, int* /*tz*/) {
+int mgettimeofday(struct timeval* tp, int* /*tz*/) {
 #if defined(_WIN32_WCE)
   /* FILETIME of Jan 1 1970 00:00:00. */
   static const unsigned __int64 epoch = 116444736000000000L;
@@ -775,4 +775,13 @@ int gettimeofday(struct timeval* tp, int* /*tz*/) {
 #endif
   return 0;
 }
+#else
+#include <time.h>
+int mgettimeofday(struct timeval* tp, int* /*tz*/) {
+    struct timespec ts;
+	clock_gettime( CLOCK_MONOTONIC, &ts );
+	tp->tv_sec = ts.tv_sec;
+	tp->tv_usec = ts.tv_nsec/1000;
+	return 0;
+}
 #endif
diff --git a/groupsock/include/GroupsockHelper.hh b/groupsock/include/GroupsockHelper.hh
index 59449ca..49d205d 100644
--- a/groupsock/include/GroupsockHelper.hh
+++ b/groupsock/include/GroupsockHelper.hh
@@ -117,10 +117,7 @@ public:
 };
 
 
-#if (defined(__WIN32__) || defined(_WIN32)) && !defined(IMN_PIM)
-// For Windoze, we need to implement our own gettimeofday()
-extern int gettimeofday(struct timeval*, int*);
-#endif
+extern int mgettimeofday(struct timeval*, int*);
 
 // The following are implemented in inet.c:
 extern "C" netAddressBits our_inet_addr(char const*);
diff --git a/liveMedia/AC3AudioStreamFramer.cpp b/liveMedia/AC3AudioStreamFramer.cpp
index 7b29313..48a6730 100644
--- a/liveMedia/AC3AudioStreamFramer.cpp
+++ b/liveMedia/AC3AudioStreamFramer.cpp
@@ -88,7 +88,7 @@ AC3AudioStreamFramer::AC3AudioStreamFramer(UsageEnvironment& env,
 					   unsigned char streamCode)
   : FramedFilter(env, inputSource), fOurStreamCode(streamCode) {
   // Use the current wallclock time as the initial 'presentation time':
-  gettimeofday(&fNextFramePresentationTime, NULL);
+  mgettimeofday(&fNextFramePresentationTime, NULL);
 
   fParser = new AC3AudioStreamParser(this, inputSource);
 }
diff --git a/liveMedia/ADTSAudioFileSource.cpp b/liveMedia/ADTSAudioFileSource.cpp
index 8c13201..32e2a65 100644
--- a/liveMedia/ADTSAudioFileSource.cpp
+++ b/liveMedia/ADTSAudioFileSource.cpp
@@ -155,7 +155,7 @@ void ADTSAudioFileSource::doGetNextFrame() {
   // Set the 'presentation time':
   if (fPresentationTime.tv_sec == 0 && fPresentationTime.tv_usec == 0) {
     // This is the first frame, so use the current time:
-    gettimeofday(&fPresentationTime, NULL);
+    mgettimeofday(&fPresentationTime, NULL);
   } else {
     // Increment by the play time of the previous frame:
     unsigned uSeconds = fPresentationTime.tv_usec + fuSecsPerFrame;
diff --git a/liveMedia/AMRAudioFileSource.cpp b/liveMedia/AMRAudioFileSource.cpp
index a75c797..36bf36f 100644
--- a/liveMedia/AMRAudioFileSource.cpp
+++ b/liveMedia/AMRAudioFileSource.cpp
@@ -158,7 +158,7 @@ void AMRAudioFileSource::doGetNextFrame() {
   // Set the 'presentation time':
   if (fPresentationTime.tv_sec == 0 && fPresentationTime.tv_usec == 0) {
     // This is the first frame, so use the current time:
-    gettimeofday(&fPresentationTime, NULL);
+    mgettimeofday(&fPresentationTime, NULL);
   } else {
     // Increment by the play time of the previous frame (20 ms)
     unsigned uSeconds	= fPresentationTime.tv_usec + 20000;
diff --git a/liveMedia/AVIFileSink.cpp b/liveMedia/AVIFileSink.cpp
index 0793fab..1af559f 100644
--- a/liveMedia/AVIFileSink.cpp
+++ b/liveMedia/AVIFileSink.cpp
@@ -266,7 +266,7 @@ void AVIFileSink::onRTCPBye(void* clientData) {
   AVISubsessionIOState* ioState = (AVISubsessionIOState*)clientData;
 
   struct timeval timeNow;
-  gettimeofday(&timeNow, NULL);
+  mgettimeofday(&timeNow, NULL);
   unsigned secsDiff
     = timeNow.tv_sec - ioState->fOurSink.fStartTime.tv_sec;
 
diff --git a/liveMedia/BasicUDPSink.cpp b/liveMedia/BasicUDPSink.cpp
index 5f40ef0..3af2406 100644
--- a/liveMedia/BasicUDPSink.cpp
+++ b/liveMedia/BasicUDPSink.cpp
@@ -39,7 +39,7 @@ BasicUDPSink::~BasicUDPSink() {
 
 Boolean BasicUDPSink::continuePlaying() {
   // Record the fact that we're starting to play now:
-  gettimeofday(&fNextSendTime, NULL);
+  mgettimeofday(&fNextSendTime, NULL);
 
   // Arrange to get and send the first payload.
   // (This will also schedule any future sends.)
@@ -81,7 +81,7 @@ void BasicUDPSink::afterGettingFrame1(unsigned frameSize, unsigned numTruncatedB
   fNextSendTime.tv_usec %= 1000000;
 
   struct timeval timeNow;
-  gettimeofday(&timeNow, NULL);
+  mgettimeofday(&timeNow, NULL);
   int uSecondsToGo;
   if (fNextSendTime.tv_sec < timeNow.tv_sec) {
     uSecondsToGo = 0; // prevents integer underflow if too far behind
diff --git a/liveMedia/ByteStreamFileSource.cpp b/liveMedia/ByteStreamFileSource.cpp
index 43679dd..d955fc3 100644
--- a/liveMedia/ByteStreamFileSource.cpp
+++ b/liveMedia/ByteStreamFileSource.cpp
@@ -145,7 +145,7 @@ void ByteStreamFileSource::doReadFromFile() {
   if (fPlayTimePerFrame > 0 && fPreferredFrameSize > 0) {
     if (fPresentationTime.tv_sec == 0 && fPresentationTime.tv_usec == 0) {
       // This is the first frame, so use the current time:
-      gettimeofday(&fPresentationTime, NULL);
+      mgettimeofday(&fPresentationTime, NULL);
     } else {
       // Increment by the play time of the previous data:
       unsigned uSeconds	= fPresentationTime.tv_usec + fLastPlayTime;
@@ -159,7 +159,7 @@ void ByteStreamFileSource::doReadFromFile() {
   } else {
     // We don't know a specific play time duration for this data,
     // so just record the current time as being the 'presentation time':
-    gettimeofday(&fPresentationTime, NULL);
+    mgettimeofday(&fPresentationTime, NULL);
   }
 
   // Inform the reader that he has data:
diff --git a/liveMedia/DigestAuthentication.cpp b/liveMedia/DigestAuthentication.cpp
index 72fcf7b..0042d07 100644
--- a/liveMedia/DigestAuthentication.cpp
+++ b/liveMedia/DigestAuthentication.cpp
@@ -67,7 +67,7 @@ void Authenticator::setRealmAndRandomNonce(char const* realm) {
     struct timeval timestamp;
     unsigned counter;
   } seedData;
-  gettimeofday(&seedData.timestamp, NULL);
+  mgettimeofday(&seedData.timestamp, NULL);
   static unsigned counter = 0;
   seedData.counter = ++counter;
 
diff --git a/liveMedia/H263plusVideoStreamFramer.cpp b/liveMedia/H263plusVideoStreamFramer.cpp
index 2522c47..b4823ed 100644
--- a/liveMedia/H263plusVideoStreamFramer.cpp
+++ b/liveMedia/H263plusVideoStreamFramer.cpp
@@ -50,7 +50,7 @@ H263plusVideoStreamFramer::H263plusVideoStreamFramer(
                                 fPictureEndMarker(False)
 {
    // Use the current wallclock time as the base 'presentation time':
-   gettimeofday(&fPresentationTimeBase, NULL);
+   mgettimeofday(&fPresentationTimeBase, NULL);
    fParser = createParser ? new H263plusVideoStreamParser(this, inputSource) : NULL;
 }
 
diff --git a/liveMedia/MP3StreamState.cpp b/liveMedia/MP3StreamState.cpp
index 18803b8..430a104 100644
--- a/liveMedia/MP3StreamState.cpp
+++ b/liveMedia/MP3StreamState.cpp
@@ -57,7 +57,7 @@ void MP3StreamState::assignStream(FILE* fid, unsigned fileSize) {
   fIsVBR = fHasXingTOC = False; // ditto
 
   // Set the first frame's 'presentation time' to the current wall time:
-  gettimeofday(&fNextFramePresentationTime, NULL);
+  mgettimeofday(&fNextFramePresentationTime, NULL);
 }
 
 struct timeval MP3StreamState::currentFramePlayTime() const {
diff --git a/liveMedia/MPEG1or2AudioStreamFramer.cpp b/liveMedia/MPEG1or2AudioStreamFramer.cpp
index 8038464..1d04ed2 100644
--- a/liveMedia/MPEG1or2AudioStreamFramer.cpp
+++ b/liveMedia/MPEG1or2AudioStreamFramer.cpp
@@ -80,7 +80,7 @@ void MPEG1or2AudioStreamFramer::flushInput() {
 void MPEG1or2AudioStreamFramer::reset() {
   // Use the current wallclock time as the initial 'presentation time':
   struct timeval timeNow;
-  gettimeofday(&timeNow, NULL);
+  mgettimeofday(&timeNow, NULL);
   resetPresentationTime(timeNow);
 }
 
diff --git a/liveMedia/MPEG2TransportStreamFramer.cpp b/liveMedia/MPEG2TransportStreamFramer.cpp
index 11efc59..aa83204 100644
--- a/liveMedia/MPEG2TransportStreamFramer.cpp
+++ b/liveMedia/MPEG2TransportStreamFramer.cpp
@@ -138,7 +138,7 @@ void MPEG2TransportStreamFramer::afterGettingFrame1(unsigned frameSize,
   // Scan through the TS packets that we read, and update our estimate of
   // the duration of each packet:
   struct timeval tvNow;
-  gettimeofday(&tvNow, NULL);
+  mgettimeofday(&tvNow, NULL);
   double timeNow = tvNow.tv_sec + tvNow.tv_usec/1000000.0;
   for (unsigned i = 0; i < numTSPackets; ++i) {
     updateTSPacketDurationEstimate(&fTo[i*TRANSPORT_PACKET_SIZE], timeNow);
diff --git a/liveMedia/MPEGVideoStreamFramer.cpp b/liveMedia/MPEGVideoStreamFramer.cpp
index 212af37..3e1a528 100644
--- a/liveMedia/MPEGVideoStreamFramer.cpp
+++ b/liveMedia/MPEGVideoStreamFramer.cpp
@@ -64,7 +64,7 @@ void MPEGVideoStreamFramer::reset() {
   fHaveSeenFirstTimeCode = False;
 
   // Use the current wallclock time as the base 'presentation time':
-  gettimeofday(&fPresentationTimeBase, NULL);
+  mgettimeofday(&fPresentationTimeBase, NULL);
 }
 
 #ifdef DEBUG
diff --git a/liveMedia/MultiFramedRTPSink.cpp b/liveMedia/MultiFramedRTPSink.cpp
index 0f81fe5..867c090 100644
--- a/liveMedia/MultiFramedRTPSink.cpp
+++ b/liveMedia/MultiFramedRTPSink.cpp
@@ -232,7 +232,7 @@ void MultiFramedRTPSink
 		     unsigned durationInMicroseconds) {
   if (fIsFirstPacket) {
     // Record the fact that we're starting to play now:
-    gettimeofday(&fNextSendTime, NULL);
+    mgettimeofday(&fNextSendTime, NULL);
   }
 
   if (numTruncatedBytes > 0) {
@@ -389,7 +389,7 @@ void MultiFramedRTPSink::sendPacketIfNecessary() {
     // is due to start playing, then make sure that we wait this long before
     // sending the next packet.
     struct timeval timeNow;
-    gettimeofday(&timeNow, NULL);
+    mgettimeofday(&timeNow, NULL);
     int uSecondsToGo;
     if (fNextSendTime.tv_sec < timeNow.tv_sec
 	|| (fNextSendTime.tv_sec == timeNow.tv_sec && fNextSendTime.tv_usec < timeNow.tv_usec)) {
diff --git a/liveMedia/MultiFramedRTPSource.cpp b/liveMedia/MultiFramedRTPSource.cpp
index dee9a53..aeb5737 100644
--- a/liveMedia/MultiFramedRTPSource.cpp
+++ b/liveMedia/MultiFramedRTPSource.cpp
@@ -284,7 +284,7 @@ void MultiFramedRTPSource::networkReadHandler(MultiFramedRTPSource* source,
 
     // Fill in the rest of the packet descriptor, and store it:
     struct timeval timeNow;
-    gettimeofday(&timeNow, NULL);
+    mgettimeofday(&timeNow, NULL);
     bPacket->assignMiscParams(rtpSeqNo, rtpTimestamp, presentationTime,
 			      hasBeenSyncedUsingRTCP, rtpMarkerBit,
 			      timeNow);
@@ -540,7 +540,7 @@ BufferedPacket* ReorderingPacketBuffer
   // our time threshold has been exceeded, then forget it, and return
   // the head packet instead:
   struct timeval timeNow;
-  gettimeofday(&timeNow, NULL);
+  mgettimeofday(&timeNow, NULL);
   unsigned uSecondsSinceReceived
     = (timeNow.tv_sec - fHeadPacket->timeReceived().tv_sec)*1000000
     + (timeNow.tv_usec - fHeadPacket->timeReceived().tv_usec);
diff --git a/liveMedia/QuickTimeFileSink.cpp b/liveMedia/QuickTimeFileSink.cpp
index 08316c7..c61a530 100644
--- a/liveMedia/QuickTimeFileSink.cpp
+++ b/liveMedia/QuickTimeFileSink.cpp
@@ -286,7 +286,7 @@ QuickTimeFileSink::QuickTimeFileSink(UsageEnvironment& env,
   // Use the current time as the file's creation and modification
   // time.  Use Apple's time format: seconds since January 1, 1904
 
-  gettimeofday(&fStartTime, NULL);
+  mgettimeofday(&fStartTime, NULL);
   fAppleCreationTime = fStartTime.tv_sec - 0x83dac000;
 
   // Begin by writing a "mdat" atom at the start of the file.
@@ -428,7 +428,7 @@ void QuickTimeFileSink::onRTCPBye(void* clientData) {
   SubsessionIOState* ioState = (SubsessionIOState*)clientData;
 
   struct timeval timeNow;
-  gettimeofday(&timeNow, NULL);
+  mgettimeofday(&timeNow, NULL);
   unsigned secsDiff
     = timeNow.tv_sec - ioState->fOurSink.fStartTime.tv_sec;
 
diff --git a/liveMedia/RTCP.cpp b/liveMedia/RTCP.cpp
index 7edc64c..5d9762d 100644
--- a/liveMedia/RTCP.cpp
+++ b/liveMedia/RTCP.cpp
@@ -109,7 +109,7 @@ void RTCPMemberDatabase::reapOldMembers(unsigned threshold) {
 
 static double dTimeNow() {
     struct timeval timeNow;
-    gettimeofday(&timeNow, NULL);
+    mgettimeofday(&timeNow, NULL);
     return (double) (timeNow.tv_sec + timeNow.tv_usec/1000000.0);
 }
 
@@ -686,7 +686,7 @@ void RTCPInstance::addSR() {
 
   // Insert the NTP and RTP timestamps for the 'wallclock time':
   struct timeval timeNow;
-  gettimeofday(&timeNow, NULL);
+  mgettimeofday(&timeNow, NULL);
   fOutBuf->enqueueWord(timeNow.tv_sec + 0x83AA7E80);
       // NTP timestamp most-significant word (1970 epoch -> 1900 epoch)
   double fractionalPart = (timeNow.tv_usec/15625.0)*0x04000000; // 2^32/10^6
@@ -793,7 +793,7 @@ RTCPInstance::enqueueReportBlock(RTPReceptionStats* stats) {
   // Figure out how long has elapsed since the last SR rcvd from this src:
   struct timeval const& LSRtime = stats->lastReceivedSR_time(); // "last SR"
   struct timeval timeNow, timeSinceLSR;
-  gettimeofday(&timeNow, NULL);
+  mgettimeofday(&timeNow, NULL);
   if (timeNow.tv_usec < LSRtime.tv_usec) {
     timeNow.tv_usec += 1000000;
     timeNow.tv_sec -= 1;
diff --git a/liveMedia/RTPSink.cpp b/liveMedia/RTPSink.cpp
index 0d7287b..8e698d5 100644
--- a/liveMedia/RTPSink.cpp
+++ b/liveMedia/RTPSink.cpp
@@ -55,7 +55,7 @@ RTPSink::RTPSink(UsageEnvironment& env,
     fNumChannels(numChannels) {
   fRTPPayloadFormatName
     = strDup(rtpPayloadFormatName == NULL ? "???" : rtpPayloadFormatName);
-  gettimeofday(&fCreationTime, NULL);
+  mgettimeofday(&fCreationTime, NULL);
   fTotalOctetCountStartTime = fCreationTime;
 
   fSeqNo = (u_int16_t)our_random();
@@ -96,7 +96,7 @@ u_int32_t RTPSink::convertToRTPTimestamp(struct timeval tv) {
 
 u_int32_t RTPSink::presetNextTimestamp() {
   struct timeval timeNow;
-  gettimeofday(&timeNow, NULL);
+  mgettimeofday(&timeNow, NULL);
 
   u_int32_t tsNow = convertToRTPTimestamp(timeNow);
   fTimestampBase = tsNow;
@@ -107,7 +107,7 @@ u_int32_t RTPSink::presetNextTimestamp() {
 
 void RTPSink::getTotalBitrate(unsigned& outNumBytes, double& outElapsedTime) {
   struct timeval timeNow;
-  gettimeofday(&timeNow, NULL);
+  mgettimeofday(&timeNow, NULL);
 
   outNumBytes = fTotalOctetCount;
   outElapsedTime = (double)(timeNow.tv_sec-fTotalOctetCountStartTime.tv_sec)
@@ -239,7 +239,7 @@ RTPTransmissionStats::RTPTransmissionStats(RTPSink& rtpSink, u_int32_t SSRC)
     fLastSRTime(0), fDiffSR_RRTime(0), fFirstPacket(True),
     fTotalOctetCount_hi(0), fTotalOctetCount_lo(0),
     fTotalPacketCount_hi(0), fTotalPacketCount_lo(0) {
-  gettimeofday(&fTimeCreated, NULL);
+  mgettimeofday(&fTimeCreated, NULL);
 
   fLastOctetCount = rtpSink.octetCount();
   fLastPacketCount = rtpSink.packetCount();
@@ -260,7 +260,7 @@ void RTPTransmissionStats
     fOldLastPacketNumReceived = fLastPacketNumReceived;
     fOldTotNumPacketsLost = fTotNumPacketsLost;
   }
-  gettimeofday(&fTimeReceived, NULL);
+  mgettimeofday(&fTimeReceived, NULL);
 
   fLastFromAddress = lastFromAddress;
   fPacketLossRatio = lossStats>>24;
diff --git a/liveMedia/RTPSource.cpp b/liveMedia/RTPSource.cpp
index f5904d7..d0b1cfb 100644
--- a/liveMedia/RTPSource.cpp
+++ b/liveMedia/RTPSource.cpp
@@ -262,7 +262,7 @@ void RTPReceptionStats
 
   // Record the inter-packet delay
   struct timeval timeNow;
-  gettimeofday(&timeNow, NULL);
+  mgettimeofday(&timeNow, NULL);
   if (fLastPacketReceptionTime.tv_sec != 0
       || fLastPacketReceptionTime.tv_usec != 0) {
     unsigned gap
@@ -356,7 +356,7 @@ void RTPReceptionStats::noteIncomingSR(u_int32_t ntpTimestampMSW,
   fLastReceivedSR_NTPmsw = ntpTimestampMSW;
   fLastReceivedSR_NTPlsw = ntpTimestampLSW;
 
-  gettimeofday(&fLastReceivedSR_time, NULL);
+  mgettimeofday(&fLastReceivedSR_time, NULL);
 
   // Use this SR to update time synchronization information:
   fSyncTimestamp = rtpTimestamp;
diff --git a/liveMedia/RTSPClient.cpp b/liveMedia/RTSPClient.cpp
index a1a21b0..a397269 100644
--- a/liveMedia/RTSPClient.cpp
+++ b/liveMedia/RTSPClient.cpp
@@ -2397,7 +2397,7 @@ Boolean RTSPClient::setupHTTPTunneling(char const* urlSuffix,
       struct timeval timestamp;
       unsigned counter;
     } seedData;
-    gettimeofday(&seedData.timestamp, NULL);
+    mgettimeofday(&seedData.timestamp, NULL);
     static unsigned counter = 0;
     seedData.counter = ++counter;
     char sessionCookie[33];
diff --git a/liveMedia/ServerMediaSession.cpp b/liveMedia/ServerMediaSession.cpp
index a2ec3fc..0083990 100644
--- a/liveMedia/ServerMediaSession.cpp
+++ b/liveMedia/ServerMediaSession.cpp
@@ -69,7 +69,7 @@ ServerMediaSession::ServerMediaSession(UsageEnvironment& env,
     = strDup(description == NULL ? libNameStr : description);
   fMiscSDPLines = strDup(miscSDPLines == NULL ? "" : miscSDPLines);
 
-  gettimeofday(&fCreationTime, NULL);
+  mgettimeofday(&fCreationTime, NULL);
 }
 
 ServerMediaSession::~ServerMediaSession() {
diff --git a/liveMedia/WAVAudioFileSource.cpp b/liveMedia/WAVAudioFileSource.cpp
index 4d24a52..0ccd569 100644
--- a/liveMedia/WAVAudioFileSource.cpp
+++ b/liveMedia/WAVAudioFileSource.cpp
@@ -234,7 +234,7 @@ void WAVAudioFileSource::doGetNextFrame() {
   // Set the 'presentation time' and 'duration' of this frame:
   if (fPresentationTime.tv_sec == 0 && fPresentationTime.tv_usec == 0) {
     // This is the first frame, so use the current time:
-    gettimeofday(&fPresentationTime, NULL);
+    mgettimeofday(&fPresentationTime, NULL);
   } else {
     // Increment by the play time of the previous data:
     unsigned uSeconds	= fPresentationTime.tv_usec + fLastPlayTime;
diff --git a/testProgs/playCommon.cpp b/testProgs/playCommon.cpp
index 44a697a..e187aa5 100644
--- a/testProgs/playCommon.cpp
+++ b/testProgs/playCommon.cpp
@@ -121,7 +121,7 @@ int main(int argc, char** argv) {
 
   progName = argv[0];
 
-  gettimeofday(&startTime, NULL);
+  mgettimeofday(&startTime, NULL);
 
 #ifdef USE_SIGNALS
   // Allow ourselves to be shut down gracefully by a SIGHUP or a SIGUSR1:
@@ -665,7 +665,7 @@ int main(int argc, char** argv) {
       unsigned headerSize;
       unsigned char* headerData = RealGenerateRMFFHeader(session, headerSize);
       struct timeval timeNow;
-      gettimeofday(&timeNow, NULL);
+      mgettimeofday(&timeNow, NULL);
       fileSink->addData(headerData, headerSize, timeNow);
       delete[] headerData;
 
@@ -743,7 +743,7 @@ int main(int argc, char** argv) {
 	    unsigned char* configData
 	      = parseGeneralConfigStr(subsession->fmtp_config(), configLen);
 	    struct timeval timeNow;
-	    gettimeofday(&timeNow, NULL);
+	    mgettimeofday(&timeNow, NULL);
 	    fileSink->addData(configData, configLen, timeNow);
 	    delete[] configData;
 	  }
@@ -901,7 +901,7 @@ void subsessionAfterPlaying(void* clientData) {
 
 void subsessionByeHandler(void* clientData) {
   struct timeval timeNow;
-  gettimeofday(&timeNow, NULL);
+  mgettimeofday(&timeNow, NULL);
   unsigned secsDiff = timeNow.tv_sec - startTime.tv_sec;
 
   MediaSubsession* subsession = (MediaSubsession*)clientData;
@@ -982,7 +982,7 @@ static unsigned nextQOSMeasurementUSecs;
 static void scheduleNextQOSMeasurement() {
   nextQOSMeasurementUSecs += qosMeasurementIntervalMS*1000;
   struct timeval timeNow;
-  gettimeofday(&timeNow, NULL);
+  mgettimeofday(&timeNow, NULL);
   unsigned timeNowUSecs = timeNow.tv_sec*1000000 + timeNow.tv_usec;
   unsigned usecsToDelay = nextQOSMeasurementUSecs - timeNowUSecs;
      // Note: This works even when nextQOSMeasurementUSecs wraps around
@@ -993,7 +993,7 @@ static void scheduleNextQOSMeasurement() {
 
 static void periodicQOSMeasurement(void* /*clientData*/) {
   struct timeval timeNow;
-  gettimeofday(&timeNow, NULL);
+  mgettimeofday(&timeNow, NULL);
 
   for (qosMeasurementRecord* qosRecord = qosRecordHead;
        qosRecord != NULL; qosRecord = qosRecord->fNext) {
@@ -1064,7 +1064,7 @@ void qosMeasurementRecord
 void beginQOSMeasurement() {
   // Set up a measurement record for each active subsession:
   struct timeval startTime;
-  gettimeofday(&startTime, NULL);
+  mgettimeofday(&startTime, NULL);
   nextQOSMeasurementUSecs = startTime.tv_sec*1000000 + startTime.tv_usec;
   qosMeasurementRecord* qosRecordTail = NULL;
   MediaSubsessionIterator iter(*session);
@@ -1261,7 +1261,7 @@ void checkForPacketArrival(void* /*clientData*/) {
   }
   if (notifyTheUser) {
     struct timeval timeNow;
-    gettimeofday(&timeNow, NULL);
+    mgettimeofday(&timeNow, NULL);
 	char timestampStr[100];
 	sprintf(timestampStr, "%ld%03ld", timeNow.tv_sec, (long)(timeNow.tv_usec/1000));
     *env << (syncStreams ? "Synchronized d" : "D")
-- 
1.5.6.3

_______________________________________________
live-devel mailing list
live-devel@lists.live555.com
http://lists.live555.com/mailman/listinfo/live-devel

Reply via email to