diff --git a/examples/AzureExamples/TextToPcm/Program.cs b/examples/AzureExamples/TextToPcm/Program.cs
index 715d38a347..fa863f51b4 100755
--- a/examples/AzureExamples/TextToPcm/Program.cs
+++ b/examples/AzureExamples/TextToPcm/Program.cs
@@ -70,7 +70,7 @@ static async Task Main(string[] args)
Console.WriteLine($"Speech synthesized to speaker for text [{text}]");
var buffer = ttsOutStream.GetPcmBuffer();
- string saveFilename = DateTime.Now.Ticks.ToString() + ".pcm16k";
+ string saveFilename = $"{DateTime.Now.Ticks}.pcm16k";
using (StreamWriter sw = new StreamWriter(saveFilename))
{
diff --git a/examples/OpenAIExamples/AliceAndBob/AudioScope/AudioScopeOpenGL.cs b/examples/OpenAIExamples/AliceAndBob/AudioScope/AudioScopeOpenGL.cs
index 56a2e62eff..71ca7411c6 100644
--- a/examples/OpenAIExamples/AliceAndBob/AudioScope/AudioScopeOpenGL.cs
+++ b/examples/OpenAIExamples/AliceAndBob/AudioScope/AudioScopeOpenGL.cs
@@ -93,7 +93,7 @@ public void Initialise(OpenGL gl)
// going to throw an exception.
if (_prog.GetLinkStatus(gl) == false)
{
- throw new SharpGL.Shaders.ShaderCompilationException(string.Format("Failed to link shader program with ID {0}.", _prog.ShaderProgramObject), _prog.GetInfoLog(gl));
+ throw new SharpGL.Shaders.ShaderCompilationException($"Failed to link shader program with ID {_prog.ShaderProgramObject}.", _prog.GetInfoLog(gl));
}
// Load clear program.
@@ -119,7 +119,7 @@ public void Initialise(OpenGL gl)
// going to throw an exception.
if (_clearProg.GetLinkStatus(gl) == false)
{
- throw new SharpGL.Shaders.ShaderCompilationException(string.Format("Failed to link the clear shader program with ID {0}.", _clearProg.ShaderProgramObject), _clearProg.GetInfoLog(gl));
+ throw new SharpGL.Shaders.ShaderCompilationException($"Failed to link the clear shader program with ID {_clearProg.ShaderProgramObject}.", _clearProg.GetInfoLog(gl));
}
_clearRectangle = new float[] { -1.0f, -1.0f, -1.0f, 1.0f, 1.0f, -1.0f, 1.0f, 1.0f };
diff --git a/examples/SIPExamples/SIPProxy/Program.cs b/examples/SIPExamples/SIPProxy/Program.cs
index c236c86e4e..50b8c22933 100644
--- a/examples/SIPExamples/SIPProxy/Program.cs
+++ b/examples/SIPExamples/SIPProxy/Program.cs
@@ -129,7 +129,7 @@ static void Main()
}
catch (Exception excp)
{
- Console.WriteLine("Exception Main. " + excp);
+ Console.WriteLine($"Exception Main. {excp}");
}
}
diff --git a/examples/Softphone/Signalling/SIPClient.cs b/examples/Softphone/Signalling/SIPClient.cs
index 19d442cd3a..389eb55a23 100755
--- a/examples/Softphone/Signalling/SIPClient.cs
+++ b/examples/Softphone/Signalling/SIPClient.cs
@@ -117,7 +117,7 @@ public async Task Call(string destination)
else
{
// This call will use the pre-configured SIP account.
- callURI = SIPURI.ParseSIPURIRelaxed(destination + "@" + m_sipServer);
+ callURI = SIPURI.ParseSIPURIRelaxed($"{destination}@{m_sipServer}");
sipUsername = m_sipUsername;
sipPassword = m_sipPassword;
fromHeader = (new SIPFromHeader(m_sipFromName, new SIPURI(m_sipUsername, m_sipServer, null), null)).ToString();
@@ -151,7 +151,7 @@ public async Task Call(string destination)
///
public void Cancel()
{
- StatusMessage(this, "Cancelling SIP call to " + m_userAgent.CallDescriptor?.Uri + ".");
+ StatusMessage(this, $"Cancelling SIP call to {m_userAgent.CallDescriptor?.Uri}.");
m_userAgent.Cancel();
}
@@ -215,7 +215,7 @@ public void Redirect(string destination)
/// Puts the remote call party on hold.
///
public async Task PutOnHold()
- {
+ {
await MediaSession.PutOnHold();
m_userAgent.PutOnHold();
StatusMessage(this, "Local party put on hold");
@@ -319,7 +319,7 @@ private VoIPMediaSession CreateMediaSession()
///
private void CallTrying(ISIPClientUserAgent uac, SIPResponse sipResponse)
{
- StatusMessage(this, "Call trying: " + sipResponse.StatusCode + " " + sipResponse.ReasonPhrase + ".");
+ StatusMessage(this, $"Call trying: {sipResponse.StatusCode} {sipResponse.ReasonPhrase}.");
}
///
@@ -327,7 +327,7 @@ private void CallTrying(ISIPClientUserAgent uac, SIPResponse sipResponse)
///
private void CallRinging(ISIPClientUserAgent uac, SIPResponse sipResponse)
{
- StatusMessage(this, "Call ringing: " + sipResponse.StatusCode + " " + sipResponse.ReasonPhrase + ".");
+ StatusMessage(this, $"Call ringing: {sipResponse.StatusCode} {sipResponse.ReasonPhrase}.");
}
///
@@ -335,7 +335,7 @@ private void CallRinging(ISIPClientUserAgent uac, SIPResponse sipResponse)
///
private void CallFailed(ISIPClientUserAgent uac, string errorMessage, SIPResponse failureResponse)
{
- StatusMessage(this, "Call failed: " + errorMessage + ".");
+ StatusMessage(this, $"Call failed: {errorMessage}.");
CallFinished(null);
}
@@ -346,7 +346,7 @@ private void CallFailed(ISIPClientUserAgent uac, string errorMessage, SIPRespons
/// The SIP answer response received from the remote party.
private void CallAnswered(ISIPClientUserAgent uac, SIPResponse sipResponse)
{
- StatusMessage(this, "Call answered: " + sipResponse.StatusCode + " " + sipResponse.ReasonPhrase + ".");
+ StatusMessage(this, $"Call answered: {sipResponse.StatusCode} {sipResponse.ReasonPhrase}.");
CallAnswer?.Invoke(this);
}
diff --git a/examples/WebRTCExamples/FfmpegToWebRTC/Program.cs b/examples/WebRTCExamples/FfmpegToWebRTC/Program.cs
index 820154f231..677d2a6ada 100644
--- a/examples/WebRTCExamples/FfmpegToWebRTC/Program.cs
+++ b/examples/WebRTCExamples/FfmpegToWebRTC/Program.cs
@@ -6,11 +6,11 @@
//
// Author(s):
// Aaron Clauson (aaron@sipsorcery.com)
-//
+//
// History:
// 08 Jul 2020 Aaron Clauson Created, Dublin, Ireland.
//
-// License:
+// License:
// BSD 3-Clause "New" or "Revised" License, see included LICENSE.md file.
//-----------------------------------------------------------------------------
@@ -89,18 +89,16 @@ static async Task Main(string[] args)
if (args?.Length > 0)
{
- switch(args[0].ToLower())
+ if (string.Equals(args[0], FFMPEG_VP8_CODEC, StringComparison.OrdinalIgnoreCase) ||
+ string.Equals(args[0], FFMPEG_VP9_CODEC, StringComparison.OrdinalIgnoreCase) ||
+ string.Equals(args[0], FFMPEG_H264_CODEC, StringComparison.OrdinalIgnoreCase) ||
+ string.Equals(args[0], FFMPEG_H265_CODEC, StringComparison.OrdinalIgnoreCase))
+ {
+ videoCodec = args[0].ToLower();
+ }
+ else
{
- case FFMPEG_VP8_CODEC:
- case FFMPEG_VP9_CODEC:
- case FFMPEG_H264_CODEC:
- case FFMPEG_H265_CODEC:
- videoCodec = args[0].ToLower();
- break;
-
- default:
- Console.WriteLine($"Video codec option not recognised. Valid values are {FFMPEG_VP8_CODEC}, {FFMPEG_VP9_CODEC} and {FFMPEG_H264_CODEC}. Using {videoCodec}.");
- break;
+ Console.WriteLine($"Video codec option not recognised. Valid values are {FFMPEG_VP8_CODEC}, {FFMPEG_VP9_CODEC} and {FFMPEG_H264_CODEC}. Using {videoCodec}.");
}
}
@@ -108,7 +106,7 @@ static async Task Main(string[] args)
logger = AddConsoleLogger();
- string ffmpegCommand = String.Format(FFMPEG_DEFAULT_COMMAND, videoCodec, FFMPEG_DEFAULT_RTP_PORT, SSRC_REMOTE_VIDEO, FFMPEG_SDP_FILE);
+ string ffmpegCommand = $"ffmpeg -re -f lavfi -i testsrc=size=640x480:rate=10 {videoCodec} -pix_fmt yuv420p -strict experimental -g 1 -ssrc {SSRC_REMOTE_VIDEO} -f rtp rtp://127.0.0.1:{FFMPEG_DEFAULT_RTP_PORT} -sdp_file {FFMPEG_SDP_FILE}";
// Start web socket.
Console.WriteLine("Starting web socket server...");
@@ -294,7 +292,7 @@ private static void WebSocketMessageReceived(WebSocketContext context, RTCPeerCo
{
logger.LogDebug("ICE Candidate: " + message);
- if (string.IsNullOrWhiteSpace(message) || message.Trim().ToLower() == SDP.END_ICE_CANDIDATES_ATTRIBUTE)
+ if (string.IsNullOrWhiteSpace(message) || message.AsSpan().Trim().Equals(SDP.END_ICE_CANDIDATES_ATTRIBUTE, StringComparison.OrdinalIgnoreCase))
{
logger.LogDebug("End of candidates message received.");
}
diff --git a/examples/WebRTCExamples/RtspToWebRTCAudioAndVideo/DemuxerConfig.cs b/examples/WebRTCExamples/RtspToWebRTCAudioAndVideo/DemuxerConfig.cs
index 0b405e8e2b..15abfa58b3 100644
--- a/examples/WebRTCExamples/RtspToWebRTCAudioAndVideo/DemuxerConfig.cs
+++ b/examples/WebRTCExamples/RtspToWebRTCAudioAndVideo/DemuxerConfig.cs
@@ -47,52 +47,18 @@ public string Args
switch (outputStream)
{
case StreamsEnum.videoAndAudio:
- return String.Format(commandTemplateDic[StreamsEnum.videoAndAudio],
- rtspUrl,
- vcodec,
- videoSsrc,
- serverIP,
- videoPort,
- acodec,
- audioSsrc,
- audioPort,
- sdpPath
- );
+ return $"-use_wallclock_as_timestamps 1 -i {rtspUrl} -map 0:v -c:v {vcodec} -ssrc {videoSsrc} -f rtp rtp://{serverIP}:{videoPort} -map 0:a -c:a {acodec} -ssrc {audioSsrc} -f rtp rtp://{serverIP}:{audioPort} -sdp_file {sdpPath} -y";
case StreamsEnum.videoAndAudioUdp:
- return String.Format(commandTemplateDic[StreamsEnum.videoAndAudioUdp],
- rtspUrl,
- vcodec,
- videoSsrc,
- serverIP,
- videoPort,
- acodec,
- audioSsrc,
- audioPort,
- sdpPath
- );
+ return $"-use_wallclock_as_timestamps 1 -rtsp_transport udp -i {rtspUrl} -map 0:v -c:v {vcodec} -ssrc {videoSsrc} -f rtp rtp://{serverIP}:{videoPort} -map 0:a -c:a {acodec} -ssrc {audioSsrc} -f rtp rtp://{serverIP}:{audioPort} -sdp_file {sdpPath} -y";
case StreamsEnum.audio:
- return String.Format(commandTemplateDic[StreamsEnum.audio],
- rtspUrl,
- acodec,
- audioSsrc,
- serverIP,
- audioPort,
- sdpPath
- );
+ return $"-re -i {rtspUrl} -vn -acodec {acodec} -ssrc {audioSsrc} -f rtp rtp://{serverIP}:{audioPort} -sdp_file {sdpPath}";
case StreamsEnum.video:
- return String.Format(commandTemplateDic[StreamsEnum.video],
- rtspUrl,
- vcodec,
- videoSsrc,
- serverIP,
- videoPort,
- sdpPath
- );
+ return $"-re -i {rtspUrl} -an -vcodec {vcodec} -ssrc {videoSsrc} -f rtp rtp://{serverIP}:{videoPort} -sdp_file {sdpPath}";
default:
return "";
}
-
-
+
+
}
}
}
diff --git a/examples/WebRTCExamples/RtspToWebRTCAudioAndVideo/WebSocketSignalingServer.cs b/examples/WebRTCExamples/RtspToWebRTCAudioAndVideo/WebSocketSignalingServer.cs
index 996ace8195..f11d544850 100644
--- a/examples/WebRTCExamples/RtspToWebRTCAudioAndVideo/WebSocketSignalingServer.cs
+++ b/examples/WebRTCExamples/RtspToWebRTCAudioAndVideo/WebSocketSignalingServer.cs
@@ -158,7 +158,7 @@ private async Task WebSocketMessageReceived(WebSocketContext context, RTCPeerCon
{
_logger.LogInformation("ICE Candidate: " + message);
- if (string.IsNullOrWhiteSpace(message) || message.Trim().ToLower() == SDP.END_ICE_CANDIDATES_ATTRIBUTE)
+ if (string.IsNullOrWhiteSpace(message) || message.AsSpan().Trim().Equals(SDP.END_ICE_CANDIDATES_ATTRIBUTE, StringComparison.OrdinalIgnoreCase))
{
_logger.LogDebug("End of candidates message received.");
}
diff --git a/examples/WebRTCExamples/UnityVideoSink/Assets/Scripts/PlayerController.cs b/examples/WebRTCExamples/UnityVideoSink/Assets/Scripts/PlayerController.cs
index 71f566ae5f..2e0446f0bc 100644
--- a/examples/WebRTCExamples/UnityVideoSink/Assets/Scripts/PlayerController.cs
+++ b/examples/WebRTCExamples/UnityVideoSink/Assets/Scripts/PlayerController.cs
@@ -47,7 +47,7 @@ void OnMove(InputValue movementValue)
void SetCountText()
{
- countText.text = "Count: " + count.ToString();
+ countText.text = $"Count: {count.ToString()}";
if (count >= 10)
{
diff --git a/examples/WebRTCExamples/UnityVideoSink/Assets/Scripts/WebRTCStream.cs b/examples/WebRTCExamples/UnityVideoSink/Assets/Scripts/WebRTCStream.cs
index 232db6addb..8c863c63e8 100644
--- a/examples/WebRTCExamples/UnityVideoSink/Assets/Scripts/WebRTCStream.cs
+++ b/examples/WebRTCExamples/UnityVideoSink/Assets/Scripts/WebRTCStream.cs
@@ -261,7 +261,7 @@ public bool IsEnabled(LogLevel logLevel)
public void Log(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func formatter)
{
- Debug.Log("[" + eventId + "] " + formatter(state, exception));
+ Debug.Log($"[{eventId}] {formatter(state, exception)}");
System.Diagnostics.Debug.WriteLine("[" + eventId + "] " + formatter(state, exception));
}
}
diff --git a/examples/WebRTCExamples/UnityVideoSource/Assets/Scripts/PlayerController.cs b/examples/WebRTCExamples/UnityVideoSource/Assets/Scripts/PlayerController.cs
index 35468afa0b..d351e66914 100644
--- a/examples/WebRTCExamples/UnityVideoSource/Assets/Scripts/PlayerController.cs
+++ b/examples/WebRTCExamples/UnityVideoSource/Assets/Scripts/PlayerController.cs
@@ -250,8 +250,7 @@ public bool IsEnabled(Microsoft.Extensions.Logging.LogLevel logLevel)
public void Log(Microsoft.Extensions.Logging.LogLevel logLevel, EventId eventId, TState state, Exception exception, Func formatter)
{
- Debug.Log("[" + eventId + "] " + formatter(state, exception));
+ Debug.Log($"[{eventId}] {formatter(state, exception)}");
System.Diagnostics.Debug.WriteLine("[" + eventId + "] " + formatter(state, exception));
}
}
-
diff --git a/examples/WebRTCExamples/WebRTCOpenGL/AudioScope/AudioScopeOpenGL.cs b/examples/WebRTCExamples/WebRTCOpenGL/AudioScope/AudioScopeOpenGL.cs
index 9393443fc9..d3334c022c 100755
--- a/examples/WebRTCExamples/WebRTCOpenGL/AudioScope/AudioScopeOpenGL.cs
+++ b/examples/WebRTCExamples/WebRTCOpenGL/AudioScope/AudioScopeOpenGL.cs
@@ -92,7 +92,7 @@ public void Initialise(OpenGL gl)
// going to throw an exception.
if (_prog.GetLinkStatus(gl) == false)
{
- throw new SharpGL.Shaders.ShaderCompilationException(string.Format("Failed to link shader program with ID {0}.", _prog.ShaderProgramObject), _prog.GetInfoLog(gl));
+ throw new SharpGL.Shaders.ShaderCompilationException($"Failed to link shader program with ID {_prog.ShaderProgramObject}.", _prog.GetInfoLog(gl));
}
// Load clear program.
@@ -118,7 +118,7 @@ public void Initialise(OpenGL gl)
// going to throw an exception.
if (_clearProg.GetLinkStatus(gl) == false)
{
- throw new SharpGL.Shaders.ShaderCompilationException(string.Format("Failed to link the clear shader program with ID {0}.", _clearProg.ShaderProgramObject), _clearProg.GetInfoLog(gl));
+ throw new SharpGL.Shaders.ShaderCompilationException($"Failed to link the clear shader program with ID {_clearProg.ShaderProgramObject}.", _clearProg.GetInfoLog(gl));
}
_clearRectangle = new float[] { -1.0f, -1.0f, -1.0f, 1.0f, 1.0f, -1.0f, 1.0f, 1.0f };
diff --git a/examples/WebRTCExamples/WebRTCOpenGLSource/AudioScope/AudioScopeOpenGL.cs b/examples/WebRTCExamples/WebRTCOpenGLSource/AudioScope/AudioScopeOpenGL.cs
index 9393443fc9..d3334c022c 100644
--- a/examples/WebRTCExamples/WebRTCOpenGLSource/AudioScope/AudioScopeOpenGL.cs
+++ b/examples/WebRTCExamples/WebRTCOpenGLSource/AudioScope/AudioScopeOpenGL.cs
@@ -92,7 +92,7 @@ public void Initialise(OpenGL gl)
// going to throw an exception.
if (_prog.GetLinkStatus(gl) == false)
{
- throw new SharpGL.Shaders.ShaderCompilationException(string.Format("Failed to link shader program with ID {0}.", _prog.ShaderProgramObject), _prog.GetInfoLog(gl));
+ throw new SharpGL.Shaders.ShaderCompilationException($"Failed to link shader program with ID {_prog.ShaderProgramObject}.", _prog.GetInfoLog(gl));
}
// Load clear program.
@@ -118,7 +118,7 @@ public void Initialise(OpenGL gl)
// going to throw an exception.
if (_clearProg.GetLinkStatus(gl) == false)
{
- throw new SharpGL.Shaders.ShaderCompilationException(string.Format("Failed to link the clear shader program with ID {0}.", _clearProg.ShaderProgramObject), _clearProg.GetInfoLog(gl));
+ throw new SharpGL.Shaders.ShaderCompilationException($"Failed to link the clear shader program with ID {_clearProg.ShaderProgramObject}.", _clearProg.GetInfoLog(gl));
}
_clearRectangle = new float[] { -1.0f, -1.0f, -1.0f, 1.0f, 1.0f, -1.0f, 1.0f, 1.0f };
diff --git a/examples/WebRTCExamples/WebRTCtoFfplay/Program.cs b/examples/WebRTCExamples/WebRTCtoFfplay/Program.cs
index 94d8ec2e94..d764ce2a09 100644
--- a/examples/WebRTCExamples/WebRTCtoFfplay/Program.cs
+++ b/examples/WebRTCExamples/WebRTCtoFfplay/Program.cs
@@ -259,7 +259,7 @@ private static RTPSession CreateRtpSession(List audioF
sw.Write(sdpOffer);
}
- string ffplayCommand = String.Format(FFPLAY_DEFAULT_COMMAND, FFPLAY_DEFAULT_SDP_PATH);
+ string ffplayCommand = $"ffplay -probesize 32 -protocol_whitelist \"file,rtp,udp\" -i {FFPLAY_DEFAULT_SDP_PATH}";
Console.WriteLine($"Start ffplay using the command below:");
Console.WriteLine(ffplayCommand);
Console.WriteLine($"To request the remote peer to send a video key frame press 'k'");
@@ -312,7 +312,7 @@ private static async Task WebSocketMessageReceived(WebSocketContext context, RTC
{
logger.LogDebug("ICE Candidate: " + message);
- if (string.IsNullOrWhiteSpace(message) || message.Trim().ToLower() == SDP.END_ICE_CANDIDATES_ATTRIBUTE)
+ if (string.IsNullOrWhiteSpace(message) || message.AsSpan().Trim().Equals(SDP.END_ICE_CANDIDATES_ATTRIBUTE, StringComparison.OrdinalIgnoreCase))
{
logger.LogDebug("End of candidates message received.");
}
diff --git a/examples/WebRTCScenarios/DataChannelStressTest/Program.cs b/examples/WebRTCScenarios/DataChannelStressTest/Program.cs
index 4904d884c9..784785ec3d 100644
--- a/examples/WebRTCScenarios/DataChannelStressTest/Program.cs
+++ b/examples/WebRTCScenarios/DataChannelStressTest/Program.cs
@@ -124,8 +124,7 @@ private static async Task RunCommand()
Console.WriteLine($"Data channel open tasks completed in {connectSW.ElapsedMilliseconds:0.##}ms.");
foreach (var pair in connectionPairs)
{
- Console.WriteLine($"PC pair {pair.Name} src datachannel {pair.DC.readyState} streamid {pair.DC.id}, " +
- $"dst datachannel {pair.PCDst.DataChannels.Single().readyState} streamid {pair.PCDst.DataChannels.Single().id}.");
+ Console.WriteLine($"PC pair {pair.Name} src datachannel {pair.DC.readyState} streamid {pair.DC.id}, dst datachannel {pair.PCDst.DataChannels.Single().readyState} streamid {pair.PCDst.DataChannels.Single().id}.");
char a = 'a';
for (int j = 1; j < TEST_DATACHANNELS_PER_PEER_CONNECTION; j++)
@@ -143,8 +142,7 @@ private static async Task RunCommand()
{
var dstdc = pair.PCDst.DataChannels.SingleOrDefault(x => x.id == srcdc.id);
- Console.WriteLine($" {srcdc.label}: src status {srcdc.readyState} streamid {srcdc.id} <-> " +
- $"dst status {dstdc.readyState} streamid {dstdc.id}.");
+ Console.WriteLine($" {srcdc.label}: src status {srcdc.readyState} streamid {srcdc.id} <-> dst status {dstdc.readyState} streamid {dstdc.id}.");
srcdc.onmessage += OnData;
dstdc.onmessage += OnData;
diff --git a/examples/webrtccmdline/Program.cs b/examples/webrtccmdline/Program.cs
index 96925382ee..e80f0cfab0 100755
--- a/examples/webrtccmdline/Program.cs
+++ b/examples/webrtccmdline/Program.cs
@@ -471,9 +471,9 @@ private async static Task ProcessInput(CancellationTokenSource cts)
else
{
// Attempt to execute the current command.
- switch (command.ToLower())
+ switch (command)
{
- case "c":
+ case var _ when string.Equals(command, "c", StringComparison.OrdinalIgnoreCase):
// Close active peer connection.
if (_peerConnection != null)
{
@@ -483,7 +483,7 @@ private async static Task ProcessInput(CancellationTokenSource cts)
}
break;
- case var x when x.StartsWith("cdc"):
+ case var x when x.StartsWith("cdc", StringComparison.OrdinalIgnoreCase):
// Attempt to create a new data channel.
if (_peerConnection != null)
{
@@ -503,7 +503,7 @@ private async static Task ProcessInput(CancellationTokenSource cts)
}
break;
- case var x when x.StartsWith("ldc"):
+ case var _ when command.StartsWith("ldc", StringComparison.OrdinalIgnoreCase):
// List data channels.
if (_peerConnection != null)
{
@@ -523,7 +523,7 @@ private async static Task ProcessInput(CancellationTokenSource cts)
}
break;
- case var x when x.StartsWith("sdc"):
+ case var x when x.StartsWith("sdc", StringComparison.OrdinalIgnoreCase):
// Send data channel message.
if (_peerConnection != null)
{
@@ -551,7 +551,7 @@ private async static Task ProcessInput(CancellationTokenSource cts)
}
break;
- case var x when x.StartsWith("dtmf"):
+ case var x when x.StartsWith("dtmf", StringComparison.OrdinalIgnoreCase):
if (_peerConnection != null)
{
if (_peerConnection.HasAudio)
@@ -577,14 +577,14 @@ private async static Task ProcessInput(CancellationTokenSource cts)
}
break;
- case "q":
+ case var _ when string.Equals(command, "q", StringComparison.OrdinalIgnoreCase):
// Quit.
Console.WriteLine();
Console.WriteLine("Quitting...");
cts.Cancel();
break;
- case "isalive":
+ case var _ when string.Equals(command, "isalive", StringComparison.OrdinalIgnoreCase):
// Check responsiveness.
Console.WriteLine();
Console.WriteLine("yep");
diff --git a/test/FFmpegConsoleApp/Program.cs b/test/FFmpegConsoleApp/Program.cs
index 7d46315ae1..f4e7b4bfc9 100755
--- a/test/FFmpegConsoleApp/Program.cs
+++ b/test/FFmpegConsoleApp/Program.cs
@@ -1,24 +1,24 @@
-using System;
-using System.Collections.Generic;
-using Microsoft.Extensions.Logging;
-using SIPSorceryMedia.Abstractions;
-using SIPSorceryMedia.FFmpeg;
-
-namespace FFmpegConsoleApp
-{
- class Program
- {
- // A valid to a video file - usefull if you want to test streaming of a video file
- // It's alo possible to set a remote file
- const String VIDEO_FILE_PATH = @"https://upload.wikimedia.org/wikipedia/commons/3/36/Cosmos_Laundromat_-_First_Cycle_-_Official_Blender_Foundation_release.webm";
- //const String VIDEO_FILE_PATH = @"C:\media\big_buck_bunny.mp4";
- //const String VIDEO_FILE_PATH = @"C:\media\Armello_Trailer.webm";
-
- static private AsciiFrame? asciiFrame = null;
-
- static void Main(string[] args)
- {
- VideoCodecsEnum VideoCodec = VideoCodecsEnum.H264;
+using System;
+using System.Collections.Generic;
+using Microsoft.Extensions.Logging;
+using SIPSorceryMedia.Abstractions;
+using SIPSorceryMedia.FFmpeg;
+
+namespace FFmpegConsoleApp
+{
+ class Program
+ {
+ // A valid to a video file - usefull if you want to test streaming of a video file
+ // It's alo possible to set a remote file
+ const String VIDEO_FILE_PATH = @"https://upload.wikimedia.org/wikipedia/commons/3/36/Cosmos_Laundromat_-_First_Cycle_-_Official_Blender_Foundation_release.webm";
+ //const String VIDEO_FILE_PATH = @"C:\media\big_buck_bunny.mp4";
+ //const String VIDEO_FILE_PATH = @"C:\media\Armello_Trailer.webm";
+
+ static private AsciiFrame? asciiFrame = null;
+
+ static void Main(string[] args)
+ {
+ VideoCodecsEnum VideoCodec = VideoCodecsEnum.H264;
IVideoSource? videoSource = null;
using var loggerFactory = LoggerFactory.Create(builder =>
@@ -31,149 +31,149 @@ static void Main(string[] args)
ILogger logger = loggerFactory.CreateLogger();
// Initialise FFmpeg librairies
- FFmpegInit.Initialise(FfmpegLogLevelEnum.AV_LOG_FATAL, null, logger);
-
- // Get cameras and monitors
- List? cameras = FFmpegCameraManager.GetCameraDevices();
- List? monitors = FFmpegMonitorManager.GetMonitorDevices();
-
- char keyChar = ' ';
- while (true)
- {
- Console.Clear();
- if (!(cameras?.Count > 0))
- Console.WriteLine("\nNo Camera found ...");
- if (!(monitors?.Count > 0))
- Console.WriteLine("\nNo Monitor found ...");
-
- Console.WriteLine("\nWhat do you want to use ?");
- if (cameras?.Count > 0)
- Console.Write("\n [c] - Camera ");
- if (monitors?.Count > 0)
- Console.Write("\n [m] - Monitor ");
- Console.Write($"\n [f] - File - Path:[{VIDEO_FILE_PATH}]");
-
- Console.WriteLine("\n");
- Console.Out.Flush();
-
- var keyConsole = Console.ReadKey();
- if ( ( (keyConsole.KeyChar == 'c') && (cameras?.Count > 0) )
- || ( (keyConsole.KeyChar == 'm') && (monitors?.Count > 0))
- || (keyConsole.KeyChar == 'f'))
- {
- keyChar = keyConsole.KeyChar;
- break;
- }
- }
- // Do we manage a camera ?
- if (keyChar == 'c')
- {
- int cameraIndex = 0;
- if (cameras?.Count > 1)
- {
- while (true)
- {
- Console.Clear();
- Console.WriteLine("\nWhich camera do you want to use:");
- int index = 0;
- foreach (Camera camera in cameras)
- {
- Console.Write($"\n [{index}] - {camera.Name} ");
- index++;
- }
- Console.WriteLine("\n");
- Console.Out.Flush();
-
- var keyConsole = Console.ReadKey();
- if (int.TryParse("" + keyConsole.KeyChar, out int keyValue) && keyValue < index && keyValue >= 0)
- {
- cameraIndex = keyValue;
- break;
- }
- }
- }
- if (cameras != null)
- {
- var selectedCamera = cameras[cameraIndex];
- SIPSorceryMedia.FFmpeg.FFmpegCameraSource cameraSource = new SIPSorceryMedia.FFmpeg.FFmpegCameraSource(selectedCamera.Path);
- videoSource = cameraSource as IVideoSource;
- }
- }
- // Do we manage a Monitor ?
- else if (keyChar == 'm')
- {
- int monitorIndex = 0;
- if (monitors?.Count > 1)
- {
- while (true)
- {
- Console.Clear();
- Console.WriteLine("\nWhich Monitor do you want to use:");
- int index = 0;
- foreach (Monitor monitor in monitors)
- {
- Console.Write($"\n [{index}] - Monitor {monitor.Name} [{monitor.Rect.Width}x{monitor.Rect.Height}] {(monitor.Primary ? " PRIMARY" : "")}");
- index++;
- }
- Console.WriteLine("\n");
- Console.Out.Flush();
-
- var keyConsole = Console.ReadKey();
- if (int.TryParse("" + keyConsole.KeyChar, out int keyValue) && keyValue < index && keyValue >= 0)
- {
- monitorIndex = keyValue;
- break;
- }
- }
- }
-
- if (monitors != null)
- {
- var selectedMonitor = monitors[monitorIndex];
- SIPSorceryMedia.FFmpeg.FFmpegScreenSource screenSource = new SIPSorceryMedia.FFmpeg.FFmpegScreenSource(selectedMonitor.Path, selectedMonitor.Rect, 20);
- videoSource = screenSource as IVideoSource;
- }
- }
- // Do we manage a File ?
- else
- {
- SIPSorceryMedia.FFmpeg.FFmpegFileSource fileSource = new SIPSorceryMedia.FFmpeg.FFmpegFileSource(VIDEO_FILE_PATH, true, null, 960, true);
- videoSource = fileSource as IVideoSource;
- }
-
-
- if(videoSource == null)
- {
- Console.WriteLine("No video source defined ...");
- return;
- }
-
- // Create object used to display video in Ascii
- asciiFrame = new AsciiFrame();
-
- videoSource.RestrictFormats(x => x.Codec == VideoCodec);
- videoSource.SetVideoSourceFormat(videoSource.GetVideoSourceFormats().Find(x => x.Codec == VideoCodec));
- videoSource.OnVideoSourceRawSampleFaster+= FileSource_OnVideoSourceRawSampleFaster;
- videoSource.StartVideo();
-
- for (var loop = true; loop;)
- {
- var cki = Console.ReadKey(true);
- switch (cki.Key)
- {
- case ConsoleKey.Q:
- case ConsoleKey.Enter:
- case ConsoleKey.Escape:
- Console.CursorVisible = true;
- loop = false;
- break;
- }
- }
- }
-
- private static void FileSource_OnVideoSourceRawSampleFaster(uint durationMilliseconds, RawImage rawImage)
- {
- asciiFrame?.GotRawImage(ref rawImage);
- }
- }
-}
+ FFmpegInit.Initialise(FfmpegLogLevelEnum.AV_LOG_FATAL, null, logger);
+
+ // Get cameras and monitors
+ List? cameras = FFmpegCameraManager.GetCameraDevices();
+ List? monitors = FFmpegMonitorManager.GetMonitorDevices();
+
+ char keyChar = ' ';
+ while (true)
+ {
+ Console.Clear();
+ if (!(cameras?.Count > 0))
+ Console.WriteLine("\nNo Camera found ...");
+ if (!(monitors?.Count > 0))
+ Console.WriteLine("\nNo Monitor found ...");
+
+ Console.WriteLine("\nWhat do you want to use ?");
+ if (cameras?.Count > 0)
+ Console.Write("\n [c] - Camera ");
+ if (monitors?.Count > 0)
+ Console.Write("\n [m] - Monitor ");
+ Console.Write($"\n [f] - File - Path:[{VIDEO_FILE_PATH}]");
+
+ Console.WriteLine("\n");
+ Console.Out.Flush();
+
+ var keyConsole = Console.ReadKey();
+ if ( ( (keyConsole.KeyChar == 'c') && (cameras?.Count > 0) )
+ || ( (keyConsole.KeyChar == 'm') && (monitors?.Count > 0))
+ || (keyConsole.KeyChar == 'f'))
+ {
+ keyChar = keyConsole.KeyChar;
+ break;
+ }
+ }
+ // Do we manage a camera ?
+ if (keyChar == 'c')
+ {
+ int cameraIndex = 0;
+ if (cameras?.Count > 1)
+ {
+ while (true)
+ {
+ Console.Clear();
+ Console.WriteLine("\nWhich camera do you want to use:");
+ int index = 0;
+ foreach (Camera camera in cameras)
+ {
+ Console.Write($"\n [{index}] - {camera.Name} ");
+ index++;
+ }
+ Console.WriteLine("\n");
+ Console.Out.Flush();
+
+ var keyConsole = Console.ReadKey();
+ if (int.TryParse($"{keyConsole.KeyChar}", out int keyValue) && keyValue < index && keyValue >= 0)
+ {
+ cameraIndex = keyValue;
+ break;
+ }
+ }
+ }
+ if (cameras != null)
+ {
+ var selectedCamera = cameras[cameraIndex];
+ SIPSorceryMedia.FFmpeg.FFmpegCameraSource cameraSource = new SIPSorceryMedia.FFmpeg.FFmpegCameraSource(selectedCamera.Path);
+ videoSource = cameraSource as IVideoSource;
+ }
+ }
+ // Do we manage a Monitor ?
+ else if (keyChar == 'm')
+ {
+ int monitorIndex = 0;
+ if (monitors?.Count > 1)
+ {
+ while (true)
+ {
+ Console.Clear();
+ Console.WriteLine("\nWhich Monitor do you want to use:");
+ int index = 0;
+ foreach (Monitor monitor in monitors)
+ {
+ Console.Write($"\n [{index}] - Monitor {monitor.Name} [{monitor.Rect.Width}x{monitor.Rect.Height}] {(monitor.Primary ? " PRIMARY" : "")}");
+ index++;
+ }
+ Console.WriteLine("\n");
+ Console.Out.Flush();
+
+ var keyConsole = Console.ReadKey();
+ if (int.TryParse($"{keyConsole.KeyChar}", out int keyValue) && keyValue < index && keyValue >= 0)
+ {
+ monitorIndex = keyValue;
+ break;
+ }
+ }
+ }
+
+ if (monitors != null)
+ {
+ var selectedMonitor = monitors[monitorIndex];
+ SIPSorceryMedia.FFmpeg.FFmpegScreenSource screenSource = new SIPSorceryMedia.FFmpeg.FFmpegScreenSource(selectedMonitor.Path, selectedMonitor.Rect, 20);
+ videoSource = screenSource as IVideoSource;
+ }
+ }
+ // Do we manage a File ?
+ else
+ {
+ SIPSorceryMedia.FFmpeg.FFmpegFileSource fileSource = new SIPSorceryMedia.FFmpeg.FFmpegFileSource(VIDEO_FILE_PATH, true, null, 960, true);
+ videoSource = fileSource as IVideoSource;
+ }
+
+
+ if(videoSource == null)
+ {
+ Console.WriteLine("No video source defined ...");
+ return;
+ }
+
+ // Create object used to display video in Ascii
+ asciiFrame = new AsciiFrame();
+
+ videoSource.RestrictFormats(x => x.Codec == VideoCodec);
+ videoSource.SetVideoSourceFormat(videoSource.GetVideoSourceFormats().Find(x => x.Codec == VideoCodec));
+ videoSource.OnVideoSourceRawSampleFaster+= FileSource_OnVideoSourceRawSampleFaster;
+ videoSource.StartVideo();
+
+ for (var loop = true; loop;)
+ {
+ var cki = Console.ReadKey(true);
+ switch (cki.Key)
+ {
+ case ConsoleKey.Q:
+ case ConsoleKey.Enter:
+ case ConsoleKey.Escape:
+ Console.CursorVisible = true;
+ loop = false;
+ break;
+ }
+ }
+ }
+
+ private static void FileSource_OnVideoSourceRawSampleFaster(uint durationMilliseconds, RawImage rawImage)
+ {
+ asciiFrame?.GotRawImage(ref rawImage);
+ }
+ }
+}
diff --git a/test/FFmpegManagedTranscodeTest/Program.cs b/test/FFmpegManagedTranscodeTest/Program.cs
index dc46b52f66..356b340ff1 100755
--- a/test/FFmpegManagedTranscodeTest/Program.cs
+++ b/test/FFmpegManagedTranscodeTest/Program.cs
@@ -105,7 +105,7 @@ unsafe static void Main(string[] args)
if(bytes != null)
{
- Console.WriteLine($"VP8 encoded packet size {bytes.Length}, sha256: " + Convert.ToBase64String(SHA256.HashData(bytes)));
+ Console.WriteLine($"VP8 encoded packet size {bytes.Length}, sha256: {Convert.ToBase64String(SHA256.HashData(bytes))}");
}
int sleep = (int)(dpts * 1000 - DateTime.Now.Subtract(startTime).TotalMilliseconds);
diff --git a/test/FFmpegMp4Test/FFmpegInit.cs b/test/FFmpegMp4Test/FFmpegInit.cs
index 45aa20def7..b8d32b916a 100755
--- a/test/FFmpegMp4Test/FFmpegInit.cs
+++ b/test/FFmpegMp4Test/FFmpegInit.cs
@@ -110,7 +110,7 @@ internal static void RegisterFFmpegBinaries(String? libPath = null)
string ffmpegExecutable = "ffmpeg";
string? path = Environment.GetEnvironmentVariable("PATH")?
.Split(';')
- .Where(s => File.Exists(Path.Combine(s, ffmpegExecutable)) || File.Exists(Path.Combine(s, ffmpegExecutable + ".exe")))
+ .Where(s => File.Exists(Path.Combine(s, ffmpegExecutable)) || File.Exists(Path.Combine(s, $"{ffmpegExecutable}.exe")))
.FirstOrDefault();
if (path != null)
diff --git a/test/FFmpegTranscodeTest/Program.cs b/test/FFmpegTranscodeTest/Program.cs
index fdecd345e2..8c3534775a 100755
--- a/test/FFmpegTranscodeTest/Program.cs
+++ b/test/FFmpegTranscodeTest/Program.cs
@@ -128,7 +128,7 @@ unsafe static void Main(string[] args)
{
byte[] arr = new byte[pPacket->size];
Marshal.Copy((IntPtr)pPacket->data, arr, 0, pPacket->size);
- Console.WriteLine($"VP8 encoded packet size {arr.Length}, sha256: " + Convert.ToBase64String(SHA256.HashData(arr)));
+ Console.WriteLine($"VP8 encoded packet size {arr.Length}, sha256: {Convert.ToBase64String(SHA256.HashData(arr))}");
}
else if (error == ffmpeg.AVERROR(ffmpeg.EAGAIN))
{
diff --git a/test/SIPSorcery.VP8.UnitTest/bitstream_unittest.cs b/test/SIPSorcery.VP8.UnitTest/bitstream_unittest.cs
index 1eaa7e632e..ad21c3dc0a 100644
--- a/test/SIPSorcery.VP8.UnitTest/bitstream_unittest.cs
+++ b/test/SIPSorcery.VP8.UnitTest/bitstream_unittest.cs
@@ -213,7 +213,7 @@ private static void AssertHeaderBytes(KeyframeHeaderConfig cfg, byte[] expected)
for (int i = 0; i < expected.Length; i++)
{
Assert.True(expected[i] == buf[i],
- "byte " + i + " mismatch: expected=0x" + expected[i].ToString("x2") + " actual=0x" + buf[i].ToString("x2"));
+ $"byte {i} mismatch: expected=0x{expected[i].ToString("x2")} actual=0x{buf[i].ToString("x2")}");
}
}
}
diff --git a/test/SIPSorcery.VP8.UnitTest/encode_inter_frame_unittest.cs b/test/SIPSorcery.VP8.UnitTest/encode_inter_frame_unittest.cs
index 040667abba..c578f670ea 100644
--- a/test/SIPSorcery.VP8.UnitTest/encode_inter_frame_unittest.cs
+++ b/test/SIPSorcery.VP8.UnitTest/encode_inter_frame_unittest.cs
@@ -72,7 +72,7 @@ public void EncodeInterFrame_StaticSourceRoundTripsExactly()
// mode tree bits -- no token coefficients at all. It
// must be no larger than the corresponding keyframe.
Assert.True(interFrame.Length <= kf.Length + 4,
- "static inter frame (" + interFrame.Length + ") should not exceed keyframe size (" + kf.Length + ")");
+ $"static inter frame ({interFrame.Length}) should not exceed keyframe size ({kf.Length})");
byte[] decoded = DecodeOne(ctx, interFrame, width, height);
AssertExact(keyDecoded, decoded);
@@ -118,8 +118,7 @@ public void EncodeInterFrame_ChangingSourceRoundTripsWithinTolerance(int qIndex,
double psnrInterVsInterSrc = ComputePSNR(interYuv, decInter);
double psnrKeyVsInterSrc = ComputePSNR(interYuv, decKey);
Assert.True(psnrInterVsInterSrc > psnrKeyVsInterSrc + 5.0,
- "inter encoding should bring the decoded frame substantially closer to the inter source than the reference. psnrInter=" +
- psnrInterVsInterSrc.ToString("F2") + " psnrKey=" + psnrKeyVsInterSrc.ToString("F2"));
+ $"inter encoding should bring the decoded frame substantially closer to the inter source than the reference. psnrInter={psnrInterVsInterSrc.ToString("F2")} psnrKey={psnrKeyVsInterSrc.ToString("F2")}");
}
[Fact]
@@ -346,7 +345,7 @@ private static void AssertExact(byte[] expected, byte[] actual)
for (int i = 0; i < expected.Length; i++)
{
Assert.True(expected[i] == actual[i],
- "byte " + i + " differs: expected=" + expected[i] + " actual=" + actual[i]);
+ $"byte {i} differs: expected={expected[i]} actual={actual[i]}");
}
}
@@ -367,7 +366,7 @@ private static void AssertWithinPSNR(byte[] expected, byte[] actual, double minP
{
double psnr = ComputePSNR(expected, actual);
Assert.True(psnr >= minPsnrDb,
- "PSNR " + psnr.ToString("F2") + " dB below required " + minPsnrDb.ToString("F2") + " dB");
+ $"PSNR {psnr.ToString("F2")} dB below required {minPsnrDb.ToString("F2")} dB");
}
}
}
diff --git a/test/SIPSorcery.VP8.UnitTest/frame_encoder_unittest.cs b/test/SIPSorcery.VP8.UnitTest/frame_encoder_unittest.cs
index ef61f82881..4f594fc6ce 100644
--- a/test/SIPSorcery.VP8.UnitTest/frame_encoder_unittest.cs
+++ b/test/SIPSorcery.VP8.UnitTest/frame_encoder_unittest.cs
@@ -324,7 +324,7 @@ private static void AssertExact(byte[] expected, byte[] actual)
for (int i = 0; i < expected.Length; i++)
{
Assert.True(expected[i] == actual[i],
- "Pixel " + i + " differs: src=" + expected[i] + " decoded=" + actual[i]);
+ $"Pixel {i} differs: src={expected[i]} decoded={actual[i]}");
}
}
@@ -335,8 +335,7 @@ private static void AssertWithin(byte[] expected, byte[] actual, int tol)
{
int d = actual[i] - expected[i];
Assert.True(d >= -tol && d <= tol,
- "Pixel " + i + " err " + d + " exceeds tolerance " + tol +
- " (src=" + expected[i] + " decoded=" + actual[i] + ")");
+ $"Pixel {i} err {d} exceeds tolerance {tol} (src={expected[i]} decoded={actual[i]})");
}
}
}
diff --git a/test/SIPSorcery.VP8.UnitTest/inter_mb_mode_bits_unittest.cs b/test/SIPSorcery.VP8.UnitTest/inter_mb_mode_bits_unittest.cs
index f08164bab2..b4d1af4572 100644
--- a/test/SIPSorcery.VP8.UnitTest/inter_mb_mode_bits_unittest.cs
+++ b/test/SIPSorcery.VP8.UnitTest/inter_mb_mode_bits_unittest.cs
@@ -245,7 +245,7 @@ public void TreedWrite_ZeroMv_MatchesDirectBoolEncode()
for (int i = 0; i < outA.Length; i++)
{
Assert.True(outA[i] == outB[i],
- "byte " + i + " mismatch: A=0x" + outA[i].ToString("x2") + " B=0x" + outB[i].ToString("x2"));
+ $"byte {i} mismatch: A=0x{outA[i].ToString("x2")} B=0x{outB[i].ToString("x2")}");
}
}
@@ -274,7 +274,7 @@ public void TreedWrite_SplitMv_MatchesDirectFourBitEncode()
for (int i = 0; i < outA.Length; i++)
{
Assert.True(outA[i] == outB[i],
- "byte " + i + " mismatch: A=0x" + outA[i].ToString("x2") + " B=0x" + outB[i].ToString("x2"));
+ $"byte {i} mismatch: A=0x{outA[i].ToString("x2")} B=0x{outB[i].ToString("x2")}");
}
}
}
diff --git a/test/SIPSorcery.VP8.UnitTest/mb_encoder_unittest.cs b/test/SIPSorcery.VP8.UnitTest/mb_encoder_unittest.cs
index 01911c2294..ec96d8eaa9 100644
--- a/test/SIPSorcery.VP8.UnitTest/mb_encoder_unittest.cs
+++ b/test/SIPSorcery.VP8.UnitTest/mb_encoder_unittest.cs
@@ -166,14 +166,14 @@ public void EncodeMacroblock_RandomInput_ReconstructionWithinQuantTolerance()
{
int diff = r.ReconY[i] - srcY[i];
Assert.True(diff >= -kTol && diff <= kTol,
- "Y[" + i + "] recon err " + diff + " exceeds tolerance " + kTol);
+ $"Y[{i}] recon err {diff} exceeds tolerance {kTol}");
}
for (int i = 0; i < 64; i++)
{
int dU = r.ReconU[i] - srcU[i];
int dV = r.ReconV[i] - srcV[i];
- Assert.True(dU >= -kTol && dU <= kTol, "U[" + i + "] recon err " + dU);
- Assert.True(dV >= -kTol && dV <= kTol, "V[" + i + "] recon err " + dV);
+ Assert.True(dU >= -kTol && dU <= kTol, $"U[{i}] recon err {dU}");
+ Assert.True(dV >= -kTol && dV <= kTol, $"V[{i}] recon err {dV}");
}
}
diff --git a/test/SIPSorcery.VP8.UnitTest/mb_encoder_zeromv_unittest.cs b/test/SIPSorcery.VP8.UnitTest/mb_encoder_zeromv_unittest.cs
index 16fbdcf04c..54569bef7b 100644
--- a/test/SIPSorcery.VP8.UnitTest/mb_encoder_zeromv_unittest.cs
+++ b/test/SIPSorcery.VP8.UnitTest/mb_encoder_zeromv_unittest.cs
@@ -103,11 +103,11 @@ public void EncodeMacroblockZeroMvLast_ConstantOffset_RoundTripsWithinTolerance(
// step on Y is ~7-8; tolerance of 16 is comfortably above
// that so we don't get false negatives from rounding noise.
for (int i = 0; i < 256; i++)
- AssertWithinTolerance(110, r.ReconY[i], 16, "Y[" + i + "]");
+ AssertWithinTolerance(110, r.ReconY[i], 16, $"Y[{i}]");
for (int i = 0; i < 64; i++)
- AssertWithinTolerance(130, r.ReconU[i], 16, "U[" + i + "]");
+ AssertWithinTolerance(130, r.ReconU[i], 16, $"U[{i}]");
for (int i = 0; i < 64; i++)
- AssertWithinTolerance(90, r.ReconV[i], 16, "V[" + i + "]");
+ AssertWithinTolerance(90, r.ReconV[i], 16, $"V[{i}]");
}
// ---------- Test 3: random source over flat prediction -> exercises coef path ----------
@@ -164,8 +164,7 @@ byte Next() {
if (err > maxErrY) maxErrY = err;
}
Assert.True(maxErrY < 100,
- "Random-input Y plane recon max error " + maxErrY
- + " is suspiciously large (> 100). The pipeline may have a sign/clip bug.");
+ $"Random-input Y plane recon max error {maxErrY} is suspiciously large (> 100). The pipeline may have a sign/clip bug.");
}
// ---------- helpers ----------
@@ -182,8 +181,7 @@ private static void AssertWithinTolerance(int expected, byte actual, int tol, st
int err = actual - expected;
if (err < 0) err = -err;
Assert.True(err <= tol,
- label + ": expected=" + expected + " actual=" + actual + " err=" + err
- + " > tol=" + tol);
+ $"{label}: expected={expected} actual={actual} err={err} > tol={tol}");
}
}
}
diff --git a/test/SIPSorcery.VP8.UnitTest/pack_tokens_unittest.cs b/test/SIPSorcery.VP8.UnitTest/pack_tokens_unittest.cs
index 8ba61df15a..a7cdbffed6 100644
--- a/test/SIPSorcery.VP8.UnitTest/pack_tokens_unittest.cs
+++ b/test/SIPSorcery.VP8.UnitTest/pack_tokens_unittest.cs
@@ -187,7 +187,7 @@ private static void AssertPackedBytes(byte[] expected, IList tokens)
for (int i = 0; i < expected.Length; i++)
{
Assert.True(expected[i] == got[i],
- "byte " + i + " mismatch: expected=0x" + expected[i].ToString("x2") + " actual=0x" + got[i].ToString("x2"));
+ $"byte {i} mismatch: expected=0x{expected[i].ToString("x2")} actual=0x{got[i].ToString("x2")}");
}
}
diff --git a/test/SIPSorcery.VP8.UnitTest/quantizer_init_unittest.cs b/test/SIPSorcery.VP8.UnitTest/quantizer_init_unittest.cs
index 169da4256d..12bd6d8eab 100644
--- a/test/SIPSorcery.VP8.UnitTest/quantizer_init_unittest.cs
+++ b/test/SIPSorcery.VP8.UnitTest/quantizer_init_unittest.cs
@@ -175,12 +175,12 @@ public unsafe void Tables_DriveQuantizerCorrectly_ForKnownCoeffBlock()
private static void AssertTablesMatch(string label, QuantizerTables t,
short[] zbin, short[] round, short[] quant, short[] qshift, short[] dequant, short[] zrun)
{
- AssertArr(label + ".zbin", zbin, t.zbin);
- AssertArr(label + ".round", round, t.round);
- AssertArr(label + ".quant", quant, t.quant);
- AssertArr(label + ".quant_shift", qshift, t.quant_shift);
- AssertArr(label + ".dequant", dequant, t.dequant);
- AssertArr(label + ".zrun_zbin_boost", zrun, t.zrun_zbin_boost);
+ AssertArr($"{label}.zbin", zbin, t.zbin);
+ AssertArr($"{label}.round", round, t.round);
+ AssertArr($"{label}.quant", quant, t.quant);
+ AssertArr($"{label}.quant_shift", qshift, t.quant_shift);
+ AssertArr($"{label}.dequant", dequant, t.dequant);
+ AssertArr($"{label}.zrun_zbin_boost", zrun, t.zrun_zbin_boost);
}
private static void AssertArr(string name, short[] expected, short[] actual)
@@ -189,7 +189,7 @@ private static void AssertArr(string name, short[] expected, short[] actual)
for (int i = 0; i < expected.Length; i++)
{
Assert.True(expected[i] == actual[i],
- name + "[" + i + "]: expected " + expected[i] + " got " + actual[i]);
+ $"{name}[{i}]: expected {expected[i]} got {actual[i]}");
}
}
}
diff --git a/test/SIPSorcery.VP8.UnitTest/tokenize_unittest.cs b/test/SIPSorcery.VP8.UnitTest/tokenize_unittest.cs
index a458be3038..117f7ae11f 100644
--- a/test/SIPSorcery.VP8.UnitTest/tokenize_unittest.cs
+++ b/test/SIPSorcery.VP8.UnitTest/tokenize_unittest.cs
@@ -247,11 +247,11 @@ private static void AssertTokens(List got, params (int token, int ex
{
var e = expected[i];
Assert.True(e.token == got[i].Token,
- "[" + i + "] Token: expected " + e.token + " got " + got[i].Token);
+ $"[{i}] Token: expected {e.token} got {got[i].Token}");
Assert.True(e.extra == got[i].Extra,
- "[" + i + "] Extra: expected " + e.extra + " got " + got[i].Extra);
+ $"[{i}] Extra: expected {e.extra} got {got[i].Extra}");
Assert.True(e.skipEob == got[i].skip_eob_node,
- "[" + i + "] skip_eob_node: expected " + e.skipEob + " got " + got[i].skip_eob_node);
+ $"[{i}] skip_eob_node: expected {e.skipEob} got {got[i].skip_eob_node}");
}
}
}
diff --git a/test/integration/SIPSorcery.IntegrationTests.csproj b/test/integration/SIPSorcery.IntegrationTests.csproj
index 3dde14380c..07159f7f1a 100755
--- a/test/integration/SIPSorcery.IntegrationTests.csproj
+++ b/test/integration/SIPSorcery.IntegrationTests.csproj
@@ -5,6 +5,7 @@
false
true
True
+ 14.0
@@ -19,6 +20,10 @@
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
diff --git a/test/integration/app/SIPUserAgentUnitTest.cs b/test/integration/app/SIPUserAgentUnitTest.cs
index 1fff9e203f..eee8d8c368 100755
--- a/test/integration/app/SIPUserAgentUnitTest.cs
+++ b/test/integration/app/SIPUserAgentUnitTest.cs
@@ -23,6 +23,7 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
+using Polyfills;
using SIPSorcery.Media;
using SIPSorcery.Net;
using SIPSorcery.SIP.App;
@@ -44,6 +45,36 @@ public SIPUserAgentUnitTest(Xunit.Abstractions.ITestOutputHelper output)
private string m_CRLF = SIPConstants.CRLF;
+ private string CreateInviteRequestWithSdp() =>
+ """
+ INVITE sip:192.168.11.50:5060 SIP/2.0
+ Via: SIP/2.0/UDP 192.168.11.50:60163;rport;branch=z9hG4bKPj869f70960bdd4204b1352eaf242a3691
+ To: ;tag=ZUJSXRRGXQ
+ From: ;tag=4a60ce364b774258873ff199e5e39938
+ Call-ID: 17324d6df8744d978008c8997bfd208d
+ CSeq: 3532 INVITE
+ Contact:
+ Max-Forwards: 70
+ User-Agent: MicroSIP/3.19.22
+ Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS
+ Supported: replaces, 100rel, timer, norefersub
+ Content-Length: 343
+ Content-Type: application/sdp
+ Session-Expires: 1800
+ Min-SE: 90
+
+ v=0
+ o=- 3785527268 3785527269 IN IP4 192.168.11.50
+ s=pjmedia
+ t=0 0
+ m=audio 4032 RTP/AVP 0 101
+ c=IN IP4 192.168.11.50
+ a=rtpmap:0 PCMU/8000
+ a=rtpmap:101 telephone-event/8000
+ a=fmtp:101 0-16
+ a=sendrecv
+ """.ReplaceLineEndings(m_CRLF);
+
///
/// Tests that the Blind Transfer function doesn't do anything unexpected. The transfer
/// request should return false since the Accepted response never arrives.
@@ -59,32 +90,7 @@ public async Task BlindTransferUnitTest()
SIPUserAgent userAgent = new SIPUserAgent(transport, null);
- string inviteReqStr = "INVITE sip:192.168.11.50:5060 SIP/2.0" + m_CRLF +
-"Via: SIP/2.0/UDP 192.168.11.50:60163;rport;branch=z9hG4bKPj869f70960bdd4204b1352eaf242a3691" + m_CRLF +
-"To: ;tag=ZUJSXRRGXQ" + m_CRLF +
-"From: ;tag=4a60ce364b774258873ff199e5e39938" + m_CRLF +
-"Call-ID: 17324d6df8744d978008c8997bfd208d" + m_CRLF +
-"CSeq: 3532 INVITE" + m_CRLF +
-"Contact: " + m_CRLF +
-"Max-Forwards: 70" + m_CRLF +
-"User-Agent: MicroSIP/3.19.22" + m_CRLF +
-"Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS" + m_CRLF +
-"Supported: replaces, 100rel, timer, norefersub" + m_CRLF +
-"Content-Length: 343" + m_CRLF +
-"Content-Type: application/sdp" + m_CRLF +
-"Session-Expires: 1800" + m_CRLF +
-"Min-SE: 90" + m_CRLF +
-"" + m_CRLF +
-"v=0" + m_CRLF +
-"o=- 3785527268 3785527269 IN IP4 192.168.11.50" + m_CRLF +
-"s=pjmedia" + m_CRLF +
-"t=0 0" + m_CRLF +
-"m=audio 4032 RTP/AVP 0 101" + m_CRLF +
-"c=IN IP4 192.168.11.50" + m_CRLF +
-"a=rtpmap:0 PCMU/8000" + m_CRLF +
-"a=rtpmap:101 telephone-event/8000" + m_CRLF +
-"a=fmtp:101 0-16" + m_CRLF +
-"a=sendrecv";
+ var inviteReqStr = CreateInviteRequestWithSdp();
SIPEndPoint dummySipEndPoint = new SIPEndPoint(new IPEndPoint(IPAddress.Any, 0));
SIPMessageBuffer sipMessageBuffer = SIPMessageBuffer.ParseSIPMessage(inviteReqStr, dummySipEndPoint, dummySipEndPoint);
@@ -114,32 +120,7 @@ public async Task BlindTransferCancelUnitTest()
SIPUserAgent userAgent = new SIPUserAgent(transport, null);
- string inviteReqStr = "INVITE sip:192.168.11.50:5060 SIP/2.0" + m_CRLF +
-"Via: SIP/2.0/UDP 192.168.11.50:60163;rport;branch=z9hG4bKPj869f70960bdd4204b1352eaf242a3691" + m_CRLF +
-"To: ;tag=ZUJSXRRGXQ" + m_CRLF +
-"From: ;tag=4a60ce364b774258873ff199e5e39938" + m_CRLF +
-"Call-ID: 17324d6df8744d978008c8997bfd208d" + m_CRLF +
-"CSeq: 3532 INVITE" + m_CRLF +
-"Contact: " + m_CRLF +
-"Max-Forwards: 70" + m_CRLF +
-"User-Agent: MicroSIP/3.19.22" + m_CRLF +
-"Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS" + m_CRLF +
-"Supported: replaces, 100rel, timer, norefersub" + m_CRLF +
-"Content-Length: 343" + m_CRLF +
-"Content-Type: application/sdp" + m_CRLF +
-"Session-Expires: 1800" + m_CRLF +
-"Min-SE: 90" + m_CRLF +
-"" + m_CRLF +
-"v=0" + m_CRLF +
-"o=- 3785527268 3785527269 IN IP4 192.168.11.50" + m_CRLF +
-"s=pjmedia" + m_CRLF +
-"t=0 0" + m_CRLF +
-"m=audio 4032 RTP/AVP 0 101" + m_CRLF +
-"c=IN IP4 192.168.11.50" + m_CRLF +
-"a=rtpmap:0 PCMU/8000" + m_CRLF +
-"a=rtpmap:101 telephone-event/8000" + m_CRLF +
-"a=fmtp:101 0-16" + m_CRLF +
-"a=sendrecv";
+ var inviteReqStr = CreateInviteRequestWithSdp();
SIPEndPoint dummySipEndPoint = new SIPEndPoint(new IPEndPoint(IPAddress.Any, 0));
SIPMessageBuffer sipMessageBuffer = SIPMessageBuffer.ParseSIPMessage(inviteReqStr, dummySipEndPoint, dummySipEndPoint);
@@ -174,32 +155,7 @@ public async Task HangupUserAgentUnitTest()
SIPUserAgent userAgent = new SIPUserAgent(transport, null);
- string inviteReqStr = "INVITE sip:192.168.11.50:5060 SIP/2.0" + m_CRLF +
-"Via: SIP/2.0/UDP 192.168.11.50:60163;rport;branch=z9hG4bKPj869f70960bdd4204b1352eaf242a3691" + m_CRLF +
-"To: ;tag=ZUJSXRRGXQ" + m_CRLF +
-"From: ;tag=4a60ce364b774258873ff199e5e39938" + m_CRLF +
-"Call-ID: 17324d6df8744d978008c8997bfd208d" + m_CRLF +
-"CSeq: 3532 INVITE" + m_CRLF +
-"Contact: " + m_CRLF +
-"Max-Forwards: 70" + m_CRLF +
-"User-Agent: MicroSIP/3.19.22" + m_CRLF +
-"Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS" + m_CRLF +
-"Supported: replaces, 100rel, timer, norefersub" + m_CRLF +
-"Content-Length: 343" + m_CRLF +
-"Content-Type: application/sdp" + m_CRLF +
-"Session-Expires: 1800" + m_CRLF +
-"Min-SE: 90" + m_CRLF +
-"" + m_CRLF +
-"v=0" + m_CRLF +
-"o=- 3785527268 3785527269 IN IP4 192.168.11.50" + m_CRLF +
-"s=pjmedia" + m_CRLF +
-"t=0 0" + m_CRLF +
-"m=audio 4032 RTP/AVP 0 101" + m_CRLF +
-"c=IN IP4 192.168.11.50" + m_CRLF +
-"a=rtpmap:0 PCMU/8000" + m_CRLF +
-"a=rtpmap:101 telephone-event/8000" + m_CRLF +
-"a=fmtp:101 0-16" + m_CRLF +
-"a=sendrecv";
+ var inviteReqStr = CreateInviteRequestWithSdp();
SIPEndPoint dummySipEndPoint = new SIPEndPoint(new IPEndPoint(IPAddress.Loopback, 0));
SIPMessageBuffer sipMessageBuffer = SIPMessageBuffer.ParseSIPMessage(inviteReqStr, dummySipEndPoint, dummySipEndPoint);
@@ -210,18 +166,21 @@ public async Task HangupUserAgentUnitTest()
await userAgent.Answer(mockUas, CreateMediaSession());
// Incremented Cseq and modified Via header from original request. Means the request is the same dialog but different tx.
- string inviteReqStr2 = "BYE sip:192.168.11.50:5060 SIP/2.0" + m_CRLF +
-"Via: SIP/2.0/UDP 192.168.11.50:60163;rport;branch=z9hG4bKPj869f70960bdd4204b1352eaf242a3700" + m_CRLF +
-"To: ;tag=ZUJSXRRGXQ" + m_CRLF +
-"From: ;tag=4a60ce364b774258873ff199e5e39938" + m_CRLF +
-"Call-ID: 17324d6df8744d978008c8997bfd208d" + m_CRLF +
-"CSeq: 3533 BYE" + m_CRLF +
-"Contact: " + m_CRLF +
-"Max-Forwards: 70" + m_CRLF +
-"User-Agent: MicroSIP/3.19.22" + m_CRLF +
-"Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS" + m_CRLF +
-"Supported: replaces, 100rel, timer, norefersub" + m_CRLF +
-"";
+ var inviteReqStr2 =
+ """
+ BYE sip:192.168.11.50:5060 SIP/2.0
+ Via: SIP/2.0/UDP 192.168.11.50:60163;rport;branch=z9hG4bKPj869f70960bdd4204b1352eaf242a3700
+ To: ;tag=ZUJSXRRGXQ
+ From: ;tag=4a60ce364b774258873ff199e5e39938
+ Call-ID: 17324d6df8744d978008c8997bfd208d
+ CSeq: 3533 BYE
+ Contact:
+ Max-Forwards: 70
+ User-Agent: MicroSIP/3.19.22
+ Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS
+ Supported: replaces, 100rel, timer, norefersub
+
+ """.ReplaceLineEndings(m_CRLF);
mockChannel.FireMessageReceived(dummySipEndPoint, dummySipEndPoint, Encoding.UTF8.GetBytes(inviteReqStr2));
}
@@ -240,19 +199,24 @@ public async Task IncomingCallNoSdpUnitTest()
SIPUserAgent userAgent = new SIPUserAgent(transport, null);
- string inviteReqStr = "INVITE sip:192.168.11.50:5060 SIP/2.0" + m_CRLF +
-"Via: SIP/2.0/UDP 192.168.11.50:60163;rport;branch=z9hG4bKPj869f70960bdd4204b1352eaf242a3691" + m_CRLF +
-"To: ;tag=ZUJSXRRGXQ" + m_CRLF +
-"From: ;tag=4a60ce364b774258873ff199e5e39938" + m_CRLF +
-"Call-ID: 17324d6df8744d978008c8997bfd208d" + m_CRLF +
-"CSeq: 3532 INVITE" + m_CRLF +
-"Contact: " + m_CRLF +
-"Max-Forwards: 70" + m_CRLF +
-"Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS" + m_CRLF +
-"Supported: replaces, 100rel, timer, norefersub" + m_CRLF +
-"Content-Length: 0" + m_CRLF +
-"Content-Type: application/sdp" + m_CRLF +
-"Session-Expires: 1800" + m_CRLF + m_CRLF;
+ var inviteReqStr =
+ """
+ INVITE sip:192.168.11.50:5060 SIP/2.0
+ Via: SIP/2.0/UDP 192.168.11.50:60163;rport;branch=z9hG4bKPj869f70960bdd4204b1352eaf242a3691
+ To: ;tag=ZUJSXRRGXQ
+ From: ;tag=4a60ce364b774258873ff199e5e39938
+ Call-ID: 17324d6df8744d978008c8997bfd208d
+ CSeq: 3532 INVITE
+ Contact:
+ Max-Forwards: 70
+ Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS
+ Supported: replaces, 100rel, timer, norefersub
+ Content-Length: 0
+ Content-Type: application/sdp
+ Session-Expires: 1800
+
+
+ """.ReplaceLineEndings(m_CRLF);
SIPEndPoint dummySipEndPoint = new SIPEndPoint(new IPEndPoint(IPAddress.Loopback, 0));
SIPMessageBuffer sipMessageBuffer = SIPMessageBuffer.ParseSIPMessage(inviteReqStr, dummySipEndPoint, dummySipEndPoint);
@@ -281,17 +245,22 @@ public async Task IncomingCallNoSdpWithACKUnitTest()
SIPUserAgent userAgent = new SIPUserAgent(transport, null);
- string inviteReqStr = @"INVITE sip:1@127.0.0.1 SIP/2.0
-Via: SIP/2.0/UDP 127.0.0.1:51200;branch=z9hG4bKbeed9b0cde8d43cc8a2aae91526b6a1d;rport
-To:
-From: ;tag=GCLNRILCDU
-Call-ID: 7265e19f53a146a1bacdf4f4f8ea70b2
-CSeq: 1 INVITE
-Contact:
-Max-Forwards: 70
-User-Agent: www.sipsorcery.com
-Content-Length: 0
-Content-Type: application/sdp" + m_CRLF + m_CRLF;
+ var inviteReqStr =
+ """
+ INVITE sip:1@127.0.0.1 SIP/2.0
+ Via: SIP/2.0/UDP 127.0.0.1:51200;branch=z9hG4bKbeed9b0cde8d43cc8a2aae91526b6a1d;rport
+ To:
+ From: ;tag=GCLNRILCDU
+ Call-ID: 7265e19f53a146a1bacdf4f4f8ea70b2
+ CSeq: 1 INVITE
+ Contact:
+ Max-Forwards: 70
+ User-Agent: www.sipsorcery.com
+ Content-Length: 0
+ Content-Type: application/sdp
+
+
+ """.ReplaceLineEndings(m_CRLF);
SIPEndPoint dummySipEndPoint = new SIPEndPoint(new IPEndPoint(IPAddress.Loopback, 0));
SIPMessageBuffer sipMessageBuffer = SIPMessageBuffer.ParseSIPMessage(inviteReqStr, dummySipEndPoint, dummySipEndPoint);
@@ -304,24 +273,29 @@ public async Task IncomingCallNoSdpWithACKUnitTest()
{
await Task.Delay(2000);
- string ackReqStr = @"ACK sip:127.0.0.1:5060 SIP/2.0
-Via: SIP/2.0/UDP 127.0.0.1:51200;branch=z9hG4bK76dfb1480ea14f778bd24afed1c8ded0;rport
-To: ;tag=YWPNZPMLPB
-From: ;tag=GCLNRILCDU
-Call-ID: 7265e19f53a146a1bacdf4f4f8ea70b2
-CSeq: 1 ACK
-Max-Forwards: 70
-Content-Length: 160
-
-v=0
-o=- 67424 0 IN IP4 127.0.0.1
-s=-
-c=IN IP4 127.0.0.1
-t=0 0
-m=audio 16976 RTP/AVP 8 101
-a=rtpmap:101 telephone-event/8000
-a=fmtp:101 0-16
-a=sendrecv" + m_CRLF + m_CRLF;
+ var ackReqStr =
+ """
+ ACK sip:127.0.0.1:5060 SIP/2.0
+ Via: SIP/2.0/UDP 127.0.0.1:51200;branch=z9hG4bK76dfb1480ea14f778bd24afed1c8ded0;rport
+ To: ;tag=YWPNZPMLPB
+ From: ;tag=GCLNRILCDU
+ Call-ID: 7265e19f53a146a1bacdf4f4f8ea70b2
+ CSeq: 1 ACK
+ Max-Forwards: 70
+ Content-Length: 160
+
+ v=0
+ o=- 67424 0 IN IP4 127.0.0.1
+ s=-
+ c=IN IP4 127.0.0.1
+ t=0 0
+ m=audio 16976 RTP/AVP 8 101
+ a=rtpmap:101 telephone-event/8000
+ a=fmtp:101 0-16
+ a=sendrecv
+
+
+ """.ReplaceLineEndings(m_CRLF);
uas.ClientTransaction.ACKReceived(dummySep, dummySep, SIPRequest.ParseSIPRequest(ackReqStr));
});
diff --git a/test/integration/net/DNS/DNSUnitTest.cs b/test/integration/net/DNS/DNSUnitTest.cs
index 26b9c338e8..c047d6fdb9 100644
--- a/test/integration/net/DNS/DNSUnitTest.cs
+++ b/test/integration/net/DNS/DNSUnitTest.cs
@@ -176,7 +176,7 @@ public async Task LookupSrvRecordMethod()
logger.BeginScope(TestHelper.GetCurrentMethodName());
//DNSResponse result = DNSManager.Lookup(SIPDNSConstants.SRV_SIP_UDP_QUERY_PREFIX + "sipsorcery.com", QType.SRV, 10, null, false, false);
- var result = await SIPDns.LookupClient.QueryAsync(SIPDNSConstants.SRV_SIP_UDP_QUERY_PREFIX + "sipsorcery.com", QueryType.SRV);
+ var result = await SIPDns.LookupClient.QueryAsync($"{SIPDNSConstants.SRV_SIP_UDP_QUERY_PREFIX}sipsorcery.com", QueryType.SRV);
foreach (var srvResult in result.Answers?.SrvRecords())
{
diff --git a/test/unit/SIPSorcery.UnitTests.csproj b/test/unit/SIPSorcery.UnitTests.csproj
index d33b85e125..484c45b6ec 100755
--- a/test/unit/SIPSorcery.UnitTests.csproj
+++ b/test/unit/SIPSorcery.UnitTests.csproj
@@ -5,6 +5,7 @@
false
true
True
+ 14.0
@@ -13,6 +14,10 @@
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
diff --git a/test/unit/app/SIPUserAgents/SIPUserAgentAttendedTransferUnitTest.cs b/test/unit/app/SIPUserAgents/SIPUserAgentAttendedTransferUnitTest.cs
index 87bfd85093..5b987987e1 100644
--- a/test/unit/app/SIPUserAgents/SIPUserAgentAttendedTransferUnitTest.cs
+++ b/test/unit/app/SIPUserAgents/SIPUserAgentAttendedTransferUnitTest.cs
@@ -113,13 +113,7 @@ private static SIPRequest CreateInviteRequest(string callId, string fromTag, str
// Minimal SDP body so Answer() can process the offer.
string sdpBody =
- "v=0\r\n" +
- $"o=- 0 0 IN IP4 {channelEndPoint.Address}\r\n" +
- "s=-\r\n" +
- $"c=IN IP4 {channelEndPoint.Address}\r\n" +
- "t=0 0\r\n" +
- "m=audio 49170 RTP/AVP 0\r\n" +
- "a=rtpmap:0 PCMU/8000\r\n";
+ $"v=0\r\no=- 0 0 IN IP4 {channelEndPoint.Address}\r\ns=-\r\nc=IN IP4 {channelEndPoint.Address}\r\nt=0 0\r\nm=audio 49170 RTP/AVP 0\r\na=rtpmap:0 PCMU/8000\r\n";
request.Body = sdpBody;
diff --git a/test/unit/core/SIP/SIPContactHeaderUnitTest.cs b/test/unit/core/SIP/SIPContactHeaderUnitTest.cs
index 521215d12a..06b0fff823 100644
--- a/test/unit/core/SIP/SIPContactHeaderUnitTest.cs
+++ b/test/unit/core/SIP/SIPContactHeaderUnitTest.cs
@@ -116,7 +116,7 @@ public void ParseContactWithParamHeaderUserTest()
logger.LogDebug("Contact Header ContactParams = {ContactParams}", sipContactHeaderList[0].ContactParameters.ToString());
Assert.True(sipContactHeaderList[0].ContactName == null, "The Contact header name was not parsed correctly.");
- Assert.True(sipContactHeaderList[0].ContactURI.ToString() == "sip:user@127.0.0.1:5060;ftag=1233", "The Contact header URI was not parsed correctly, parsed valued = " + sipContactHeaderList[0].ContactURI.ToString() + ".");
+ Assert.True(sipContactHeaderList[0].ContactURI.ToString() == "sip:user@127.0.0.1:5060;ftag=1233", $"The Contact header URI was not parsed correctly, parsed valued = {sipContactHeaderList[0].ContactURI.ToString()}.");
Assert.True(sipContactHeaderList[0].ContactURI.Parameters.Get("ftag") == "1233", "The Contact header ftag URI parameter was not parsed correctly.");
}
@@ -135,7 +135,7 @@ public void ParseExpiresContactHeaderUserTest()
logger.LogDebug("Contact = {Contact}", sipContactHeaderList[0].ToString());
Assert.True(sipContactHeaderList[0].ContactName == null, "The Contact header name was not parsed correctly.");
- Assert.True(sipContactHeaderList[0].ContactURI.ToString() == "sip:user@127.0.0.1:5060", "The Contact header URI was not parsed correctly, parsed valued = " + sipContactHeaderList[0].ContactURI.ToString() + ".");
+ Assert.True(sipContactHeaderList[0].ContactURI.ToString() == "sip:user@127.0.0.1:5060", $"The Contact header URI was not parsed correctly, parsed valued = {sipContactHeaderList[0].ContactURI.ToString()}.");
Assert.True(sipContactHeaderList[0].Expires == 60, "The Contact header Expires parameter was not parsed correctly.");
}
@@ -154,7 +154,7 @@ public void ParseZeroExpiresContactHeaderUserTest()
logger.LogDebug("Contact = {Contact}", sipContactHeaderList[0].ToString());
Assert.True(sipContactHeaderList[0].ContactName == null, "The Contact header name was not parsed correctly.");
- Assert.True(sipContactHeaderList[0].ContactURI.ToString() == "sip:user@127.0.0.1:5060", "The Contact header URI was not parsed correctly, parsed valued = " + sipContactHeaderList[0].ContactURI.ToString() + ".");
+ Assert.True(sipContactHeaderList[0].ContactURI.ToString() == "sip:user@127.0.0.1:5060", $"The Contact header URI was not parsed correctly, parsed valued = {sipContactHeaderList[0].ContactURI.ToString()}.");
Assert.True(sipContactHeaderList[0].Expires == 0, "The Contact header Expires parameter was not parsed correctly.");
}
@@ -173,7 +173,7 @@ public void MultipleContactsHeaderUserTest()
logger.LogDebug("Contact Header ContactParams = {ContactParams}", sipContactHeaderList[0].ContactParameters.ToString());
Assert.True(sipContactHeaderList[0].ContactName == "Mr. Watson", "The Contact header name was not parsed correctly.");
- Assert.True(sipContactHeaderList[0].ContactURI.ToString() == "sip:watson@worcester.bell-telephone.com", "The Contact header URI was not parsed correctly, parsed valued = " + sipContactHeaderList[0].ContactURI.ToString() + ".");
+ Assert.True(sipContactHeaderList[0].ContactURI.ToString() == "sip:watson@worcester.bell-telephone.com", $"The Contact header URI was not parsed correctly, parsed valued = {sipContactHeaderList[0].ContactURI.ToString()}.");
Assert.True(sipContactHeaderList[0].Expires == 3600, "The Contact header Expires parameter was not parsed correctly.");
Assert.True(sipContactHeaderList[0].Q == "0.7", "The Contact header Q parameter was not parsed correctly.");
}
@@ -193,7 +193,7 @@ public void MultipleContactsWithURIParamsHeaderUserTest()
logger.LogDebug("Contact Header ContactParams = {ContactParams}", sipContactHeaderList[0].ContactParameters.ToString());
Assert.True(sipContactHeaderList[0].ContactName == "Mr. Watson", "The Contact header name was not parsed correctly.");
- Assert.True(sipContactHeaderList[0].ContactURI.ToString() == "sip:watson@worcester.bell-telephone.com;ftag=1232", "The Contact header URI was not parsed correctly, parsed valued = " + sipContactHeaderList[0].ContactURI.ToString() + ".");
+ Assert.True(sipContactHeaderList[0].ContactURI.ToString() == "sip:watson@worcester.bell-telephone.com;ftag=1232", $"The Contact header URI was not parsed correctly, parsed valued = {sipContactHeaderList[0].ContactURI.ToString()}.");
Assert.True(sipContactHeaderList[0].Expires == 3600, "The Contact header Expires parameter was not parsed correctly.");
Assert.True(sipContactHeaderList[0].Q == "0.7", "The Contact header Q parameter was not parsed correctly.");
Assert.True(sipContactHeaderList[0].ContactURI.Parameters.Get("ftag") == "1232", "The Contact header URI ftag parameter was not parsed correctly.");
diff --git a/test/unit/core/SIP/SIPHeaderUnitTest.cs b/test/unit/core/SIP/SIPHeaderUnitTest.cs
index 4db38de822..ea27175e5f 100644
--- a/test/unit/core/SIP/SIPHeaderUnitTest.cs
+++ b/test/unit/core/SIP/SIPHeaderUnitTest.cs
@@ -35,16 +35,7 @@ public void ParseXTenHeadersTest()
logger.BeginScope(TestHelper.GetCurrentMethodName());
string xtenInviteHeaders =
- "Via: SIP/2.0/UDP 192.168.1.2:5065;rport;branch=z9hG4bKFBB7EAC06934405182D13950BD51F001" + m_CRLF +
- "From: SER Test X ;tag=196468136" + m_CRLF +
- "To: " + m_CRLF +
- "Contact: " + m_CRLF +
- "Call-ID: A3DF9A04-0EFE-47E4-98B1-E18AA186F3D6@192.168.1.2" + m_CRLF +
- "CSeq: 49429 INVITE" + m_CRLF +
- "Max-Forwards: 70" + m_CRLF +
- "Content-Type: application/sdp" + m_CRLF +
- "User-Agent: X-PRO release 1103v" + m_CRLF +
- "Content-Length: 271" + m_CRLF;
+ $"Via: SIP/2.0/UDP 192.168.1.2:5065;rport;branch=z9hG4bKFBB7EAC06934405182D13950BD51F001{m_CRLF}From: SER Test X ;tag=196468136{m_CRLF}To: {m_CRLF}Contact: {m_CRLF}Call-ID: A3DF9A04-0EFE-47E4-98B1-E18AA186F3D6@192.168.1.2{m_CRLF}CSeq: 49429 INVITE{m_CRLF}Max-Forwards: 70{m_CRLF}Content-Type: application/sdp{m_CRLF}User-Agent: X-PRO release 1103v{m_CRLF}Content-Length: 271{m_CRLF}";
logger.LogDebug("Original SIP Headers:\n{Headers}", xtenInviteHeaders);
@@ -59,19 +50,19 @@ public void ParseXTenHeadersTest()
Assert.True(sipHeader.Vias.TopViaHeader.Transport == SIPProtocolsEnum.udp, "The Via transport was not parsed correctly.");
Assert.True(sipHeader.Vias.TopViaHeader.Branch == "z9hG4bKFBB7EAC06934405182D13950BD51F001", "The Via branch was not parsed correctly.");
Assert.True(sipHeader.Vias.TopViaHeader.ViaParameters.Has("rport"), "The Via rport parameter was not parsed correctly.");
- Assert.True("SER Test X" == sipHeader.From.FromName, "The From Name value was not parsed correctly, " + sipHeader.From.FromName + ".");
- Assert.True("sip:aaronxten@sip.blueface.ie:5065" == sipHeader.From.FromURI.ToString(), "The From URI value was not parsed correctly, " + sipHeader.From.FromURI + ".");
- Assert.True("196468136" == sipHeader.From.FromTag, "The From tag value was not parsed correctly, " + sipHeader.From.FromTag + ".");
- Assert.True(null == sipHeader.To.ToName, "The To Name value was not parsed correctly, " + sipHeader.To.ToName + ".");
- Assert.True("sip:303@sip.blueface.ie" == sipHeader.To.ToURI.ToString(), "The To URI value was not parsed correctly, " + sipHeader.To.ToURI + ".");
- Assert.True(null == sipHeader.To.ToTag, "The To tag value was not parsed correctly, " + sipHeader.To.ToTag + ".");
- Assert.True("A3DF9A04-0EFE-47E4-98B1-E18AA186F3D6@192.168.1.2" == sipHeader.CallId, "The Call ID values was not parsed correctly, " + sipHeader.CallId + ".");
- Assert.True(49429 == sipHeader.CSeq, "The CSeq value was not parsed correctly, " + sipHeader.CSeq + ".");
- Assert.True(SIPMethodsEnum.INVITE == sipHeader.CSeqMethod, "The CSeq Method value was not parsed correctly, " + sipHeader.CSeqMethod + ".");
- Assert.True(70 == sipHeader.MaxForwards, "The MaxForwards value was not parsed correctly, " + sipHeader.MaxForwards + ".");
- Assert.True("X-PRO release 1103v" == sipHeader.UserAgent, "The UserAgent value was not parsed correctly, " + sipHeader.UserAgent + ".");
- Assert.True("application/sdp" == sipHeader.ContentType, "The ContentType value was not parsed correctly, " + sipHeader.ContentType + ".");
- Assert.True(271 == sipHeader.ContentLength, "The ContentLength value was not parsed correctly, " + sipHeader.ContentLength + ".");
+ Assert.True("SER Test X" == sipHeader.From.FromName, $"The From Name value was not parsed correctly, {sipHeader.From.FromName}.");
+ Assert.True("sip:aaronxten@sip.blueface.ie:5065" == sipHeader.From.FromURI.ToString(), $"The From URI value was not parsed correctly, {sipHeader.From.FromURI}.");
+ Assert.True("196468136" == sipHeader.From.FromTag, $"The From tag value was not parsed correctly, {sipHeader.From.FromTag}.");
+ Assert.True(null == sipHeader.To.ToName, $"The To Name value was not parsed correctly, {sipHeader.To.ToName}.");
+ Assert.True("sip:303@sip.blueface.ie" == sipHeader.To.ToURI.ToString(), $"The To URI value was not parsed correctly, {sipHeader.To.ToURI}.");
+ Assert.True(null == sipHeader.To.ToTag, $"The To tag value was not parsed correctly, {sipHeader.To.ToTag}.");
+ Assert.True("A3DF9A04-0EFE-47E4-98B1-E18AA186F3D6@192.168.1.2" == sipHeader.CallId, $"The Call ID values was not parsed correctly, {sipHeader.CallId}.");
+ Assert.True(49429 == sipHeader.CSeq, $"The CSeq value was not parsed correctly, {sipHeader.CSeq}.");
+ Assert.True(SIPMethodsEnum.INVITE == sipHeader.CSeqMethod, $"The CSeq Method value was not parsed correctly, {sipHeader.CSeqMethod}.");
+ Assert.True(70 == sipHeader.MaxForwards, $"The MaxForwards value was not parsed correctly, {sipHeader.MaxForwards}.");
+ Assert.True("X-PRO release 1103v" == sipHeader.UserAgent, $"The UserAgent value was not parsed correctly, {sipHeader.UserAgent}.");
+ Assert.True("application/sdp" == sipHeader.ContentType, $"The ContentType value was not parsed correctly, {sipHeader.ContentType}.");
+ Assert.True(271 == sipHeader.ContentLength, $"The ContentLength value was not parsed correctly, {sipHeader.ContentLength}.");
logger.LogDebug("---------------------------------------------------");
}
@@ -83,18 +74,7 @@ public void ParseAsteriskRecordRouteHeadersTest()
logger.BeginScope(TestHelper.GetCurrentMethodName());
string xtenInviteHeaders =
- "Via: SIP/2.0/UDP 213.168.225.135:5060;branch=z9hG4bK8Z4EIWBeY45fRGwC0qIeu/xpw3A=" + m_CRLF +
- "Via: SIP/2.0/UDP 192.168.1.2:5065;received=220.240.255.198:64091;branch=z9hG4bK4E0728C26A0640E7830D7C9179D08D67" + m_CRLF +
- "Record-Route: ," + m_CRLF +
- "From: bluesipd ;tag=457825353" + m_CRLF +
- "To: ;tag=as02a64a42" + m_CRLF +
- "Call-ID: 8A702FA2-18F0-4DFC-AED5-C1A883EADB84@192.168.1.2" + m_CRLF +
- "CSeq: 38002 INVITE" + m_CRLF +
- "User-Agent: asterisk" + m_CRLF +
- "Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY" + m_CRLF +
- "Contact: " + m_CRLF +
- "Content-Type: application/sdp" + m_CRLF +
- "Content-Length: 350" + m_CRLF;
+ $"Via: SIP/2.0/UDP 213.168.225.135:5060;branch=z9hG4bK8Z4EIWBeY45fRGwC0qIeu/xpw3A={m_CRLF}Via: SIP/2.0/UDP 192.168.1.2:5065;received=220.240.255.198:64091;branch=z9hG4bK4E0728C26A0640E7830D7C9179D08D67{m_CRLF}Record-Route: ,{m_CRLF}From: bluesipd ;tag=457825353{m_CRLF}To: ;tag=as02a64a42{m_CRLF}Call-ID: 8A702FA2-18F0-4DFC-AED5-C1A883EADB84@192.168.1.2{m_CRLF}CSeq: 38002 INVITE{m_CRLF}User-Agent: asterisk{m_CRLF}Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY{m_CRLF}Contact: {m_CRLF}Content-Type: application/sdp{m_CRLF}Content-Length: 350{m_CRLF}";
logger.LogDebug("Original SIP Headers:\n{Headers}", xtenInviteHeaders);
string[] headersCollection = Regex.Split(xtenInviteHeaders, "\r\n");
@@ -116,18 +96,7 @@ public void ParseAMulitLineHeaderTest()
logger.BeginScope(TestHelper.GetCurrentMethodName());
string mulitLineHeader =
- "Via: SIP/2.0/UDP 213.168.225.135:5060;branch=z9hG4bK8Z4EIWBeY45fRGwC0qIeu/xpw3A=" + m_CRLF +
- "Via: SIP/2.0/UDP 192.168.1.2:5065;received=220.240.255.198:64091;branch=z9hG4bK4E0728C26A0640E7830D7C9179D08D67" + m_CRLF +
- "Record-Route: ," + m_CRLF +
- " " + m_CRLF +
- "From: bluesipd ;tag=457825353" + m_CRLF +
- "To: ;tag=as02a64a42" + m_CRLF +
- "Call-ID: 8A702FA2-18F0-4DFC-AED5-C1A883EADB84@192.168.1.2" + m_CRLF +
- "CSeq: 38002 INVITE" + m_CRLF +
- "Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY" + m_CRLF +
- "Contact: " + m_CRLF +
- "Content-Type: application/sdp" + m_CRLF +
- "Content-Length: 350" + m_CRLF;
+ $"Via: SIP/2.0/UDP 213.168.225.135:5060;branch=z9hG4bK8Z4EIWBeY45fRGwC0qIeu/xpw3A={m_CRLF}Via: SIP/2.0/UDP 192.168.1.2:5065;received=220.240.255.198:64091;branch=z9hG4bK4E0728C26A0640E7830D7C9179D08D67{m_CRLF}Record-Route: ,{m_CRLF} {m_CRLF}From: bluesipd ;tag=457825353{m_CRLF}To: ;tag=as02a64a42{m_CRLF}Call-ID: 8A702FA2-18F0-4DFC-AED5-C1A883EADB84@192.168.1.2{m_CRLF}CSeq: 38002 INVITE{m_CRLF}Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY{m_CRLF}Contact: {m_CRLF}Content-Type: application/sdp{m_CRLF}Content-Length: 350{m_CRLF}";
logger.LogDebug("Original SIP Headers:\n{Headers}", mulitLineHeader);
@@ -145,7 +114,7 @@ public void ParseAMulitLineHeaderTest()
logger.LogDebug("Parsed SIP Headers:\n{Headers}", sipHeader.ToString());
- Assert.True(sipHeader.RecordRoutes.Length == 2, "An incorrect number of record route entries was extracted, number was " + sipHeader.RecordRoutes.Length + ".");
+ Assert.True(sipHeader.RecordRoutes.Length == 2, $"An incorrect number of record route entries was extracted, number was {sipHeader.RecordRoutes.Length}.");
SIPRoute topRoute = sipHeader.RecordRoutes.PopRoute();
Assert.True(topRoute.Host == "213.168.225.133:5060", "The top record route was not parsed correctly.");
@@ -160,18 +129,7 @@ public void ParseAuthenticationRequiredHeadersTest()
logger.BeginScope(TestHelper.GetCurrentMethodName());
string authReqdHeaders =
- "SIP/2.0 407 Proxy Authentication Required" + m_CRLF +
- "Via: SIP/2.0/UDP 192.168.1.2:5066;received=220.240.255.198:64066;branch=65cacee9-25b6-405c-8f82-e40427438af7" + m_CRLF +
- "From: SER Test X ;tag=196468136" + m_CRLF +
- "To: ;tag=as67b6416e" + m_CRLF +
- "Contact: " + m_CRLF +
- "Call-ID: 5bcb927f-9571-47d0-a2a1-36226bcf7665@192.168.1.2" + m_CRLF +
- "CSeq: 908 INVITE" + m_CRLF +
- "Max-Forwards: 70" + m_CRLF +
- "User-Agent: asterisk" + m_CRLF +
- "Proxy-Authenticate: Digest realm=\"asterisk\", nonce=\"15aeff81\"" + m_CRLF +
- "Record-Route: " + m_CRLF +
- "Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY" + m_CRLF + m_CRLF;
+ $"SIP/2.0 407 Proxy Authentication Required{m_CRLF}Via: SIP/2.0/UDP 192.168.1.2:5066;received=220.240.255.198:64066;branch=65cacee9-25b6-405c-8f82-e40427438af7{m_CRLF}From: SER Test X ;tag=196468136{m_CRLF}To: ;tag=as67b6416e{m_CRLF}Contact: {m_CRLF}Call-ID: 5bcb927f-9571-47d0-a2a1-36226bcf7665@192.168.1.2{m_CRLF}CSeq: 908 INVITE{m_CRLF}Max-Forwards: 70{m_CRLF}User-Agent: asterisk{m_CRLF}Proxy-Authenticate: Digest realm=\"asterisk\", nonce=\"15aeff81\"{m_CRLF}Record-Route: {m_CRLF}Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY{m_CRLF}{m_CRLF}";
logger.LogDebug("Original SIP Headers:\n{Headers}", authReqdHeaders);
string[] headersCollection = Regex.Split(authReqdHeaders, "\r\n");
@@ -190,16 +148,7 @@ public void ParseNoViaHeadersUnitTest()
logger.BeginScope(TestHelper.GetCurrentMethodName());
string noViaHeaders =
- "SIP/2.0 407 Proxy Authentication Required" + m_CRLF +
- "From: dev ;tag=0013c339acec050c0635cf7b-48c41caf" + m_CRLF +
- "To: ;tag=as019f14fe" + m_CRLF +
- "Call-ID: 0013c339-acec0011-7181eff5-7cfa0e24@89.100.92.186" + m_CRLF +
- "CSeq: 101 INVITE" + m_CRLF +
- "User-Agent: asterisk" + m_CRLF +
- "Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY" + m_CRLF +
- "Contact: " + m_CRLF +
- "Proxy-Authenticate: Digest algorithm=MD5, realm=\"sip.blueface.ie\", nonce=\"789f00ab\"" + m_CRLF +
- "Content-Length: 0" + m_CRLF + m_CRLF;
+ $"SIP/2.0 407 Proxy Authentication Required{m_CRLF}From: dev ;tag=0013c339acec050c0635cf7b-48c41caf{m_CRLF}To: ;tag=as019f14fe{m_CRLF}Call-ID: 0013c339-acec0011-7181eff5-7cfa0e24@89.100.92.186{m_CRLF}CSeq: 101 INVITE{m_CRLF}User-Agent: asterisk{m_CRLF}Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY{m_CRLF}Contact: {m_CRLF}Proxy-Authenticate: Digest algorithm=MD5, realm=\"sip.blueface.ie\", nonce=\"789f00ab\"{m_CRLF}Content-Length: 0{m_CRLF}{m_CRLF}";
logger.LogDebug("Original SIP Headers:\n{Headers}", noViaHeaders);
@@ -217,16 +166,7 @@ public void LowerCaseExpiresUnitTest()
logger.BeginScope(TestHelper.GetCurrentMethodName());
string sipMsg =
- "Via: SIP/2.0/UDP 192.168.1.32:10254;branch=z9hG4bK-d87543-eb7c9f44883c5955-1--d87543-;rport;received=89.100.104.191" + m_CRLF +
- "To: aaronxten " + m_CRLF +
- "From: aaronxten ;tag=774d2561" + m_CRLF +
- "Call-ID: MTBhNGZjZmQ2OTc3MWU5MTZjNWUxMDYxOTk1MjdmYzk." + m_CRLF +
- "CSeq: 2 REGISTER" + m_CRLF +
- "Contact: ;expires=0" + m_CRLF +
- "Max-Forwards: 69" + m_CRLF +
- "expires: 60" + m_CRLF +
- "User-Agent: X-Lite release 1006e stamp 34025" + m_CRLF +
- "Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO" + m_CRLF + m_CRLF;
+ $"Via: SIP/2.0/UDP 192.168.1.32:10254;branch=z9hG4bK-d87543-eb7c9f44883c5955-1--d87543-;rport;received=89.100.104.191{m_CRLF}To: aaronxten {m_CRLF}From: aaronxten ;tag=774d2561{m_CRLF}Call-ID: MTBhNGZjZmQ2OTc3MWU5MTZjNWUxMDYxOTk1MjdmYzk.{m_CRLF}CSeq: 2 REGISTER{m_CRLF}Contact: ;expires=0{m_CRLF}Max-Forwards: 69{m_CRLF}expires: 60{m_CRLF}User-Agent: X-Lite release 1006e stamp 34025{m_CRLF}Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO{m_CRLF}{m_CRLF}";
logger.LogDebug("Original SIP Headers:\n{Headers}", sipMsg);
@@ -246,16 +186,7 @@ public void HuaweiRegisterUnitTest()
logger.BeginScope(TestHelper.GetCurrentMethodName());
string sipMsg =
- "From: ;tag=0477183750" + m_CRLF +
- "To: ;tag=414dedfe" + m_CRLF +
- "CSeq: 1 REGISTER" + m_CRLF +
- "Call-ID: 438676792abe47328fc557da2d84d0ee" + m_CRLF +
- "Via: SIP/2.0/UDP 192.168.1.102:7246;branch=z9hG4bK92460620adf84edab2341899a3453f79;received=124.168.235.200;rport=10552" + m_CRLF +
- "Server: Huawei SoftX3000 R006B03D" + m_CRLF +
- "WWW-Authenticate: Digest realm=\"huawei\"," + m_CRLF +
- " nonce=\"248e4b4457f252ae53c859bfe03c4f93\",domain=\"sip:huawei.com\"," + m_CRLF +
- " stale=false,algorithm=MD5" + m_CRLF +
- "Content-Length: 0" + m_CRLF + m_CRLF;
+ $"From: ;tag=0477183750{m_CRLF}To: ;tag=414dedfe{m_CRLF}CSeq: 1 REGISTER{m_CRLF}Call-ID: 438676792abe47328fc557da2d84d0ee{m_CRLF}Via: SIP/2.0/UDP 192.168.1.102:7246;branch=z9hG4bK92460620adf84edab2341899a3453f79;received=124.168.235.200;rport=10552{m_CRLF}Server: Huawei SoftX3000 R006B03D{m_CRLF}WWW-Authenticate: Digest realm=\"huawei\",{m_CRLF} nonce=\"248e4b4457f252ae53c859bfe03c4f93\",domain=\"sip:huawei.com\",{m_CRLF} stale=false,algorithm=MD5{m_CRLF}Content-Length: 0{m_CRLF}{m_CRLF}";
logger.LogDebug("Original SIP Headers:\n{Headers}", sipMsg);
@@ -278,18 +209,7 @@ public void MultipleContactHeadersUnitTest()
logger.BeginScope(TestHelper.GetCurrentMethodName());
string sipMsg =
- "From: ;tag=0477183750" + m_CRLF +
- "To: ;tag=414dedfe" + m_CRLF +
- "CSeq: 1 REGISTER" + m_CRLF +
- "Contact: \"Joe Bloggs\" ;expires=0" + m_CRLF +
- "Call-ID: 438676792abe47328fc557da2d84d0ee" + m_CRLF +
- "Via: SIP/2.0/UDP 192.168.1.102:7246;branch=z9hG4bK92460620adf84edab2341899a3453f79;received=124.168.235.200;rport=10552" + m_CRLF +
- "Server: Huawei SoftX3000 R006B03D" + m_CRLF +
- "WWW-Authenticate: Digest realm=\"huawei\"," + m_CRLF +
- " nonce=\"248e4b4457f252ae53c859bfe03c4f93\",domain=\"sip:huawei.com\"," + m_CRLF +
- " stale=false,algorithm=MD5" + m_CRLF +
- "Contact: \"Jane Doe\" " + m_CRLF +
- "Content-Length: 0" + m_CRLF + m_CRLF;
+ $"From: ;tag=0477183750{m_CRLF}To: ;tag=414dedfe{m_CRLF}CSeq: 1 REGISTER{m_CRLF}Contact: \"Joe Bloggs\" ;expires=0{m_CRLF}Call-ID: 438676792abe47328fc557da2d84d0ee{m_CRLF}Via: SIP/2.0/UDP 192.168.1.102:7246;branch=z9hG4bK92460620adf84edab2341899a3453f79;received=124.168.235.200;rport=10552{m_CRLF}Server: Huawei SoftX3000 R006B03D{m_CRLF}WWW-Authenticate: Digest realm=\"huawei\",{m_CRLF} nonce=\"248e4b4457f252ae53c859bfe03c4f93\",domain=\"sip:huawei.com\",{m_CRLF} stale=false,algorithm=MD5{m_CRLF}Contact: \"Jane Doe\" {m_CRLF}Content-Length: 0{m_CRLF}{m_CRLF}";
logger.LogDebug("Original SIP Headers:\n{Headers}", sipMsg);
@@ -311,18 +231,7 @@ public void ExtractHeadersUnitTest()
logger.BeginScope(TestHelper.GetCurrentMethodName());
string sipMsg =
- "From: ;tag=0477183750" + m_CRLF +
- "To: ;tag=414dedfe" + m_CRLF +
- "CSeq: 1 REGISTER" + m_CRLF +
- "Call-ID: 438676792abe47328fc557da2d84d0ee" + m_CRLF +
- "Via: SIP/2.0/UDP 192.168.1.102:7246;branch=z9hG4bK92460620adf84edab2341899a3453f79;received=124.168.235.200;rport=10552" + m_CRLF +
- "Server: Huawei SoftX3000 R006B03D" + m_CRLF +
- "Refer-To: Test Refer-To" + m_CRLF +
- "Authentication-Info: Test Authentication-Info" + m_CRLF +
- "WWW-Authenticate: Digest realm=\"huawei\"," + m_CRLF +
- " nonce=\"248e4b4457f252ae53c859bfe03c4f93\",domain=\"sip:huawei.com\"," + m_CRLF +
- " stale=false,algorithm=MD5" + m_CRLF +
- "Content-Length: 0" + m_CRLF + m_CRLF;
+ $"From: ;tag=0477183750{m_CRLF}To: ;tag=414dedfe{m_CRLF}CSeq: 1 REGISTER{m_CRLF}Call-ID: 438676792abe47328fc557da2d84d0ee{m_CRLF}Via: SIP/2.0/UDP 192.168.1.102:7246;branch=z9hG4bK92460620adf84edab2341899a3453f79;received=124.168.235.200;rport=10552{m_CRLF}Server: Huawei SoftX3000 R006B03D{m_CRLF}Refer-To: Test Refer-To{m_CRLF}Authentication-Info: Test Authentication-Info{m_CRLF}WWW-Authenticate: Digest realm=\"huawei\",{m_CRLF} nonce=\"248e4b4457f252ae53c859bfe03c4f93\",domain=\"sip:huawei.com\",{m_CRLF} stale=false,algorithm=MD5{m_CRLF}Content-Length: 0{m_CRLF}{m_CRLF}";
logger.LogDebug("Original SIP Headers:\n{Headers}", sipMsg);
@@ -439,7 +348,7 @@ public void ParseFromHeaderNoSpaceTest()
SIPFromHeader sipFromHeader = SIPFromHeader.ParseFromHeader(testFromHeader);
- Assert.True(sipFromHeader.FromName == "UNAVAILABLE", "The From header name was not parsed correctly, name=" + sipFromHeader.FromName + ".");
+ Assert.True(sipFromHeader.FromName == "UNAVAILABLE", $"The From header name was not parsed correctly, name={sipFromHeader.FromName}.");
Assert.True(sipFromHeader.FromURI.ToString() == "sip:user@domaintest.com:5060", "The From header URI was not parsed correctly.");
Assert.True(sipFromHeader.FromTag == "abcd", "The From header Tag was not parsed correctly.");
}
@@ -767,18 +676,7 @@ public void ParseRequireAndSupportedExtensionsTest()
logger.BeginScope(TestHelper.GetCurrentMethodName());
string inviteHeaders =
- "Via: SIP/2.0/UDP 192.168.1.2:5065;rport;branch=z9hG4bKFBB7EAC06934405182D13950BD51F001" + m_CRLF +
- "From: SER Test X ;tag=196468136" + m_CRLF +
- "To: " + m_CRLF +
- "Contact: " + m_CRLF +
- "Call-ID: A3DF9A04-0EFE-47E4-98B1-E18AA186F3D6@192.168.1.2" + m_CRLF +
- "CSeq: 49429 INVITE" + m_CRLF +
- "Max-Forwards: 70" + m_CRLF +
- "Content-Type: application/sdp" + m_CRLF +
- "User-Agent: X-PRO release 1103v" + m_CRLF +
- "Content-Length: 271" + m_CRLF +
- "Require: abcd, 100rel, xyz" + m_CRLF +
- "Supported: 100rel, other" + m_CRLF;
+ $"Via: SIP/2.0/UDP 192.168.1.2:5065;rport;branch=z9hG4bKFBB7EAC06934405182D13950BD51F001{m_CRLF}From: SER Test X ;tag=196468136{m_CRLF}To: {m_CRLF}Contact: {m_CRLF}Call-ID: A3DF9A04-0EFE-47E4-98B1-E18AA186F3D6@192.168.1.2{m_CRLF}CSeq: 49429 INVITE{m_CRLF}Max-Forwards: 70{m_CRLF}Content-Type: application/sdp{m_CRLF}User-Agent: X-PRO release 1103v{m_CRLF}Content-Length: 271{m_CRLF}Require: abcd, 100rel, xyz{m_CRLF}Supported: 100rel, other{m_CRLF}";
string[] headersCollection = Regex.Split(inviteHeaders, "\r\n");
SIPHeader sipHeader = SIPHeader.ParseSIPHeaders(headersCollection);
@@ -800,16 +698,7 @@ public void ParseRSeqHeaderTest()
logger.BeginScope(TestHelper.GetCurrentMethodName());
string ringResponse =
- "SIP/2.0 180 Ringing" + m_CRLF +
- "Via: SIP/2.0/UDP 0.0.0.0:6060;branch=z9hG4bK299925765f7c4defb20cef3fde520172;rport=6060;received=127.0.0.1" + m_CRLF +
- "To: " + m_CRLF +
- "From: ;tag=NEEBBCYYZR" + m_CRLF +
- "Call-ID: 9add71138b794dadbd709a2b8c0cfc89" + m_CRLF +
- "CSeq: 1 INVITE" + m_CRLF +
- "Allow: ACK, BYE, CANCEL, INFO, INVITE, NOTIFY, OPTIONS, REFER, REGISTER, SUBSCRIBE" + m_CRLF +
- "Supported: 100rel" + m_CRLF +
- "Content-Length: 0" + m_CRLF +
- "RSeq: 266163001" + m_CRLF + m_CRLF;
+ $"SIP/2.0 180 Ringing{m_CRLF}Via: SIP/2.0/UDP 0.0.0.0:6060;branch=z9hG4bK299925765f7c4defb20cef3fde520172;rport=6060;received=127.0.0.1{m_CRLF}To: {m_CRLF}From: ;tag=NEEBBCYYZR{m_CRLF}Call-ID: 9add71138b794dadbd709a2b8c0cfc89{m_CRLF}CSeq: 1 INVITE{m_CRLF}Allow: ACK, BYE, CANCEL, INFO, INVITE, NOTIFY, OPTIONS, REFER, REGISTER, SUBSCRIBE{m_CRLF}Supported: 100rel{m_CRLF}Content-Length: 0{m_CRLF}RSeq: 266163001{m_CRLF}{m_CRLF}";
var sipResponse = SIPResponse.ParseSIPResponse(ringResponse);
@@ -828,15 +717,7 @@ public void ParseRAckHeaderTest()
logger.BeginScope(TestHelper.GetCurrentMethodName());
string prackRequest =
- "PRACK sip:127.0.0.1 SIP/2.0" + m_CRLF +
- "Via: SIP/2.0/UDP 0.0.0.0:6060;branch=z9hG4bKed0553cb6e4b476990a34d7c98f58a14;rport" + m_CRLF +
- "To: " + m_CRLF +
- "From: ;tag=YPACUCOFBG" + m_CRLF +
- "Call-ID: c22e9dc218a1423695b1f5ef33020b84" + m_CRLF +
- "CSeq: 1 ACK" + m_CRLF +
- "Max-Forwards: 70" + m_CRLF +
- "Content-Length: 0" + m_CRLF +
- "RAck: 423501656 1 INVITE" + m_CRLF + m_CRLF;
+ $"PRACK sip:127.0.0.1 SIP/2.0{m_CRLF}Via: SIP/2.0/UDP 0.0.0.0:6060;branch=z9hG4bKed0553cb6e4b476990a34d7c98f58a14;rport{m_CRLF}To: {m_CRLF}From: ;tag=YPACUCOFBG{m_CRLF}Call-ID: c22e9dc218a1423695b1f5ef33020b84{m_CRLF}CSeq: 1 ACK{m_CRLF}Max-Forwards: 70{m_CRLF}Content-Length: 0{m_CRLF}RAck: 423501656 1 INVITE{m_CRLF}{m_CRLF}";
var sipRequest = SIPRequest.ParseSIPRequest(prackRequest);
@@ -856,16 +737,7 @@ public void ParseServerHeaderTest()
var expectedServerValue = "SomeServerValue";
string inviteWithServerHeader =
- "Via: SIP/2.0/UDP 192.168.1.2:5065;rport;branch=z9hG4bKFBB7EAC06934405182D13950BD51F001" + m_CRLF +
- "From: SER Test X ;tag=196468136" + m_CRLF +
- "To: " + m_CRLF +
- "Contact: " + m_CRLF +
- "Call-ID: A3DF9A04-0EFE-47E4-98B1-E18AA186F3D6@192.168.1.2" + m_CRLF +
- "CSeq: 49429 INVITE" + m_CRLF +
- "Max-Forwards: 70" + m_CRLF +
- "Content-Type: application/sdp" + m_CRLF +
- "Content-Length: 271" + m_CRLF +
- "Server: " + expectedServerValue + m_CRLF;
+ $"Via: SIP/2.0/UDP 192.168.1.2:5065;rport;branch=z9hG4bKFBB7EAC06934405182D13950BD51F001{m_CRLF}From: SER Test X ;tag=196468136{m_CRLF}To: {m_CRLF}Contact: {m_CRLF}Call-ID: A3DF9A04-0EFE-47E4-98B1-E18AA186F3D6@192.168.1.2{m_CRLF}CSeq: 49429 INVITE{m_CRLF}Max-Forwards: 70{m_CRLF}Content-Type: application/sdp{m_CRLF}Content-Length: 271{m_CRLF}Server: {expectedServerValue}{m_CRLF}";
string[] headersCollection = Regex.Split(inviteWithServerHeader, "\r\n");
SIPHeader sipHeader = SIPHeader.ParseSIPHeaders(headersCollection);
diff --git a/test/unit/core/SIP/SIPMessageUnitTest.cs b/test/unit/core/SIP/SIPMessageUnitTest.cs
index db3764c243..226da54096 100644
--- a/test/unit/core/SIP/SIPMessageUnitTest.cs
+++ b/test/unit/core/SIP/SIPMessageUnitTest.cs
@@ -36,17 +36,7 @@ public void ParseResponseUnitTest()
logger.BeginScope(TestHelper.GetCurrentMethodName());
string sipMsg =
- "SIP/2.0 100 Trying" + CRLF +
- "Via: SIP/2.0/UDP 213.168.225.135:5060;branch=z9hG4bKD+ta2mJ+C+VV/L50aPO1lFJnrag=" + CRLF +
- "Via: SIP/2.0/UDP 192.168.1.2:5065;received=220.240.255.198:64193;branch=z9hG4bKB86FC8D2431F49E9862D1EE439C78AD8" + CRLF +
- "From: bluesipd ;tag=3272744142" + CRLF +
- "To: " + CRLF +
- "Call-ID: FE63F90D-4339-4AD0-9D44-59F44A1935E7@192.168.1.2" + CRLF +
- "CSeq: 45560 INVITE" + CRLF +
- "User-Agent: asterisk" + CRLF +
- "Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY" + CRLF +
- "Contact: " + CRLF +
- "Content-Length: 0" + CRLF + CRLF;
+ $"SIP/2.0 100 Trying{CRLF}Via: SIP/2.0/UDP 213.168.225.135:5060;branch=z9hG4bKD+ta2mJ+C+VV/L50aPO1lFJnrag={CRLF}Via: SIP/2.0/UDP 192.168.1.2:5065;received=220.240.255.198:64193;branch=z9hG4bKB86FC8D2431F49E9862D1EE439C78AD8{CRLF}From: bluesipd ;tag=3272744142{CRLF}To: {CRLF}Call-ID: FE63F90D-4339-4AD0-9D44-59F44A1935E7@192.168.1.2{CRLF}CSeq: 45560 INVITE{CRLF}User-Agent: asterisk{CRLF}Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY{CRLF}Contact: {CRLF}Content-Length: 0{CRLF}{CRLF}";
SIPMessageBuffer sipMessageBuffer = SIPMessageBuffer.ParseSIPMessage(Encoding.UTF8.GetBytes(sipMsg), null, null);
@@ -62,34 +52,7 @@ public void ParseResponseWithBodyUnitTest()
logger.BeginScope(TestHelper.GetCurrentMethodName());
string sipMsg =
- "SIP/2.0 200 OK" + CRLF +
- "Via: SIP/2.0/UDP 213.168.225.135:5060;branch=z9hG4bKT36BdhXPlT5cqPFQQr81yMmZ37U=" + CRLF +
- "Via: SIP/2.0/UDP 192.168.1.2:5065;received=220.240.255.198:64216;branch=z9hG4bK7D8B6549580844AEA104BD4A837049DD" + CRLF +
- "From: bluesipd ;tag=630217013" + CRLF +
- "To: ;tag=as46f418e9" + CRLF +
- "Call-ID: 9AA41C8F-D691-49F3-B346-2538B5FD962F@192.168.1.2" + CRLF +
- "CSeq: 27481 INVITE" + CRLF +
- "User-Agent: asterisk" + CRLF +
- "Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY" + CRLF +
- "Contact: " + CRLF +
- "Content-Type: application/sdp" + CRLF +
- "Content-Length: 352" + CRLF +
- CRLF +
- "v=0" + CRLF +
- "o=root 24710 24712 IN IP4 213.168.225.133" + CRLF +
- "s=session" + CRLF +
- "c=IN IP4 213.168.225.133" + CRLF +
- "t=0 0" + CRLF +
- "m=audio 18656 RTP/AVP 0 8 18 3 97 111 101" + CRLF +
- "a=rtpmap:0 PCMU/8000" + CRLF +
- "a=rtpmap:8 PCMA/8000" + CRLF +
- "a=rtpmap:18 G729/8000" + CRLF +
- "a=rtpmap:3 GSM/8000" + CRLF +
- "a=rtpmap:97 iLBC/8000" + CRLF +
- "a=rtpmap:111 G726-32/8000" + CRLF +
- "a=rtpmap:101 telephone-event/8000" + CRLF +
- "a=fmtp:101 0-16" + CRLF +
- "a=silenceSupp:off - - - -" + CRLF;
+ $"SIP/2.0 200 OK{CRLF}Via: SIP/2.0/UDP 213.168.225.135:5060;branch=z9hG4bKT36BdhXPlT5cqPFQQr81yMmZ37U={CRLF}Via: SIP/2.0/UDP 192.168.1.2:5065;received=220.240.255.198:64216;branch=z9hG4bK7D8B6549580844AEA104BD4A837049DD{CRLF}From: bluesipd ;tag=630217013{CRLF}To: ;tag=as46f418e9{CRLF}Call-ID: 9AA41C8F-D691-49F3-B346-2538B5FD962F@192.168.1.2{CRLF}CSeq: 27481 INVITE{CRLF}User-Agent: asterisk{CRLF}Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY{CRLF}Contact: {CRLF}Content-Type: application/sdp{CRLF}Content-Length: 352{CRLF}{CRLF}v=0{CRLF}o=root 24710 24712 IN IP4 213.168.225.133{CRLF}s=session{CRLF}c=IN IP4 213.168.225.133{CRLF}t=0 0{CRLF}m=audio 18656 RTP/AVP 0 8 18 3 97 111 101{CRLF}a=rtpmap:0 PCMU/8000{CRLF}a=rtpmap:8 PCMA/8000{CRLF}a=rtpmap:18 G729/8000{CRLF}a=rtpmap:3 GSM/8000{CRLF}a=rtpmap:97 iLBC/8000{CRLF}a=rtpmap:111 G726-32/8000{CRLF}a=rtpmap:101 telephone-event/8000{CRLF}a=fmtp:101 0-16{CRLF}a=silenceSupp:off - - - -{CRLF}";
SIPMessageBuffer sipMessageBuffer = SIPMessageBuffer.ParseSIPMessage(Encoding.UTF8.GetBytes(sipMsg), null, null);
@@ -105,17 +68,7 @@ public void ParseResponseNoEndDoubleCRLFUnitTest()
logger.BeginScope(TestHelper.GetCurrentMethodName());
string sipMsg =
- "SIP/2.0 100 Trying" + CRLF +
- "Via: SIP/2.0/UDP 213.168.225.135:5060;branch=z9hG4bKD+ta2mJ+C+VV/L50aPO1lFJnrag=" + CRLF +
- "Via: SIP/2.0/UDP 192.168.1.2:5065;received=220.240.255.198:64193;branch=z9hG4bKB86FC8D2431F49E9862D1EE439C78AD8" + CRLF +
- "From: bluesipd ;tag=3272744142" + CRLF +
- "To: " + CRLF +
- "Call-ID: FE63F90D-4339-4AD0-9D44-59F44A1935E7@192.168.1.2" + CRLF +
- "CSeq: 45560 INVITE" + CRLF +
- "User-Agent: asterisk" + CRLF +
- "Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY" + CRLF +
- "Contact: " + CRLF +
- "Content-Length: 0" + CRLF;
+ $"SIP/2.0 100 Trying{CRLF}Via: SIP/2.0/UDP 213.168.225.135:5060;branch=z9hG4bKD+ta2mJ+C+VV/L50aPO1lFJnrag={CRLF}Via: SIP/2.0/UDP 192.168.1.2:5065;received=220.240.255.198:64193;branch=z9hG4bKB86FC8D2431F49E9862D1EE439C78AD8{CRLF}From: bluesipd ;tag=3272744142{CRLF}To: {CRLF}Call-ID: FE63F90D-4339-4AD0-9D44-59F44A1935E7@192.168.1.2{CRLF}CSeq: 45560 INVITE{CRLF}User-Agent: asterisk{CRLF}Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY{CRLF}Contact: {CRLF}Content-Length: 0{CRLF}";
SIPMessageBuffer sipMessageBuffer = SIPMessageBuffer.ParseSIPMessage(Encoding.UTF8.GetBytes(sipMsg), null, null);
@@ -131,28 +84,7 @@ public void ParseCiscoOptionsResponseUnitTest()
logger.BeginScope(TestHelper.GetCurrentMethodName());
string sipMsg =
- "SIP/2.0 200 OK" + CRLF +
- "Via: SIP/2.0/UDP 213.168.225.133:5060;branch=z9hG4bK7ae332e73550dbdf2f159061651e7ed5bb88ac52, SIP/2.0/UDP 194.213.29.52:5064;branch=z9hG4bK1121681627" + CRLF +
- "From: ;tag=8341482660" + CRLF +
- "To: ;tag=000e38e46c60ef28651381fe-201e6ab1" + CRLF +
- "Call-ID: 1125158248@194.213.29.52" + CRLF +
- "Date: Wed, 29 Nov 2006 22:31:58 GMT" + CRLF +
- "CSeq: 148 OPTIONS" + CRLF +
- "Server: CSCO/7" + CRLF +
- "Content-Type: application/sdp" + CRLF +
- "Allow: OPTIONS,INVITE,BYE,CANCEL,REGISTER,ACK,NOTIFY,REFER" + CRLF +
- "Content-Length: 193" + CRLF +
- CRLF +
- "v=0" + CRLF +
- "o=Cisco-SIPUA (null) (null) IN IP4 87.198.196.121" + CRLF +
- "s=SIP Call" + CRLF +
- "c=IN IP4 87.198.196.121" + CRLF +
- "t=0 0" + CRLF +
- "m=audio 1 RTP/AVP 18 0 8" + CRLF +
- "a=rtpmap:18 G729/8000" + CRLF +
- "a=rtpmap:0 PCMU/8000" + CRLF +
- "a=rtpmap:8 PCMA/8000" + CRLF +
- CRLF;
+ $"SIP/2.0 200 OK{CRLF}Via: SIP/2.0/UDP 213.168.225.133:5060;branch=z9hG4bK7ae332e73550dbdf2f159061651e7ed5bb88ac52, SIP/2.0/UDP 194.213.29.52:5064;branch=z9hG4bK1121681627{CRLF}From: ;tag=8341482660{CRLF}To: ;tag=000e38e46c60ef28651381fe-201e6ab1{CRLF}Call-ID: 1125158248@194.213.29.52{CRLF}Date: Wed, 29 Nov 2006 22:31:58 GMT{CRLF}CSeq: 148 OPTIONS{CRLF}Server: CSCO/7{CRLF}Content-Type: application/sdp{CRLF}Allow: OPTIONS,INVITE,BYE,CANCEL,REGISTER,ACK,NOTIFY,REFER{CRLF}Content-Length: 193{CRLF}{CRLF}v=0{CRLF}o=Cisco-SIPUA (null) (null) IN IP4 87.198.196.121{CRLF}s=SIP Call{CRLF}c=IN IP4 87.198.196.121{CRLF}t=0 0{CRLF}m=audio 1 RTP/AVP 18 0 8{CRLF}a=rtpmap:18 G729/8000{CRLF}a=rtpmap:0 PCMU/8000{CRLF}a=rtpmap:8 PCMA/8000{CRLF}{CRLF}";
SIPMessageBuffer sipMessageBuffer = SIPMessageBuffer.ParseSIPMessage(Encoding.UTF8.GetBytes(sipMsg), null, null);
SIPResponse sipResponse = SIPResponse.ParseSIPResponse(sipMessageBuffer);
@@ -173,18 +105,7 @@ public void ContentLengthParseFromSingleRequestTest()
logger.BeginScope(TestHelper.GetCurrentMethodName());
string notifyRequest =
-"NOTIFY sip:10.1.1.5:62647;transport=tcp SIP/2.0" + CRLF +
-"Via: SIP/2.0/TCP 10.1.1.5:4506;branch=z9hG4bKa4d17f991015b1d8b788f2ac54d66ec66811226a;rport" + CRLF +
-"Via: SIP/2.0/UDP 127.0.0.1:5060;branch=z9hG4bKc2224b79f5af4c4a9b1cd649890c6497;rport" + CRLF +
-"Via: SIP/2.0/UDP 127.0.0.1:5003;branch=z9hG4bK0495dc29b7eb40008779a75c3734c4c5;rport=5003;received=127.0.0.1" + CRLF +
-"To: ;tag=1892981968" + CRLF +
-"From: ;tag=1555449860" + CRLF +
-"Call-ID: 1b569032-d1e4-4869-be9f-67d4ba8a4e3a" + CRLF +
-"CSeq: 4 NOTIFY" + CRLF +
-"Content-Length: 2393" + CRLF +
-"Contact: " + CRLF +
-"Max-Forwards: 69" + CRLF +
-"Event: dialog" + CRLF + CRLF;
+$"NOTIFY sip:10.1.1.5:62647;transport=tcp SIP/2.0{CRLF}Via: SIP/2.0/TCP 10.1.1.5:4506;branch=z9hG4bKa4d17f991015b1d8b788f2ac54d66ec66811226a;rport{CRLF}Via: SIP/2.0/UDP 127.0.0.1:5060;branch=z9hG4bKc2224b79f5af4c4a9b1cd649890c6497;rport{CRLF}Via: SIP/2.0/UDP 127.0.0.1:5003;branch=z9hG4bK0495dc29b7eb40008779a75c3734c4c5;rport=5003;received=127.0.0.1{CRLF}To: ;tag=1892981968{CRLF}From: ;tag=1555449860{CRLF}Call-ID: 1b569032-d1e4-4869-be9f-67d4ba8a4e3a{CRLF}CSeq: 4 NOTIFY{CRLF}Content-Length: 2393{CRLF}Contact: {CRLF}Max-Forwards: 69{CRLF}Event: dialog{CRLF}{CRLF}";
byte[] notifyRequestBytes = UTF8Encoding.UTF8.GetBytes(notifyRequest);
@@ -205,18 +126,7 @@ public void ContentLengthParseFromSingleRequestExtraSpacingTest()
logger.BeginScope(TestHelper.GetCurrentMethodName());
string notifyRequest =
-"NOTIFY sip:10.1.1.5:62647;transport=tcp SIP/2.0" + CRLF +
-"Via: SIP/2.0/TCP 10.1.1.5:4506;branch=z9hG4bKa4d17f991015b1d8b788f2ac54d66ec66811226a;rport" + CRLF +
-"Via: SIP/2.0/UDP 127.0.0.1:5060;branch=z9hG4bKc2224b79f5af4c4a9b1cd649890c6497;rport" + CRLF +
-"Via: SIP/2.0/UDP 127.0.0.1:5003;branch=z9hG4bK0495dc29b7eb40008779a75c3734c4c5;rport=5003;received=127.0.0.1" + CRLF +
-"To: ;tag=1892981968" + CRLF +
-"From: ;tag=1555449860" + CRLF +
-"Call-ID: 1b569032-d1e4-4869-be9f-67d4ba8a4e3a" + CRLF +
-"CSeq: 4 NOTIFY" + CRLF +
-"Content-Length : 2393 " + CRLF +
-"Contact: " + CRLF +
-"Max-Forwards: 69" + CRLF +
-"Event: dialog" + CRLF + CRLF;
+$"NOTIFY sip:10.1.1.5:62647;transport=tcp SIP/2.0{CRLF}Via: SIP/2.0/TCP 10.1.1.5:4506;branch=z9hG4bKa4d17f991015b1d8b788f2ac54d66ec66811226a;rport{CRLF}Via: SIP/2.0/UDP 127.0.0.1:5060;branch=z9hG4bKc2224b79f5af4c4a9b1cd649890c6497;rport{CRLF}Via: SIP/2.0/UDP 127.0.0.1:5003;branch=z9hG4bK0495dc29b7eb40008779a75c3734c4c5;rport=5003;received=127.0.0.1{CRLF}To: ;tag=1892981968{CRLF}From: ;tag=1555449860{CRLF}Call-ID: 1b569032-d1e4-4869-be9f-67d4ba8a4e3a{CRLF}CSeq: 4 NOTIFY{CRLF}Content-Length : 2393 {CRLF}Contact: {CRLF}Max-Forwards: 69{CRLF}Event: dialog{CRLF}{CRLF}";
byte[] notifyRequestBytes = UTF8Encoding.UTF8.GetBytes(notifyRequest);
@@ -237,18 +147,7 @@ public void ContentLengthCompactParseFromSingleRequestTest()
logger.BeginScope(TestHelper.GetCurrentMethodName());
string notifyRequest =
-"NOTIFY sip:10.1.1.5:62647;transport=tcp SIP/2.0" + CRLF +
-"Via: SIP/2.0/TCP 10.1.1.5:4506;branch=z9hG4bKa4d17f991015b1d8b788f2ac54d66ec66811226a;rport" + CRLF +
-"Via: SIP/2.0/UDP 127.0.0.1:5060;branch=z9hG4bKc2224b79f5af4c4a9b1cd649890c6497;rport" + CRLF +
-"Via: SIP/2.0/UDP 127.0.0.1:5003;branch=z9hG4bK0495dc29b7eb40008779a75c3734c4c5;rport=5003;received=127.0.0.1" + CRLF +
-"To: ;tag=1892981968" + CRLF +
-"From: ;tag=1555449860" + CRLF +
-"Call-ID: 1b569032-d1e4-4869-be9f-67d4ba8a4e3a" + CRLF +
-"CSeq: 4 NOTIFY" + CRLF +
-"l: 2393" + CRLF +
-"Contact: " + CRLF +
-"Max-Forwards: 69" + CRLF +
-"Event: dialog" + CRLF + CRLF;
+$"NOTIFY sip:10.1.1.5:62647;transport=tcp SIP/2.0{CRLF}Via: SIP/2.0/TCP 10.1.1.5:4506;branch=z9hG4bKa4d17f991015b1d8b788f2ac54d66ec66811226a;rport{CRLF}Via: SIP/2.0/UDP 127.0.0.1:5060;branch=z9hG4bKc2224b79f5af4c4a9b1cd649890c6497;rport{CRLF}Via: SIP/2.0/UDP 127.0.0.1:5003;branch=z9hG4bK0495dc29b7eb40008779a75c3734c4c5;rport=5003;received=127.0.0.1{CRLF}To: ;tag=1892981968{CRLF}From: ;tag=1555449860{CRLF}Call-ID: 1b569032-d1e4-4869-be9f-67d4ba8a4e3a{CRLF}CSeq: 4 NOTIFY{CRLF}l: 2393{CRLF}Contact: {CRLF}Max-Forwards: 69{CRLF}Event: dialog{CRLF}{CRLF}";
byte[] notifyRequestBytes = UTF8Encoding.UTF8.GetBytes(notifyRequest);
@@ -270,18 +169,7 @@ public void ContentLengthCompactParseFromSingleRequestExtraSpacingTest()
logger.BeginScope(TestHelper.GetCurrentMethodName());
string notifyRequest =
-"NOTIFY sip:10.1.1.5:62647;transport=tcp SIP/2.0" + CRLF +
-"Via: SIP/2.0/TCP 10.1.1.5:4506;branch=z9hG4bKa4d17f991015b1d8b788f2ac54d66ec66811226a;rport" + CRLF +
-"Via: SIP/2.0/UDP 127.0.0.1:5060;branch=z9hG4bKc2224b79f5af4c4a9b1cd649890c6497;rport" + CRLF +
-"Via: SIP/2.0/UDP 127.0.0.1:5003;branch=z9hG4bK0495dc29b7eb40008779a75c3734c4c5;rport=5003;received=127.0.0.1" + CRLF +
-"To: ;tag=1892981968" + CRLF +
-"From: ;tag=1555449860" + CRLF +
-"Call-ID: 1b569032-d1e4-4869-be9f-67d4ba8a4e3a" + CRLF +
-"CSeq: 4 NOTIFY" + CRLF +
-"l : 2393" + CRLF +
-"Contact: " + CRLF +
-"Max-Forwards: 69" + CRLF +
-"Event: dialog" + CRLF + CRLF;
+$"NOTIFY sip:10.1.1.5:62647;transport=tcp SIP/2.0{CRLF}Via: SIP/2.0/TCP 10.1.1.5:4506;branch=z9hG4bKa4d17f991015b1d8b788f2ac54d66ec66811226a;rport{CRLF}Via: SIP/2.0/UDP 127.0.0.1:5060;branch=z9hG4bKc2224b79f5af4c4a9b1cd649890c6497;rport{CRLF}Via: SIP/2.0/UDP 127.0.0.1:5003;branch=z9hG4bK0495dc29b7eb40008779a75c3734c4c5;rport=5003;received=127.0.0.1{CRLF}To: ;tag=1892981968{CRLF}From: ;tag=1555449860{CRLF}Call-ID: 1b569032-d1e4-4869-be9f-67d4ba8a4e3a{CRLF}CSeq: 4 NOTIFY{CRLF}l : 2393{CRLF}Contact: {CRLF}Max-Forwards: 69{CRLF}Event: dialog{CRLF}{CRLF}";
byte[] notifyRequestBytes = UTF8Encoding.UTF8.GetBytes(notifyRequest);
@@ -300,17 +188,7 @@ public void ParseReceiveNoContentLengthHeaderRequestTest()
logger.BeginScope(TestHelper.GetCurrentMethodName());
string notifyRequest =
-"NOTIFY sip:10.1.1.5:62647;transport=tcp SIP/2.0" + CRLF +
-"Via: SIP/2.0/TCP 10.1.1.5:4506;branch=z9hG4bKa4d17f991015b1d8b788f2ac54d66ec66811226a;rport" + CRLF +
-"Via: SIP/2.0/UDP 127.0.0.1:5060;branch=z9hG4bKc2224b79f5af4c4a9b1cd649890c6497;rport" + CRLF +
-"Via: SIP/2.0/UDP 127.0.0.1:5003;branch=z9hG4bK0495dc29b7eb40008779a75c3734c4c5;rport=5003;received=127.0.0.1" + CRLF +
-"To: ;tag=1892981968" + CRLF +
-"From: ;tag=1555449860" + CRLF +
-"Call-ID: 1b569032-d1e4-4869-be9f-67d4ba8a4e3a" + CRLF +
-"CSeq: 4 NOTIFY" + CRLF +
-"Contact: " + CRLF +
-"Max-Forwards: 69" + CRLF +
-"Event: dialog" + CRLF + CRLF;
+$"NOTIFY sip:10.1.1.5:62647;transport=tcp SIP/2.0{CRLF}Via: SIP/2.0/TCP 10.1.1.5:4506;branch=z9hG4bKa4d17f991015b1d8b788f2ac54d66ec66811226a;rport{CRLF}Via: SIP/2.0/UDP 127.0.0.1:5060;branch=z9hG4bKc2224b79f5af4c4a9b1cd649890c6497;rport{CRLF}Via: SIP/2.0/UDP 127.0.0.1:5003;branch=z9hG4bK0495dc29b7eb40008779a75c3734c4c5;rport=5003;received=127.0.0.1{CRLF}To: ;tag=1892981968{CRLF}From: ;tag=1555449860{CRLF}Call-ID: 1b569032-d1e4-4869-be9f-67d4ba8a4e3a{CRLF}CSeq: 4 NOTIFY{CRLF}Contact: {CRLF}Max-Forwards: 69{CRLF}Event: dialog{CRLF}{CRLF}";
byte[] notifyRequestBytes = UTF8Encoding.UTF8.GetBytes(notifyRequest);
byte[] parsedNotifyBytes = SIPMessageBuffer.ParseSIPMessageFromStream(notifyRequestBytes, 0, notifyRequestBytes.Length, out _);
@@ -328,96 +206,7 @@ public void ParseReceiveSingleRequestTest()
logger.BeginScope(TestHelper.GetCurrentMethodName());
string notifyRequest =
-"NOTIFY sip:10.1.1.5:62647;transport=tcp SIP/2.0" + CRLF +
-"Via: SIP/2.0/TCP 10.1.1.5:4506;branch=z9hG4bKa4d17f991015b1d8b788f2ac54d66ec66811226a;rport" + CRLF +
-"Via: SIP/2.0/UDP 127.0.0.1:5060;branch=z9hG4bKc2224b79f5af4c4a9b1cd649890c6497;rport" + CRLF +
-"Via: SIP/2.0/UDP 127.0.0.1:5003;branch=z9hG4bK0495dc29b7eb40008779a75c3734c4c5;rport=5003;received=127.0.0.1" + CRLF +
-"To: ;tag=1892981968" + CRLF +
-"From: ;tag=1555449860" + CRLF +
-"Call-ID: 1b569032-d1e4-4869-be9f-67d4ba8a4e3a" + CRLF +
-"CSeq: 4 NOTIFY" + CRLF +
-"Contact: " + CRLF +
-"Max-Forwards: 69" + CRLF +
-"Content-Length: 2393" + CRLF +
-"Event: dialog" + CRLF +
-CRLF +
-"" + CRLF +
-"" + CRLF +
-" " + CRLF +
-" " + CRLF +
-"";
+$"NOTIFY sip:10.1.1.5:62647;transport=tcp SIP/2.0{CRLF}Via: SIP/2.0/TCP 10.1.1.5:4506;branch=z9hG4bKa4d17f991015b1d8b788f2ac54d66ec66811226a;rport{CRLF}Via: SIP/2.0/UDP 127.0.0.1:5060;branch=z9hG4bKc2224b79f5af4c4a9b1cd649890c6497;rport{CRLF}Via: SIP/2.0/UDP 127.0.0.1:5003;branch=z9hG4bK0495dc29b7eb40008779a75c3734c4c5;rport=5003;received=127.0.0.1{CRLF}To: ;tag=1892981968{CRLF}From: ;tag=1555449860{CRLF}Call-ID: 1b569032-d1e4-4869-be9f-67d4ba8a4e3a{CRLF}CSeq: 4 NOTIFY{CRLF}Contact: {CRLF}Max-Forwards: 69{CRLF}Content-Length: 2393{CRLF}Event: dialog{CRLF}{CRLF}{CRLF}{CRLF} {CRLF} {CRLF}";
byte[] notifyRequestBytes = Encoding.ASCII.GetBytes(notifyRequest);
byte[] parsedNotifyBytes = SIPMessageBuffer.ParseSIPMessageFromStream(notifyRequestBytes, 0, notifyRequestBytes.Length, out _);
@@ -435,48 +224,7 @@ public void ParseMultiRequestAndResponseTest()
logger.BeginScope(TestHelper.GetCurrentMethodName());
string testReceive =
- "SUBSCRIBE sip:aaron@10.1.1.5 SIP/2.0" + CRLF +
-"Via: SIP/2.0/TCP 10.1.1.5:62647;branch=z9hG4bKa58b912c426f415daa887289efda50cd;rport" + CRLF +
-"To: " + CRLF +
-"From: ;tag=1902440575" + CRLF +
-"Call-ID: 1b569032-d1e4-4869-be9f-67d4ba8a4e3a" + CRLF +
-"CSeq: 3 SUBSCRIBE" + CRLF +
-"Contact: " + CRLF +
-"Max-Forwards: 70" + CRLF +
-"Expires: 600" + CRLF +
-"Content-Length: 15" + CRLF +
-"Content-Type: text/text" + CRLF +
-"Event: dialog" + CRLF +
-CRLF +
-"includesdp=trueSUBSCRIBE sip:aaron@10.1.1.5 SIP/2.0" + CRLF +
-"Via: SIP/2.0/UDP 127.0.0.1:5060;branch=z9hG4bK82b1f0704fc31f47b4c9e0bc383d3e0e41f2a60f;rport" + CRLF +
-"Via: SIP/2.0/TCP 10.1.1.5:4506;branch=z9hG4bK6d88a47e4b5c4bde9c45270ca64a1c53;rport" + CRLF +
-"Via: SIP/2.0/TCP 10.1.1.5:62647;branch=z9hG4bKa58b912c426f415daa887289efda50cd;rport=62647;received=10.1.1.5" + CRLF +
-"To: " + CRLF +
-"From: ;tag=1902440575" + CRLF +
-"Call-ID: 1b569032-d1e4-4869-be9f-67d4ba8a4e3a" + CRLF +
-"CSeq: 3 SUBSCRIBE" + CRLF +
-"Contact: " + CRLF +
-"Max-Forwards: 69" + CRLF +
-"Expires: 600" + CRLF +
-"Content-Length: 15" + CRLF +
-"Content-Type: text/text" + CRLF +
-"Event: dialog" + CRLF +
-"Proxy-ReceivedFrom: tcp:10.1.1.5:62647" + CRLF +
-"Proxy-ReceivedOn: tcp:10.1.1.5:4506" + CRLF +
-CRLF +
-"includesdp=trueSIP/2.0 200 Ok" + CRLF +
-"Via: SIP/2.0/UDP 127.0.0.1:5060;branch=z9hG4bKba4e75d7c55baef96457b36b7b570dae9a253dd8;rport=5060;received=127.0.0.1" + CRLF +
-"Via: SIP/2.0/TCP 10.1.1.5:4506;branch=z9hG4bKc6f4c0fcd4684246abf539848017c0f0;rport" + CRLF +
-"Via: SIP/2.0/TCP 10.1.1.5:62647;branch=z9hG4bK17bbf15513b44e6aa88b605410148d2b;rport=62647;received=10.1.1.5" + CRLF +
-"To: ;tag=2140367015" + CRLF +
-"From: ;tag=1557768010" + CRLF +
-"Call-ID: a65b4461-6929-4604-b498-256f6643e6ac" + CRLF +
-"CSeq: 2 REGISTER" + CRLF +
-"Contact: ;expires=113" + CRLF +
-"Date: Wed, 10 Mar 2010 00:21:14 GMT" + CRLF +
-"Content-Length: 0" + CRLF +
-"Server: www.sipsorcery.com" + CRLF + CRLF;
+ $"SUBSCRIBE sip:aaron@10.1.1.5 SIP/2.0{CRLF}Via: SIP/2.0/TCP 10.1.1.5:62647;branch=z9hG4bKa58b912c426f415daa887289efda50cd;rport{CRLF}To: {CRLF}From: ;tag=1902440575{CRLF}Call-ID: 1b569032-d1e4-4869-be9f-67d4ba8a4e3a{CRLF}CSeq: 3 SUBSCRIBE{CRLF}Contact: {CRLF}Max-Forwards: 70{CRLF}Expires: 600{CRLF}Content-Length: 15{CRLF}Content-Type: text/text{CRLF}Event: dialog{CRLF}{CRLF}includesdp=trueSUBSCRIBE sip:aaron@10.1.1.5 SIP/2.0{CRLF}Via: SIP/2.0/UDP 127.0.0.1:5060;branch=z9hG4bK82b1f0704fc31f47b4c9e0bc383d3e0e41f2a60f;rport{CRLF}Via: SIP/2.0/TCP 10.1.1.5:4506;branch=z9hG4bK6d88a47e4b5c4bde9c45270ca64a1c53;rport{CRLF}Via: SIP/2.0/TCP 10.1.1.5:62647;branch=z9hG4bKa58b912c426f415daa887289efda50cd;rport=62647;received=10.1.1.5{CRLF}To: {CRLF}From: ;tag=1902440575{CRLF}Call-ID: 1b569032-d1e4-4869-be9f-67d4ba8a4e3a{CRLF}CSeq: 3 SUBSCRIBE{CRLF}Contact: {CRLF}Max-Forwards: 69{CRLF}Expires: 600{CRLF}Content-Length: 15{CRLF}Content-Type: text/text{CRLF}Event: dialog{CRLF}Proxy-ReceivedFrom: tcp:10.1.1.5:62647{CRLF}Proxy-ReceivedOn: tcp:10.1.1.5:4506{CRLF}{CRLF}includesdp=trueSIP/2.0 200 Ok{CRLF}Via: SIP/2.0/UDP 127.0.0.1:5060;branch=z9hG4bKba4e75d7c55baef96457b36b7b570dae9a253dd8;rport=5060;received=127.0.0.1{CRLF}Via: SIP/2.0/TCP 10.1.1.5:4506;branch=z9hG4bKc6f4c0fcd4684246abf539848017c0f0;rport{CRLF}Via: SIP/2.0/TCP 10.1.1.5:62647;branch=z9hG4bK17bbf15513b44e6aa88b605410148d2b;rport=62647;received=10.1.1.5{CRLF}To: ;tag=2140367015{CRLF}From: ;tag=1557768010{CRLF}Call-ID: a65b4461-6929-4604-b498-256f6643e6ac{CRLF}CSeq: 2 REGISTER{CRLF}Contact: ;expires=113{CRLF}Date: Wed, 10 Mar 2010 00:21:14 GMT{CRLF}Content-Length: 0{CRLF}Server: www.sipsorcery.com{CRLF}{CRLF}";
byte[] testReceiveBytes = UTF8Encoding.UTF8.GetBytes(testReceive);
@@ -502,20 +250,7 @@ public void ParseRequestOneByteMissingTest()
logger.BeginScope(TestHelper.GetCurrentMethodName());
string testReceive =
- "SUBSCRIBE sip:aaron@10.1.1.5 SIP/2.0" + CRLF +
-"Via: SIP/2.0/TCP 10.1.1.5:62647;branch=z9hG4bKa58b912c426f415daa887289efda50cd;rport" + CRLF +
-"To: " + CRLF +
-"From: ;tag=1902440575" + CRLF +
-"Call-ID: 1b569032-d1e4-4869-be9f-67d4ba8a4e3a" + CRLF +
-"CSeq: 3 SUBSCRIBE" + CRLF +
-"Contact: " + CRLF +
-"Max-Forwards: 70" + CRLF +
-"Expires: 600" + CRLF +
-"Content-Length: 15" + CRLF +
-"Content-Type: text/text" + CRLF +
-"Event: dialog" + CRLF +
-"" + CRLF +
-"includesdp=tru";
+ $"SUBSCRIBE sip:aaron@10.1.1.5 SIP/2.0{CRLF}Via: SIP/2.0/TCP 10.1.1.5:62647;branch=z9hG4bKa58b912c426f415daa887289efda50cd;rport{CRLF}To: {CRLF}From: ;tag=1902440575{CRLF}Call-ID: 1b569032-d1e4-4869-be9f-67d4ba8a4e3a{CRLF}CSeq: 3 SUBSCRIBE{CRLF}Contact: {CRLF}Max-Forwards: 70{CRLF}Expires: 600{CRLF}Content-Length: 15{CRLF}Content-Type: text/text{CRLF}Event: dialog{CRLF}{CRLF}includesdp=tru";
byte[] testReceiveBytes = UTF8Encoding.UTF8.GetBytes(testReceive);
byte[] request1Bytes = SIPMessageBuffer.ParseSIPMessageFromStream(testReceiveBytes, 0, testReceiveBytes.Length, out _);
@@ -533,20 +268,7 @@ public void ParseRequestOneByteExtraTest()
logger.BeginScope(TestHelper.GetCurrentMethodName());
string testReceive =
- "SUBSCRIBE sip:aaron@10.1.1.5 SIP/2.0" + CRLF +
-"Via: SIP/2.0/TCP 10.1.1.5:62647;branch=z9hG4bKa58b912c426f415daa887289efda50cd;rport" + CRLF +
-"To: " + CRLF +
-"From: ;tag=1902440575" + CRLF +
-"Call-ID: 1b569032-d1e4-4869-be9f-67d4ba8a4e3a" + CRLF +
-"CSeq: 3 SUBSCRIBE" + CRLF +
-"Contact: " + CRLF +
-"Max-Forwards: 70" + CRLF +
-"Expires: 600" + CRLF +
-"Content-Length: 15" + CRLF +
-"Content-Type: text/text" + CRLF +
-"Event: dialog" + CRLF +
-CRLF +
-"includesdp=true!";
+ $"SUBSCRIBE sip:aaron@10.1.1.5 SIP/2.0{CRLF}Via: SIP/2.0/TCP 10.1.1.5:62647;branch=z9hG4bKa58b912c426f415daa887289efda50cd;rport{CRLF}To: {CRLF}From: ;tag=1902440575{CRLF}Call-ID: 1b569032-d1e4-4869-be9f-67d4ba8a4e3a{CRLF}CSeq: 3 SUBSCRIBE{CRLF}Contact: {CRLF}Max-Forwards: 70{CRLF}Expires: 600{CRLF}Content-Length: 15{CRLF}Content-Type: text/text{CRLF}Event: dialog{CRLF}{CRLF}includesdp=true!";
byte[] testReceiveBytes = UTF8Encoding.UTF8.GetBytes(testReceive);
byte[] request1Bytes = SIPMessageBuffer.ParseSIPMessageFromStream(testReceiveBytes, 0, testReceiveBytes.Length, out _);
@@ -566,20 +288,7 @@ public void ParseRequestBytesReadShortTest()
logger.BeginScope(TestHelper.GetCurrentMethodName());
string testReceive =
- "SUBSCRIBE sip:aaron@10.1.1.5 SIP/2.0" + CRLF +
-"Via: SIP/2.0/TCP 10.1.1.5:62647;branch=z9hG4bKa58b912c426f415daa887289efda50cd;rport" + CRLF +
-"To: " + CRLF +
-"From: ;tag=1902440575" + CRLF +
-"Call-ID: 1b569032-d1e4-4869-be9f-67d4ba8a4e3a" + CRLF +
-"CSeq: 3 SUBSCRIBE" + CRLF +
-"Contact: " + CRLF +
-"Max-Forwards: 70" + CRLF +
-"Expires: 600" + CRLF +
-"Content-Length: 15" + CRLF +
-"Content-Type: text/text" + CRLF +
-"Event: dialog" + CRLF +
-"" + CRLF +
-"include ";
+ $"SUBSCRIBE sip:aaron@10.1.1.5 SIP/2.0{CRLF}Via: SIP/2.0/TCP 10.1.1.5:62647;branch=z9hG4bKa58b912c426f415daa887289efda50cd;rport{CRLF}To: {CRLF}From: ;tag=1902440575{CRLF}Call-ID: 1b569032-d1e4-4869-be9f-67d4ba8a4e3a{CRLF}CSeq: 3 SUBSCRIBE{CRLF}Contact: {CRLF}Max-Forwards: 70{CRLF}Expires: 600{CRLF}Content-Length: 15{CRLF}Content-Type: text/text{CRLF}Event: dialog{CRLF}{CRLF}include ";
byte[] testReceiveBytes = UTF8Encoding.UTF8.GetBytes(testReceive);
byte[] request1Bytes = SIPMessageBuffer.ParseSIPMessageFromStream(testReceiveBytes, 0, testReceiveBytes.Length - 100, out _);
@@ -597,20 +306,7 @@ public void ParseRequestWithLeadingNATKeepAliveBytesTest()
logger.BeginScope(TestHelper.GetCurrentMethodName());
string testReceive =
- " SUBSCRIBE sip:aaron@10.1.1.5 SIP/2.0" + CRLF +
-"Via: SIP/2.0/TCP 10.1.1.5:62647;branch=z9hG4bKa58b912c426f415daa887289efda50cd;rport" + CRLF +
-"To: " + CRLF +
-"From: ;tag=1902440575" + CRLF +
-"Call-ID: 1b569032-d1e4-4869-be9f-67d4ba8a4e3a" + CRLF +
-"CSeq: 3 SUBSCRIBE" + CRLF +
-"Contact: " + CRLF +
-"Max-Forwards: 70" + CRLF +
-"Expires: 600" + CRLF +
-"Content-Length: 15" + CRLF +
-"Content-Type: text/text" + CRLF +
-"Event: dialog" + CRLF +
-CRLF +
-"includesdp=true";
+ $" SUBSCRIBE sip:aaron@10.1.1.5 SIP/2.0{CRLF}Via: SIP/2.0/TCP 10.1.1.5:62647;branch=z9hG4bKa58b912c426f415daa887289efda50cd;rport{CRLF}To: {CRLF}From: ;tag=1902440575{CRLF}Call-ID: 1b569032-d1e4-4869-be9f-67d4ba8a4e3a{CRLF}CSeq: 3 SUBSCRIBE{CRLF}Contact: {CRLF}Max-Forwards: 70{CRLF}Expires: 600{CRLF}Content-Length: 15{CRLF}Content-Type: text/text{CRLF}Event: dialog{CRLF}{CRLF}includesdp=true";
byte[] testReceiveBytes = UTF8Encoding.UTF8.GetBytes(testReceive);
@@ -633,20 +329,7 @@ public void TestProcessRecevieWithBytesToSkipTest()
logger.BeginScope(TestHelper.GetCurrentMethodName());
string testReceive =
-" SUBSCRIBE sip:aaron@10.1.1.5 SIP/2.0" + CRLF +
-"Via: SIP/2.0/TCP 10.1.1.5:62647;branch=z9hG4bKa58b912c426f415daa887289efda50cd;rport" + CRLF +
-"To: " + CRLF +
-"From: ;tag=1902440575" + CRLF +
-"Call-ID: 1b569032-d1e4-4869-be9f-67d4ba8a4e3a" + CRLF +
-"CSeq: 3 SUBSCRIBE" + CRLF +
-"Contact: " + CRLF +
-"Max-Forwards: 70" + CRLF +
-"Expires: 600" + CRLF +
-"Content-Length: 15" + CRLF +
-"Content-Type: text/text" + CRLF +
-"Event: dialog" + CRLF +
-CRLF +
-"includesdp=true";
+$" SUBSCRIBE sip:aaron@10.1.1.5 SIP/2.0{CRLF}Via: SIP/2.0/TCP 10.1.1.5:62647;branch=z9hG4bKa58b912c426f415daa887289efda50cd;rport{CRLF}To: {CRLF}From: ;tag=1902440575{CRLF}Call-ID: 1b569032-d1e4-4869-be9f-67d4ba8a4e3a{CRLF}CSeq: 3 SUBSCRIBE{CRLF}Contact: {CRLF}Max-Forwards: 70{CRLF}Expires: 600{CRLF}Content-Length: 15{CRLF}Content-Type: text/text{CRLF}Event: dialog{CRLF}{CRLF}includesdp=true";
byte[] testReceiveBytes = UTF8Encoding.UTF8.GetBytes(testReceive);
@@ -680,17 +363,7 @@ public void IsPingUnitTest()
Assert.True(SIPMessageBuffer.IsPing(buffer), "Buffer \\0\\0\\0\\0 is not a Ping message.");
string sipMsg =
- "SIP/2.0 100 Trying" + CRLF +
- "Via: SIP/2.0/UDP 213.168.225.135:5060;branch=z9hG4bKD+ta2mJ+C+VV/L50aPO1lFJnrag=" + CRLF +
- "Via: SIP/2.0/UDP 192.168.1.2:5065;received=220.240.255.198:64193;branch=z9hG4bKB86FC8D2431F49E9862D1EE439C78AD8" + CRLF +
- "From: bluesipd ;tag=3272744142" + CRLF +
- "To: " + CRLF +
- "Call-ID: FE63F90D-4339-4AD0-9D44-59F44A1935E7@192.168.1.2" + CRLF +
- "CSeq: 45560 INVITE" + CRLF +
- "User-Agent: asterisk" + CRLF +
- "Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY" + CRLF +
- "Contact: " + CRLF +
- "Content-Length: 0" + CRLF + CRLF;
+ $"SIP/2.0 100 Trying{CRLF}Via: SIP/2.0/UDP 213.168.225.135:5060;branch=z9hG4bKD+ta2mJ+C+VV/L50aPO1lFJnrag={CRLF}Via: SIP/2.0/UDP 192.168.1.2:5065;received=220.240.255.198:64193;branch=z9hG4bKB86FC8D2431F49E9862D1EE439C78AD8{CRLF}From: bluesipd ;tag=3272744142{CRLF}To: {CRLF}Call-ID: FE63F90D-4339-4AD0-9D44-59F44A1935E7@192.168.1.2{CRLF}CSeq: 45560 INVITE{CRLF}User-Agent: asterisk{CRLF}Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY{CRLF}Contact: {CRLF}Content-Length: 0{CRLF}{CRLF}";
Assert.False(SIPMessageBuffer.IsPing(Encoding.UTF8.GetBytes(sipMsg)), "The SIP message is a Ping.");
@@ -704,17 +377,7 @@ public void ParseWithDefaultEncodingPersistsEndPoints()
logger.BeginScope(TestHelper.GetCurrentMethodName());
string sipMsg =
- "SIP/2.0 100 Trying" + CRLF +
- "Via: SIP/2.0/UDP 213.168.225.135:5060;branch=z9hG4bKD+ta2mJ+C+VV/L50aPO1lFJnrag=" + CRLF +
- "Via: SIP/2.0/UDP 192.168.1.2:5065;received=220.240.255.198:64193;branch=z9hG4bKB86FC8D2431F49E9862D1EE439C78AD8" + CRLF +
- "From: bluesipd ;tag=3272744142" + CRLF +
- "To: " + CRLF +
- "Call-ID: FE63F90D-4339-4AD0-9D44-59F44A1935E7@192.168.1.2" + CRLF +
- "CSeq: 45560 INVITE" + CRLF +
- "User-Agent: asterisk" + CRLF +
- "Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY" + CRLF +
- "Contact: " + CRLF +
- "Content-Length: 0" + CRLF + CRLF;
+ $"SIP/2.0 100 Trying{CRLF}Via: SIP/2.0/UDP 213.168.225.135:5060;branch=z9hG4bKD+ta2mJ+C+VV/L50aPO1lFJnrag={CRLF}Via: SIP/2.0/UDP 192.168.1.2:5065;received=220.240.255.198:64193;branch=z9hG4bKB86FC8D2431F49E9862D1EE439C78AD8{CRLF}From: bluesipd ;tag=3272744142{CRLF}To: {CRLF}Call-ID: FE63F90D-4339-4AD0-9D44-59F44A1935E7@192.168.1.2{CRLF}CSeq: 45560 INVITE{CRLF}User-Agent: asterisk{CRLF}Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY{CRLF}Contact: {CRLF}Content-Length: 0{CRLF}{CRLF}";
byte[] testReceiveBytes = UTF8Encoding.UTF8.GetBytes(sipMsg);
var localEndPoint = new SIPEndPoint(new IPEndPoint(IPAddress.Parse("192.168.1.1"), 5060));
diff --git a/test/unit/core/SIP/SIPRequestUnitTest.cs b/test/unit/core/SIP/SIPRequestUnitTest.cs
index 02dad379d2..c2d3203a06 100644
--- a/test/unit/core/SIP/SIPRequestUnitTest.cs
+++ b/test/unit/core/SIP/SIPRequestUnitTest.cs
@@ -41,30 +41,7 @@ public void ParseXtenINVITEUnitTest()
logger.BeginScope(TestHelper.GetCurrentMethodName());
string sipMsg =
- "INVITE sip:303@sip.blueface.ie SIP/2.0" + m_CRLF +
- "Via: SIP/2.0/UDP 192.168.1.2:5065;rport;branch=z9hG4bKFBB7EAC06934405182D13950BD51F001" + m_CRLF +
- "From: SER Test X ;tag=196468136" + m_CRLF +
- "To: " + m_CRLF +
- "Contact: " + m_CRLF +
- "Call-ID: A3DF9A04-0EFE-47E4-98B1-E18AA186F3D6@192.168.1.2" + m_CRLF +
- "CSeq: 49429 INVITE" + m_CRLF +
- "Max-Forwards: 70" + m_CRLF +
- "Content-Type: application/sdp" + m_CRLF +
- "User-Agent: X-PRO release 1103v" + m_CRLF +
- "Content-Length: 271" + m_CRLF +
- m_CRLF +
- "v=0" + m_CRLF +
- "o=aaronxten 423137371 423137414 IN IP4 192.168.1.2" + m_CRLF +
- "s=X-PRO" + m_CRLF +
- "c=IN IP4 192.168.1.2" + m_CRLF +
- "t=0 0" + m_CRLF +
- "m=audio 8004 RTP/AVP 0 8 3 97 101" + m_CRLF +
- "a=rtpmap:0 pcmu/8000" + m_CRLF +
- "a=rtpmap:8 pcma/8000" + m_CRLF +
- "a=rtpmap:3 gsm/8000" + m_CRLF +
- "a=rtpmap:97 speex/8000" + m_CRLF +
- "a=rtpmap:101 telephone-event/8000" + m_CRLF +
- "a=fmtp:101 0-15" + m_CRLF;
+ $"INVITE sip:303@sip.blueface.ie SIP/2.0{m_CRLF}Via: SIP/2.0/UDP 192.168.1.2:5065;rport;branch=z9hG4bKFBB7EAC06934405182D13950BD51F001{m_CRLF}From: SER Test X