[Libav-user] interrupt_callback issue
Selmeci Tamás
tselmeci at open-st.eu
Fri Nov 22 17:03:34 CET 2013
Hello all!
I'm using ffmpeg libraries to demultiplex MPEG2/H264 streams in an IPTV
player application. The demultiplexed frames are decoded by a special
target HW on Freescale iMX535. Input is from a network stream.
My problem in general is that if I call av_read_frame(...) and currently
there's no data available through TCP, it blocks and waits for new data.
This can take up to 100-150 ms, and my program must not be blocked for
such a long period. (I know I could do it on a separate thread, but for
certain reasons I want to avoid it now)
The idea is to use the interrupt callback functionality and interrupt
av_read_frame if it would last too long.
My program is something like this:
struct program_context prog_context;
ctx = avformat_alloc_context();
ctx->flags |= AVFMT_FLAG_NONBLOCK;
ctx->interrupt_callback.callback = interrupt_cb;
ctx->interrupt_callback.opaque = &prog_context;
avformat_open_input(url, ...);
if (need_to_get_stream_info)
avformat_find_stream_info(...)
for (;;) {
read_packet(...)
}
int interrupt_cb(char *arg)
{
struct program_context *c = (struct program_context *)arg;
if (c->need_to_interrupt)
return 1;
return 0;
}
void read_packet(...)
{
AVPacket p;
av_read_frame(..., &p);
...
}
If c->need_to_interrupt is non-zero in interrupt_cb(...), the read
operation is interrupted as expected. However, the next read operation
will not call interrupt_cb(...) any more and returns with error. And all
consecutive reads do fail. I can't interrupt the read operation.
I believe this is a bug, since in my home project I do use a
significantly older ffmpeg version, which has a perfect and working
interrupt mechanism; unfortunately it's not an option to switch the IPTV
project to that ancient version.
I thought of filing a bug request on this issue, but it looked like to
me Trac contains the command-line ffmpeg issues only.
Sorry if I sent this mail to a wrong place.
Could you please help me? I have some experience in ffmpeg patching, but
I wouldn't begin wasting time on it if somebody had a quick solution to
this problem.
Regards,
--
Selmeci Tamás
http://www.open-st.eu/
More information about the Libav-user
mailing list