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, IMediaBlockDynamicInputsInheritance
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
settingsWebRTCSinkSettings-
The WebRTC sink settings.
Properties
Input
Gets the first input pad.
public override MediaBlockPad Input { get; }Property Value
Inputs
Gets all input pads.
public override MediaBlockPad[] Inputs { get; }Property Value
Output
Gets the output pad. Always null for sink blocks.
public override MediaBlockPad Output { get; }Property Value
Outputs
Gets all output pads. Always empty for sink blocks.
public override MediaBlockPad[] Outputs { get; }Property Value
Settings
Gets or sets the WebRTC sink settings.
public WebRTCSinkSettings Settings { get; set; }Property Value
Type
Gets the media block type identifier.
public override MediaBlockType Type { get; }Property Value
Methods
Build()
Builds the webrtcsink element and requests one of its pads per input.
public override bool Build()Returns
- bool
-
trueif successful;falseotherwise.
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
mediaTypeMediaBlockPadMediaType-
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
disposingbool-
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
mediaTypeMediaBlockPadMediaType-
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
-
trueif this media block is available; otherwise,false.
SetFilenameOrURL(string)
Sets the address of the viewer page web server.
public void SetFilenameOrURL(string value)Parameters
valuestring-
The web server address.
IMediaBlockInternals.SetContext(MediaBlocksPipeline)
Sets the pipeline context.
void IMediaBlockInternals.SetContext(MediaBlocksPipeline pipeline)Parameters
pipelineMediaBlocksPipeline-
The owning pipeline.
ConsumerAdded
Occurs when a browser connects. Raised from a GStreamer thread.
public event EventHandler<WebRTCConsumerEventArgs> ConsumerAddedEvent Type
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