Here is the code sample from SharpRTSP that handle the transport
```
// Check the RTSP transport
// If it is UDP or Multicast, create the sockets
// If it is RTP over RTSP we send data via the RTSP Listener
// FIXME client may send more than one possible transport.
// very rare
Rtsp.Messages.RtspTransport transport = setupMessage.GetTransports()[0];
// Construct the Transport: reply from the Server to the client
Rtsp.Messages.RtspTransport transport_reply = new Rtsp.Messages.RtspTransport();
transport_reply.SSrc = global_ssrc.ToString("X8"); // Convert to Hex, padded to 8 characters
if (transport.LowerTransport == Rtsp.Messages.RtspTransport.LowerTransportType.TCP)
{
// RTP over RTSP mode}
transport_reply.LowerTransport = Rtsp.Messages.RtspTransport.LowerTransportType.TCP;
transport_reply.Interleaved = new Rtsp.Messages.PortCouple(transport.Interleaved.First, transport.Interleaved.Second);
}
if (transport.LowerTransport == Rtsp.Messages.RtspTransport.LowerTransportType.UDP
&& transport.IsMulticast == false)
{
// RTP over UDP mode}
// Create a pair of UDP sockets
// Pass the Port of the two sockets back in the reply
transport_reply.LowerTransport = Rtsp.Messages.RtspTransport.LowerTransportType.UDP;
transport_reply.IsMulticast = false;
transport_reply.ClientPort = transport.ClientPort; // FIX
//transport_reply.ServerPort = new Rtsp.Messages.PortCouple(16384, 32767);
var firstPort = GetAvailablePort(16384, 32767);
var secondPort = GetAvailablePort(firstPort + 1, 32767);
transport_reply.ServerPort = new Rtsp.Messages.PortCouple(firstPort, secondPort);
//UDPSocket
// for now until implemented
transport_reply = null;
}
if (transport.LowerTransport == Rtsp.Messages.RtspTransport.LowerTransportType.UDP
&& transport.IsMulticast == true)
{
// RTP over Multicast UDP mode}
// Create a pair of UDP sockets in Multicast Mode
// Pass the Ports of the two sockets back in the reply
transport_reply.LowerTransport = Rtsp.Messages.RtspTransport.LowerTransportType.UDP;
transport_reply.IsMulticast = true;
transport_reply.Port = new Rtsp.Messages.PortCouple(7000, 7001); // FIX
// for now until implemented
transport_reply = null;
}
if (transport_reply != null)
{
RTPSession new_session = new RTPSession();
new_session.rtspLink = setupMessage.RtspUri.AbsolutePath;
new_session.listener = listener;
new_session.sequence_number = (UInt16)rnd.Next(65535); // start with a random 16 bit sequence number
new_session.ssrc = global_ssrc;
// Add the transports to the Session
new_session.client_transport = transport;
new_session.transport_reply = transport_reply;
lock (rtp_list)
{
// Create a 'Session' and add it to the Session List
// ToDo - Check the Track ID. In the SDP the H264 video track is TrackID 0
// Place Lock() here so the Session Count and the addition to the list is locked
new_session.session_id = session_count.ToString();
// Add the new session to the Sessions List
rtp_list.Add(new_session);
session_count++;
}
Rtsp.Messages.RtspResponse setup_response = setupMessage.CreateResponse();
setup_response.Headers[Rtsp.Messages.RtspHeaderNames.Transport] = transport_reply.ToString();
setup_response.Session = new_session.session_id;
listener.SendMessage(setup_response);
}
else
{
Rtsp.Messages.RtspResponse setup_response = setupMessage.CreateResponse();
// unsuported transport
setup_response.ReturnCode = 461;
listener.SendMessage(setup_response);
}
```
As you can see there is a "not implemented" comment, but it still sends a reply with code 461 (transport not supported)