Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/AzureExamples/TextToPcm/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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 };
Expand Down
2 changes: 1 addition & 1 deletion examples/SIPExamples/SIPProxy/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ static void Main()
}
catch (Exception excp)
{
Console.WriteLine("Exception Main. " + excp);
Console.WriteLine($"Exception Main. {excp}");
}
}

Expand Down
14 changes: 7 additions & 7 deletions examples/Softphone/Signalling/SIPClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -151,7 +151,7 @@ public async Task Call(string destination)
/// </summary>
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();
}

Expand Down Expand Up @@ -215,7 +215,7 @@ public void Redirect(string destination)
/// Puts the remote call party on hold.
/// </summary>
public async Task PutOnHold()
{
{
await MediaSession.PutOnHold();
m_userAgent.PutOnHold();
StatusMessage(this, "Local party put on hold");
Expand Down Expand Up @@ -319,23 +319,23 @@ private VoIPMediaSession CreateMediaSession()
/// </summary>
private void CallTrying(ISIPClientUserAgent uac, SIPResponse sipResponse)
{
StatusMessage(this, "Call trying: " + sipResponse.StatusCode + " " + sipResponse.ReasonPhrase + ".");
StatusMessage(this, $"Call trying: {sipResponse.StatusCode} {sipResponse.ReasonPhrase}.");
}

/// <summary>
/// A ringing response has been received from the remote SIP UAS on an outgoing call.
/// </summary>
private void CallRinging(ISIPClientUserAgent uac, SIPResponse sipResponse)
{
StatusMessage(this, "Call ringing: " + sipResponse.StatusCode + " " + sipResponse.ReasonPhrase + ".");
StatusMessage(this, $"Call ringing: {sipResponse.StatusCode} {sipResponse.ReasonPhrase}.");
}

/// <summary>
/// An outgoing call was rejected by the remote SIP UAS on an outgoing call.
/// </summary>
private void CallFailed(ISIPClientUserAgent uac, string errorMessage, SIPResponse failureResponse)
{
StatusMessage(this, "Call failed: " + errorMessage + ".");
StatusMessage(this, $"Call failed: {errorMessage}.");
CallFinished(null);
}

Expand All @@ -346,7 +346,7 @@ private void CallFailed(ISIPClientUserAgent uac, string errorMessage, SIPRespons
/// <param name="sipResponse">The SIP answer response received from the remote party.</param>
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);
}

Expand Down
28 changes: 13 additions & 15 deletions examples/WebRTCExamples/FfmpegToWebRTC/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
//-----------------------------------------------------------------------------

Expand Down Expand Up @@ -89,26 +89,24 @@ 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}.");
}
}

CancellationTokenSource exitCts = new CancellationTokenSource();

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...");
Expand Down Expand Up @@ -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.");
}
Expand Down
46 changes: 6 additions & 40 deletions examples/WebRTCExamples/RtspToWebRTCAudioAndVideo/DemuxerConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 "";
}


}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void OnMove(InputValue movementValue)

void SetCountText()
{
countText.text = "Count: " + count.ToString();
countText.text = $"Count: {count.ToString()}";

if (count >= 10)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ public bool IsEnabled(LogLevel logLevel)

public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter)
{
Debug.Log("[" + eventId + "] " + formatter(state, exception));
Debug.Log($"[{eventId}] {formatter(state, exception)}");
System.Diagnostics.Debug.WriteLine("[" + eventId + "] " + formatter(state, exception));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,7 @@ public bool IsEnabled(Microsoft.Extensions.Logging.LogLevel logLevel)

public void Log<TState>(Microsoft.Extensions.Logging.LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter)
{
Debug.Log("[" + eventId + "] " + formatter(state, exception));
Debug.Log($"[{eventId}] {formatter(state, exception)}");
System.Diagnostics.Debug.WriteLine("[" + eventId + "] " + formatter(state, exception));
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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 };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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 };
Expand Down
4 changes: 2 additions & 2 deletions examples/WebRTCExamples/WebRTCtoFfplay/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ private static RTPSession CreateRtpSession(List<SDPAudioVideoMediaFormat> 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'");
Expand Down Expand Up @@ -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.");
}
Expand Down
6 changes: 2 additions & 4 deletions examples/WebRTCScenarios/DataChannelStressTest/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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++)
Expand All @@ -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;
Expand Down
Loading
Loading