Table of Contents

Class WebView2SourceBlock

Namespace
VisioForge.Core.MediaBlocks.Sources
Assembly
VisioForge.Core.dll

WebView2 video source block that renders web pages as video output. Windows-only. Requires the GStreamer webview2 plugin.

public class WebView2SourceBlock : MediaBlock, IMediaBlock, IDisposable, IMediaBlockInternals

Inheritance

Implements

Inherited Members

Extension Methods

Constructors

WebView2SourceBlock(WebView2SourceSettings)

Initializes a new instance of the VisioForge.Core.MediaBlocks.Sources.WebView2SourceBlock class.

public WebView2SourceBlock(WebView2SourceSettings settings)

Parameters

settings WebView2SourceSettings

The WebView2 source settings.

Properties

Input

Gets the primary input pad for this media block.

public override MediaBlockPad Input { get; }

Property Value

MediaBlockPad

Inputs

Gets the collection of input pads for this media block.

public override MediaBlockPad[] Inputs { get; }

Property Value

MediaBlockPad[]

Output

Gets the primary output pad for this media block.

public override MediaBlockPad Output { get; }

Property Value

MediaBlockPad

Outputs

Gets the collection of output pads for this media block.

public override MediaBlockPad[] Outputs { get; }

Property Value

MediaBlockPad[]

Settings

Gets or sets the settings for this block.

public WebView2SourceSettings Settings { get; set; }

Property Value

WebView2SourceSettings

Type

Gets or sets the functional type of this media block (source, sink, effect, encoder, etc.). This property must be overridden in derived classes to specify the block's role in the pipeline.

public override MediaBlockType Type { get; }

Property Value

MediaBlockType

Exceptions

NotImplementedException

Thrown when the derived class has not implemented this property.

NotImplementedException

Thrown when the derived class has not implemented the setter.

Methods

Build()

Builds and initializes this media block, creating any necessary GStreamer elements and configuring them. This method must be overridden in derived classes to implement block-specific initialization logic.

public override bool Build()

Returns

bool

true if the block was successfully built; otherwise, false.

CleanUp()

Releases all internal resources.

public void CleanUp()

Dispose(bool)

Releases unmanaged and - optionally - managed resources. Override this method in derived classes to implement block-specific cleanup logic.

protected override void Dispose(bool disposing)

Parameters

disposing bool

true to release both managed and unmanaged resources; false to release only unmanaged resources.

Remarks

An override must call its CleanUp() only under disposing. VisioForge.Core.MediaBlocks.MediaBlock.Finalize reaches this method with false, and a block's CleanUp() releases GstSharp wrappers - which takes GStreamer locks and can block - on the finalizer thread, which must never do either. A block that is never disposed leaves its elements to the pipeline that owns them; that is what their toggle refs are for. base.Dispose(disposing) stays outside the guard, because the latch below has to be set on both paths. The one carve-out is a block holding a resource nothing else can release - a device handle, say, which no pipeline owns and no toggle ref reclaims; such a block may run its CleanUp() on the finalizer path, guarded against throwing, and has to say why at the call site (see AndroidUVCSourceBlock). GitHub issue #958.

GetCore()

Retrieves the core BaseElement wrapper that provides additional functionality around the GStreamer element. This wrapper adds VisioForge-specific features and simplifies common operations on the underlying GStreamer element.

public BaseElement GetCore()

Returns

BaseElement

The BaseElement wrapper instance that encapsulates the GStreamer element.

GetElement()

Retrieves the primary GStreamer element that represents this MediaBlock in the pipeline. This element is the main component that performs the actual media processing and is connected to other elements in the GStreamer pipeline.

public Element GetElement()

Returns

Element

The GStreamer Element instance, or null if the block hasn't been built yet.

IsAvailable()

Determines whether this media block is available. The GStreamer webview2 plugin must be installed.

public static bool IsAvailable()

Returns

bool

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

IMediaBlockInternals.SetContext(MediaBlocksPipeline)

Associates this MediaBlock with a pipeline and initializes its internal context. This method is called automatically when the block is added to a pipeline, providing access to shared resources and pipeline-wide configuration.

void IMediaBlockInternals.SetContext(MediaBlocksPipeline pipeline)

Parameters

pipeline MediaBlocksPipeline

The MediaBlocksPipeline instance that will manage this block.