SIPSorcery 8.0.20-pre

This is a prerelease version of SIPSorcery.
There is a newer version of this package available.
See the version list below for details.
dotnet add package SIPSorcery --version 8.0.20-pre
                    
NuGet\Install-Package SIPSorcery -Version 8.0.20-pre
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SIPSorcery" Version="8.0.20-pre" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SIPSorcery" Version="8.0.20-pre" />
                    
Directory.Packages.props
<PackageReference Include="SIPSorcery" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SIPSorcery --version 8.0.20-pre
                    
#r "nuget: SIPSorcery, 8.0.20-pre"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=SIPSorcery&version=8.0.20-pre&prerelease
                    
Install SIPSorcery as a Cake Addin
#tool nuget:?package=SIPSorcery&version=8.0.20-pre&prerelease
                    
Install SIPSorcery as a Cake Tool

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

License

⚠️ License Update (May 18, 2025)
This project is now dual-licensed under the BSD 3-Clause “New” or “Revised” License and the additional BDS BY-NC-SA restriction (see LICENSE § 2).

Key points of the BDS restriction:

  • No use inside Israel or the Occupied Territories until the 1967 occupation ends, equality for Arab-Palestinians is enshrined, and the right of return for Palestinian refugees is honored.
  • Everywhere else, the BSD 3-Clause terms apply, provided that any redistribution retains this BDS restriction and complies with Attribution-NonCommercial-ShareAlike.
  • In case of conflict, the BDS terms in Section 2 take precedence over Section 1.

Read the full text in LICENSE.

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.

Real-time Communications Overview

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.

  • This library provides only a small number of audio and video codecs (G711, G722 and G729). OPUS is available via Concentus. 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 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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.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 was computed.  net462 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (16)

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.

ivrToolkit.Plugin.SipSorcery

A SipSorcery plugin for the IvrToolkit. For use with ivrToolkit.Core. 100% c# SIP

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.

GitHub repositories (5)

Showing the top 5 popular GitHub repositories that depend on SIPSorcery:

