Skip to content

Instantly share code, notes, and snippets.

@asavartsov
Created April 17, 2015 21:35
Show Gist options
  • Save asavartsov/0e5fc6c5ec76c559afc5 to your computer and use it in GitHub Desktop.
Save asavartsov/0e5fc6c5ec76c559afc5 to your computer and use it in GitHub Desktop.
using System;
using System.Net.Sockets;
using Media.Rtsp;
namespace RtspAuthTest
{
class SafeRtspClient : RtspClient
{
public SafeRtspClient(Uri location, ClientProtocolType? rtpProtocolType = null, int bufferSize = DefaultBufferSize, Socket existing = null, bool leaveOpen = false, int responseTimeoutInterval = (int)Media.Common.Extensions.TimeSpan.TimeSpanExtensions.MicrosecondsPerMillisecond)
: base(location, rtpProtocolType, bufferSize, existing, leaveOpen, responseTimeoutInterval)
{
}
public SafeRtspClient(string location, ClientProtocolType? rtpProtocolType = null, int bufferSize = DefaultBufferSize)
: base(location, rtpProtocolType, bufferSize)
{
}
public override RtspMessage Authenticate(RtspMessage request, RtspMessage response = null, bool force = false)
{
if (force == false &&
response != null &&
request.ContainsHeader(RtspHeaders.Authorization) &&
response.ContainsHeader(RtspHeaders.WWWAuthenticate) &&
response.StatusCode == RtspStatusCode.Unauthorized)
{
return null;
}
return base.Authenticate(request, response, force);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment