Class MP3OutputBlock
- Namespace
- VisioForge.Core.MediaBlocks.Sinks
- Assembly
- VisioForge.Core.dll
MP3 audio output block for creating widely compatible compressed audio files with professional encoding capabilities. Provides industry-standard MP3 audio file creation with configurable lossy compression for music distribution, podcasting, and audio content creation with broad device compatibility and efficient file sizes for streaming and storage optimization. Implements the VisioForge.Core.MediaBlocks.MediaBlock. Implements the VisioForge.Core.MediaBlocks.IMediaBlockInternals. Implements the IDisposable.
public class MP3OutputBlock : MediaBlock, IMediaBlock, IDisposable, IMediaBlockInternalsInheritance
Implements
Inherited Members
Extension Methods
Constructors
MP3OutputBlock(string, MP3EncoderSettings)
Initializes a new instance of the VisioForge.Core.MediaBlocks.Sinks.MP3OutputBlock class with custom MP3 encoder settings. Provides full control over audio compression parameters for professional MP3 file creation.
public MP3OutputBlock(string filename, MP3EncoderSettings mp3Settings)Parameters
filenamestring-
The output MP3 file path where the compressed audio content will be written.
mp3SettingsMP3EncoderSettings-
The MP3 encoder settings controlling compression quality, bitrate, and parameters.
MP3OutputBlock(string, MP3EncoderSettings, MediaFileTags)
Initializes a new instance of the VisioForge.Core.MediaBlocks.Sinks.MP3OutputBlock class with custom MP3 encoder settings and metadata tags. Provides full control over audio compression parameters and metadata for professional MP3 file creation with tag support.
public MP3OutputBlock(string filename, MP3EncoderSettings mp3Settings, MediaFileTags tags)Parameters
filenamestring-
The output MP3 file path where the compressed audio content will be written.
mp3SettingsMP3EncoderSettings-
The MP3 encoder settings controlling compression quality, bitrate, and parameters.
tagsMediaFileTags-
The metadata tags to be written to the MP3 file, including title, artist, album, and other information.
Properties
Input
Gets the audio input pad for receiving audio streams.
public override MediaBlockPad Input { get; }Property Value
Inputs
Gets all input pads available on this block (single audio input for MP3 encoding).
public override MediaBlockPad[] Inputs { get; }Property Value
Output
Gets the primary output pad (none for output blocks that write to files).
public override MediaBlockPad Output { get; }Property Value
Outputs
Gets all output pads available on this block (none for output blocks).
public override MediaBlockPad[] Outputs { get; }Property Value
Tags
Gets or sets the metadata tags to be written to the MP3 file. These tags include information such as title, artist, album, year, and other audio metadata. Tags can be set before building the pipeline and will be applied during the encoding process.
public MediaFileTags Tags { get; set; }Property Value
Type
Gets the media block type identifier for MP3 output operations.
public override MediaBlockType Type { get; }Property Value
Methods
Build()
Builds and initializes the MP3 output block within the pipeline context. Creates the file sink, MP3 encoder, ID3 tag muxer, and establishes all necessary connections for encoding and writing audio content to the MP3 file with metadata tags.
public override bool Build()Returns
- bool
-
trueif the MP3 output block was successfully built and configured; otherwise,false.
CleanUp()
Cleans up all resources associated with the MP3 output operations, including encoder, sink, and file handles.
public void CleanUp()Dispose(bool)
Releases unmanaged and managed resources used by the MP3 output block. Properly disposes of GStreamer elements, encoder, and file writing resources.
protected override void Dispose(bool disposing)Parameters
disposingbool-
trueto release both managed and unmanaged resources;falseto release only unmanaged resources.
GetCore()
Gets the core GStreamer element wrapper for advanced configuration and monitoring.
public BaseElement GetCore()Returns
- BaseElement
-
Always null for composite output blocks with multiple internal elements.
GetElement()
Gets the native GStreamer element for direct GStreamer pipeline integration.
public Element GetElement()Returns
- Element
-
Always null for composite output blocks with multiple internal elements.
GetFilenameOrURL()
Gets the current output filename or URL where the MP3 content is being written.
public string GetFilenameOrURL()Returns
- string
-
The file path or URL string for the MP3 output destination.
IsAvailable()
Determines whether MP3 output functionality is available on the current system. Requires GStreamer MP3 encoder and file sink plugins to be installed and functional.
public static bool IsAvailable()Returns
- bool
-
trueif MP3 output is supported; otherwise,false.
SetFilenameOrURL(string)
Updates the output filename or URL for the MP3 file destination, allowing dynamic output redirection.
public void SetFilenameOrURL(string value)Parameters
valuestring-
The new file path or URL where MP3 content should be written.
IMediaBlockInternals.SetContext(MediaBlocksPipeline)
Sets the pipeline context for this MP3 output block, providing access to the parent pipeline and logging context.
void IMediaBlockInternals.SetContext(MediaBlocksPipeline pipeline)Parameters
pipelineMediaBlocksPipeline-
The parent MediaBlocks pipeline containing this MP3 output block.