Skip to content

Repository files navigation

Logo C# RTSP Client for .NET

NuGet version (RtspClientSharp)Build Status

This repo contains C# RTSP client implementation (called "RtspClientSharp") for .NET Standard 2.0

Features

  • Supported transport protocols: TCP/HTTP/UDP
  • Supported media codecs: H.264/MJPEG/AAC/G711A/G711U/PCM/G726
  • No external dependencies, pure C# code
  • Asynchronous nature with cancellation tokens support
  • Designed to be fast and scaleable
  • Low GC pressure during receive stage (when RTSP session is established); low amount of freezes under high load

Installation

The easiest way to get started is to use the NuGet package for RtspClientSharp

You can install using NuGet like this:

nuget install RtspClientSharp

Or select it from the NuGet packages UI on Visual Studio.

On Visual Studio, make sure that you are targeting .NET 4.6.1/.NET Core 2.0 or later, as this package uses some features of newer .NETs. Otherwise, the package will not be added. Once you do this, you can just use the RtspClientSharp nuget

Alternatively, you can download it directly.

Using RtspClientSharp

Something like this:

varserverUri=newUri("rtsp://192.168.1.77:554/ucast/11");varcredentials=newNetworkCredential("admin","123456");varconnectionParameters=newConnectionParameters(serverUri,credentials);connectionParameters.RtpTransport=RtpTransportProtocol.TCP;using(varrtspClient=newRtspClient(connectionParameters)){rtspClient.FrameReceived+=(sender,frame)=>{//process (e.g. decode/save to file) encoded frame here or //make deep copy to use it later because frame buffer (see FrameSegment property) will be reused by clientswitch(frame){caseRawH264IFrameh264IFrame:caseRawH264PFrameh264PFrame:caseRawJpegFramejpegFrame:caseRawAACFrameaacFrame:caseRawG711AFrameg711AFrame:caseRawG711UFrameg711UFrame:caseRawPCMFramepcmFrame:caseRawG726Frameg726Frame:break;}}
await rtspClient.ConnectAsync(token);awaitrtspClient.ReceiveAsync(token);}

You could find more complex samples here (e.g. simple RTSP player with full frame decoding and rendering processes): https://github.com/BogdanovKirill/RtspClientSharp/tree/master/Examples

Donation

If this project help you reduce time to develop, you can give me a cup of coffee :) You could also make per-feature donations, write me to bogdanov.kv@bk.ru

paypal

About

Pure C# RTSP client for .NET Standard without external dependencies and with true async nature. I welcome contributions.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages