Class OGGSinkBlock
- Namespace
- VisioForge.Core.MediaBlocks.Sinks
- Assembly
- VisioForge.Core.dll
Provides a media sink for writing OGG container files with Vorbis audio and Theora video streams.
public class OGGSinkBlock : MediaBlock, IMediaBlock, IDisposable, IMediaBlockInternals, IMediaBlockDynamicInputsInheritance
Implements
Inherited Members
Extension Methods
Examples
// Create OGG sink for recording
var settings = new OGGSinkSettings
{
Filename = "output.ogg",
EnableMetadata = true
};
var oggSink = new OGGSinkBlock(settings);
// Create inputs for video and audio
var videoInput = oggSink.CreateNewInput(MediaBlockPadMediaType.Video);
var audioInput = oggSink.CreateNewInput(MediaBlockPadMediaType.Audio);
// Connect encoded streams
pipeline.Connect(theoraEncoder.Output, videoInput);
pipeline.Connect(vorbisEncoder.Output, audioInput);
Remarks
The OGGSinkBlock enables recording of audio and video content to OGG files, an open-source container format commonly used with Vorbis audio and Theora video codecs. It supports multiplexing multiple audio and video streams into a single container file.
Key features include:
- Support for multiple video streams (Theora codec)
- Support for multiple audio streams (Vorbis codec)
- Dynamic input creation for multi-stream recording
- Royalty-free, open-source format
- Streaming-friendly container structure
Common use cases:
- Web video streaming with open formats
- Audio podcast recording and distribution
- Cross-platform media archiving
- Open-source media production workflows
- Educational and non-commercial content
The block expects pre-encoded Theora video and Vorbis audio streams. Encoding must be performed by upstream encoder blocks before connecting to this sink.
Constructors
OGGSinkBlock(OGGSinkSettings)
Initializes a new instance of the VisioForge.Core.MediaBlocks.Sinks.OGGSinkBlock class with the specified settings.
public OGGSinkBlock(OGGSinkSettings settings)Parameters
settingsOGGSinkSettings-
The OGG sink configuration settings that define output options.
Remarks
The settings must specify a valid output filename before building the block. The block name is automatically set to "OGGSink".
Exceptions
- ArgumentNullException
-
Thrown when
settingsisnull.
Properties
Input
Gets the first 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
Settings
Gets or sets the OGG sink configuration settings.
public OGGSinkSettings Settings { get; set; }Property Value
Remarks
The settings determine the output filename and various OGG container options. Changes to settings after building the block will not take effect.
Type
Gets the type.
public override MediaBlockType Type { get; }Property Value
Methods
Build()
Builds the OGG sink block and configures input pads for video and audio streams.
public override bool Build()Returns
- bool
-
trueif the block was successfully built; otherwise,false.
Remarks
This method initializes the underlying GStreamer OGG muxer element and creates appropriate input pads for each configured stream. The muxer uses specific pad templates for different stream types:
- Video streams: "video_%u" template (expects Theora-encoded data)
- Audio streams: "audio_%u" template (expects Vorbis-encoded data)
Subtitle inputs are currently not supported by the OGG format and will be skipped. Each successfully created pad is assigned to its corresponding input in the block.
CleanUp()
Cleans up.
public void CleanUp()CreateNewInput(MediaBlockPadMediaType)
Creates a new input pad for the specified media type to support multi-stream OGG files.
public MediaBlockPad CreateNewInput(MediaBlockPadMediaType mediaType)Parameters
mediaTypeMediaBlockPadMediaType-
The type of media stream (video or audio) for the new input.
Returns
- MediaBlockPad
-
A new VisioForge.Core.MediaBlocks.MediaBlockPad configured for the specified media type.
Remarks
This method enables dynamic creation of inputs for multi-stream OGG files. Video inputs expect Theora-encoded streams, while audio inputs expect Vorbis-encoded streams.
Multiple streams of the same type can be created (e.g., multiple audio tracks for different languages or commentary tracks).
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 the OGG file.
public string GetFilenameOrURL()Returns
- string
-
The configured output filename path.
Remarks
This method implements the IMediaBlockSink interface requirement and returns the filename specified in the settings.
GetInput(MediaBlockPadMediaType)
Retrieves an existing input pad of the specified media type.
public MediaBlockPad GetInput(MediaBlockPadMediaType mediaType)Parameters
mediaTypeMediaBlockPadMediaType-
The media type to search for.
Returns
- MediaBlockPad
-
The first VisioForge.Core.MediaBlocks.MediaBlockPad matching the specified type, or
nullif none exists.
Remarks
This method returns the first input pad that matches the requested media type. If multiple inputs of the same type exist, only the first one is returned. Use VisioForge.Core.MediaBlocks.Sinks.OGGSinkBlock.Inputs to access all input pads.
IsAvailable()
Determines whether the OGG sink functionality is available in the current environment.
public static bool IsAvailable()Returns
- bool
-
trueif OGG muxing is supported; otherwise,false.
Remarks
Availability depends on the presence of required GStreamer plugins (oggmux) and the correct NuGet SDK redistribution package must be included in your project.
SetFilenameOrURL(string)
Sets the output filename for the OGG file.
public void SetFilenameOrURL(string value)Parameters
valuestring-
The new output filename path.
Remarks
This method updates the filename in the settings. Changes made after the block is built will not take effect until the block is rebuilt.
The filename should include the full path and use the .ogg or .ogv extension for proper file type identification.
IMediaBlockInternals.SetContext(MediaBlocksPipeline)
Sets the context.
void IMediaBlockInternals.SetContext(MediaBlocksPipeline pipeline)Parameters
pipelineMediaBlocksPipeline-
The pipeline.