.NET Server SDK

The Vonage Video .NET SDK provides methods for:

Installation

Either look for "Vonage" is your package manager, or run the following command using the Package Manager Console:

Or a terminal:

Usage

Initializing

The Vonage packages uses a JWT for Authorization. The SDK handles JWT generation in the background for you, but will require an ApplicationId and PrivateKey as credentials in order to generate the token.

These credentials are loaded from your project settings. For more details on how to do that, feel free to take a look at the Configuration section.

Otherwise, you can initialize the client manually, like below:

The Video client exposes various functionalities of our Video APIs.

How to handle Video results

Every method will return the response wrapped into a Result<T> Monad, where T is the type of the response.

It contains either a Success state (T) if the operation succeeded or a Failure state (IResultFailure) if something went wrong. The failure contains an error message and can be converted to the according exception. It can represent any kind of issue:

  • invalid request
  • failed authentication
  • failed request
  • failed data deserialization
  • etc.

You can use .Match() to provide methods for both states, or you can call .GetSuccessUnsafe to get the response and catch an exception if the process failed. It contains also other methods to manipulate, transform and extract the underlying result.

Mode details and explanations on the repository.

Creating Sessions

To create a Vonage Video Session, call the client's VideoClient.SessionClient.CreateSessionAsync(CreateSessionRequest)method. You can use a default request with all default values, or create a custom one using the .Build() method.

  • location : An IPv4 address used as a location hint. (default: string.empty)
  • MediaMode : Specifies whether the session will use the Vonage Video Media Router) (MediaMode.ROUTED) or attempt to transmit streams directly between clients (MediaMode.RELAYED, the default). A routed session is required for some Vonage Video features (such as archiving).
  • ArchiveMode : Specifies whether the session will be automatically archived (ArchiveMode.ALWAYS) or not (ArchiveMode.MANUAL, the default)

The return value is a Result<CreateSessionResponse> object.

Generating Tokens

Once a Session is created, you can start generating Tokens for clients to use when connecting to it. You can generate a token by calling the GenerateToken method.

Working with Archives

You can only archive sessions that use the Vonage Video Media Router (sessions with the media mode set to routed).

Creating an archive

You can start the recording of a Vonage Video Session using VideoClient.ArchiveClient.CreateArchiveAsync(CreateSessionRequest) method. The return value is a Result<CreateArchiveRequest> object.

Note that you can only start an Archive on a Session that has clients connected.

Here are all the methods you can use on the builder:

  • WithName allows you to add a name for the archive (to use for identification).
  • DisableVideo allows you to disable video recording.
  • DisableAudio allows you to disable audio recording.
  • WithResolution allows you to set the resolution of the recording. Please note that you cannot specify the resolution when you set the outputMode parameter to OutputMode.INDIVIDUAL.
  • WithOutputMode allows you to set the output mode on the stream. By default, all streams are recorded to a single ( composed) file. You can record the different streams in the session to individual files (instead of a single composed file) by providing OutputMode.INDIVIDUAL.
  • WithStreamMode allows you to indicate whether streams are selected automatically or manually.

Stopping an archive

You can stop the recording of a started Archive using the VideoClient.ArchiveClient.StopArchiveAsync(StopArchiveRequest) method.

Retrieving an archive

You can retrieve an Archive, with all its information, using the VideoClient.ArchiveClient.GetArchiveAsync(GetArchiveRequest) method.

Deleting an archive

You can delete an archive using the VideoClient.ArchiveClient.DeleteArchiveAsync(DeleteArchiveRequest) method.

Retrieving all archives

You can retrieve a list of all the Archives you've created, up to 1000 archives, using the VideoClient.ArchiveClient.GetArchivesAsync(GetArchivesRequest) method.

This request supports pagination using WithCount and WithOffset on the builder.

Working with Streams

Retrieving a stream

You can retrieve a Stream, with all its information, using the VideoClient.SessionClient.GetStreamAsync(GetStreamRequest) method.

Retrieving all streams

You can retrieve all the streams in a session, using the VideoClient.SessionClient.GetStreamsAsync(GetStreamsRequest) method.

Force Disconnecting

Your application server can disconnect a client from a Vonage Video session using the VideoClient.ModerationClient.DisconnectConnectionAsync(DisconnectConnectionRequest) method.

Sending Signals

Once a Session is created, you can send signals to everyone in the session or to a specific connection.

The Content parameter is an instance of SignalContent, where you can set type and data.

  • type (string): The type string for the signal. You can send a maximum of 128 characters, and only the following characters are allowed: A-Z, a-z, numbers (0-9), '-', '_', and '~'.
  • data (string): The data string for the signal. You can send a maximum of 8kB.

Working with live streaming broadcasts

Starting a broadcast

You can start a live-streaming broadcast of a Vonage Video Session using the VonageClient.BroadcastClient.StartBroadcastsAsync(StartBroadcastRequest) method.

Stopping a broadcast

You can stop a broadcast using the VonageClient.BroadcastClient.StopBroadcastsAsync(StopBroadcastRequest) method.

Also see the documentation for the VonageClient.BroadcastClient.StopBroadcastsAsync(StopBroadcastRequest) and VonageClient.BroadcastClient.GetBroadcastsAsync(GetBroadcastRequest) methods.

Retrieving a broadcast

You can retrieve a broadcast using the VonageClient.BroadcastClient.StopBroadcastsAsync(StopBroadcastRequest) method.

Retrieving broadcasts

You can retrieve all broadcast using the VonageClient.BroadcastClient.StopBroadcastsAsync(StopBroadcastRequest) method. This method supports pagination too.

SIP

Initiating a SIP call

You can connect a SIP platform to a Vonage Video session using the VonageClient.SipClient.InitiateCallAsync(InitiateCallRequest) method.

Playing a tone

You can send DTMF digits to all participants an active Vonage Video session, or to a specific client connected to that session.

Forcing clients in a session to mute published audio

You can force the publisher to stop publishing audio, for a specific stream or all streams in a session.

Requirements

You need an application with Video capabilities enabled. The ApplicationId and the PrivateKey will be required for authentication.

You need a Vonage Video API key and API secret, which you can obtain by logging into your Vonage Video API account.

The Vonage .NET SDK targets netstandard2.0, which is compatible with all supported frameworks.

Release Notes

See the .NET SDK changelog page for details about each release.