[FFmpeg-devel] RTP PCM_MULAW packet size

Luca Barbato lu_zero
Thu Feb 19 08:59:18 CET 2009


Georges-Etienne Legendre wrote:
> Hi,
> 
> The RTP format allows to set the packet size with the pkt_size  
> parameter (in the URL). In the rtpenc.c file, when the function  
> rtp_write_packet is called (or other more specialized function like  
> rtp_send_samples), this packet size parameter is taken into account.
> 
> The problem with this approach, at least for PCM MULAW, is that RTP  
> packets are sent without respecting the -re parameter. That's because  
> final RTP packet size is driven in the rtpenc.c file, and not before.  
> The other problem is that small packets are generated.
> 
> Here is an example for PCM MULAW:
> 
> --------- Situation #1 ---------
> In that situation, if the -re option is used, RTP packets are sent  
> only when needed.
> 
> Without the pkt_size set:
> 1. RTP packet size = 588 (including header), 576 bytes of payload
> 2. RTP packet size = 588 (including header), 576 bytes of payload
> 
> --------- Situation #2 ---------
> In that situation, if the -re option is used, RTP packets are sent in  
> block.
> 
> With pkt_size set to 92 (rtp://localhost:5000?pkt_size=92):
> Only one call to rtp_send_samples, the split is performed here
> 1.1. RTP packet size = 92, 80 bytes of payload
> 1.2. RTP packet size = 92, 80 bytes of payload
> 1.3. RTP packet size = 92, 80 bytes of payload
> 1.4. RTP packet size = 92, 80 bytes of payload
> 1.5. RTP packet size = 92, 80 bytes of payload
> 1.6. RTP packet size = 92, 80 bytes of payload
> 1.7. RTP packet size = 92, 80 bytes of payload
> 1.8. RTP packet size = 28, 16 bytes of payload
> 
> 2.1. RTP packet size = 92, 80 bytes of payload
> 2.2. RTP packet size = 92, 80 bytes of payload
> 2.3. RTP packet size = 92, 80 bytes of payload
> 2.4. RTP packet size = 92, 80 bytes of payload
> 2.5. RTP packet size = 92, 80 bytes of payload
> 2.6. RTP packet size = 92, 80 bytes of payload
> 2.7. RTP packet size = 92, 80 bytes of payload
> 2.8. RTP packet size = 28, 16 bytes of payload
> 
> ------
> 
> I'm trying to figure out where in the code the size is really enforced  
> (where before the call to rtp_write_packet).
> 
> For my use case, I need to send RTP packets with 80 bytes of payload,  
> at their respective rate (not in block).

packet size an bitrate are different...

with a certain bitrate you say the encoder has to output at most/average 
a number of bit per second, a number of bit per encoded sample.
-re makes that amount pushed through rtp as soon it's ready.
the packet size tell rtp which is the right size the transport medium 
accepts. If it gets an encoded sample/frame bigger than that it 
fragments it and send it by a serie of fragments, all sent before a 
deadline.

there are algorithm that try to smooth the process, avoiding peaks (in 
feng we got one of the simplest) using information either gathered from 
rtcp or otherwise.


It's early morning and I just awake, doublecheck what I wrote for errors =)

lu


-- 

Luca Barbato
Gentoo Council Member
Gentoo/linux Gentoo/PPC
http://dev.gentoo.org/~lu_zero





More information about the ffmpeg-devel mailing list