RTP-packets sent over network and too quick playback - Why?

This forum is about all development around libVLC.
andersbranderud
Blank Cone
Blank Cone
Posts: 10
Joined: 26 Mar 2012 20:54

RTP-packets sent over network and too quick playback - Why?

Postby andersbranderud » 15 Jul 2012 18:19

I am developing an application, in which a RTP-stream streamed by VLC (the data is a mp4 played at regular speed) and recorded with Wireshark is sent from a sender to a receiver. The sender FEC-encodes (using the library OpenFEC) the data and the receiver FEC-decodes the data and sents the RTP-packets to port 5004. In each FEC-unit there is e.g. 250 RTP-packets. There are 3 ms. between the sending of each RTP-packet.

At the receiver-side, when an whole FEC-unit is received, it is FEC-decoded; and all of the RTP-packets in the FEC-unit are sent in their correct order to VLC listening at port 5004 (rtp://127.0.0.1:5004).

When playing the stream, I notice that it plays quicker than it should. What is the reason for this and how can I resolve the problem?

Thanks!
Anders Branderud
Master's student, Computer science
www.abitsolutions.org
www.proofexistencegod.com

andersbranderud
Blank Cone
Blank Cone
Posts: 10
Joined: 26 Mar 2012 20:54

Re: RTP-packets sent over network and too quick playback - W

Postby andersbranderud » 20 Jul 2012 21:46

Here is part of my solution, which solved the problem. I still have a problem to make a HD-stream run as smooth as it is done when it is streamed by VLC. I guess that I would have to understand the timestamps better in order to do so.

Code: Select all

int timeStampDifference=0 ; //calcuate time-differnce, between two coming packets. char* nextTimestamp = new char[timeStampSizeRTP]; char* currentTimestamp = new char[timeStampSizeRTP]; int currentDifferenceTimeStampInt = 0; for (int j=0; j < nr_src_symb; j++ ) //last is j = nr_src_symb -1;; say j= 2 .. max is 3;; if take 3 => crash.. { currentTimestamp = ExtractBytesFromCharArrayAndReturnArrayWithIt (source_symbols[j],timeStampFirstByteNrOfRTPPacket, timeStampSizeRTP, j ); if (j < nr_src_symb -1) { nextTimestamp = ExtractBytesFromCharArrayAndReturnArrayWithIt (source_symbols[j+1],timeStampFirstByteNrOfRTPPacket, timeStampSizeRTP,j ); currentDifferenceTimeStampInt = calculateDifferenceBetweenTwoHexaValuesInCharArrays (currentTimestamp,nextTimestamp) ; //difference between next and current.. } retcode = sendto(rtpPlayerSocket,source_symbols[j] , symbolSize,0, (struct sockaddr *)&rtpPlayerAddress, sizeof(rtpPlayerAddress) ); int totalSleepMicroSec = currentDifferenceTimeStampInt * sleepMultiplicationFactor ; if (totalSleepMicroSec / 1000 > maxSleepInMilliSecBetweenRTPPackets) { printOutRTPPktSendingLog (concatenateIntWithString("\n;Old sleep value[s]::::: Sleep before changing [millisec] \n", totalSleepMicroSec /1000 ) ); totalSleepMicroSec = maxSleepInMilliSecBetweenRTPPackets*1000; } printOutRTPPktSendingLog (concatenateIntWithString("\n Sleep [millisec] \n", totalSleepMicroSec /1000 ) ); usleep (totalSleepMicroSec); //200 mikrosec max....
Anders Branderud
Master's student, Computer science
www.abitsolutions.org
www.proofexistencegod.com


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 16 guests