[Live-devel] incorrect uSecondsToGo value

Ross Finlayson finlayson at live555.com
Mon Nov 29 21:09:09 PST 2010


>     At line 391 of MultiFramedRTPSink.cpp :
>
>         int64_t uSecondsToGo = (fNextSendTime.tv_sec - 
>timeNow.tv_sec)*1000000 + (fNextSendTime.tv_usec - timeNow.tv_usec);
>
>     In some situations, (fNextSendTime.tv_sec - 
>timeNow.tv_sec)*1000000  will become a huge, but positive value.
>     ex. 
>             timeNow.tv_sec = 1291086790;
>             fNextSendTime.tv_sec = 1291084611;
>
>             (fNextSendTime.tv_sec - timeNow.tv_sec) = -2179;
>             (fNextSendTime.tv_sec - timeNow.tv_sec)*1000000 = 2115967296;

Thanks for the report.

As far as I can tell, there are only two possible ways that this 
problem ("fNextSendTime" being less than "timeNow") could occur:
1/ The source object that feeds into this is generating invalid 
"durationInMicroseconds" values,
2/ The system clock got set forward in time.

I don't care about 1/ (if the inputting source object is buggy, then 
that's its problem, not ours), but 2/ is a legitimate concern. 
(Sebastien Escudier has also noted similar problems.)

To overcome this situation, I suggest adding the following code to 
replace the assignment of "uSecondsToGo" (i.e.,  replacing line 391):

	int secsDiff = fNextSendTime.tv_sec - timeNow.tv_sec;
	int64_t uSecondsToGo = secsDiff*1000000 + 
(fNextSendTime.tv_usec - timeNow.tv_usec);
	if (secsDiff < 0 || uSecondsToGo < 0) { // sanity check 
(perhaps the system clock jumped ahead?)
		uSecondsToGo = 0;
		fNextSendTime = timeNow;
	}

This change will be added to the next release of the code.


>      And I think the same problem will be happened at 
>line 86 of BasicUDPSink.cpp.

Yes.
-- 

Ross Finlayson
Live Networks, Inc.
http://www.live555.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.live555.com/pipermail/live-devel/attachments/20101129/57b65659/attachment.html>


More information about the live-devel mailing list