[FFmpeg-devel] [PATCH] Maximum number of frames in an RTP packet

Michael Niedermayer michaelni
Wed Sep 26 14:05:00 CEST 2007


Hi

On Tue, Sep 25, 2007 at 02:07:27PM +0200, Luca Abeni wrote:
> Hi all,
>
> when encapsulating audio or video frames in an RTP packet, some RFCs
> allow to aggregate multiple frames in a single packet (this often happens
> for audio). FFMPEG's RTP packetizer currently does this for AAC or MPEG
> audio.
>
> The attached patch introduces a new field (max_frames_per_packet) in
> the RTPDemuxContext structure, and sets it based on the AVFormatContext
> "max_delay" field (the muxing delay obviously depends on the number of
> frames per packet). This new field is then used in the ACC packetizer
> (if the patch is accepted, I can write similar code for the MPEG audio
> packetizer).
>
> In this way, the patch addresses a comment by Luca Barbato about the
> maximum number of AAC frames per RTP packet.
>
> Comments?
>
>
> 			Thanks,
> 				Luca

> Index: libavformat/rtp.c
> ===================================================================
> --- libavformat/rtp.c	(revision 10571)
> +++ libavformat/rtp.c	(working copy)
> @@ -746,6 +746,20 @@
>      if (max_packet_size <= 12)
>          return AVERROR(EIO);
>      s->max_payload_size = max_packet_size - 12;
> +   
> +    s->max_frames_per_packet = 0;
> +    if (s1->max_delay) {
> +        if (st->codec->codec_type == CODEC_TYPE_AUDIO) {
> +            if (st->codec->frame_size == 0) {
> +                av_log(s1, AV_LOG_ERROR, "Cannot respect max delay: frame size = 0\n");
> +            } else {
> +                s->max_frames_per_packet = av_rescale(s1->max_delay, st->codec->sample_rate, AV_TIME_BASE * st->codec->frame_size);

this should use av_rescale_rnd() if you want max_delay strictly followed

and the patch looks mostly ok (didnt review to carefull...) 
but iam not rtp maintainer ...

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

There will always be a question for which you do not know the correct awnser.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20070926/72453c23/attachment.pgp>



More information about the ffmpeg-devel mailing list