[FFmpeg-devel] [PATCH] Non-blocking protocols

Nicolas George nicolas.george
Sun Jan 23 13:12:48 CET 2011


Hi.

The attached patches start to implement non-blocking URL protocols, which
are necessary in certain situations, especially with formats that need
several URL contexts at once (RTP for example).

The first patch introduces the URL_FLAG_NONBLOCK and documents it. Its
principle was approved by Michael on 2011-01-17, but I reworded slightly the
documentation.

The second patch implements the necessary code in the wrapper functions
(url_read/url_write).

The third patch add support for non-blocking to TCP sockets.

make test still succeeds and a small test-program against a remote rot13
server works as expected.


I noticed that there is a lot of duplicated code between the wrapper
functions and the member functions of each URLProtocol: handling of short
reads, looping on EINTR, etc. I tried to do each task in only one place;
this allowed me to greatly simplify the code for TCP sockets (cf. the
diffstat).

Here is the summary of the choices I made about who is responsible for what:

- blocking for a short while if blocking: URLProtocol member functions;
- looping on EINTR: avio wrapper;
- looping on EAGAIN if blocking: avio wrapper;
- checking for url_interrupt_cb: avio wrapper;
- looping on short reads and write: avio wrapper;

The code implemented by the second patch thus guarantees that:

- url_read(_complete) and url_write never return AVERROR(EAGAIN) if
  URL_FLAG_NONBLOCK is not set;

- url_read(_complete) and url_write return AVERROR(EINTR) if and only if an
  interrupt callback was triggered.

Regards,

-- 
  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Non-blocking-protocols-flag-and-documentation.patch
Type: text/x-diff
Size: 2049 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20110123/16f8cebd/attachment.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-Non-blocking-protocol-core-wrapper-functions.patch
Type: text/x-diff
Size: 3280 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20110123/16f8cebd/attachment-0001.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-Non-blocking-protocols-TCP.patch
Type: text/x-diff
Size: 3453 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20110123/16f8cebd/attachment-0002.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20110123/16f8cebd/attachment.pgp>



More information about the ffmpeg-devel mailing list