[Live-devel] RE: RTP packet rate smoothing?
Karl Gierach
KGierach at avst.com
Fri Jan 20 12:52:44 PST 2006
Ross,
I have a seemingly related problem where I experience CPU thrashing.
I am streaming real time audio recorded from a telephony interface.
The audio is fed into a buffer from the telephony interface at a
constant real-time rate, and I have code which integrates with the
live555 framework and reads the audio from this buffer.
I am finding that, very quickly, my buffer becomes empty.
I have traced a symptom of the problem down to this location of code in
MultiFramedRTPSink::sendPacketIfNecessary(). The computed value of
"uSecondsToGo" gradually becomes negative or 0, and my CPU begins to
thrash a bit as the active live555 thread continues to query the buffer
for data even though it is empty.
if (fNextSendTime.tv_sec < timeNow.tv_sec) {
uSecondsToGo = 0; // prevents integer underflow if too far behind
} else {
uSecondsToGo = (fNextSendTime.tv_sec - timeNow.tv_sec)*1000000
+ (fNextSendTime.tv_usec - timeNow.tv_usec);
}
// karl begin
if( uSecondsToGo < 0 )
{
uSecondsToGo = 20000; // std packet length - 20 ms
}
// karl end
I see that my first attempt to fix this is similar to what you have
proposed below. In my particular situation, should I stick with this
solution or would you recommend something else?
Thanks,
-Karl
>>Any suggestions on to spread out the packets that make up a given
>>frame so they are uniformly distributed over the frame time
>>(durationInMicroSeconds).
>
>A better (or at least easier) solution would be to ensure that
>there's at least a minimum delay between successive outgoing packets,
>so as to not exceed the overall bit rate of the network.
>
>I.e., add the following statement just before the call to
>"scheduleDelayedTask()" in "MultiFramedRTPSink.cpp":
> if (uSecondsToGo < minInterPacketGap) uSecondsToGo =
>minInterPacketGap;
More information about the live-devel
mailing list