Module API

Top-level module API.

If you’d like to import Shaka Streamer as a Python module and build it into your own application, this is the top-level API you can use for that. You may also want to look at the source code to the command-line front end script shaka-streamer.

class streamer.controller_node.ControllerNode[source]

Bases: object

Controls all other nodes and manages shared resources.

start(output_location: str, input_config_dict: Dict[str, Any], pipeline_config_dict: Dict[str, Any], bitrate_config_dict: Dict[Any, Any] = {}, check_deps: bool = True, use_hermetic: bool = True) ControllerNode[source]

Create and start all other nodes.

Raises:

RuntimeError if the controller has already started.

Raises:

streamer.configuration.ConfigError if the configuration is invalid.

check_status() ProcessStatus[source]

Checks the status of all the nodes.

If one node is errored, this returns Errored; otherwise if one node is running, this returns Running; this only returns Finished if all nodes are finished. If there are no nodes, this returns Finished.

stop() None[source]

Stop all nodes.

is_vod() bool[source]

Returns True if the pipeline is running in VOD mode.

Return type:

bool

is_low_latency_dash_mode() bool[source]

Returns True if the pipeline is running in LL-DASH mode.

Return type:

bool

exception streamer.controller_node.VersionError(name: str, problem: str, required_version: str, exact_match: bool = False, addendum: str = '')[source]

Bases: Exception

A version error for one of Shaka Streamer’s external dependencies.

Raised when a dependency (like FFmpeg) is missing or not new enough to work with Shaka Streamer. See also Installing Prerequisites.

add_note(object, /)

Exception.add_note(note) – add a note to the exception

args
with_traceback(object, /)

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

class streamer.node_base.ProcessStatus(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: Enum

Finished = 0

The node has completed its task and shut down.

Running = 1

The node is still running.

Errored = 2

The node has failed.

exception streamer.configuration.ConfigError(class_ref, field_name, field)[source]

Bases: Exception

A base class for config errors.

Each subclass provides a meaningful, human-readable string representation in English.

class_ref

A reference to the config class that the error refers to.

class_name

The name of the config class that the error refers to.

field_name

The name of the field that the error refers to.

field

The Field metadata object that the error refers to.

exception streamer.configuration.UnrecognizedField(class_ref, field_name, field)[source]

Bases: ConfigError

An error raised when an unrecognized field is encountered in the input.

exception streamer.configuration.WrongType(class_ref, field_name, field)[source]

Bases: ConfigError

An error raised when a field in the input has the wrong type.

exception streamer.configuration.MissingRequiredField(class_ref, field_name, field)[source]

Bases: ConfigError

An error raised when a required field is missing from the input.

exception streamer.configuration.MalformedField(class_ref, field_name, field, reason)[source]

Bases: ConfigError

An error raised when a field is malformed.

exception streamer.configuration.ConflictingFields(class_ref, field1_name, field2_name)[source]

Bases: ConfigError

An error raised when multiple fields are given and only one of them is allowed at a time.

exception streamer.configuration.MissingRequiredExclusiveFields(class_ref, field1_name, field2_name)[source]

Bases: ConfigError

An error raised when one of an exclusively required fields is missing.

class streamer.configuration.HexString[source]

Bases: ValidatingType, str

A wrapper that can be used in Field() to require a hex string.

class streamer.configuration.RuntimeMap(dictionary: Dict[str, Any])[source]

Bases: Generic[RuntimeMapSubclass], Base

Maintains a map of keys to specific instances from the config file.

This means a Field can have its type defined before the valid keys/values of that type are known. For example, this is used for resolutions, which are defined by a config file.

After calling set_map on the subclass, the get_value method can be used to look up a value from its key. For example, after setting the map to {‘foo’: ‘bar’}, ‘foo’ becomes the only valid key. Passing the key ‘foo’ to the get_value then results in the value ‘bar’ being returned.

classmethod set_map(map: Dict[str, RuntimeMapSubclass]) None[source]

Set the map of valid values for this class.

classmethod get_value(key: str) RuntimeMapSubclass[source]

Get a valid value by its key.

classmethod keys()[source]

This allows the config system to print the list of allowed strings.

classmethod sorted_values() List[RuntimeMapSubclass][source]
class streamer.configuration.RuntimeMapKeyValidator[source]

Bases: ValidatingType, str

A validator that only allows the valid keys for a certain RuntimeMap subclass.

A RuntimeMap subclass should be paired with a RuntimeMapKeyValidator subclass. The RuntimeMapKeyValidator subclass should have a “map_class” variable which points to the RuntimeMap subclass.

map_class: Type[RuntimeMap] = None
classmethod name() str[source]
classmethod validate(key)[source]