<div dir="ltr"><div><div>Hi,<br><br></div>Thanks for these useful informations. It works great, I used libpcl.<br><br></div>Cheers.<br><div class="gmail_extra"><br><br><div class="gmail_quote">On Sun, Mar 10, 2013 at 7:44 PM, Nicolas George <span dir="ltr"><<a href="mailto:nicolas.george@normalesup.org" target="_blank">nicolas.george@normalesup.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Le nonidi 19 ventôse, an CCXXI, Nicolas a écrit :<br>
<div><div class="h5">> I am using libav with custom I/O (with avio_alloc_context()) for reading<br>
> various stream.<br>
><br>
> In my project, all my I/O are asynchronous but ffmpeg callbacks work in a<br>
> synchronous way. So right now, what I am doing is to use an internal buffer<br>
> 4 times bigger than my avio buffer and each time my read callback is called<br>
> I copy a part of my buffer and get new data asynchronously, this works well<br>
> for reading, but when I seek my media I don't have (yet) data in my<br>
> internal buffer. In such case what should I return in my read callback?<br>
><br>
> Also, there is a flag AVIO_FLAG_NONBLOCKING that I could pass to<br>
> avio_alloc_context but i couldn't figure how to use it (what should I<br>
> return in my read callback?)<br>
><br>
> is there any way to use custom I/O in an asynchronous fashion?<br>
<br>
</div></div>Unfortunately, no, there is currently no way of working with asynchronous<br>
and non-blocking I/O. Some of the network protocols can be set to work<br>
non-blocking, but not all, and the demuxers themselves can not work in<br>
non-blocking mode.<br>
<br>
The usual solution for that is to use threads. You could, for example, run<br>
the demuxer in a separate thread. When the demuxer calls the read function<br>
in your custom I/O context, the thread becomes blocked waiting for data from<br>
the main thread, and when it has demuxed a packet, it can wake the main<br>
thread using some kind of signalfd/self-pipe. That way, the demuxing thread<br>
do not force you to abandon your async model (using a few threads has a<br>
tendency to force you to use threads everywhere).<br>
<br>
Also note that since you are using the thread not for concurrency but only<br>
to keep the local context of the demuxer, you do not have to use "real"<br>
threads, you can consider using, for examples, GNU Pth, or libpcl.<br>
<br>
Regards,<br>
<span class=""><font color="#888888"><br>
--<br>
  Nicolas George<br>
</font></span><br>-----BEGIN PGP SIGNATURE-----<br>
Version: GnuPG v1.4.12 (GNU/Linux)<br>
<br>
iEYEARECAAYFAlE81JAACgkQsGPZlzblTJMtkACeLJzEZTJoWgQsPoMRjEHrKCuZ<br>
aJMAoJaX+tNbEtsk0lmfasNLFnVD1BQd<br>
=qnqx<br>
-----END PGP SIGNATURE-----<br>
<br>_______________________________________________<br>
Libav-user mailing list<br>
<a href="mailto:Libav-user@ffmpeg.org">Libav-user@ffmpeg.org</a><br>
<a href="http://ffmpeg.org/mailman/listinfo/libav-user" target="_blank">http://ffmpeg.org/mailman/listinfo/libav-user</a><br>
<br></blockquote></div><br></div></div>