<!doctype html public "-//W3C//DTD W3 HTML//EN">
<html><head><style type="text/css"><!--
blockquote, dl, ul, ol, li { padding-top: 0 ; padding-bottom: 0 }
 --></style><title>Re: [Live-devel] incorrect uSecondsToGo
value</title></head><body>
<blockquote type="cite" cite><font face="Arial"
size="-1">    At line
391 of MultiFramedRTPSink.cpp :</font></blockquote>
<blockquote type="cite" cite> </blockquote>
<blockquote type="cite" cite><font face="Arial"
size="-1">        int64_t
uSecondsToGo = (fNextSendTime.tv_sec - timeNow.tv_sec)*1000000 +
(fNextSendTime.tv_usec - timeNow.tv_usec);</font></blockquote>
<blockquote type="cite" cite> </blockquote>
<blockquote type="cite" cite><font face="Arial"
size="-1">    In some situations,
(fNextSendTime.tv_sec - timeNow.tv_sec)*1000000  will become a
huge, but positive value.</font></blockquote>
<blockquote type="cite" cite><font face="Arial"
size="-1">    ex. <br>
           <span
></span> timeNow.tv_sec = 1291086790;<br>
           
fNextSendTime.tv_sec = 1291084611;</font></blockquote>
<blockquote type="cite" cite> </blockquote>
<blockquote type="cite" cite><font face="Arial"
size="-1"
>           <span
></span> (fNextSendTime.tv_sec - timeNow.tv_sec) =
-2179;</font></blockquote>
<blockquote type="cite" cite><font face="Arial"
size="-1"
>           <span
></span> (fNextSendTime.tv_sec - timeNow.tv_sec)*1000000 =
2115967296;</font></blockquote>
<div><br></div>
<div>Thanks for the report.</div>
<div><br></div>
<div>As far as I can tell, there are only two possible ways that this
problem ("fNextSendTime" being less than
"timeNow") could occur:</div>
<div>1/ The source object that feeds into this is generating invalid
"durationInMicroseconds" values,</div>
<div>2/ The system clock got set forward in time.</div>
<div><br></div>
<div>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.)</div>
<div><br></div>
<div>To overcome this situation, I suggest adding the following code
to replace the assignment of "uSecondsToGo" (i.e., 
replacing line 391):</div>
<div><br></div>
<div><x-tab>        </x-tab>int
secsDiff = fNextSendTime.tv_sec - timeNow.tv_sec;</div>
<div><x-tab>        </x-tab>int64_t
uSecondsToGo = secsDiff*1000000 + (fNextSendTime.tv_usec -
timeNow.tv_usec);</div>
<div><x-tab>        </x-tab>if
(secsDiff < 0 || uSecondsToGo < 0) { // sanity check (perhaps
the system clock jumped ahead?)</div>
<div><x-tab>       
</x-tab><x-tab>       
</x-tab>uSecondsToGo = 0;</div>
<div><x-tab>       
</x-tab><x-tab>       
</x-tab>fNextSendTime = timeNow;</div>
<div><x-tab>        </x-tab>}</div>
<div><br></div>
<div>This change will be added to the next release of the code.</div>
<div><br></div>
<div><br></div>
<blockquote type="cite" cite> <font face="Arial" size="-1">
   And I think the same problem will be
happened at
line 86 of BasicUDPSink.cpp.</font></blockquote>
<div><br></div>
<div>Yes.</div>
<x-sigsep><pre>-- 
</pre></x-sigsep>
<div><br>
Ross Finlayson<br>
Live Networks, Inc.<br>
http://www.live555.com/</div>
</body>
</html>