private bool HandleRTSPResponse200Describe(RtspProtocol rtspProtocol, Variant requestHeaders, ref string requestContent, Variant responseHeaders, ref string responseContent)
{
//1. Make sure we ONLY handle application/sdp
if (responseHeaders[RTSP_HEADERS, RTSP_HEADERS_CONTENT_TYPE] == null)
{
FATAL("Invalid DESCRIBE response:\n{0}", (requestHeaders.ToString()));
return false;
}
if (responseHeaders[RTSP_HEADERS, RTSP_HEADERS_CONTENT_TYPE] == RTSP_HEADERS_ACCEPT_APPLICATIONSDP)
{
FATAL("Invalid DESCRIBE response:\n{0}", (requestHeaders.ToString()));
return false;
}
//2. Get the SDP
var sdp = rtspProtocol.InboundSDP;
//3. Parse the SDP
if (!SDP.ParseSDP(sdp, responseContent))
{
FATAL("Unable to parse the SDP");
return false;
}
//4. Get the first video track
var videoTrack = sdp.GetVideoTrack(0,requestHeaders[RTSP_FIRST_LINE,RTSP_URL]);
var audioTrack = sdp.GetAudioTrack(0,requestHeaders[RTSP_FIRST_LINE,RTSP_URL]);
if ((videoTrack == VariantType.Null) && (audioTrack == VariantType.Null))
{
FATAL("No compatible tracks found");
return false;
}
var forceTcp = rtspProtocol.CustomParameters["forceTcp"];
var rtcpDetectionInterval = Application.Configuration[CONF_APPLICATION_RTCPDETECTIONINTERVAL];
if (rtspProtocol.CustomParameters[CONF_APPLICATION_RTCPDETECTIONINTERVAL]!=null)
rtcpDetectionInterval = (byte)rtspProtocol.CustomParameters[CONF_APPLICATION_RTCPDETECTIONINTERVAL];
//5. Store the tracks inside the session for later use
if (audioTrack != VariantType.Null)
{
audioTrack["isTcp"] = (bool)forceTcp;
rtspProtocol.CustomParameters["pendingTracks"][(int)audioTrack["globalTrackIndex"]] = audioTrack;
}
if (videoTrack != VariantType.Null)
{
videoTrack["isTcp"] = (bool)forceTcp;
rtspProtocol.CustomParameters["pendingTracks"][(int)videoTrack["globalTrackIndex"]] = videoTrack;
}
//6. Save the streamName
string streamName = sdp.GetStreamName();
if (streamName == "")
{
streamName = "rtsp_stream_"+rtspProtocol.Id;
}
rtspProtocol.CustomParameters["sdpStreamName"] = streamName;
//7. Save the bandwidth hint
rtspProtocol.CustomParameters["sdpBandwidthHint"] = sdp.GetTotalBandwidth();
//8. Get the inbound connectivity
var pInboundConnectivity = rtspProtocol.GetInboundConnectivity(streamName, sdp.GetTotalBandwidth(),
rtcpDetectionInterval);
if (pInboundConnectivity == null)
{
FATAL("Unable to create inbound connectivity");
return false;
}
//9. Start sending the setup commands on the pending tracks;
return SendSetupTrackMessages(rtspProtocol);
}