<div dir="ltr"><div><br></div><div>Hello</div><div><br></div><div>I am trying to push a stream over rtsp using ffmpeg (version 2_8_1)<br></div><div><br></div><div>RTSP server is setup for authentication</div><div><br></div><div><br></div><div>There are two scenarios</div><div><br></div><div><b>Scenario 1 </b>- where username and password is not provided and <br></div><div>we expect avformat_write_header to fail</div><div><br></div><div>url - rtsp://<a href="http://127.0.0.1/push_stream">127.0.0.1/push_stream</a></div><div><br></div><div>avformat_write_header invokes a call back which I have setup for the output context</div><div><br></div><div>static int rtspInterruptCallback(void *ctx)<br> {<br> AVFormatContext* formatContext = reinterpret_cast<AVFormatContext*>(ctx);<br> printf("In the callback on error\n");<br> return -1;<br> }</div><div><br></div><div><br></div><div>{</div><div>.</div><div>outContext->interrupt_callback.callback = rtspInterruptCallback; outContext->interrupt_callback.opaque = outContext;<br>outContext->flags = outContext->flags | AVFMT_FLAG_NONBLOCK;<br></div><div>.<br></div><div>ret = avformat_write_header(outContext, NULL);</div><div><br></div><div>if (ret < 0) {</div><div> // error handling</div><div>}<br></div><div>.</div><div>.</div><div>}<br></div><div><br></div><div><br></div><div><b>Scenario 2 </b>- 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)<br></div><div><br></div><div>
url - rtsp://<a href="http://user:pass@127.0.0.1/push_stream">user:pass@127.0.0.1/push_stream</a>
<br></div><div><br></div><div><br></div><div>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)</div><div><br></div><div>After I reach the callback, <br></div><div>1) If I return a 0 from callback, we never comeout of the avformat_write_header_call</div><div><br></div><div>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</div><div><br></div><div><br></div><div>Any suggestions on how to get around this conflicting behaviour?</div><div><br></div><div><br></div><div>Thanks</div><div>A<br></div><div><br></div><div><br></div></div>