[libav-api] question about non-blocking protocols
aviad rozenhek
aviadr1 at gmail.com
Sat Apr 30 20:53:57 CEST 2011
thanks for your suggestion,
I have found what I believe to be a cleaner approach, your feedback
appreciated.
const char* url = "udp://localhost?localport=1234";
// pre-allocate the AVFormatContext and set the non block flag
AVFormatContext* ctx = avformat_alloc_context();
ctx->flags |= AVFMT_FLAG_NONBLOCK;
AVFormatParameters params;
memset(¶ms, 0, sizeof(params));
params.prealloced_context = 1; // let av_open_input_file() know we already
allocated the context
av_open_input_file(&ctx, url, NULL, 0, ¶ms);
On Tue, Apr 19, 2011 at 00:08, Ronald S. Bultje <rsbultje at gmail.com> wrote:
> Hi,
>
> On Tue, Apr 5, 2011 at 10:18 AM, aviad rozenhek <aviadr1 at gmail.com> wrote:
> > when I use libav* in server environment, I usually need that calls
> > to av_read_frame return with some error code when input is not available
> > [such as when multicast udp feed is down]
> > this can be achieved if the udp protocol is opened with
> > the URL_FLAG_NONBLOCK flag.
> > the question is:
> > how can I make sure the protocol is opened with the
> > said URL_FLAG_NONBLOCK flag, when the av_open_input_file() function
> doesn't
> > give me an opportunity to specify this flag?
>
> You need to open the I/O layer manually, using avio_open(), assign
> that to AVFormatContext->pb and read from there.
>
> Ronald
>
--
Aviad Rozenhek
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.libav.org/pipermail/libav-api/attachments/20110430/d0808d78/attachment.htm>
More information about the libav-api
mailing list