Class FileSinkBlock
- Namespace
- VisioForge.Core.MediaBlocks.Sinks
- Assembly
- VisioForge.Core.dll
Implements a sink block that writes raw media data directly to a file without any container format. Suitable for writing elementary streams or raw data that will be processed later.
public class FileSinkBlock : MediaBlock, IMediaBlock, IDisposable, IMediaBlockInternals, IMediaBlockDynamicInputsInheritance
Implements
Inherited Members
Extension Methods
Remarks
The FileSinkBlock provides basic file writing functionality for media streams. Unlike container-based sinks (MP4, AVI, etc.), this sink writes raw data directly to disk without any file structure or metadata. This makes it suitable for: - Elementary video streams (raw H.264, HEVC) - Raw audio data (PCM, compressed audio frames) - Intermediate processing files - Custom data formats
The sink accepts any type of media data and writes it sequentially to the specified file. An optional queue can be added to prevent the file I/O from blocking the pipeline.
Common use cases include: - Debugging pipeline output - Creating raw stream files for analysis - Temporary storage during multi-pass processing - Writing custom binary formats
Constructors
FileSinkBlock(string, bool)
Initializes a new instance of the VisioForge.Core.MediaBlocks.Sinks.FileSinkBlock class.
public FileSinkBlock(string filename, bool addQueue = true)Parameters
filenamestring-
The full path to the output file where data will be written.
addQueuebool-
If
true, adds a queue element for buffering to prevent blocking.
Remarks
Adding a queue is recommended to prevent file I/O operations from blocking the pipeline, especially when writing to slow storage devices.
Properties
Filename
Gets or sets the output filename where data will be written.
public string Filename { get; set; }Property Value
Remarks
If the file already exists, it will be overwritten. Ensure the directory exists before starting the pipeline.
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 sink.
public void CleanUp()Remarks
This method releases the underlying GStreamer element and resets the build state. Any buffered data is flushed to disk before cleanup.
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 file sink accepts any data).
Returns
- MediaBlockPad
-
The single input pad of this sink.
Remarks
File 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 output filename for this sink.
public string GetFilenameOrURL()Returns
- string
-
The full path to the output file.
GetInput(MediaBlockPadMediaType)
Gets the existing input.
public MediaBlockPad GetInput(MediaBlockPadMediaType mediaType)Parameters
mediaTypeMediaBlockPadMediaType-
Type of the media.
Returns
- MediaBlockPad
-
MediaBlockPad.
IsAvailable()
Determines whether file sink functionality is available on the current platform.
public static bool IsAvailable()Returns
- bool
-
trueif file sink is available; otherwise,false. This basic functionality is typically available on all platforms.
Remarks
File sink is a core GStreamer element and should be available on all platforms where GStreamer is properly installed.
SetFilenameOrURL(string)
Sets the output filename for this sink.
public void SetFilenameOrURL(string value)Parameters
valuestring-
The full path where the file should be written.
Remarks
Changing the filename after the pipeline has started may not take effect until the pipeline is restarted.
IMediaBlockInternals.SetContext(MediaBlocksPipeline)
Sets the context.
void IMediaBlockInternals.SetContext(MediaBlocksPipeline pipeline)Parameters
pipelineMediaBlocksPipeline-
The pipeline.