Table of Contents

Class IImageSource

Namespace
VAST.Image
Assembly
VAST.Common.dll

Provides an abstract base class for image-based media sources that can generate video frames from static images.

public abstract class IImageSource : IMediaSource, IReferenceable, IDisposable
Inheritance
IImageSource
Implements
Derived
Inherited Members

Remarks

The actual implementation is loaded dynamically based on the current platform. Use the Create(bool, bool) factory method to instantiate an image source.

Constructors

IImageSource(bool, bool)

Initializes a new instance of the IImageSource class.

public IImageSource(bool useAbsoluteTimestamps, bool loop)

Parameters

useAbsoluteTimestamps bool

True to use absolute timestamps for samples; false to use relative timestamps.

loop bool

True to continuously loop the image playback; false to output a single frame.

Properties

Capabilities

Gets the list of capabilities supported by this source.

public List<SourceCapability> Capabilities { get; }

Property Value

List<SourceCapability>

IsDisposed

Gets a value indicating whether the object has been disposed and can no longer be used.

public bool IsDisposed { get; }

Property Value

bool

IsNetworkSource

Gets a value indicating whether this is a network source. Always returns false for image sources.

public bool IsNetworkSource { get; }

Property Value

bool

Parameters

Gets or sets the configuration parameters for the source.

public SourceParameters Parameters { get; set; }

Property Value

SourceParameters

Exceptions

InvalidOperationException

Thrown when attempting to set the value after the source has been opened.

RefCount

Gets the current reference count of the object.

public int RefCount { get; }

Property Value

int

State

Gets the current state of the media source.

public MediaState State { get; protected set; }

Property Value

MediaState

StreamCount

Gets the total number of streams in the source.

public int StreamCount { get; }

Property Value

int

UniqueId

Gets or sets the unique identifier for this source.

public Guid UniqueId { get; set; }

Property Value

Guid

Uri

Gets or sets the URI of the image source. Setting this property loads the image from the specified path.

public string Uri { get; set; }

Property Value

string

Methods

AddRef()

Increments the reference count of the object.

public void AddRef()

Create(bool, bool)

Creates a new image source instance by dynamically loading the platform-specific implementation.

public static IImageSource Create(bool useAbsoluteTimestamps = false, bool loop = true)

Parameters

useAbsoluteTimestamps bool

True to use absolute timestamps for samples; false to use relative timestamps.

loop bool

True to continuously loop the image playback; false to output a single frame.

Returns

IImageSource

A new IImageSource instance, or null if no suitable implementation is available.

Dispose()

Releases all resources used by the image source.

public void Dispose()

GetMediaType(int)

Gets media type of the stream

public MediaType GetMediaType(int streamIndex)

Parameters

streamIndex int

Stream index to get media type for

Returns

MediaType

Media type of requested stream

Open()

Opens the image source and prepares it for playback.

public void Open()

Release()

Decrements the reference count and disposes the object when the count reaches zero.

public void Release()

Remarks

The calling object must not use this instance after calling this method if the reference count becomes zero.

SetDesiredOutputType(int, MediaType)

Sets desired output media type of the specified stream. Desired media type could be an incomplete media type specifying only necessary parameters. Source should implement decoding or encoding internally to provide requested output type. It is not guaranteed though that an actual output type will match a desired type exactly. GetMediaType function should be used to obtain actual output media type.

public Task SetDesiredOutputType(int streamIndex, MediaType mediaType)

Parameters

streamIndex int

Stream index to set desired output media type for

mediaType MediaType

Desired media type

Returns

Task

SetImage(byte[])

Sets the image source from a byte array containing image data.

public void SetImage(byte[] imageBuffer)

Parameters

imageBuffer byte[]

The byte array containing the image data.

SetImage(Stream, bool)

Sets the image source from a stream containing image data.

public abstract void SetImage(Stream imageStream, bool leaveOpen = false)

Parameters

imageStream Stream

The stream containing the image data.

leaveOpen bool

True to leave the stream open after reading; false to close it.

SetImage(string)

Sets the image source from a file path or URL.

public void SetImage(string imageFilePath)

Parameters

imageFilePath string

The file path or URL of the image to load.

Exceptions

ArgumentException

Thrown when the file extension is unknown or the file format is not supported.

SetImageAsync(byte[])

Asynchronously sets the image source from a byte array containing image data.

public Task SetImageAsync(byte[] imageBuffer)

Parameters

imageBuffer byte[]

The byte array containing the image data.

Returns

Task

A task representing the asynchronous operation.

SetImageAsync(Stream, bool)

Asynchronously sets the image source from a stream containing image data.

public abstract Task SetImageAsync(Stream imageStream, bool leaveOpen = false)

Parameters

imageStream Stream

The stream containing the image data.

leaveOpen bool

True to leave the stream open after reading; false to close it.

Returns

Task

A task representing the asynchronous operation.

SetImageAsync(string)

Asynchronously sets the image source from a file path or URL.

public Task SetImageAsync(string imageFilePath)

Parameters

imageFilePath string

The file path or URL of the image to load.

Returns

Task

A task representing the asynchronous operation.

SetText(OverlayText)

Sets the image source to display the specified text overlay.

public abstract void SetText(OverlayText content)

Parameters

content OverlayText

The text overlay content to display.

SetTextAsync(OverlayText)

Asynchronously sets the image source to display the specified text overlay.

public abstract Task SetTextAsync(OverlayText content)

Parameters

content OverlayText

The text overlay content to display.

Returns

Task

A task representing the asynchronous operation.

Start()

Starts the image source and begins generating samples.

public void Start()

Stop()

Stops the image source and releases associated resources.

public void Stop()

Events

Error

Occurs when an error is encountered during image processing.

public event EventHandler<ErrorEventArgs> Error

Event Type

EventHandler<ErrorEventArgs>

NewSample

Occurs when a new sample is ready to be consumed.

public event EventHandler<NewSampleEventArgs> NewSample

Event Type

EventHandler<NewSampleEventArgs>

NewStream

Occurs when a new stream is created or stream information becomes available.

public event EventHandler<NewStreamEventArgs> NewStream

Event Type

EventHandler<NewStreamEventArgs>

StateChanged

Occurs when the source state changes.

public event EventHandler<MediaState> StateChanged

Event Type

EventHandler<MediaState>