SIPSorcery 8.0.4
See the version list below for details.
dotnet add package SIPSorcery --version 8.0.4
NuGet\Install-Package SIPSorcery -Version 8.0.4
<PackageReference Include="SIPSorcery" Version="8.0.4" />
paket add SIPSorcery --version 8.0.4
#r "nuget: SIPSorcery, 8.0.4"
// Install SIPSorcery as a Cake Addin #addin nuget:?package=SIPSorcery&version=8.0.4 // Install SIPSorcery as a Cake Tool #tool nuget:?package=SIPSorcery&version=8.0.4
CI | win-x64 | linux-x64 | osx-x64 | Examples <br/> (win-x64) |
---|---|---|---|---|
<sup>GitHub Actions</sup> |
What Is It?
This fully C# library can be used to add Real-time Communications, typically audio and video calls, to .NET applications.
The diagram below is a high level overview of a Real-time audio and video call between Alice and Bob. It illustrates where the SIPSorcery
and associated libraries can help.
Supports both VoIP (get started) and WebRTC (get started).
Some of the protocols supported:
- Session Initiation Protocol (SIP),
- Real-time Transport Protocol (RTP),
- Web Real-time Communications (WebRTC), as of 26 Jan 2021 now an official IETF and W3C specification,
- Interactive Connectivity Establishment (ICE),
- SCTP, SDP, STUN and more.
Media End Points - Audio/Video Sinks and Sources:
The main
SIPSorcery
library does not provide access to audio and video devices or native codecs. Providing cross platform access to to these features on top of .NET is a large undertaking. A number of separate demonstration libraries show some different approaches to accessing audio/video devices and wrapping codecs with .NET.- SIPSorceryMedia.Windows: An example of a Windows specific library that provides audio capture and playback.
- SIPSorceryMedia.Encoders: An example of a Windows specific wrapper for the VP8 video codec.
- SIPSorceryMedia.FFmpeg: An example of a cross platform library that features audio and video codecs using PInvoke and FFmpeg.
- Others: Contributions welcome. Frequently requested are Xamarin Forms on Android/iOS and Unix (Linux and/or Mac). New implementations need to implement one or more of the Audio Sink/Source and/or Video Sink/Source interfaces from SIPSorceryMedia.Abstractions.
This library provides only a small number of audio and video codecs (G711 and G722). Additional codecs, particularly video ones, require C or C++ libraries. An effort is underway to port the VP8 video codec to C# see VP8.Net.
Installation
The library is should work with .NET Framework >= 4.6.1 and all .NET Core and .NET versions. The demo applications initially targetted .NET Core 3.1 and are updated to later .NET versions as time and interest permit. The library is available via NuGet.
dotnet add package SIPSorcery
With Visual Studio Package Manager Console (or search for SIPSorcery on NuGet):
Install-Package SIPSorcery
Documentation
Class reference documentation and articles explaining common usage are available at https://sipsorcery-org.github.io/sipsorcery/.
Getting Started VoIP
The simplest possible example to place an audio-only SIP call is shown below. This example relies on the Windows specific SIPSorceryMedia.Windows
library to play the received audio and only works on Windows (due to lack of .NET audio device support on non-Windows platforms).
dotnet new console --name SIPGetStarted --framework net8.0 --target-framework-override net8.0-windows10.0.17763.0
cd SIPGetStarted
dotnet add package SIPSorcery
dotnet add package SIPSorceryMedia.Windows
# Paste the code below into Program.cs.
dotnet run
# If successful you will hear a "Hello World" announcement.
string DESTINATION = "music@iptel.org";
Console.WriteLine("SIP Get Started");
var userAgent = new SIPSorcery.SIP.App.SIPUserAgent();
var winAudio = new SIPSorceryMedia.Windows.WindowsAudioEndPoint(new SIPSorcery.Media.AudioEncoder());
var voipMediaSession = new SIPSorcery.Media.VoIPMediaSession(winAudio.ToMediaEndPoints());
// Place the call and wait for the result.
bool callResult = await userAgent.Call(DESTINATION, null, null, voipMediaSession);
Console.WriteLine($"Call result {(callResult ? "success" : "failure")}.");
Console.WriteLine("Press any key to hangup and exit.");
Console.ReadLine();
The GetStarted example contains the full source and project file for the example above.
The three key classes in the above example are described in dedicated articles:
The examples folder contains sample code to demonstrate other common SIP/VoIP cases.
Getting Started WebRTC
The WebRTC specifications do not include directions about how signaling should be done (for VoIP the signaling protocol is SIP; WebRTC has no equivalent). The example below uses a simple JSON message exchange over web sockets for signaling. Part of the reason the Getting Started WebRTC
is longer than the Getting Started VoIP
example is the need for custom signaling.
The example requires two steps:
- Run the
dotnet
console application, - Open an HTML page in a browser on the same machine.
The full project file and code are available at WebRTC Get Started.
The example relies on the Windows specific SIPSorceryMedia.Encoders
package, which is mainly a wrapper around libvpx. Hopefully in the future there will be equivalent packages for other platforms.
Step 1:
dotnet new console --name WebRTCGetStarted
cd WebRTCGetStarted
dotnet add package SIPSorcery
dotnet add package SIPSorceryMedia.Encoders
# Paste the code below into Program.cs.
dotnet run
using System;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
using SIPSorcery.Media;
using SIPSorcery.Net;
using SIPSorceryMedia.Encoders;
using WebSocketSharp.Server;
namespace demo
{
class Program
{
private const int WEBSOCKET_PORT = 8081;
static void Main()
{
Console.WriteLine("WebRTC Get Started");
// Start web socket.
Console.WriteLine("Starting web socket server...");
var webSocketServer = new WebSocketServer(IPAddress.Any, WEBSOCKET_PORT);
webSocketServer.AddWebSocketService<WebRTCWebSocketPeer>("/", (peer) => peer.CreatePeerConnection = () => CreatePeerConnection());
webSocketServer.Start();
Console.WriteLine($"Waiting for web socket connections on {webSocketServer.Address}:{webSocketServer.Port}...");
Console.WriteLine("Press any key exit.");
Console.ReadLine();
}
private static Task<RTCPeerConnection> CreatePeerConnection()
{
var pc = new RTCPeerConnection(null);
var testPatternSource = new VideoTestPatternSource(new VpxVideoEncoder());
MediaStreamTrack videoTrack = new MediaStreamTrack(testPatternSource.GetVideoSourceFormats(), MediaStreamStatusEnum.SendOnly);
pc.addTrack(videoTrack);
testPatternSource.OnVideoSourceEncodedSample += pc.SendVideo;
pc.OnVideoFormatsNegotiated += (formats) => testPatternSource.SetVideoSourceFormat(formats.First());
pc.onconnectionstatechange += async (state) =>
{
Console.WriteLine($"Peer connection state change to {state}.");
switch(state)
{
case RTCPeerConnectionState.connected:
await testPatternSource.StartVideo();
break;
case RTCPeerConnectionState.failed:
pc.Close("ice disconnection");
break;
case RTCPeerConnectionState.closed:
await testPatternSource.CloseVideo();
testPatternSource.Dispose();
break;
}
};
return Task.FromResult(pc);
}
}
}
Step 2:
Create an HTML file, paste the contents below into it, open it in a browser that supports WebRTC and finally press the start
button.
<!DOCTYPE html>
<head>
<script type="text/javascript">
const WEBSOCKET_URL = "ws://127.0.0.1:8081/"
var pc, ws;
async function start() {
pc = new RTCPeerConnection();
pc.ontrack = evt => document.querySelector('#videoCtl').srcObject = evt.streams[0];
pc.onicecandidate = evt => evt.candidate && ws.send(JSON.stringify(evt.candidate));
ws = new WebSocket(document.querySelector('#websockurl').value, []);
ws.onmessage = async function (evt) {
var obj = JSON.parse(evt.data);
if (obj?.candidate) {
pc.addIceCandidate(obj);
}
else if (obj?.sdp) {
await pc.setRemoteDescription(new RTCSessionDescription(obj));
pc.createAnswer()
.then((answer) => pc.setLocalDescription(answer))
.then(() => ws.send(JSON.stringify(pc.localDescription)));
}
};
};
async function closePeer() {
await pc?.close();
await ws?.close();
};
</script>
</head>
<body>
<video controls autoplay="autoplay" id="videoCtl" width="640" height="480"></video>
<div>
<input type="text" id="websockurl" size="40" />
<button type="button" class="btn btn-success" onclick="start();">Start</button>
<button type="button" class="btn btn-success" onclick="closePeer();">Close</button>
</div>
</body>
<script>
document.querySelector('#websockurl').value = WEBSOCKET_URL;
</script>
Result:
If successful the browser should display a test pattern image.
The examples folder contains sample code to demonstrate other common WebRTC cases.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 is compatible. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
.NET Framework | net461 is compatible. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETCoreApp 3.1
- DnsClient (>= 1.7.0)
- Portable.BouncyCastle (>= 1.9.0)
- SIPSorcery.WebSocketSharp (>= 0.0.1)
- SIPSorceryMedia.Abstractions (>= 1.2.1)
- System.Net.WebSockets.Client (>= 4.3.2)
-
.NETFramework 4.6.1
- DnsClient (>= 1.7.0)
- Portable.BouncyCastle (>= 1.9.0)
- SIPSorcery.WebSocketSharp (>= 0.0.1)
- SIPSorceryMedia.Abstractions (>= 1.2.1)
- System.Net.WebSockets.Client (>= 4.3.2)
-
.NETStandard 2.0
- DnsClient (>= 1.7.0)
- Portable.BouncyCastle (>= 1.9.0)
- SIPSorcery.WebSocketSharp (>= 0.0.1)
- SIPSorceryMedia.Abstractions (>= 1.2.1)
- System.Net.WebSockets.Client (>= 4.3.2)
-
.NETStandard 2.1
- DnsClient (>= 1.7.0)
- Portable.BouncyCastle (>= 1.9.0)
- SIPSorcery.WebSocketSharp (>= 0.0.1)
- SIPSorceryMedia.Abstractions (>= 1.2.1)
- System.Net.WebSockets.Client (>= 4.3.2)
-
net5.0
- DnsClient (>= 1.7.0)
- Portable.BouncyCastle (>= 1.9.0)
- SIPSorcery.WebSocketSharp (>= 0.0.1)
- SIPSorceryMedia.Abstractions (>= 1.2.1)
- System.Net.WebSockets.Client (>= 4.3.2)
-
net6.0
- DnsClient (>= 1.7.0)
- Portable.BouncyCastle (>= 1.9.0)
- SIPSorcery.WebSocketSharp (>= 0.0.1)
- SIPSorceryMedia.Abstractions (>= 1.2.1)
- System.Net.WebSockets.Client (>= 4.3.2)
-
net8.0
- DnsClient (>= 1.7.0)
- Portable.BouncyCastle (>= 1.9.0)
- SIPSorcery.WebSocketSharp (>= 0.0.1)
- SIPSorceryMedia.Abstractions (>= 1.2.1)
- System.Net.WebSockets.Client (>= 4.3.2)
NuGet packages (12)
Showing the top 5 NuGet packages that depend on SIPSorcery:
Package | Downloads |
---|---|
SIPSorceryMedia
The SIPSorcery package for WebRTC plumbing and Windows audio and video capture. |
|
Resonance.WebRTC
WebRTC Adapter for Resonance. Resonance is a high-performance real-time C# communication library with built-in support for several different transcoding and delivery methods. This library provides an intuitive API for asynchronous communication between machines and devices by exposing a set of easy to use, pluggable components. |
|
WebRTC.Healthcheck
Simple healthcheck for WebRTC |
|
WebRTCme
WebRTC library with a single, unified API for .NET MAUI and Blazor middlewares/applications. |
|
QCR575DotNet
Package Description |
GitHub repositories (4)
Showing the top 4 popular GitHub repositories that depend on SIPSorcery:
Repository | Stars |
---|---|
odedshimon/BruteShark
Network Analysis Tool
|
|
sipsorcery-org/sipsorcery
A WebRTC, SIP and VoIP library for C# and .NET. Designed for real-time communications apps.
|
|
melihercan/WebRTCme
A cross-platform framework for adding WebRTC support to .NET MAUI, Blazor, and Desktop applications by using a single unified .NET/C# API.
|
|
friflo/Friflo.Json.Fliox
C# ECS + ORM
|
Version | Downloads | Last updated |
---|---|---|
8.0.6 | 1,209 | 11/15/2024 |
8.0.5 | 93 | 11/15/2024 |
8.0.4 | 171 | 11/15/2024 |
8.0.3 | 1,478 | 11/8/2024 |
8.0.1 | 1,783 | 10/26/2024 |
8.0.0 | 6,412 | 9/27/2024 |
6.2.4 | 30,180 | 4/24/2024 |
6.2.3 | 1,162 | 4/16/2024 |
6.2.1 | 7,624 | 2/24/2024 |
6.2.0 | 21,098 | 1/14/2024 |
6.1.1-pre | 1,620 | 12/13/2023 |
6.1.0-pre | 1,252 | 12/10/2023 |
6.0.12 | 102,207 | 3/4/2023 |
6.0.11 | 61,408 | 9/12/2022 |
6.0.9 | 36,889 | 7/15/2022 |
6.0.8 | 4,712 | 6/14/2022 |
6.0.7 | 17,351 | 4/30/2022 |
6.0.6 | 7,834 | 2/11/2022 |
6.0.4 | 15,027 | 1/3/2022 |
6.0.3 | 7,078 | 11/28/2021 |
6.0.2 | 799 | 11/28/2021 |
6.0.1-pre | 2,491 | 11/11/2021 |
5.3.3-pre | 601 | 10/5/2021 |
5.3.0-pre | 2,791 | 7/30/2021 |
5.2.3 | 20,703 | 6/26/2021 |
5.2.0 | 26,395 | 4/28/2021 |
5.1.8-pre | 813 | 4/15/2021 |
5.1.7-pre | 300 | 4/15/2021 |
5.1.6-pre | 1,969 | 4/10/2021 |
5.1.5-pre | 753 | 3/26/2021 |
5.1.4-pre | 281 | 3/26/2021 |
5.1.2 | 7,064 | 3/11/2021 |
5.1.1 | 923 | 3/5/2021 |
5.1.0 | 2,665 | 2/17/2021 |
5.0.32-pre | 284 | 2/14/2021 |
5.0.31-pre | 207 | 2/13/2021 |
5.0.27-pre | 402 | 2/8/2021 |
5.0.26-pre | 268 | 2/7/2021 |
5.0.20-pre | 235 | 2/4/2021 |
5.0.19-pre | 225 | 2/4/2021 |
5.0.18-pre | 236 | 2/2/2021 |
5.0.14-pre | 368 | 1/28/2021 |
5.0.13-pre | 223 | 1/27/2021 |
5.0.12-pre | 365 | 1/21/2021 |
5.0.11-pre | 560 | 1/19/2021 |
5.0.10-pre | 229 | 1/15/2021 |
5.0.9-pre | 222 | 1/13/2021 |
5.0.8-pre | 242 | 1/10/2021 |
5.0.7-pre | 749 | 12/27/2020 |
5.0.6-pre | 247 | 12/26/2020 |
5.0.5-pre | 323 | 12/21/2020 |
5.0.4-pre | 271 | 12/21/2020 |
5.0.3 | 7,916 | 12/17/2020 |
5.0.2 | 707 | 12/13/2020 |
5.0.0 | 11,880 | 12/4/2020 |
4.0.91-pre | 603 | 11/19/2020 |
4.0.90-pre | 409 | 11/18/2020 |
4.0.89-pre | 272 | 11/17/2020 |
4.0.88-pre | 687 | 11/5/2020 |
4.0.87-pre | 261 | 11/2/2020 |
4.0.86-pre | 436 | 11/1/2020 |
4.0.85-pre | 1,120 | 10/21/2020 |
4.0.84-pre | 574 | 10/20/2020 |
4.0.83-pre | 503 | 10/14/2020 |
4.0.82-pre | 756 | 10/12/2020 |
4.0.81-pre | 33,175 | 10/2/2020 |
4.0.80-pre | 370 | 10/1/2020 |
4.0.79-pre | 422 | 9/23/2020 |
4.0.78-pre | 243 | 9/23/2020 |
4.0.77-pre | 373 | 9/20/2020 |
4.0.76-pre | 386 | 9/20/2020 |
4.0.75-pre | 545 | 9/15/2020 |
4.0.74-pre | 1,143 | 9/14/2020 |
4.0.71-pre | 499 | 9/13/2020 |
4.0.70-pre | 2,999 | 9/10/2020 |
4.0.69-pre | 497 | 9/10/2020 |
4.0.67-pre | 1,219 | 9/5/2020 |
4.0.61-pre | 408 | 9/2/2020 |
4.0.60-pre | 3,032 | 7/28/2020 |
4.0.59-pre | 779 | 7/22/2020 |
4.0.58-pre | 1,188 | 7/7/2020 |
4.0.55-pre | 978 | 6/26/2020 |
4.0.51-pre | 5,333 | 6/3/2020 |
4.0.50-pre | 975 | 6/2/2020 |
4.0.49-pre | 3,466 | 5/16/2020 |
4.0.47-pre | 1,425 | 5/10/2020 |
4.0.46-pre | 1,018 | 5/6/2020 |
4.0.45-pre | 563 | 5/5/2020 |
4.0.44-pre | 608 | 4/29/2020 |
4.0.43-pre | 836 | 4/22/2020 |
4.0.42-pre | 3,596 | 4/21/2020 |
4.0.41-pre | 748 | 4/4/2020 |
4.0.40-pre | 907 | 4/3/2020 |
4.0.35-pre | 807 | 3/26/2020 |
4.0.34-pre | 432 | 3/26/2020 |
4.0.33-pre | 420 | 3/25/2020 |
4.0.32-pre | 424 | 3/25/2020 |
4.0.31-pre | 433 | 3/24/2020 |
4.0.30-pre | 423 | 3/24/2020 |
4.0.29-pre | 957 | 3/14/2020 |
4.0.28-pre | 863 | 2/28/2020 |
4.0.13-pre | 1,066 | 2/7/2020 |
4.0.8-rc | 843 | 2/1/2020 |
4.0.7-rc | 23,518 | 12/31/2019 |
4.0.4-rc | 603 | 12/15/2019 |
4.0.3-rc | 530 | 12/10/2019 |
4.0.2-rc | 587 | 12/2/2019 |
4.0.1-rc | 8,122 | 11/27/2019 |
4.0.0-rc | 487 | 11/25/2019 |
3.6.0 | 4,652 | 11/14/2019 |
3.5.0 | 761 | 11/13/2019 |
3.4.0 | 691 | 11/7/2019 |
3.3.0 | 772 | 10/31/2019 |
3.2.0 | 6,188 | 10/26/2019 |
3.1.0 | 781 | 10/16/2019 |
3.0.4 | 714 | 10/13/2019 |
3.0.3 | 620 | 10/12/2019 |
3.0.2 | 647 | 10/8/2019 |
3.0.1 | 1,344 | 9/23/2019 |
3.0.0 | 762 | 9/22/2019 |
2.0.1 | 823 | 9/12/2019 |
2.0.0 | 704 | 9/12/2019 |
1.6.2 | 842 | 8/25/2019 |
1.6.1 | 3,579 | 4/15/2018 |
1.6.0 | 1,298 | 4/14/2018 |
1.5.6 | 3,261 | 4/21/2017 |
1.5.5 | 2,874 | 3/4/2016 |
1.5.3 | 1,349 | 2/29/2016 |
1.5.2 | 1,517 | 2/28/2016 |
1.5.0 | 1,656 | 2/24/2016 |
1.4.1 | 1,248 | 2/21/2016 |
1.4.0 | 1,958 | 10/29/2015 |
1.3.1 | 2,302 | 11/21/2014 |
-v8.0.4: Bug fixes.
-v8.0.3: Bug fixes.
-v8.0.1-pre: Performance improvements (thanks to @weltmeyer). Add ECDSA as default option for WebRTC DTLS.
-v8.0.0: RTP header extension improvements (thanks to @ChristopheI). Major version to 8 to reflect highest .net runtime supported.
-v6.2.4: WebRTC fix for DTLS change in Chrome v124.
-v6.2.3: Bug fixes.
-v6.2.1: Bug fixes.
-v6.2.0: Stable release. Added net8 target.
-v6.1.1-pre: Reverted BouncyCastle update.
-v6.1.0-pre: BouncyCastle depency update. Bug fixes.
-v6.0.12: Bug fixes.
-v6.0.11: Bug fixes.
-v6.0.9: Supporting custom SIP TLS certificate validation callback. SCTP improvements.
-v6.0.8: Multiple audio and video stream support and other fixes.
-v6.0.7: Synchronise with audio/video abstractions library.
-v6.0.6: Minor bug fixes. G729 codec thanks to @edscodeblenders.
-v6.0.4: SIPUserAgent hangup fixes. SIP Expire header fix. Other minor bug fixes.
-v6.0.3: No changes. Aligning release tag.
-v6.0.2: Set .net6 targetted version as stable.
-v6.0.1-pre: Added .net6 target.