Class ShoutcastSinkBlock
- Namespace
- VisioForge.Core.MediaBlocks.Sinks
- Assembly
- VisioForge.Core.dll
Provides a media sink for streaming audio to Shoutcast/Icecast servers.
public class ShoutcastSinkBlock : MediaBlock, IMediaBlock, IDisposable, IMediaBlockInternalsInheritance
Implements
Inherited Members
Extension Methods
Examples
// Create Shoutcast sink for internet radio
var settings = new ShoutcastSinkSettings
{
URL = "http://streaming.server.com:8000/stream",
Password = "hackme",
Mount = "/live.mp3",
StreamName = "My Radio Station",
StreamGenre = "Rock",
StreamDescription = "24/7 Rock Music"
};
var shoutcastSink = new ShoutcastSinkBlock(settings);
// Connect MP3 encoded audio
pipeline.Connect(mp3Encoder.Output, shoutcastSink.Input);
Remarks
The ShoutcastSinkBlock enables live audio streaming to Shoutcast or Icecast servers, supporting internet radio broadcasting and audio distribution. It accepts encoded audio streams and transmits them to the server using the Shoutcast/Icecast protocol.
Key features include:
- Support for Shoutcast v1/v2 and Icecast servers
- MP3 and OGG Vorbis audio format support
- Metadata streaming for track information
- Automatic reconnection on connection loss
- Server authentication support
- Real-time streaming with minimal latency
Common use cases:
- Internet radio station broadcasting
- Live event audio streaming
- Podcast live streaming
- Background music distribution
- Multi-channel audio broadcasting
The block expects pre-encoded audio (MP3 or Vorbis) on its input. Raw audio must be encoded by an upstream encoder block before streaming.
Constructors
ShoutcastSinkBlock(ShoutcastSinkSettings)
Initializes a new instance of the VisioForge.Core.MediaBlocks.Sinks.ShoutcastSinkBlock class with the specified settings.
public ShoutcastSinkBlock(ShoutcastSinkSettings settings)Parameters
settingsShoutcastSinkSettings-
The Shoutcast sink configuration settings that define server connection and stream properties.
Remarks
The settings must specify a valid server URL and authentication credentials before building the block. The block name is automatically set to "ShoutcastSink".
The input pad is configured to accept only audio streams, as Shoutcast/Icecast servers are designed for audio broadcasting.
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 Shoutcast sink configuration settings.
public ShoutcastSinkSettings Settings { get; set; }Property Value
Remarks
The settings include server URL, authentication credentials, mount point, and stream metadata like name, genre, and description. 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 Shoutcast sink block and configures the streaming connection.
public override bool Build()Returns
- bool
-
trueif the block was successfully built; otherwise,false.
Remarks
This method initializes the underlying GStreamer Shoutcast sink element (shout2send) with the configured server settings. The sink accepts encoded audio through its single "sink" pad.
The build process:
- Creates the Shoutcast sink element
- Configures server URL, authentication, and metadata
- Retrieves and assigns the static sink pad
The element will attempt to connect to the server when the pipeline starts playing. Connection failures will be reported through the pipeline's error handling mechanism.
CleanUp()
Cleans up.
public void CleanUp()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 Shoutcast/Icecast server URL.
public string GetFilenameOrURL()Returns
- string
-
The configured server URL including mount point.
Remarks
This method implements the IMediaBlockSink interface requirement and returns the server URL from the settings. The URL typically includes the server address, port, and mount point.
Example: "http://server.com:8000/stream.mp3"
IsAvailable()
Determines whether the Shoutcast sink functionality is available in the current environment.
public static bool IsAvailable()Returns
- bool
-
trueif Shoutcast/Icecast streaming is supported; otherwise,false.
Remarks
Availability depends on the presence of the required GStreamer plugin (shout2send). The correct NuGet SDK redistribution package must be included in your project for this block to function.
SetFilenameOrURL(string)
Sets the Shoutcast/Icecast server URL.
public void SetFilenameOrURL(string value)Parameters
valuestring-
The new server URL including mount point.
Remarks
This method updates the URL in the settings. Changes made after the block is built will not take effect until the block is rebuilt.
The URL should include:
- Protocol (http:// or https://)
- Server address and port
- Mount point (e.g., /stream.mp3)
IMediaBlockInternals.SetContext(MediaBlocksPipeline)
Sets the context.
void IMediaBlockInternals.SetContext(MediaBlocksPipeline pipeline)Parameters
pipelineMediaBlocksPipeline-
The pipeline.