Elements

This section contains information important in general when implementing elements. The following sections contain information about implementing elements with special characteristics:

Interfaces

All elements must implement the IElement interface. In addition to this all elements except source elements must implement the IInputPad interface to be able to receive stream data. The IPump interface in the Streamer core is used by all elements to release segments and metadata. All elements except the sink elements use the IOutputPad interface to commit segments and metadata to the output pad of the next element in the pipeline.

Most elements also use the IDebug interface to write messages to the log. Another commonly used interface in the Streamer core is the IBlackboard interface used to read and write parameters on the Streamer blackboard. If the element subscribes to changes on a parameter on the blackboard it must implement the IBlackboardObserver interface as well.

An intermediate (not source or sink) element and interfaces.

Implementation Principles

How data flows between elements is described in a comprehensive way in the Element Data Flow section. However, there are some hands-on principles that must be considered when implementing an element.

Opening pads

When an element opens a pad, the a new element will be selected, created and added to the pipeline. To avoid creating elements that are not used, pads should not be opened until they are actually needed, e.g. an element demuxing audio and video data should not open a pad for video until it knows the stream actually contains video (it might be an audio-only stream).

Elements that have not opened any pad yet must not destroy any metadata that passes through the element since it might be required on the blackboard. The metadata should be published on the blackboard using the Publish() function in the IPump interface. Consequently, sink elements should always publish all metadata unless it knows it should not be written on the blackboard.

Note! Metadata must not be destroyed by elements that have no pad opened. It should be published instead.

One might argue that metadata required by an element might not arrive at all to the element if an element earlier in the pipeline does not open all its pads at once (metadata that flows through the stream before a pad is opened). This problem is solved by the Streamer pump which will inject the needed metadata in the stream (all continual metadata listed in the elements descriptor).

Empty segments

If an element commits metadata and no segments or metadata after all segments have been committed an empty segment is created. The empty segment will act as a placeholder for the metadata and should be ignored by any element processing the segment, i.e. the empty segment should not be committed or released.

Note! Empty segments can not be committed or released.

Observe that empty segments can only occur last in a processed segment list. If an element processes (commits or releases) all segments prior to an empty segment in a list, the metadata attached to the empty segment must be processed as well since the pump will assume the element does so.