AVIOContext中的异常处理读取回调

时间:2018-05-01 01:06:43

标签: exception ffmpeg

m_formatCtx = avformat_alloc_context ();
uint8_t * buffer = NULL, * avio_ctx_buffer = NULL;
size_t buffer_size, avio_ctx_buffer_size = 200;
avio_ctx_buffer = (uint8_t *) av_malloc (avio_ctx_buffer_size * 10);
AVIOContext * avio_ctx = avio_alloc_context (avio_ctx_buffer, avio_ctx_buffer_size,                                           0,
                                           tcp, &socketRead, NULL, NULL);

如上所述通过socketRead读取视频/音频信息。

int socketRead (void * ptr, uint8_t * buf, int buf_size)
{
    printf ("socketRead bufsize =% d \ n", buf_size);
    ssize_t readSize = 0;
    TCPClient * tcp = (TCPClient *) ptr;
    readSize = tcp-> read (buf, buf_size);
    return readSize;
}

但是,如果在中间错误地收到视频数据包,

D / libnav: socketRead bufsize = 2048
D / libnav: socketRead bufsize = 2048
D / libnav: socketRead bufsize = 4096
D / libnav: socketRead bufsize = 8192
D / libnav: socketRead bufsize = 16384
D / libnav: socketRead bufsize = 32768
D / libnav: socketRead bufsize = 65536
D / libnav: socketRead bufsize = 131072
D / libnav: socketRead bufsize = 262144
D / libnav: socketRead bufsize = 524288

最后,socketRead的buf_size增加并最终

A / libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x440 in tid 19369 (Thread-21565)

我收到此错误。

我想做一些其他灵活处理而不是崩溃。我需要帮助。

0 个答案:

没有答案