stream module

High-level tools to build GStreamer pipelines.

class stream.Buffer(name, t0, duration, data, caps, is_gap)

Bases: tuple

property caps

Alias for field number 4

property data

Alias for field number 3

property duration

Alias for field number 2

property is_gap

Alias for field number 5

property name

Alias for field number 0

property t0

Alias for field number 1

class stream.SourceElem(datasource, is_live, gps_range, state_vector, dq_vector, idq_series)

Bases: tuple

property datasource

Alias for field number 0

property dq_vector

Alias for field number 4

property gps_range

Alias for field number 2

property idq_series

Alias for field number 5

property is_live

Alias for field number 1

property state_vector

Alias for field number 3

class stream.Stream(name: Optional[str] = None, mainloop: Optional[MainLoop] = None, pipeline: Optional[Pipeline] = None, handler: Optional[StreamHandler] = None, source: Optional[SourceElem] = None, head: Optional[Union[Mapping[str, Element], Element]] = None)[source]

Bases: ElementRegistry

Class for building a GStreamer-based pipeline.

add_callback(msg_type: MessageType, *args) None[source]

Attach a callback which get invoked when new bus messages are available.

Args:
msg_type:

Gst.MessageType, the type of message to invoke a callback for.

*args:

extra arguments

bufsink(func: Callable[Buffer, None], caps: Optional[Caps] = None) None[source]

Terminate this stream with an appsink element and process new buffers with a callback.

Args:
func:

Callable[[Buffer], None], a callback that gets invoked when a new buffer is available

caps:

Gst.Caps, how to interpret the contents of the raw buffers. If not set, defaults to raw audio buffers (audio/x-raw).

clear() Stream[source]

Return a new stream with all pointers to elements cleared out.

connect(*args, **kwargs) None[source]

Attach a callback to one of this element’s signals.

classmethod from_datasource(data_source_info: DataSourceInfo, ifos: Union[str, Iterable[str]], name: Optional[str] = None, verbose: bool = False, state_vector: bool = False, dq_vector: bool = False, idq_series: bool = False) Stream[source]

Construct a Stream from a datasource.DataSourceInfo object.

Args:
data_source_info:

DataSourceInfo, the object to construct this stream with.

ifos:

Union[str, Iterable[str]], the detectors read timeseries data for.

name:

str, a name for the GStreamer pipeline (optional). If not set, generates a unique name.

verbose:

bool, default False, whether to display logging/progress information.

state_vector:

bool, default False, whether to attach state vector information to this Stream

dq_vector:

bool, default False, whether to attach data quality vector information to this Stream

idq_series:

bool, default False, whether to fetch idq data information with this Stream

Returns:

Stream, the newly created stream.

get_element_by_name(name: str) Element[source]

Retrieve an element from the stream’s pipeline by name.

Args:
name:

str, the name of the element to retrieve

Returns:

Gst.Element, the element associated with the name given.

items() Iterable[Tuple[str, Stream]][source]
keys() Iterable[str][source]
post_message(msg_name: None, timestamp: Optional[int] = None) None[source]

Post a new application message to this stream’s bus.

Args:
msg_name:

str, the name of the application message to send.

timestamp:

(int, optional), the timestamp to attach to this message.

set_state(state: State) None[source]

Set pipeline state, checking for errors.

Args:
state:

Gst.State: The state to set this stream’s pipeline to.

Raises:
RuntimeError:

If the pipeline failed to transition to the state specified.

start() None[source]

Start the main event loop for this stream.

values() Iterable[Stream][source]
class stream.StreamHandler(*args, **kwargs)[source]

Bases: Handler

add_callback(msg_type: MessageType, *args) None[source]

Attach a callback which get invoked when new bus messages are available.

Args:
msg_type:

Gst.MessageType, the type of message to invoke a callback for.

*args:

extra arguments

do_on_message(bus: Bus, message: Message)[source]

Invoke registered callbacks when new bus messages are received.

Args:
bus:

Gst.Bus, the GStreamer bus.

message:

Gst.Message, the message received.

Returns:

bool, whether further message handling is performed by the parent class with default cases for EOS, INFO, WARNING and ERROR messages.