Windows-specific audio capture, audio playback, and video capture end-points for the SIPSorcery real-time communications library. Built on NAudio for audio and Windows Media Foundation for video.
Use this package when:
- You're targeting Windows and want microphone / speaker / webcam access without pulling in FFmpeg.
- You need a quick way to give a SIPSorcery
RTPSessionsomething to send audio from and play received audio into.
For cross-platform audio + video, use SIPSorceryMedia.FFmpeg instead.
- Target:
net10.0-windows10.0.17763.0(Windows 10 1809+). - Runtime: Windows only -- the package PInvokes Windows-specific audio and video APIs.
dotnet add package SIPSorcery
dotnet add package SIPSorceryMedia.WindowsThe SIPSorceryMedia.Abstractions interfaces this package implements
come in transitively.
| Class | Implements | Purpose |
|---|---|---|
WindowsAudioEndPoint |
IAudioEndPoint (source + sink) |
Microphone capture and speaker playback. Wraps NAudio's WaveInEvent and WaveOutEvent. |
WindowsVideoEndPoint |
IVideoSource |
Webcam capture via Windows Media Foundation. Surfaces enumerated formats and resolutions. |
WindowsAudioSession |
IAudioSession |
Convenience pairing of audio source + sink + encoder. |
The audio end-point automatically resamples between the device's native sample rate and the codec's sample rate (e.g. 48 kHz device, 8 kHz G.711 codec).
The simplest possible example: place an outbound SIP audio call and hear the audio through Windows speakers.
dotnet new console --name SIPGetStarted --framework net10.0-windows10.0.17763.0
cd SIPGetStarted
dotnet add package SIPSorcery
dotnet add package SIPSorceryMedia.WindowsPaste into Program.cs:
using SIPSorcery.Media;
using SIPSorcery.SIP.App;
using SIPSorceryMedia.Windows;
const string DESTINATION = "music@iptel.org";
var userAgent = new SIPUserAgent();
var winAudio = new WindowsAudioEndPoint(new AudioEncoder());
var session = new VoIPMediaSession(winAudio.ToMediaEndPoints());
bool ok = await userAgent.Call(DESTINATION, null, null, session);
Console.WriteLine($"Call result: {(ok ? "success" : "failure")}");
Console.WriteLine("Press any key to hangup.");
Console.ReadLine();dotnet run -- you should hear the test audio.
The full sample lives at
examples/WebRTCExamples/WebRTCGetStarted.
Pair WindowsVideoEndPoint with a video encoder
(SIPSorceryMedia.FFmpeg's FFmpegVideoEncoder,
SIPSorcery.VP8, or a
custom IVideoEncoder) and feed the encoded samples into
RTCPeerConnection.SendVideo.
WindowsAudioEndPointdefaults to 8 kHz internal processing -- fine for narrow-band G.711 / G.722 codecs which are the most common in VoIP.- For wide-band Opus or 48 kHz codecs, construct the end-point with
the higher sample rate so internal resampling is minimised:
new WindowsAudioEndPoint(new AudioEncoder(), audioSampleRate: 48000).
- SIPSorcery -- the main real-time communications library.
- SIPSorceryMedia.Abstractions -- the interfaces this package implements.
- SIPSorceryMedia.FFmpeg -- cross-platform alternative built on FFmpeg.
BSD 3-Clause License. See LICENSE at the repo root.