Table of Contents

Class HTTPMJPEGLiveSinkBlock

Namespace
VisioForge.Core.MediaBlocks.Sinks
Assembly
VisioForge.Core.dll

Implements a sink block that streams video as Motion JPEG (MJPEG) over HTTP. Creates a simple HTTP server that clients can connect to for viewing live video streams.

public class HTTPMJPEGLiveSinkBlock : MediaBlock, IMediaBlock, IDisposable, IMediaBlockInternals, IMediaBlockDynamicInputs

Inheritance

Implements

Inherited Members

Extension Methods

Remarks

The HTTPMJPEGLiveSinkBlock provides a lightweight video streaming solution using the Motion JPEG format over HTTP. Key features include: - Simple HTTP server on a specified port - MJPEG stream compatible with web browsers - Multiple simultaneous client connections - No special client software required - Low latency streaming

MJPEG streams each video frame as a separate JPEG image, making it: - Easy to implement and decode - Compatible with most browsers and devices - Suitable for local network streaming - Higher bandwidth than modern codecs but simpler

Common use cases include: - Security camera viewing - Local network video distribution - Simple web-based video monitoring - Development and testing of video pipelines

Clients can view the stream by navigating to: http://[server-ip]:[port]/ in a web browser

Constructors

HTTPMJPEGLiveSinkBlock(int)

Initializes a new instance of the VisioForge.Core.MediaBlocks.Sinks.HTTPMJPEGLiveSinkBlock class.

public HTTPMJPEGLiveSinkBlock(int port)

Parameters

port int

The TCP port number on which to serve the MJPEG stream.

Remarks

The HTTP server will start listening on the specified port when the pipeline begins. Ensure the port is not already in use by another application.

Exceptions

ArgumentOutOfRangeException

Thrown when port is not between 1 and 65535.

Properties

Input

Gets the first input.

public override MediaBlockPad Input { get; }

Property Value

MediaBlockPad

Inputs

Gets the inputs.

public override MediaBlockPad[] Inputs { get; }

Property Value

MediaBlockPad[]

Output

Gets the output.

public override MediaBlockPad Output { get; }

Property Value

MediaBlockPad

Outputs

Gets the outputs.

public override MediaBlockPad[] Outputs { get; }

Property Value

MediaBlockPad[]

Port

Gets the TCP port number on which the HTTP server listens.

public int Port { get; }

Property Value

int

Remarks

Common ports include 8080, 8081, or any available port above 1024. Ports below 1024 may require administrator privileges.

Type

Gets the type.

public override MediaBlockType Type { get; }

Property Value

MediaBlockType

Methods

Build()

Builds this instance.

public override bool Build()

Returns

bool

true if successfull, false otherwise.

CleanUp()

Performs cleanup of resources used by the HTTP MJPEG sink.

public void CleanUp()

Remarks

This method stops the HTTP server, closes all client connections, and releases the underlying GStreamer element.

CreateNewInput(MediaBlockPadMediaType)

Creates a new input pad (returns the existing video input pad).

public MediaBlockPad CreateNewInput(MediaBlockPadMediaType mediaType)

Parameters

mediaType MediaBlockPadMediaType

The media type (should be video for MJPEG streaming).

Returns

MediaBlockPad

The video input pad of this sink.

Remarks

HTTP MJPEG sink only accepts video input. The video frames will be automatically converted to JPEG format for streaming.

Dispose(bool)

Releases unmanaged and - optionally - managed resources.

protected override void Dispose(bool disposing)

Parameters

disposing bool

true to release both managed and unmanaged resources; false to 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 URL where the MJPEG stream can be accessed.

public string GetFilenameOrURL()

Returns

string

Not implemented for HTTP MJPEG sink.

Exceptions

NotImplementedException

This method is not applicable for HTTP streaming.

GetInput(MediaBlockPadMediaType)

Gets the existing input.

public MediaBlockPad GetInput(MediaBlockPadMediaType mediaType)

Parameters

mediaType MediaBlockPadMediaType

Type of the media.

Returns

MediaBlockPad

MediaBlockPad.

IsAvailable()

Determines whether HTTP MJPEG streaming functionality is available on the current platform.

public static bool IsAvailable()

Returns

bool

true if HTTP MJPEG sink is available; otherwise, false. Requires GStreamer's multipartmux and souphttpsrc plugins.

Remarks

This functionality requires specific GStreamer plugins for HTTP serving and MJPEG multiplexing. Availability may vary by platform.

SetFilenameOrURL(string)

Sets the filename or URL for this sink.

public void SetFilenameOrURL(string value)

Parameters

value string

The value to set (not applicable).

Remarks

HTTP MJPEG sink uses a port number, not a filename or URL. The URL is determined by the server's IP address and port.

Exceptions

NotImplementedException

This method is not applicable for HTTP streaming.

IMediaBlockInternals.SetContext(MediaBlocksPipeline)

Sets the context.

void IMediaBlockInternals.SetContext(MediaBlocksPipeline pipeline)

Parameters

pipeline MediaBlocksPipeline

The pipeline.

See Also