[Live-devel] Simulation and packet loss, part three
Antonio Tirri
antoniotirri at libero.it
Tue Mar 13 12:46:42 PDT 2007
Hi,
I edited the live555 mediaserver in order to apply the Gilbert model to
send the video packets (gilbert model.jpg)
The code is:
void MultiFramedRTPSink::sendPacketIfNecessary() { //antonio
static int state = 0;
double p = 0.70; // defining p
double q = 0.20; // defining q
if (fNumFramesUsedSoFar > 0) {
if ((state == 0) && ((double)(our_random()%10000))/10000.0 <= p)
stato =1;
else if((state == 1) && ((double)(our_random()%10000))/10000.0
<=q) stato =0;
if(stato == 0)fRTPInterface.sendPacket(fOutBuf->packet(),
fOutBuf->curPacketSize());
++fPacketCount;
fTotalOctetCount += fOutBuf->curPacketSize();
fOctetCount += fOutBuf->curPacketSize()
- rtpHeaderSize - fSpecialHeaderSize -
fTotalFrameSpecificHeaderSizes;
++fSeqNo; // for next time
}
if (fOutBuf->haveOverflowData()
&& fOutBuf->totalBytesAvailable() > fOutBuf->totalBufferSize()/2) {
// Efficiency hack: Reset the packet start pointer to just in front of
// the overflow data (allowing for the RTP header and special headers),
// so that we probably don't have to "memmove()" the overflow data
// into place when building the next packet:
unsigned newPacketStart = fOutBuf->curPacketSize()
- (rtpHeaderSize + fSpecialHeaderSize + frameSpecificHeaderSize());
fOutBuf->adjustPacketStart(newPacketStart);
} else {
// Normal case: Reset the packet start pointer back to the start:
fOutBuf->resetPacketStart();
}
fOutBuf->resetOffset();
fNumFramesUsedSoFar = 0;
if (fNoFramesLeft) {
// We're done:
onSourceClosure(this);
} else {
// We have more frames left to send. Figure out when the next frame
// is due to start playing, then make sure that we wait this long
before
// sending the next packet.
struct timeval timeNow;
gettimeofday(&timeNow, NULL);
int uSecondsToGo;
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);
}
// Delay this amount of time:
nextTask() = envir().taskScheduler().scheduleDelayedTask(uSecondsToGo,
(TaskFunc*)sendNext, this);
}
}
I need to implement a scrambler and a descrambler as showed in the
modello.gif, in order to implement this technique of scrambling
(for more information:
http://en.wikipedia.org/wiki/Scrambler_%28randomizer%29 )
How can i start this work?
Thanks,
Antonio Tirri
-------------- next part --------------
A non-text attachment was scrubbed...
Name: modello.GIF
Type: image/gif
Size: 2376 bytes
Desc: not available
Url : http://lists.live555.com/pipermail/live-devel/attachments/20070313/72f82c1f/attachment-0001.gif
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gilbert model.jpg
Type: image/jpeg
Size: 11902 bytes
Desc: not available
Url : http://lists.live555.com/pipermail/live-devel/attachments/20070313/72f82c1f/attachment-0001.jpg
More information about the live-devel
mailing list