The RTP specification says that the RTCP packets for a given RTP stream will be sent on a port that is +1 of the main RTP port. So for example, if you have video arriving on RTP port 9010, then on port 9011, you can expect RTCP packets.
When I'm negotiating a unicast stream (via the RTSP protocol), I have to suggest pair of ports that I would like the video sent to me on (1 for RTP, and 1 for RTCP)...
Now, I know that if I bind a socket with a port of 0, the system will pick a free port from the ephemeral range... The problem I have is that I actually need a pair of ports, and I need the RTCP port to be +1 of the RTP port (in fact, I think I need the RTP port to be an even number).
Is there a way to locate a pair of free ports? How is this normally done?