Repository Stars
odedshimon/BruteShark
Network Analysis Tool
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# ORM - High Performance, SQL, NoSQL, Messaging, Pub-Sub
jihadkhawaja/Egroo
An open-source, privacy-focused social platform empowering users to connect securely and control their data.
qiuqiuqiu131/SukiChat.Client
Version Downloads Last updated
8.0.22 2,558 6/4/2025
8.0.21-pre 147 6/3/2025
8.0.20-pre 164 6/1/2025
8.0.15-pre 151 5/17/2025
8.0.14 4,629 5/8/2025
8.0.13 939 5/1/2025
8.0.12 1,460 4/24/2025
8.0.11 6,867 3/13/2025
8.0.10 1,438 3/9/2025
8.0.9 18,159 2/4/2025
8.0.7 13,810 1/4/2025
8.0.6 23,192 11/15/2024
8.0.5 274 11/15/2024
8.0.4 375 11/15/2024
8.0.3 4,598 11/8/2024
8.0.1 4,511 10/26/2024
8.0.0 15,353 9/27/2024
6.2.4 42,526 4/24/2024
6.2.3 1,515 4/16/2024
6.2.1 9,409 2/24/2024
6.2.0 26,802 1/14/2024
6.1.1-pre 1,917 12/13/2023
6.1.0-pre 1,289 12/10/2023
6.0.12 133,590 3/4/2023
6.0.11 65,991 9/12/2022
6.0.9 43,454 7/15/2022
6.0.8 4,892 6/14/2022
6.0.7 18,666 4/30/2022
6.0.6 8,623 2/11/2022
6.0.4 16,041 1/3/2022
6.0.3 7,739 11/28/2021
6.0.2 1,045 11/28/2021
6.0.1-pre 2,541 11/11/2021
5.3.3-pre 657 10/5/2021
5.3.0-pre 3,160 7/30/2021
5.2.3 21,653 6/26/2021
5.2.0 27,096 4/28/2021
5.1.8-pre 868 4/15/2021
5.1.7-pre 353 4/15/2021
5.1.6-pre 2,024 4/10/2021
5.1.5-pre 810 3/26/2021
5.1.4-pre 335 3/26/2021
5.1.2 8,224 3/11/2021
5.1.1 999 3/5/2021
5.1.0 2,977 2/17/2021
5.0.32-pre 344 2/14/2021
5.0.31-pre 263 2/13/2021
5.0.27-pre 463 2/8/2021
5.0.26-pre 326 2/7/2021
5.0.20-pre 294 2/4/2021
5.0.19-pre 287 2/4/2021
5.0.18-pre 297 2/2/2021
5.0.14-pre 425 1/28/2021
5.0.13-pre 285 1/27/2021
5.0.12-pre 426 1/21/2021
5.0.11-pre 636 1/19/2021
5.0.10-pre 286 1/15/2021
5.0.9-pre 283 1/13/2021
5.0.8-pre 302 1/10/2021
5.0.7-pre 815 12/27/2020
5.0.6-pre 304 12/26/2020
5.0.5-pre 384 12/21/2020
5.0.4-pre 329 12/21/2020
5.0.3 12,348 12/17/2020
5.0.2 775 12/13/2020
5.0.0 12,058 12/4/2020
4.0.91-pre 672 11/19/2020
4.0.90-pre 474 11/18/2020
4.0.89-pre 335 11/17/2020
4.0.88-pre 757 11/5/2020
4.0.87-pre 322 11/2/2020
4.0.86-pre 556 11/1/2020
4.0.85-pre 1,178 10/21/2020
4.0.84-pre 635 10/20/2020
4.0.83-pre 564 10/14/2020
4.0.82-pre 816 10/12/2020
4.0.81-pre 33,240 10/2/2020
4.0.80-pre 430 10/1/2020
4.0.79-pre 485 9/23/2020
4.0.78-pre 303 9/23/2020
4.0.77-pre 432 9/20/2020
4.0.76-pre 446 9/20/2020
4.0.75-pre 605 9/15/2020
4.0.74-pre 1,253 9/14/2020
4.0.71-pre 562 9/13/2020
4.0.70-pre 3,099 9/10/2020
4.0.69-pre 1,341 9/10/2020
4.0.67-pre 1,432 9/5/2020
4.0.61-pre 469 9/2/2020
4.0.60-pre 3,137 7/28/2020
4.0.59-pre 841 7/22/2020
4.0.58-pre 1,249 7/7/2020
4.0.55-pre 1,040 6/26/2020
4.0.51-pre 5,394 6/3/2020
4.0.50-pre 1,038 6/2/2020
4.0.49-pre 3,531 5/16/2020
4.0.47-pre 1,557 5/10/2020
4.0.46-pre 1,086 5/6/2020
4.0.45-pre 629 5/5/2020
4.0.44-pre 673 4/29/2020
4.0.43-pre 903 4/22/2020
4.0.42-pre 4,926 4/21/2020
4.0.41-pre 811 4/4/2020
4.0.40-pre 970 4/3/2020
4.0.35-pre 871 3/26/2020
4.0.34-pre 498 3/26/2020
4.0.33-pre 486 3/25/2020
4.0.32-pre 486 3/25/2020
4.0.31-pre 498 3/24/2020
4.0.30-pre 487 3/24/2020
4.0.29-pre 1,023 3/14/2020
4.0.28-pre 927 2/28/2020
4.0.13-pre 1,131 2/7/2020
4.0.8-rc 911 2/1/2020
4.0.7-rc 23,582 12/31/2019
4.0.4-rc 667 12/15/2019
4.0.3-rc 605 12/10/2019
4.0.2-rc 652 12/2/2019
4.0.1-rc 8,185 11/27/2019
4.0.0-rc 552 11/25/2019
3.6.0 4,939 11/14/2019
3.5.0 837 11/13/2019
3.4.0 767 11/7/2019
3.3.0 855 10/31/2019
3.2.0 7,867 10/26/2019
3.1.0 861 10/16/2019
3.0.4 792 10/13/2019
3.0.3 693 10/12/2019
3.0.2 723 10/8/2019
3.0.1 1,423 9/23/2019
3.0.0 876 9/22/2019
2.0.1 921 9/12/2019
2.0.0 820 9/12/2019
1.6.2 924 8/25/2019
1.6.1 3,828 4/15/2018
1.6.0 1,533 4/14/2018
1.5.6 3,429 4/21/2017
1.5.5 3,043 3/4/2016
1.5.3 1,521 2/29/2016
1.5.2 1,692 2/28/2016
1.5.0 1,845 2/24/2016
1.4.1 1,417 2/21/2016
1.4.0 2,135 10/29/2015
1.3.1 2,715 11/21/2014

-v8.0.20-pre: Improvements to the audio pipeline to avoid consumers needing to handle raw RTP packets.
-v8.0.15-pre: BouncyCastle update (thanks to @joaoladeiraext).
-v8.0.14: Fix for OPUS codec using multiple channels.
-v8.0.13: Added ASP.NET web socket signalling option for WebRTC. Bug fixes.
-v8.0.12: Bug fixes.
-v8.0.11: Real-time text (thanks to @xBasov). Bug fixes.
-v8.0.10: H265 and MJEG packetisation (thanks to @Drescher86), RTCP feedback improvements (thanks to @ispysoftware).
-v8.0.9: Minor improvements and bug fixes.
-v8.0.7: Bug fixes and all sipsorcery packages release.
-v8.0.6: Nuget publish.
-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.