[Libav-user] RTSP Connection timeout
Taha Ansari
mtaha.ansari at gmail.com
Wed Jun 17 11:10:08 CEST 2015
> this is the piece of code responsable of open the stream :
>
> const char *filename = "rtsp://hostname/live.sdp";
>
> av_register_all();
> avformat_network_init();
>
> AVFormatContext *pFormatCtx = NULL;
>
> // Open video file
> if (avformat_open_input(&pFormatCtx, filename, NULL, NULL) != 0){
> std::cout << "could not open file " << filename << std::endl;
> return -1; // Couldn't open file
> }else{
> std::cout << "video opened" << std::endl;
> }
>
> The problem is that when the host is down the function avformat_open_input
> does not return any value, it just stay there forever.
>
This is a known behavior. You need to setup a callback mechanism before
calling avformat_open_input() function.
Just before avformat_open_input() call pFormatCtx->interrupt_callback =
int_cb;
where int_cb is the callback function's variable:
AVIOInterruptCB int_cb;
with following signature:
AVIOInterruptCB {
int (*callback)(void*);
void *opaque;
}
set the callback function and implement a timeout mechanism. In general if
you return '1' from callback it means to exit from avformat_open_input()
function, else return 0 if you want to give it some more time (perhaps also
applies to all read operations but you can take it from here).
some help here:
https://trac.ffmpeg.org/ticket/2694
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20150617/0317488c/attachment.html>
More information about the Libav-user
mailing list