[FFmpeg-devel] const abuse in rtp.c

Luca Abeni lucabe72
Mon Sep 10 13:39:25 CEST 2007


while frequently recompiling rtp.c (for implementing new 
packetizations), I noticed this annoying warning, and I found out the 
M?ns already noticed it some time ago:

M?ns Rullg?rd wrote:
> rtp.c, line 691 looks like this:
>             s->buf_ptr = buf;
> Here, buf is const uint8_t * argument to the function rtp_parse_packet(),
> and s->buf_ptr is a plain uint8_t *.  Hence gcc gives us a friendly
> warning:
> /home/mru/src/ffmpeg/libavformat/rtp.c:691: warning: assignment discards qualifiers from pointer target type

After re-reading the code some times and trying to understand it, I 
cannot find why the above mentioned line is needed. As far as I can see, 
the "buf_ptr" field is only used when sending an RTP packet, and not 
when receiving it...
So, I would be tempted to believe that such line of code can be safely 

> In other parts of the file data is written through this same
> s->buf_ptr pointer.

Yes, that happens when packetizing a audio or video stream inside an RTP 
packet. BTW, I am beginning to suspect that using the same 
RTPDemuxContext for the RTP muxer and demuxer is not a good idea, after 

> Not having examined the code closely (and to be
> honest, it quite frightens me), I'm ready to believe that these uses
> of s->buf_ptr are mutually exclusive.

As far as I understand, the rtp_parse* or rtp_read* code should not even 
touch the buf_ptr field. Or am I missing something?

BTW, that code has been introduced in r4306
patch by Romain DEGEZ (Romain, are you subscribed to ffmpeg-devel?)


More information about the ffmpeg-devel mailing list