Skip to content

Auto reconnection

When no frames are received after a "device lost" timeout, the filter tries to reconnect automatically or notifies the graph that the device has been lost.

By default the filter tries to reconnect automatically. The auto reconnection can be disabled:

  • either by specifying >autoreconnect=0 at the end of the RTSP URL,
  • either by invoking DatasteadRtspSourceConfig.SetBool(RTSP_Source_AutoReconnect_bool, false) when configuring the filter.

Auto reconnection disabled

When the device lost timeout occurs, an EC_DEVICE_LOST notification event is notified to the filter graph, that stops.

Auto reconnection enabled

When the device lost timeout occurs:

  • an EC_RTSPNOTIFY (EC_RTSP_PARAM1_DEVICELOST_RECONNECTING, 0) notification event is sent to the filter graph,
  • the filter graph is paused,
  • the auto reconnection process begins.

When the reconnection completes:

  • the filter graph is run again,
  • a custom EC_RTSPNOTIFY (EC_RTSP_PARAM1_DEVICELOST_RECONNECTED, 0) notification is sent to the filter graph.

If the reconnection fails again after the device lost timeout, the reconnection cycle is repeated until it succeeds or the graph stops.

Retrying the initial connection

If the URL is being opened asynchronously and it is not available, it is possible to specify an indefinite reconnection (after the initial connection timeout occurs) with the following setting:

DatasteadRtspSourceConfig.SetInt(RTSP_Source_RetryInitialConnect_int, -1)

(or adding >retryinitialconnect=-1 at the end of the URL)

It is also possible to specify a retry count (depending on the RTSP_Source_ConnectionTimeOut_int duration). E.g. to retry 4 times:

DatasteadRtspSourceConfig.SetInt(RTSP_Source_RetryInitialConnect_int, 4)

will retry 4 times. If the connection timeout is set to 10 seconds, this will try to reconnect during 10x4 = 40 seconds.