Ansersion / myRtspClient

A RTSP client based on jrtplib
Apache License 2.0
162 stars 92 forks source link

how to avoid program exiting #23

Open cafecai opened 5 years ago

cafecai commented 5 years ago

When the rtsp server is restarted and disconnected, the socket is interrupted. The following prompt appears. When I try to reconnect in the program, the program exits. How can I solve the problem and avoid the program exiting, but I can reconnect to the rtsp server.

Adding destination Deleting destination No RTP data : Error sending over socket 25, removing destination No RTP data No RTP data No RTP data No RTP data No RTP data

cafecai commented 5 years ago

while(1) { string RtspUri(pstVdecSend->cFileName); Client.SetURI(RtspUri); Client.DoDESCRIBE(); Client.ParseSDP(); Client.DoSETUP("video", true); //Client.SetVideoByeFromServerClbk(ByeFromServerClbk); printf("start PLAY\n"); //printf("SDP: %s\n", Client.GetSDP().c_str()); Client.DoPLAY("video"); int i=0,j=0; while(1) {
if(!Client.GetMediaData("video", pbuf, &size, BufSize)) { sleep(1); if(j++==5) { j=0; break; } continue; } if(size>0) { play_frame() } if(pstVdecSend->bSettingsChanged||pstVdecSend->eCtrlSinal==VDEC_CTRL_STOP) { pstVdecSend->bSettingsChanged=HI_FALSE; break; } / if(ByeFromServerFlag) { break; } /

}
Client.DoTEARDOWN();
if(pstVdecSend->eCtrlSinal==VDEC_CTRL_STOP)
    break;

}

Ansersion commented 5 years ago

Use a new RtspClient

cafecai commented 5 years ago

I see, thank you! So how do I detect that the server has been disconnected? Is there an interface to check the connection?

Ansersion commented 5 years ago

ByeFromServerClbk will be called when the server disconnected