Class FDSinkBlock
- Namespace
- VisioForge.Core.MediaBlocks.Sinks
- Assembly
- VisioForge.Core.dll
Implements a sink block that writes media data to a file descriptor (Unix-style file handle). Enables writing to pipes, sockets, or other file descriptor-based outputs.
public class FDSinkBlock : MediaBlock, IMediaBlock, IDisposable, IMediaBlockInternals, IMediaBlockDynamicInputsInheritance
Implements
Inherited Members
Extension Methods
Remarks
The FDSinkBlock provides low-level output capabilities by writing directly to file descriptors. This is particularly useful for: - Inter-process communication via pipes - Network streaming via sockets - Integration with external processes - Writing to special device files
File descriptors are integer values that reference open files, pipes, or sockets in Unix-like operating systems. Standard descriptors include: - 0: Standard input (stdin) - 1: Standard output (stdout) - 2: Standard error (stderr) - 3+: Custom file descriptors
The block can optionally add a queue before the sink to handle buffering and prevent blocking in the main pipeline thread.
Constructors
FDSinkBlock(int, bool)
Initializes a new instance of the VisioForge.Core.MediaBlocks.Sinks.FDSinkBlock class.
public FDSinkBlock(int descriptor, bool addQueue = true)Parameters
descriptorint-
The file descriptor number to write to. Must be a valid open descriptor.
addQueuebool-
If set to
true, adds a queue element for buffering to prevent blocking.
Remarks
Adding a queue is recommended for most use cases to prevent the sink from blocking the pipeline if the file descriptor write operations are slow.
Properties
Descriptor
Gets or sets the file descriptor number to write to.
public int Descriptor { get; set; }Property Value
Remarks
The file descriptor must be open and writable before starting the pipeline. Writing to a closed descriptor will cause pipeline errors.
Input
Gets the input.
public override MediaBlockPad Input { get; }Property Value
Inputs
Gets the inputs.
public override MediaBlockPad[] Inputs { get; }Property Value
Output
Gets the output.
public override MediaBlockPad Output { get; }Property Value
Outputs
Gets the outputs.
public override MediaBlockPad[] Outputs { get; }Property Value
Type
Gets the type.
public override MediaBlockType Type { get; }Property Value
Methods
Build()
Builds this instance.
public override bool Build()Returns
- bool
-
trueif successful,falseotherwise.
CleanUp()
Performs cleanup of resources used by the file descriptor sink.
public void CleanUp()Remarks
This method releases the underlying GStreamer element and resets the build state. Note that it does not close the file descriptor itself, which remains the responsibility of the code that opened it.
CreateNewInput(MediaBlockPadMediaType)
Creates a new input pad (returns the existing single input pad).
public MediaBlockPad CreateNewInput(MediaBlockPadMediaType mediaType)Parameters
mediaTypeMediaBlockPadMediaType-
The media type (ignored as FD sink accepts any data).
Returns
- MediaBlockPad
-
The single input pad of this sink.
Remarks
FD sink has only one input pad that accepts any media type. This method always returns the same pad regardless of the media type parameter.
Dispose(bool)
Releases unmanaged and - optionally - managed resources.
protected override void Dispose(bool disposing)Parameters
disposingbool-
trueto release both managed and unmanaged resources;falseto release only unmanaged resources.
GetCore()
Gets core.
public BaseElement GetCore()Returns
- BaseElement
-
VisioForge.Core.GStreamer.Base.BaseElement.
GetElement()
Gets the element.
public Element GetElement()Returns
- Element
-
Gst.Element.
GetFilenameOrURL()
Gets the filename or URL for this sink.
public string GetFilenameOrURL()Returns
- string
-
Always returns an empty string as FD sinks use descriptors, not filenames.
GetInput(MediaBlockPadMediaType)
Gets the existing input.
public MediaBlockPad GetInput(MediaBlockPadMediaType mediaType)Parameters
mediaTypeMediaBlockPadMediaType-
Type of the media.
Returns
- MediaBlockPad
-
MediaBlockPad.
IsAvailable()
Determines whether file descriptor sink functionality is available on the current platform.
public static bool IsAvailable()Returns
- bool
-
trueif FD sink is available; otherwise,false. Typically available on Unix-like systems (Linux, macOS) but limited on Windows.
Remarks
File descriptor support varies by platform. On Windows, this may only work with certain types of handles that can be treated as file descriptors.
SetFilenameOrURL(string)
Sets the filename or URL for this sink.
public void SetFilenameOrURL(string value)Parameters
valuestring-
The value to set (ignored).
Remarks
This method has no effect as FD sinks use file descriptors, not filenames. It exists to satisfy the IMediaBlockSink interface.
IMediaBlockInternals.SetContext(MediaBlocksPipeline)
Sets the context.
void IMediaBlockInternals.SetContext(MediaBlocksPipeline pipeline)Parameters
pipelineMediaBlocksPipeline-
The pipeline.