Table of Contents

Class WebRTCSinkBlock

Namespace
VisioForge.Core.MediaBlocks.Sinks
Assembly
VisioForge.Core.dll

WebRTC sink block that streams audio and video straight to web browsers, with no media server.

public class WebRTCSinkBlock : MediaBlock, IMediaBlock, IDisposable, IMediaBlockInternals, IMediaBlockDynamicInputs

Inheritance

Implements

Inherited Members

Extension Methods

Remarks

The block runs its own WebSocket signalling server and, when VisioForge.Core.Types.X.Sinks.WebRTCSinkSettings.WebServerDirectory is set, an HTTP server for the viewer page. Every browser that connects gets its own WebRTC session, encoder and congestion control.

Inputs take raw video and audio (the block encodes them per viewer, video to VP8 and audio to Opus) or already encoded VP8 video and Opus audio, sent without re-encoding.

Constructors

WebRTCSinkBlock(WebRTCSinkSettings)

Initializes a new instance of the VisioForge.Core.MediaBlocks.Sinks.WebRTCSinkBlock class.

public WebRTCSinkBlock(WebRTCSinkSettings settings)

Parameters

settings WebRTCSinkSettings

The WebRTC sink settings.

Properties

Input

Gets the first input pad.

public override MediaBlockPad Input { get; }

Property Value

MediaBlockPad

Inputs

Gets all input pads.

public override MediaBlockPad[] Inputs { get; }

Property Value

MediaBlockPad[]

Output

Gets the output pad. Always null for sink blocks.

public override MediaBlockPad Output { get; }

Property Value

MediaBlockPad

Outputs

Gets all output pads. Always empty for sink blocks.

public override MediaBlockPad[] Outputs { get; }

Property Value

MediaBlockPad[]

Settings

Gets or sets the WebRTC sink settings.

public WebRTCSinkSettings Settings { get; set; }

Property Value

WebRTCSinkSettings

Type

Gets the media block type identifier.

public override MediaBlockType Type { get; }

Property Value

MediaBlockType

Methods

Build()

Builds the webrtcsink element and requests one of its pads per input.

public override bool Build()

Returns

bool

true if successful; false otherwise.

CleanUp()

Cleans up resources.

public void CleanUp()

CreateNewInput(MediaBlockPadMediaType)

Creates a new input pad for a video or audio stream.

public MediaBlockPad CreateNewInput(MediaBlockPadMediaType mediaType)

Parameters

mediaType MediaBlockPadMediaType

The type of media stream to accept.

Returns

MediaBlockPad

A new VisioForge.Core.MediaBlocks.MediaBlockPad configured for the specified media type.

Dispose(bool)

Releases resources.

protected override void Dispose(bool disposing)

Parameters

disposing bool

Whether to release managed resources.

GetCore()

Gets the core GStreamer wrapper element.

public BaseElement GetCore()

Returns

BaseElement

The VisioForge.Core.GStreamer.Base.BaseElement wrapper.

GetElement()

Gets the native GStreamer element.

public Element GetElement()

Returns

Element

The underlying Gst.Element.

GetFilenameOrURL()

Gets the address of the viewer page web server.

public string GetFilenameOrURL()

Returns

string

The web server address.

GetInput(MediaBlockPadMediaType)

Gets an existing input pad matching the specified media type.

public MediaBlockPad GetInput(MediaBlockPadMediaType mediaType)

Parameters

mediaType MediaBlockPadMediaType

The media type to search for.

Returns

MediaBlockPad

The matching pad, or null if not found.

IsAvailable()

Determines whether this media block is available.

public static bool IsAvailable()

Returns

bool

true if this media block is available; otherwise, false.

SetFilenameOrURL(string)

Sets the address of the viewer page web server.

public void SetFilenameOrURL(string value)

Parameters

value string

The web server address.

IMediaBlockInternals.SetContext(MediaBlocksPipeline)

Sets the pipeline context.

void IMediaBlockInternals.SetContext(MediaBlocksPipeline pipeline)

Parameters

pipeline MediaBlocksPipeline

The owning pipeline.

ConsumerAdded

Occurs when a browser connects. Raised from a GStreamer thread.

public event EventHandler<WebRTCConsumerEventArgs> ConsumerAdded

Event Type

EventHandler<WebRTCConsumerEventArgs>

ConsumerRemoved

Occurs when a browser disconnects. Raised from a GStreamer thread. Not raised for the browsers still connected when the pipeline stops: their sessions end with it.

public event EventHandler<WebRTCConsumerEventArgs> ConsumerRemoved

Event Type

EventHandler<WebRTCConsumerEventArgs>