Table of Contents

Class DecryptorPlayerBlock

Namespace
VisioForge.Core.MediaBlocks.Special
Assembly
VisioForge.Core.dll

Provides a complete media playback solution for encrypted files by combining decryption, demuxing, and decoding.

public class DecryptorPlayerBlock : MediaBlock, IMediaBlock, IDisposable, IMediaBlockInternals

Inheritance

Implements

Inherited Members

Extension Methods

Examples

// Check if decryption is available
if (!DecryptorPlayerBlock.IsAvailable())
{
    throw new NotSupportedException("Decryption support not available");
}

// Create a decryptor player for an encrypted video file
var decryptorPlayer = new DecryptorPlayerBlock(
    pipeline,
    "/path/to/encrypted/video.enc",
    "your-encryption-key",
    "initialization-vector",
    renderVideo: true,
    renderAudio: true,
    renderSubtitle: false);

// Connect outputs to renderers
pipeline.Connect(decryptorPlayer.VideoOutput, videoRenderer.Input);
pipeline.Connect(decryptorPlayer.AudioOutput, audioRenderer.Input);

// Start playback
await pipeline.StartAsync();

Remarks

The VisioForge.Core.MediaBlocks.Special.DecryptorPlayerBlock is a composite block that integrates multiple components to handle encrypted media playback. It automatically chains together file reading, decryption, queuing, and decoding operations to produce ready-to-render audio, video, and subtitle streams.

This block is particularly useful for:

  • Playing DRM-protected or encrypted media files
  • Secure media playback applications
  • Content protection systems
  • Encrypted video streaming solutions

The block internally manages a pipeline consisting of:

  1. BasicFileSourceBlock for reading the encrypted file
  2. DecryptorBlock for decrypting the content
  3. QueueBlock for buffering
  4. DecodeBinBlock for demuxing and decoding

Platform Requirements: Requires the decryption plugin to be available in your GStreamer installation. Use VisioForge.Core.MediaBlocks.Special.DecryptorPlayerBlock.IsAvailable to verify support before creating instances.

Constructors

DecryptorPlayerBlock(MediaBlocksPipeline, string, string, string, bool, bool, bool)

Initializes a new instance of the VisioForge.Core.MediaBlocks.Special.DecryptorPlayerBlock class.

public DecryptorPlayerBlock(MediaBlocksPipeline pipeline, string filename, string key, string iv, bool renderVideo = true, bool renderAudio = true, bool renderSubtitle = false)

Parameters

pipeline MediaBlocksPipeline

The media pipeline to which this block belongs.

filename string

The path to the encrypted media file to play.

key string

The encryption key used to decrypt the content.

iv string

The initialization vector (IV) for the encryption algorithm.

renderVideo bool

Whether to enable video stream output. Default is true.

renderAudio bool

Whether to enable audio stream output. Default is true.

renderSubtitle bool

Whether to enable subtitle stream output. Default is false.

Remarks

The constructor automatically creates and connects the internal pipeline components. If any connection fails, error messages are logged to the pipeline context.

The encryption parameters must match those used when the file was encrypted. Incorrect parameters will result in playback failure or corrupted output.

Exceptions

ArgumentNullException

Thrown when pipeline, filename, key, or iv is null.

Properties

AudioOutput

Gets the audio output pad that provides decoded audio samples.

public MediaBlockPad AudioOutput { get; }

Property Value

MediaBlockPad

Remarks

This pad is only available when renderAudio was set to true during construction. Connect this to an audio renderer or further processing blocks.

Input

Gets the input.

public override MediaBlockPad Input { get; }

Property Value

MediaBlockPad

Inputs

Gets the inputs.

public override MediaBlockPad[] Inputs { get; }

Property Value

MediaBlockPad[]

Output

Gets the output.

public override MediaBlockPad Output { get; }

Property Value

MediaBlockPad

Outputs

Gets the outputs.

public override MediaBlockPad[] Outputs { get; }

Property Value

MediaBlockPad[]

SubtitleOutput

Gets the subtitle output pad that provides decoded subtitle data.

public MediaBlockPad SubtitleOutput { get; }

Property Value

MediaBlockPad

Remarks

This pad is only available when renderSubtitle was set to true during construction. Connect this to a subtitle renderer or overlay block.

Type

Gets the type.

public override MediaBlockType Type { get; }

Property Value

MediaBlockType

VideoOutput

Gets the video output pad that provides decoded video frames.

public MediaBlockPad VideoOutput { get; }

Property Value

MediaBlockPad

Remarks

This pad is only available when renderVideo was set to true during construction. Connect this to a video renderer or further processing blocks.

Methods

Build()

Builds the internal components of the decryptor player block.

public override bool Build()

Returns

bool

true if all components were successfully built; otherwise, false.

Remarks

This method is called automatically by the pipeline during initialization. It builds all internal components (source, decryptor, queue, and decoder) in sequence.

The method is idempotent - calling it multiple times has no effect after the first successful build. If any component fails to build, the entire operation fails and returns false.

CleanUp()

Performs cleanup of all internal components and resources.

public void CleanUp()

Remarks

This method disposes of all internal blocks in reverse order of their creation: DecodeBin, BasicFileSource, Queue, and Decryptor.

After cleanup, the block cannot be used again and must be recreated if needed. This method is called automatically during disposal.

Dispose(bool)

Releases unmanaged and - optionally - managed resources.

protected override void Dispose(bool disposing)

Parameters

disposing bool

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

GetCore()

Gets the core wrapper element for this block.

public BaseElement GetCore()

Returns

BaseElement

Always returns null as this is a composite block without a single core element.

Remarks

Composite blocks that manage multiple internal elements typically return null as they don't have a single representative core element.

GetElement()

Gets the primary GStreamer element of this block.

public Element GetElement()

Returns

Element

The file source element, which is the entry point of the internal pipeline.

Remarks

For composite blocks like this, the returned element is typically the first element in the internal chain, which in this case is the file source.

IsAvailable()

Determines whether the decryption functionality required by this block is available.

public static bool IsAvailable()

Returns

bool

true if decryption support is available; otherwise, false.

Remarks

This method checks for the availability of the underlying decryption plugin in the GStreamer installation. Always call this method before attempting to create instances of VisioForge.Core.MediaBlocks.Special.DecryptorPlayerBlock.

Availability depends on:

  • Correct GStreamer plugins being installed
  • Proper NuGet SDK redistribution packages included in your project
  • Platform-specific dependencies being met

IMediaBlockInternals.SetContext(MediaBlocksPipeline)

Sets the context.

void IMediaBlockInternals.SetContext(MediaBlocksPipeline pipeline)

Parameters

pipeline MediaBlocksPipeline

The pipeline.

See Also