[Libav-user] Custom IO for streaming protocols

yoda_alex yoda_alex at yahoo.co.uk
Fri Jun 3 14:34:24 CEST 2011


Hello all,

I'm pretty new to libav, so please forgive any incompetance on my part!

I'm trying to write an application that receives H264 over RTP, extracts the
H.264 and saves it to an mp4 file on disk. I already have an RTP stack that
I want to use to receive the packets (rather than letting libav do the IO
directly). So I've done the following:

-  Created a custom RTP demuxer (reusing code in libavcodec, such as
rtpdec.c and rtpdec_h264.c). When its read_packet() callback is called, it
does an avio_read() to get an RTP packet, and then processes it. 
-  Manually creating an AVIOContext, with a callback to read RTP packets out
of an in-memory buffer (owned by my app). This is then linked to an
AVFormatContext which uses my custom demuxer.  
-  When ever I receive an RTP packet, my application puts it in the buffer,
and then calls av_read_frame(). 

The problem I'm having is that the IO read_packet() callback is called
multiple times for each call to avio_read(). 
-  The first call reads the RTP packet out of the memory buffer. 
-  When subsequent calls happen I'm forced to return a value of 0 (no data
available to read), which causes avio_read to think its hit the EOF, and
everything stops working. 

Any ideas how this is supposed to work, or what I'm doing wrong? Is the only
option for my RTP demuxer to read out of the memory buffer directly (this
seems architecturally worng). 

Thanks in advance,
Alex.


--
View this message in context: http://libav-users.943685.n4.nabble.com/Custom-IO-for-streaming-protocols-tp3570716p3570716.html
Sent from the libav-users mailing list archive at Nabble.com.


More information about the Libav-user mailing list