Skip to content
Open
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/OpenAIExamples/WebRTCOpenAI/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ private static async Task<RTCPeerConnection> CreatePeerConnection(SemaphoreSlim
WindowsAudioEndPoint windowsAudioEP = new WindowsAudioEndPoint(new AudioEncoder(includeOpus: true), -1, -1, false, false);
windowsAudioEP.RestrictFormats(x => x.FormatName == "OPUS");
windowsAudioEP.OnAudioSinkError += err => logger.LogWarning($"Audio sink error. {err}.");
windowsAudioEP.OnAudioSourceEncodedSample += peerConnection.SendAudio;
windowsAudioEP.OnAudioSourceEncodedSample += peerConnection.SendAudio;

MediaStreamTrack audioTrack = new MediaStreamTrack(windowsAudioEP.GetAudioSourceFormats(), MediaStreamStatusEnum.SendRecv);
peerConnection.addTrack(audioTrack);
Expand Down
1 change: 0 additions & 1 deletion src/app/Media/Sources/AudioSignalGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ public int Read(float[] buffer, int offset, int count)

break;


case SignalGeneratorType.Square:

// Square Generator
Expand Down
2 changes: 1 addition & 1 deletion src/app/Media/VoIPMediaSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ private void AudioFormatsNegotiated(List<AudioFormat> audoFormats)
Media.AudioSource?.SetAudioSourceFormat(audioFormat);
_audioExtrasSource.SetAudioSourceFormat(audioFormat);

if (AudioStream != null && AudioStream.LocalTrack.NoDtmfSupport == false)
if (AudioStream != null && !AudioStream.LocalTrack.NoDtmfSupport)
{
logger.LogDebug("Audio track negotiated DTMF payload ID {AudioStreamNegotiatedRtpEventPayloadID}.", AudioStream.NegotiatedRtpEventPayloadID);
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/SIPUserAgents/SIPClientUserAgent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ private SIPRequest GetInviteRequest(SIPCallDescriptor sipCallDescriptor, string
inviteHeader.UserAgent = SIPConstants.SipUserAgentVersionString;
inviteHeader.Routes = routeSet;
inviteHeader.Supported = SIPExtensionHeaders.REPLACES + ", " + SIPExtensionHeaders.NO_REFER_SUB
+ ((PrackSupported == true) ? ", " + SIPExtensionHeaders.PRACK : "");
+ (PrackSupported ? ", " + SIPExtensionHeaders.PRACK : "");

inviteRequest.Header = inviteHeader;

Expand Down
2 changes: 1 addition & 1 deletion src/app/SIPUserAgents/SIPServerUserAgent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ public void Hangup(bool clientHungup)
}

// Only need to send a BYE request if the client didn't already do so.
if (clientHungup == false)
if (!clientHungup)
{
try
{
Expand Down
34 changes: 17 additions & 17 deletions src/app/SIPUserAgents/SIPUserAgent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ public void Cancel()
{
if (m_uac != null)
{
if (m_uac.IsUACAnswered == false)
if (!m_uac.IsUACAnswered)
{
m_uac.Cancel();
}
Expand Down Expand Up @@ -1778,10 +1778,10 @@ private void CallEnded(string callId)
m_semaphoreSlim.Wait();
CallEndedSyncronized(callId);
}
catch (ObjectDisposedException)
{
//Swallow it
}
catch (ObjectDisposedException)
{
//Swallow it
}
finally
{
TryReleaseSemaphore();
Expand Down Expand Up @@ -1974,17 +1974,17 @@ public void Dispose()
TryReleaseSemaphore();
m_semaphoreSlim.Dispose();
}
private void TryReleaseSemaphore()
{
try
{
m_semaphoreSlim.Release();
}
catch (ObjectDisposedException)
{
//Swallow it
}
}
private void TryReleaseSemaphore()
{
try
{
m_semaphoreSlim.Release();
}
catch (ObjectDisposedException)
{
//Swallow it
}
}
}
}
2 changes: 1 addition & 1 deletion src/core/SIP/Channels/SIPClientWebSocketChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ private void MonitorReceiveTasks()
var receiveTasks = m_egressConnections.Select(x => x.Value.ReceiveTask).ToArray();
int completedTaskIndex = Task.WaitAny(receiveTasks);
Task<WebSocketReceiveResult> receiveTask = receiveTasks[completedTaskIndex];
var conn = m_egressConnections.Where(x => x.Value.ReceiveTask.Id == receiveTask.Id).Single().Value;
var conn = m_egressConnections.Single(x => x.Value.ReceiveTask.Id == receiveTask.Id).Value;

if (receiveTask.IsCompleted)
{
Expand Down
2 changes: 1 addition & 1 deletion src/core/SIP/Channels/SIPTCPChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ public override bool IsProtocolSupported(SIPProtocolsEnum protocol)
/// </summary>
public override void Close()
{
if (!Closed == true)
if (!Closed)
{
logger.LogDebug("Closing SIP {ProtDescr} Channel {ListeningEndPoint}.", ProtDescr, ListeningEndPoint);

Expand Down
9 changes: 1 addition & 8 deletions src/core/SIP/SIPConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -232,14 +232,7 @@ public static bool IsAllowedProtocol(string protocol)
/// <returns>True if the protocol is connectionless.</returns>
public static bool IsConnectionless(SIPProtocolsEnum protocol)
{
if (protocol == SIPProtocolsEnum.udp)
{
return true;
}
else
{
return false;
}
return protocol == SIPProtocolsEnum.udp;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/SIP/SIPHeader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1153,7 +1153,7 @@ public void RemoveBottomRoute()
if (m_sipRoutes.Count > 0)
{
m_sipRoutes.RemoveAt(m_sipRoutes.Count - 1);
};
}
}

public SIPRouteSet Reversed()
Expand Down
2 changes: 1 addition & 1 deletion src/core/SIPEvents/SIPEventPackages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public static SIPEventPackagesEnum Parse(string value)

public static string GetEventHeader(SIPEventPackagesEnum eventPackage)
{
switch(eventPackage)
switch (eventPackage)
{
case SIPEventPackagesEnum.Dialog:
return DIALOG_EVENT_VALUE;
Expand Down
2 changes: 1 addition & 1 deletion src/core/SIPTransactions/SIPTransaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ protected virtual Task<SocketError> SendProvisionalResponse(SIPResponse sipRespo
{
UpdateTransactionState(SIPTransactionStatesEnum.Proceeding);

if (PrackSupported == true)
if (PrackSupported)
{
if (RSeq == 0)
{
Expand Down
2 changes: 1 addition & 1 deletion src/core/SIPTransactions/UACInviteTransaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ private async Task<SocketError> UACInviteTransaction_TransactionFinalResponseRec
// BranchId for 2xx responses needs to be a new one, non-2xx final responses use same one as original request.
if (sipResponse.StatusCode >= 200 && sipResponse.StatusCode < 299)
{
if (_sendOkAckManually == false)
if (!_sendOkAckManually)
{
AckRequest = GetAcknowledgeRequest(sipResponse, SIPMethodsEnum.ACK, sipResponse.Header.CSeq, null, null);
await SendRequestAsync(AckRequest).ConfigureAwait(false);
Expand Down
2 changes: 1 addition & 1 deletion src/core/SIPTransactions/UASInviteTransaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public SIPResponse GetOkResponse(string contentType, string messageBody)
okResponse.Header.MaxForwards = Int32.MinValue;
okResponse.Header.RecordRoutes = requestHeader.RecordRoutes;
okResponse.Header.Supported = SIPExtensionHeaders.REPLACES + ", " + SIPExtensionHeaders.NO_REFER_SUB
+ ((PrackSupported == true) ? ", " + SIPExtensionHeaders.PRACK : "");
+ (PrackSupported ? ", " + SIPExtensionHeaders.PRACK : "");

okResponse.Body = messageBody;
okResponse.Header.ContentType = contentType;
Expand Down
11 changes: 5 additions & 6 deletions src/net/ICE/RtpIceChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,7 @@ public void AddRemoteCandidate(RTCIceCandidate candidate)
{
OnIceCandidateError?.Invoke(candidate, $"Remote ICE candidate had an invalid port {candidate.port}.");
}
else if(IPAddress.TryParse(candidate.address, out var addrIPv6) &&
else if (IPAddress.TryParse(candidate.address, out var addrIPv6) &&
addrIPv6.AddressFamily == AddressFamily.InterNetworkV6 &&
!Socket.OSSupportsIPv6 &&
NetServices.HasActiveIPv6Address())
Expand Down Expand Up @@ -1506,12 +1506,12 @@ private void AddChecklistEntry(ChecklistEntry entry)

lock (_checklistLock)
{
var existingEntry = _checklist.Where(x =>
var existingEntry = _checklist.SingleOrDefault(x =>
x.LocalCandidate.type == entry.LocalCandidate.type
&& x.RemoteCandidate.DestinationEndPoint != null
&& x.RemoteCandidate.DestinationEndPoint.Address.Equals(entryRemoteEP.Address)
&& x.RemoteCandidate.DestinationEndPoint.Port == entryRemoteEP.Port
&& x.RemoteCandidate.protocol == entry.RemoteCandidate.protocol).SingleOrDefault();
&& x.RemoteCandidate.protocol == entry.RemoteCandidate.protocol);

if (existingEntry != null)
{
Expand Down Expand Up @@ -2270,8 +2270,7 @@ private IceServer GetIceServerForTransactionID(byte[] transactionID)
string txID = Encoding.ASCII.GetString(transactionID);

var entry = _iceServerConnections
.Where(x => x.Value.IsTransactionIDMatch(txID))
.SingleOrDefault();
.SingleOrDefault(x => x.Value.IsTransactionIDMatch(txID));

if (!entry.Equals(default(KeyValuePair<STUNUri, IceServer>)))
{
Expand Down Expand Up @@ -2669,7 +2668,7 @@ private async Task<IPAddress[]> ResolveMdnsName(RTCIceCandidate candidate)
{
if (MdnsResolve != null)
{
logger.LogWarning("RTP ICE channel has both "+ nameof(MdnsGetAddresses) + " and " + nameof(MdnsGetAddresses) + " set. Only " + nameof(MdnsGetAddresses) + " will be used.");
logger.LogWarning("RTP ICE channel has both " + nameof(MdnsGetAddresses) + " and " + nameof(MdnsGetAddresses) + " set. Only " + nameof(MdnsGetAddresses) + " will be used.");
}
return await MdnsGetAddresses(candidate.address).ConfigureAwait(false);
}
Expand Down
4 changes: 2 additions & 2 deletions src/net/WebRTC/RTCPeerConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1301,7 +1301,7 @@ void AddIceCandidates(SDPMediaAnnouncement announcement)
announcement.IceRole = IceRole;
announcement.DtlsFingerprint = dtlsFingerprint;

if (iceCandidatesAdded == false && !excludeIceCandidates)
if (!iceCandidatesAdded && !excludeIceCandidates)
{
AddIceCandidates(announcement);
iceCandidatesAdded = true;
Expand Down Expand Up @@ -1349,7 +1349,7 @@ void AddIceCandidates(SDPMediaAnnouncement announcement)
dataChannelAnnouncement.IceRole = IceRole;
dataChannelAnnouncement.DtlsFingerprint = dtlsFingerprint;

if (iceCandidatesAdded == false && !excludeIceCandidates)
if (!iceCandidatesAdded && !excludeIceCandidates)
{
AddIceCandidates(dataChannelAnnouncement);
iceCandidatesAdded = true;
Expand Down
2 changes: 1 addition & 1 deletion src/sys/StorageTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public enum StorageTypes

public class StorageTypesConverter
{
private static ILogger logger = Log.Logger;
private static readonly ILogger logger = Log.Logger;

public static StorageTypes GetStorageType(string storageType)
{
Expand Down
7 changes: 1 addition & 6 deletions src/sys/TypeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,7 @@ public static bool IsNullOrBlank(this string s)

public static bool NotNullOrBlank(this string s)
{
if (s == null || s.Trim(WhiteSpaceChars).Length == 0)
{
return false;
}

return true;
return !s.IsNullOrBlank();
}

public static long GetEpoch(this DateTime dateTime)
Expand Down
16 changes: 8 additions & 8 deletions test/integration/core/SIPTransportIntegrationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ await RunClient(
logger.LogWarning("Tasks timed out");
}

if (testComplete.Task.IsCompleted == false)
if (!testComplete.Task.IsCompleted)
{
// The client did not set the completed signal. This means the delay task must have completed and hence the test failed.
testComplete.SetResult(false);
Expand Down Expand Up @@ -132,7 +132,7 @@ await RunClient(
logger.LogWarning("Tasks timed out");
}

if (testComplete.Task.IsCompleted == false)
if (!testComplete.Task.IsCompleted)
{
// The client did not set the completed signal. This means the delay task must have completed and hence the test failed.
testComplete.SetResult(false);
Expand Down Expand Up @@ -188,7 +188,7 @@ await RunClient(
logger.LogWarning("Tasks timed out");
}

if (testComplete.Task.IsCompleted == false)
if (!testComplete.Task.IsCompleted)
{
// The client did not set the completed signal. This means the delay task must have completed and hence the test failed.
testComplete.SetResult(false);
Expand Down Expand Up @@ -237,7 +237,7 @@ await RunClient(
logger.LogWarning("Tasks timed out");
}

if (testComplete.Task.IsCompleted == false)
if (!testComplete.Task.IsCompleted)
{
// The client did not set the completed signal. This means the delay task must have completed and hence the test failed.
testComplete.SetResult(false);
Expand Down Expand Up @@ -291,7 +291,7 @@ public void IPv4TcpLoopbackConsecutiveSendReceiveTest()
logger.LogWarning("Tasks timed out");
}

if (testComplete.Task.IsCompleted == false)
if (!testComplete.Task.IsCompleted)
{
// The client did not set the completed signal. This means the delay task must have completed and hence the test failed.
testComplete.SetResult(false);
Expand Down Expand Up @@ -364,7 +364,7 @@ await RunClient(
logger.LogWarning("Tasks timed out");
}

if (testComplete.Task.IsCompleted == false)
if (!testComplete.Task.IsCompleted)
{
// The client did not set the completed signal. This means the delay task must have completed and hence the test failed.
testComplete.SetResult(false);
Expand Down Expand Up @@ -428,7 +428,7 @@ await RunClient(
logger.LogWarning("Tasks timed out");
}

if (testComplete.Task.IsCompleted == false)
if (!testComplete.Task.IsCompleted)
{
// The client did not set the completed signal. This means the delay task must have completed and hence the test failed.
testComplete.SetResult(false);
Expand Down Expand Up @@ -699,7 +699,7 @@ await RunClient(
logger.LogWarning("Tasks timed out");
}

if (testComplete.Task.IsCompleted == false)
if (!testComplete.Task.IsCompleted)
{
// The client did not set the completed signal. This means the delay task must have completed and hence the test failed.
testComplete.SetResult(false);
Expand Down
8 changes: 4 additions & 4 deletions test/unit/net/RTP/RTPSessionUnitTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,8 @@ public void AudioVideoOfferNoLocalVideoUnitTest()

var answer = localSession.CreateAnswer(null);

Assert.Equal(MediaStreamStatusEnum.SendRecv, answer.Media.Where(x => x.Media == SDPMediaTypesEnum.audio).Single().MediaStreamStatus);
Assert.Equal(MediaStreamStatusEnum.Inactive, answer.Media.Where(x => x.Media == SDPMediaTypesEnum.video).Single().MediaStreamStatus);
Assert.Equal(MediaStreamStatusEnum.SendRecv, answer.Media.Single(x => x.Media == SDPMediaTypesEnum.audio).MediaStreamStatus);
Assert.Equal(MediaStreamStatusEnum.Inactive, answer.Media.Single(x => x.Media == SDPMediaTypesEnum.video).MediaStreamStatus);

localSession.Close("normal");
remoteSession.Close("normal");
Expand Down Expand Up @@ -346,8 +346,8 @@ public void AudioVideoOfferNoLocalAudioUnitTest()

var answer = localSession.CreateAnswer(null);

Assert.Equal(MediaStreamStatusEnum.Inactive, answer.Media.Where(x => x.Media == SDPMediaTypesEnum.audio).Single().MediaStreamStatus);
Assert.Equal(MediaStreamStatusEnum.SendRecv, answer.Media.Where(x => x.Media == SDPMediaTypesEnum.video).Single().MediaStreamStatus);
Assert.Equal(MediaStreamStatusEnum.Inactive, answer.Media.Single(x => x.Media == SDPMediaTypesEnum.audio).MediaStreamStatus);
Assert.Equal(MediaStreamStatusEnum.SendRecv, answer.Media.Single(x => x.Media == SDPMediaTypesEnum.video).MediaStreamStatus);

localSession.Close("normal");
remoteSession.Close("normal");
Expand Down
Loading