[Libav-user] avformat_write_header getting blocked

Ajay Sood ajays at apra.in
Tue Aug 28 14:37:27 EEST 2018


Hello

I am trying to push a stream over rtsp using ffmpeg (version 2_8_1)

RTSP server is setup for authentication


There are two scenarios

*Scenario 1 *- where username and password is not provided and
we expect avformat_write_header to fail

url - rtsp://127.0.0.1/push_stream

avformat_write_header invokes a call back which I have setup for the output
context

static int rtspInterruptCallback(void *ctx)
    {
        AVFormatContext* formatContext =
reinterpret_cast<AVFormatContext*>(ctx);
        printf("In the callback on error\n");
        return -1;
    }


{
.
outContext->interrupt_callback.callback = rtspInterruptCallback;
outContext->interrupt_callback.opaque = outContext;
outContext->flags = outContext->flags | AVFMT_FLAG_NONBLOCK;
.
ret = avformat_write_header(outContext, NULL);

if (ret < 0) {
    // error handling
}
.
.
}


*Scenario 2 *- where we provide the correct username and password and we
expect the avformat_write_header to succeed   - (expected to be a success
case and succeeds if I dont setup a callback)

url - rtsp://user:pass@127.0.0.1/push_stream


What I observe is that callback gets invoked even for this case (that is it
is getting called when I expect avformat_write_header to fail because of
authentication error but also when I expect avformat_write_header to
succeed)

After I reach the callback,
1) If I return a 0 from callback, we never comeout of the
avformat_write_header_call

2) If I return a -1 from callback, avformat_write_header comes out with a
negative value and we are not able to distinguish that the call should have
succeeded


Any suggestions on how to get around this conflicting behaviour?


Thanks
A
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20180828/a07a635d/attachment.html>


More information about the Libav-user mailing list