I'm reading some RTSP
stream in an iOS app using FFmpeg
. If the firewall or other services stops the network from receiving via UDP
, FFmpeg
nicely falls back to reading via TCP
. My question is: How can I be notified that the fallback to TCP
happened? I need to know whether the app is reading the stream via UDP
or TCP
and still let FFmpeg
do its nice fallback.
Is there a callback for this? Is there a way to get the protocol that is using?
Thank you.
I found the solution: After the connection is made one can read the lower transport protocol from the AVFormatContext
's private data (priv_data
). Bellow is how I'm doing it:
-(BOOL)lowerTransportProtocolIsUDP
{
RTSPState* rtsp_state = (RTSPState*) _avFmtCtx->priv_data;
enum RTSPLowerTransport lowerTransportProtocol = rtsp_state->lower_transport;
NSLog(@"lowerTransportProtocol = %d", lowerTransportProtocol);
if (lowerTransportProtocol == RTSP_LOWER_TRANSPORT_UDP) {
return YES;
}
return NO;
}
Where _avFmtCtx
is a AVFormatContext
instance.