Created
April 17, 2015 21:35
-
-
Save asavartsov/0e5fc6c5ec76c559afc5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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