Skip to main content
Version: 2.5.x (dev)

Source / Input / Active

input​

Input an audio stream using the default operator.

Type:

(?id : string?, ?start : bool, ?fallible : bool) -> source(audio=pcm('A))

Synchronization:

This source uses the PulseAudio clock as synchronization source when self_sync=true and the stream is open.

Composition:

This source uses live composition by default.

Arguments:

  • id (of type string?, which defaults to null): Force the value of the source ID.
  • start (of type bool, which defaults to true): Automatically start outputting whenever possible. If true, an infallible (normal) output will start outputting as soon as it is created, and a fallible output will (re)start as soon as its source becomes available for streaming.
  • fallible (of type bool, which defaults to false): Allow the child source to fail, in which case the output will be (temporarily) stopped.

Methods:

  • buffered (of type () -> [string * float]): Length of buffered data.
  • callbacks_count (of type () -> [string * int]): Callbacks a script has registered on this source, as pairs of callback name and count. A count that keeps growing is a function registering on a source it is handed without releasing what it registered.
  • clear_last_metadata (of type () -> unit): Clear the last metadata from the source.
  • clock (of type clock): The source's clock
  • duration (of type () -> float): Estimation of the duration of the current track.
  • elapsed (of type () -> float): Elapsed time in the current track.
  • fallible (of type bool): Indicate if a source may fail, i.e. may not be ready to stream.
  • generate_frame (of type () -> unit): Generate a frame from the source without consuming it. This can be useful in advanced cases where generating a frame is required to trigger some side effect like calculating some metadata before making a decision. You should make sure that the source is available before calling this function and it should only be called inside synchronous streaming loop callback such as on_frame!
  • id (of type () -> string): Identifier of the source.
  • insert_metadata (of type (?override : bool, ?new_track : bool, [string * string]) -> unit): Dynamically insert metadata in a stream. Inserts a new track with the given metadata if new_track is true. When override is false, metadata that the source provides itself takes precedence over the inserted one.
  • is_active (of type () -> bool): true if the source is active, i.e. it is continuously animated by its own clock whenever it is ready. Typically, true for outputs and sources such as input.http.
  • is_ready (of type () -> bool): Indicate if a source is ready to stream. This does not mean that the source is currently streaming, just that its resources are all properly initialized.
  • is_started (of type () -> bool): true if the output or source is started.
  • is_up (of type () -> bool): Indicate that the source can be asked to produce some data at any time. This is true when the source is currently being used or if it could be used at any time, typically inside a switch or fallback.
  • last_metadata (of type () -> [string * string]?): Return the last metadata from the source.
  • log (of type {level : (() -> int).{exchange : (int) -> int, set : (int) -> unit}}): Get or set the source's log level, from 1 to 5.
  • register_command (of type (?usage : string?, description : string, string, ((string) -> string)) -> unit): Register a server command for this source. Command is registered under the source's id namespace when it gets up and de-registered when it gets down.
  • remaining (of type () -> float): Estimation of remaining time in the current track.
  • reset_last_metadata_on_track (of type (() -> bool).{exchange : (bool) -> bool, set : (bool) -> unit}): If true, the source's last_metadata is reset on each new track. If a metadata is present along with the track mark, then it becomes the new last_metadata, otherwise, last_metadata becomes null`.
  • seek (of type (float) -> float): Seek forward, in seconds (returns the amount of time effectively seeked).
  • self_sync (of type () -> bool): Is the source currently controlling its own real-time loop.
  • self_sync_description (of type () -> string): This source uses the PulseAudio clock as synchronization source when self_sync=true and the stream is open.
  • skip (of type () -> unit): Skip to the next track.
  • start (of type () -> unit): Ask the source or output to start.
  • stop (of type () -> unit): Ask the source or output to stop.
  • time (of type () -> float): Get a source's time, based on its assigned clock.

Callbacks:

  • on_collect (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called when source is collected
  • on_frame (of type (?before : bool, synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler on frame. When before is true, callback is executed before computing the frame and after otherwise
  • on_frame_checksum (of type (?before : ((string?) -> unit)?, synchronous : bool, ((cache : string?, string) -> unit)) -> {release : () -> unit}): Call a given handler Register callbacks to compute frame checksums for debugging purposes. This is useful to track frame content changes through the streaming pipeline. The before callback is called before computing the frame with the checksum of the cached frame (if any, null otherwise). The main callback is called after computing the frame with the checksum of the generated frame and the remaining cache (if any).
  • on_metadata (of type (synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}): Call a given handler to execute on each metadata
  • on_position (of type (position : {float}, ?remaining : bool, ?allow_partial : bool, synchronous : bool, ((float, [string * string]) -> unit)) -> {release : () -> unit}): Call a given handler on track position. If remaining is false, callback is executed when position in track is more or equal to position. If remaining is true, callback is executed when remaining time in the current track is less or equal to position. Keep in mind that elapsed time is exact while remaining time is always estimated. Remaining time is usually more accurate for file-based sources. When allow_partial is true, if the current track ends before the offset position is reached, callback is still executed
  • on_shutdown (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called when source shuts down
  • on_start (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler when source starts
  • on_stop (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler when source stops
  • on_track (of type (synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}): Call a given handler on track marks
  • on_wake_up (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called after the source is asked to get ready

Composition methods:

  • composition_type (of type (() -> string).{exchange : (string) -> string, set : (string) -> unit}): This source uses live composition by default.
  • on_leave (of type ({source : source(audio=pcm('A)), track_sensitive : bool}) -> unit): Called after switching away from this source in a switch operator, once the transition using the ending source has completed. Receives a record with source (the source being left) and track_sensitive (true if the ending source's last frame had a track mark, i.e. it finished naturally; false if it was preempted mid-track). This function must return quickly as it runs in the streaming thread. The default depends on the active composition profile: file sources (source.composition.file) skip the source when preempted mid-track so it starts fresh on its next selection, and do nothing when it finished naturally; live sources (source.composition.live) do nothing.
  • on_select (of type ( { ending : source(audio=pcm('A))?, replay_metadata : bool, starting : source(audio=pcm('A)) }) -> source(audio=pcm('A))): Called when selecting this source in a switch operator. Receives a record with starting (the incoming source) and ending (the previous source, or null when the ending source reached a track boundary). Returns the source to use. By default, both file and live profiles fade out ending when non-null (up to 1 second). The default is looked up at runtime from the active composition profile (source.composition.file or source.composition.live depending on composition_type).
  • replay_metadata (of type {bool}): Whether to replay the latest metadata on this source when it is selected in a switch operator. Defaults to true. The value is looked up at runtime from the active composition profile (source.composition.file or source.composition.live depending on composition_type).
  • single (of type bool): Forbid the selection of this source for two consecutive tracks in switch operators. Defaults to false.
  • track_sensitive (of type {bool}): Whether this source insists on track boundaries in switch operators: when true, it prefers not to be interrupted mid-track and not to be started mid-track. A switch may only cut into a track that is still playing when at least one of the two sources involved has track_sensitive set to false; otherwise it waits for the playing source to reach a track boundary. File-based sources default to true; live network and hardware inputs default to false. The value is looked up at runtime from the active composition profile (source.composition.file or source.composition.live depending on composition_type).

input.alsa​

Stream from an ALSA input device.

Type:

(?id : string?, ?buffer_size : float?, ?device : string, ?fallible : bool,
?self_sync : bool, ?start : bool) -> source(audio=pcm('a))

Synchronization:

This source uses the ALSA hardware clock as synchronization source when self_sync=true and the device is open.

Composition:

This source uses live composition by default.

Arguments:

  • id (of type string?, which defaults to null): Force the value of the source ID.
  • buffer_size (of type float?, which defaults to null): ALSA buffer size in seconds. Defaults to frame duration when null.
  • device (of type string, which defaults to "default"): Alsa device to use
  • fallible (of type bool, which defaults to false): Allow the source to fail. If set to false, start must be true and stop method raises an error.
  • self_sync (of type bool, which defaults to true): Mark the source as being synchronized by the ALSA driver.
  • start (of type bool, which defaults to true): Start input as soon as it is available.

Methods:

  • buffered (of type () -> [string * float]): Length of buffered data.
  • callbacks_count (of type () -> [string * int]): Callbacks a script has registered on this source, as pairs of callback name and count. A count that keeps growing is a function registering on a source it is handed without releasing what it registered.
  • clear_last_metadata (of type () -> unit): Clear the last metadata from the source.
  • clock (of type clock): The source's clock
  • duration (of type () -> float): Estimation of the duration of the current track.
  • elapsed (of type () -> float): Elapsed time in the current track.
  • fallible (of type bool): Indicate if a source may fail, i.e. may not be ready to stream.
  • generate_frame (of type () -> unit): Generate a frame from the source without consuming it. This can be useful in advanced cases where generating a frame is required to trigger some side effect like calculating some metadata before making a decision. You should make sure that the source is available before calling this function and it should only be called inside synchronous streaming loop callback such as on_frame!
  • id (of type () -> string): Identifier of the source.
  • insert_metadata (of type (?override : bool, ?new_track : bool, [string * string]) -> unit): Dynamically insert metadata in a stream. Inserts a new track with the given metadata if new_track is true. When override is false, metadata that the source provides itself takes precedence over the inserted one.
  • is_active (of type () -> bool): true if the source is active, i.e. it is continuously animated by its own clock whenever it is ready. Typically, true for outputs and sources such as input.http.
  • is_ready (of type () -> bool): Indicate if a source is ready to stream. This does not mean that the source is currently streaming, just that its resources are all properly initialized.
  • is_started (of type () -> bool): true if the output or source is started.
  • is_up (of type () -> bool): Indicate that the source can be asked to produce some data at any time. This is true when the source is currently being used or if it could be used at any time, typically inside a switch or fallback.
  • last_metadata (of type () -> [string * string]?): Return the last metadata from the source.
  • log (of type {level : (() -> int).{exchange : (int) -> int, set : (int) -> unit}}): Get or set the source's log level, from 1 to 5.
  • register_command (of type (?usage : string?, description : string, string, ((string) -> string)) -> unit): Register a server command for this source. Command is registered under the source's id namespace when it gets up and de-registered when it gets down.
  • remaining (of type () -> float): Estimation of remaining time in the current track.
  • reset_last_metadata_on_track (of type (() -> bool).{exchange : (bool) -> bool, set : (bool) -> unit}): If true, the source's last_metadata is reset on each new track. If a metadata is present along with the track mark, then it becomes the new last_metadata, otherwise, last_metadata becomes null`.
  • seek (of type (float) -> float): Seek forward, in seconds (returns the amount of time effectively seeked).
  • self_sync (of type () -> bool): Is the source currently controlling its own real-time loop.
  • self_sync_description (of type () -> string): This source uses the ALSA hardware clock as synchronization source when self_sync=true and the device is open.
  • skip (of type () -> unit): Skip to the next track.
  • start (of type () -> unit): Ask the source or output to start.
  • stop (of type () -> unit): Ask the source or output to stop.
  • time (of type () -> float): Get a source's time, based on its assigned clock.

Callbacks:

  • on_collect (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called when source is collected
  • on_frame (of type (?before : bool, synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler on frame. When before is true, callback is executed before computing the frame and after otherwise
  • on_frame_checksum (of type (?before : ((string?) -> unit)?, synchronous : bool, ((cache : string?, string) -> unit)) -> {release : () -> unit}): Call a given handler Register callbacks to compute frame checksums for debugging purposes. This is useful to track frame content changes through the streaming pipeline. The before callback is called before computing the frame with the checksum of the cached frame (if any, null otherwise). The main callback is called after computing the frame with the checksum of the generated frame and the remaining cache (if any).
  • on_metadata (of type (synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}): Call a given handler to execute on each metadata
  • on_position (of type (position : {float}, ?remaining : bool, ?allow_partial : bool, synchronous : bool, ((float, [string * string]) -> unit)) -> {release : () -> unit}): Call a given handler on track position. If remaining is false, callback is executed when position in track is more or equal to position. If remaining is true, callback is executed when remaining time in the current track is less or equal to position. Keep in mind that elapsed time is exact while remaining time is always estimated. Remaining time is usually more accurate for file-based sources. When allow_partial is true, if the current track ends before the offset position is reached, callback is still executed
  • on_shutdown (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called when source shuts down
  • on_start (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler when source starts
  • on_stop (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler when source stops
  • on_track (of type (synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}): Call a given handler on track marks
  • on_wake_up (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called after the source is asked to get ready

Composition methods:

  • composition_type (of type (() -> string).{exchange : (string) -> string, set : (string) -> unit}): This source uses live composition by default.
  • on_leave (of type ({source : source(audio=pcm('a)), track_sensitive : bool}) -> unit): Called after switching away from this source in a switch operator, once the transition using the ending source has completed. Receives a record with source (the source being left) and track_sensitive (true if the ending source's last frame had a track mark, i.e. it finished naturally; false if it was preempted mid-track). This function must return quickly as it runs in the streaming thread. The default depends on the active composition profile: file sources (source.composition.file) skip the source when preempted mid-track so it starts fresh on its next selection, and do nothing when it finished naturally; live sources (source.composition.live) do nothing.
  • on_select (of type ( { ending : source(audio=pcm('a))?, replay_metadata : bool, starting : source(audio=pcm('a)) }) -> source(audio=pcm('a))): Called when selecting this source in a switch operator. Receives a record with starting (the incoming source) and ending (the previous source, or null when the ending source reached a track boundary). Returns the source to use. By default, both file and live profiles fade out ending when non-null (up to 1 second). The default is looked up at runtime from the active composition profile (source.composition.file or source.composition.live depending on composition_type).
  • replay_metadata (of type {bool}): Whether to replay the latest metadata on this source when it is selected in a switch operator. Defaults to true. The value is looked up at runtime from the active composition profile (source.composition.file or source.composition.live depending on composition_type).
  • single (of type bool): Forbid the selection of this source for two consecutive tracks in switch operators. Defaults to false.
  • track_sensitive (of type {bool}): Whether this source insists on track boundaries in switch operators: when true, it prefers not to be interrupted mid-track and not to be started mid-track. A switch may only cut into a track that is still playing when at least one of the two sources involved has track_sensitive set to false; otherwise it waits for the playing source to reach a track boundary. File-based sources default to true; live network and hardware inputs default to false. The value is looked up at runtime from the active composition profile (source.composition.file or source.composition.live depending on composition_type).

input.ffmpeg​

Read a stream from a URL or a device with FFmpeg.

Type:

(?id : string?, ?debug : bool, ?deduplicate_metadata : bool,
?float_args : [string * float], ?format : string?,
?int_args : [string * int], ?max_buffer : float,
?metadata_filter : (([string * string]) -> [string * string])?,
?new_track_on_metadata : bool, ?poll_delay : float, ?self_sync : {bool},
?start : bool, ?string_args : [string * string], ?timeout : float,
?trim_url : bool, {string}) -> source('a)

Synchronization:

This source paces its clock while connected when self_sync is true.

Composition:

This source uses live composition by default.

Arguments:

  • id (of type string?, which defaults to null): Force the value of the source ID.
  • debug (of type bool, which defaults to false): Log every fault with its backtrace at error level.
  • deduplicate_metadata (of type bool, which defaults to true): Drop metadata equal to the previous one of the same connection.
  • float_args (of type [string * float], which defaults to []): FFmpeg options, each stored as a float option.
  • format (of type string?, which defaults to null): Input format short name.
  • int_args (of type [string * int], which defaults to []): FFmpeg options, each stored as an integer option.
  • max_buffer (of type float, which defaults to 5.0): Maximum decoded data held by the source, in seconds.
  • metadata_filter (of type (([string * string]) -> [string * string])?, which defaults to null): Metadata filter, replacing the default one, which drops the keys starting with id3v2_priv.
  • new_track_on_metadata (of type bool, which defaults to true): Start a new track at each metadata.
  • poll_delay (of type float, which defaults to 2.0): Delay before a retry after a failure, and interval of the URL check while failed, in seconds.
  • self_sync (of type {bool}, which defaults to false): Pace the clock while connected. For live URLs only: on an input whose reads do not block (a file, a generator) the clock then runs as fast as the reads return.
  • start (of type bool, which defaults to true): Start input as soon as it is available.
  • string_args (of type [string * string], which defaults to []): FFmpeg options, each stored as a string option.
  • timeout (of type float, which defaults to 10.0): Longest a single blocking read may last, in seconds, on an input that is not listening.
  • trim_url (of type bool, which defaults to true): Strip leading and trailing whitespace from the URL.
  • (unlabeled) (of type {string}): URL to read from.

Methods:

  • buffered (of type () -> [string * float]): Length of buffered data.
  • callbacks_count (of type () -> [string * int]): Callbacks a script has registered on this source, as pairs of callback name and count. A count that keeps growing is a function registering on a source it is handed without releasing what it registered.
  • clear_last_metadata (of type () -> unit): Clear the last metadata from the source.
  • clock (of type clock): The source's clock
  • duration (of type () -> float): Estimation of the duration of the current track.
  • elapsed (of type () -> float): Elapsed time in the current track.
  • fallible (of type bool): Indicate if a source may fail, i.e. may not be ready to stream.
  • generate_frame (of type () -> unit): Generate a frame from the source without consuming it. This can be useful in advanced cases where generating a frame is required to trigger some side effect like calculating some metadata before making a decision. You should make sure that the source is available before calling this function and it should only be called inside synchronous streaming loop callback such as on_frame!
  • id (of type () -> string): Identifier of the source.
  • insert_metadata (of type (?override : bool, ?new_track : bool, [string * string]) -> unit): Dynamically insert metadata in a stream. Inserts a new track with the given metadata if new_track is true. When override is false, metadata that the source provides itself takes precedence over the inserted one.
  • is_active (of type () -> bool): true if the source is active, i.e. it is continuously animated by its own clock whenever it is ready. Typically, true for outputs and sources such as input.http.
  • is_ready (of type () -> bool): Indicate if a source is ready to stream. This does not mean that the source is currently streaming, just that its resources are all properly initialized.
  • is_started (of type () -> bool): true if the output or source is started.
  • is_up (of type () -> bool): Indicate that the source can be asked to produce some data at any time. This is true when the source is currently being used or if it could be used at any time, typically inside a switch or fallback.
  • last_metadata (of type () -> [string * string]?): Return the last metadata from the source.
  • log (of type {level : (() -> int).{exchange : (int) -> int, set : (int) -> unit}}): Get or set the source's log level, from 1 to 5.
  • register_command (of type (?usage : string?, description : string, string, ((string) -> string)) -> unit): Register a server command for this source. Command is registered under the source's id namespace when it gets up and de-registered when it gets down.
  • remaining (of type () -> float): Estimation of remaining time in the current track.
  • reset_last_metadata_on_track (of type (() -> bool).{exchange : (bool) -> bool, set : (bool) -> unit}): If true, the source's last_metadata is reset on each new track. If a metadata is present along with the track mark, then it becomes the new last_metadata, otherwise, last_metadata becomes null`.
  • seek (of type (float) -> float): Seek forward, in seconds (returns the amount of time effectively seeked).
  • self_sync (of type () -> bool): Is the source currently controlling its own real-time loop.
  • self_sync_description (of type () -> string): This source paces its clock while connected when self_sync is true.
  • set_url (of type ({string}) -> unit): Set the URL, used at the next connection.
  • skip (of type () -> unit): Skip to the next track.
  • start (of type () -> unit): Ask the source or output to start.
  • status (of type () -> string): Status: "stopped", "starting", "polling", "connected <url>", "stopping" or "failed".
  • stop (of type () -> unit): Ask the source or output to stop.
  • time (of type () -> float): Get a source's time, based on its assigned clock.
  • url (of type () -> string): Current URL.

Callbacks:

  • on_collect (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called when source is collected
  • on_connect (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler when connected, before the source plays the connection's data.
  • on_disconnect (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler when a connection whose on_connect callbacks ran ends.
  • on_error (of type (synchronous : bool, ((error) -> unit)) -> {release : () -> unit}): Call a given handler on each connection or feeding failure.
  • on_frame (of type (?before : bool, synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler on frame. When before is true, callback is executed before computing the frame and after otherwise
  • on_frame_checksum (of type (?before : ((string?) -> unit)?, synchronous : bool, ((cache : string?, string) -> unit)) -> {release : () -> unit}): Call a given handler Register callbacks to compute frame checksums for debugging purposes. This is useful to track frame content changes through the streaming pipeline. The before callback is called before computing the frame with the checksum of the cached frame (if any, null otherwise). The main callback is called after computing the frame with the checksum of the generated frame and the remaining cache (if any).
  • on_metadata (of type (synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}): Call a given handler to execute on each metadata
  • on_position (of type (position : {float}, ?remaining : bool, ?allow_partial : bool, synchronous : bool, ((float, [string * string]) -> unit)) -> {release : () -> unit}): Call a given handler on track position. If remaining is false, callback is executed when position in track is more or equal to position. If remaining is true, callback is executed when remaining time in the current track is less or equal to position. Keep in mind that elapsed time is exact while remaining time is always estimated. Remaining time is usually more accurate for file-based sources. When allow_partial is true, if the current track ends before the offset position is reached, callback is still executed
  • on_shutdown (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called when source shuts down
  • on_start (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler when source starts
  • on_stop (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler when source stops
  • on_track (of type (synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}): Call a given handler on track marks
  • on_wake_up (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called after the source is asked to get ready

Composition methods:

  • composition_type (of type (() -> string).{exchange : (string) -> string, set : (string) -> unit}): This source uses live composition by default.
  • on_leave (of type ({source : source('a), track_sensitive : bool}) -> unit): Called after switching away from this source in a switch operator, once the transition using the ending source has completed. Receives a record with source (the source being left) and track_sensitive (true if the ending source's last frame had a track mark, i.e. it finished naturally; false if it was preempted mid-track). This function must return quickly as it runs in the streaming thread. The default depends on the active composition profile: file sources (source.composition.file) skip the source when preempted mid-track so it starts fresh on its next selection, and do nothing when it finished naturally; live sources (source.composition.live) do nothing.
  • on_select (of type ({ending : source('a)?, replay_metadata : bool, starting : source('a)}) -> source('a)): Called when selecting this source in a switch operator. Receives a record with starting (the incoming source) and ending (the previous source, or null when the ending source reached a track boundary). Returns the source to use. By default, both file and live profiles fade out ending when non-null (up to 1 second). The default is looked up at runtime from the active composition profile (source.composition.file or source.composition.live depending on composition_type).
  • replay_metadata (of type {bool}): Whether to replay the latest metadata on this source when it is selected in a switch operator. Defaults to true. The value is looked up at runtime from the active composition profile (source.composition.file or source.composition.live depending on composition_type).
  • single (of type bool): Forbid the selection of this source for two consecutive tracks in switch operators. Defaults to false.
  • track_sensitive (of type {bool}): Whether this source insists on track boundaries in switch operators: when true, it prefers not to be interrupted mid-track and not to be started mid-track. A switch may only cut into a track that is still playing when at least one of the two sources involved has track_sensitive set to false; otherwise it waits for the playing source to reach a track boundary. File-based sources default to true; live network and hardware inputs default to false. The value is looked up at runtime from the active composition profile (source.composition.file or source.composition.live depending on composition_type).

input.harbor​

Create a source that receives a http/icecast stream and forwards it as a stream.

Type:

(?id : string?,
?accept : ((
{
address : string,
headers : [string * string],
method : string,
password : string,
query : [string * string],
uri : string,
user : string
}) ->
{
refuse? :
{headers? : [string * string], reason : string, status : int
}?}?)?,
?auth : ((
{
address : string,
headers : [string * string],
method : string,
password : string,
query : [string * string],
uri : string,
user : string
}) -> bool)?,
?buffer : float, ?debug : bool, ?dumpfile : string?, ?icy : bool,
?icy_metadata_charset : string?, ?logfile : string?, ?max : float,
?metadata_charset : string?, ?password : string, ?port : int,
?replay_metadata : bool, ?timeout : {float}, ?transport : http_transport,
?user : string, string) -> source('a)

Composition:

This source uses live composition by default.

Arguments:

  • id (of type string?, which defaults to null): Force the value of the source ID.
  • accept (of type (( { address : string, headers : [string * string], method : string, password : string, query : [string * string], uri : string, user : string }) -> {refuse? : {headers? : [string * string], reason : string, status : int}?}?)?, which defaults to null): Admission of a source client that passed auth, with the same record. It also runs for the GET logins of ICY metadata updates. A decision with refuse = {status, reason, headers?} refuses the client with that reply and an empty body; null or no refuse admits it. A refusal whose status is outside 300 to 599, or with a line break in its reason or headers, and a function that raises, refuse with 403 Forbidden.
  • auth (of type (( { address : string, headers : [string * string], method : string, password : string, query : [string * string], uri : string, user : string }) -> bool)?, which defaults to null): Authentication function. Receives a record with: user, password, uri (request URI), query (URL query parameters as a list of key-value pairs), address (client network address) and method (connection method: "PUT" or "POST" for HTTP source connections, "SOURCE" for Xaudiocast/ICE sources, "ICY" for Shoutcast/ICY sources, "WEBSOCKET" for WebSocket sources, "GET" for ICY metadata updates), and headers (the request headers, lowercase names, empty for ICY sources) and returns true if the user should be granted access for this login. A request without credentials is refused unless accept is given, in which case it is passed empty ones. Override any other method if used.
  • buffer (of type float, which defaults to 12.0): Duration of the pre-buffered data (in seconds). Default value is set to make it possible to use crossfade transitions with input.harbor. You might be able to reduce it but, in this case, make sure to not use the operator with crossfade or make sure that it has enough buffered data for it.
  • debug (of type bool, which defaults to false): Run in debugging mode by not catching some exceptions.
  • dumpfile (of type string?, which defaults to null): Dump stream to file, for debugging purpose. Disabled if null.
  • icy (of type bool, which defaults to false): Enable ICY (shoutcast) protocol.
  • icy_metadata_charset (of type string?, which defaults to null): ICY (shoutcast) metadata charset. Guessed if null. Default for shoutcast is ISO-8859-1. Set to that value if all your clients send metadata using this charset and automatic detection is not working for you.
  • logfile (of type string?, which defaults to null): Log buffer status to file, for debugging purpose. Disabled if null.
  • max (of type float, which defaults to 20.0): Maximum duration of the buffered data (in seconds).
  • metadata_charset (of type string?, which defaults to null): Metadata charset for non-ICY (shoutcast) source protocols. Guessed if null.
  • password (of type string, which defaults to "hackme"): Source password.
  • port (of type int, which defaults to 8005): Port used to connect to the source.
  • replay_metadata (of type bool, which defaults to false): Replay last known metadata when switching back to this source. This helps when source has dropped due to temporary connection issues.
  • timeout (of type {float}, which defaults to 30.0): Timeout for source connections, in seconds. input.harbor reads it when it is created, input.harbor.dynamic when each client connects.
  • transport (of type http_transport, which defaults to <unix_transport>): Http transport. Use http.transport.ssl, when available, to enable HTTPS output
  • user (of type string, which defaults to "source"): Source user.
  • (unlabeled) (of type string): Mountpoint to look for.

Methods:

  • buffer_length (of type () -> float): Length of the buffer (in seconds).
  • buffered (of type () -> [string * float]): Length of buffered data.
  • bytes_read (of type () -> int): Bytes read from source clients since the input was created.
  • callbacks_count (of type () -> [string * int]): Callbacks a script has registered on this source, as pairs of callback name and count. A count that keeps growing is a function registering on a source it is handed without releasing what it registered.
  • clear_last_metadata (of type () -> unit): Clear the last metadata from the source.
  • clock (of type clock): The source's clock
  • connected_client (of type () -> string?): Returns the address of the client currently connected, if there is one.
  • duration (of type () -> float): Estimation of the duration of the current track.
  • elapsed (of type () -> float): Elapsed time in the current track.
  • fallible (of type bool): Indicate if a source may fail, i.e. may not be ready to stream.
  • generate_frame (of type () -> unit): Generate a frame from the source without consuming it. This can be useful in advanced cases where generating a frame is required to trigger some side effect like calculating some metadata before making a decision. You should make sure that the source is available before calling this function and it should only be called inside synchronous streaming loop callback such as on_frame!
  • id (of type () -> string): Identifier of the source.
  • insert_metadata (of type (?override : bool, ?new_track : bool, [string * string]) -> unit): Dynamically insert metadata in a stream. Inserts a new track with the given metadata if new_track is true. When override is false, metadata that the source provides itself takes precedence over the inserted one.
  • is_active (of type () -> bool): true if the source is active, i.e. it is continuously animated by its own clock whenever it is ready. Typically, true for outputs and sources such as input.http.
  • is_ready (of type () -> bool): Indicate if a source is ready to stream. This does not mean that the source is currently streaming, just that its resources are all properly initialized.
  • is_up (of type () -> bool): Indicate that the source can be asked to produce some data at any time. This is true when the source is currently being used or if it could be used at any time, typically inside a switch or fallback.
  • last_metadata (of type () -> [string * string]?): Return the last metadata from the source.
  • log (of type {level : (() -> int).{exchange : (int) -> int, set : (int) -> unit}}): Get or set the source's log level, from 1 to 5.
  • register_command (of type (?usage : string?, description : string, string, ((string) -> string)) -> unit): Register a server command for this source. Command is registered under the source's id namespace when it gets up and de-registered when it gets down.
  • remaining (of type () -> float): Estimation of remaining time in the current track.
  • reset_last_metadata_on_track (of type (() -> bool).{exchange : (bool) -> bool, set : (bool) -> unit}): If true, the source's last_metadata is reset on each new track. If a metadata is present along with the track mark, then it becomes the new last_metadata, otherwise, last_metadata becomes null`.
  • seek (of type (float) -> float): Seek forward, in seconds (returns the amount of time effectively seeked).
  • self_sync (of type () -> bool): Is the source currently controlling its own real-time loop.
  • self_sync_description (of type () -> string)
  • skip (of type () -> unit): Skip to the next track.
  • status (of type () -> string): Current status of the input.
  • stop (of type () -> unit): Disconnect the client currently connected to the harbor. Does nothing if no client is connected.
  • time (of type () -> float): Get a source's time, based on its assigned clock.

Callbacks:

  • on_collect (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called when source is collected
  • on_connect (of type (synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}): Call a given handler when a source is connected. Its receives the list of headers, of the form: (
  • on_disconnect (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler when a source is disconnected.
  • on_frame (of type (?before : bool, synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler on frame. When before is true, callback is executed before computing the frame and after otherwise
  • on_frame_checksum (of type (?before : ((string?) -> unit)?, synchronous : bool, ((cache : string?, string) -> unit)) -> {release : () -> unit}): Call a given handler Register callbacks to compute frame checksums for debugging purposes. This is useful to track frame content changes through the streaming pipeline. The before callback is called before computing the frame with the checksum of the cached frame (if any, null otherwise). The main callback is called after computing the frame with the checksum of the generated frame and the remaining cache (if any).
  • on_metadata (of type (synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}): Call a given handler to execute on each metadata
  • on_position (of type (position : {float}, ?remaining : bool, ?allow_partial : bool, synchronous : bool, ((float, [string * string]) -> unit)) -> {release : () -> unit}): Call a given handler on track position. If remaining is false, callback is executed when position in track is more or equal to position. If remaining is true, callback is executed when remaining time in the current track is less or equal to position. Keep in mind that elapsed time is exact while remaining time is always estimated. Remaining time is usually more accurate for file-based sources. When allow_partial is true, if the current track ends before the offset position is reached, callback is still executed
  • on_shutdown (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called when source shuts down
  • on_track (of type (synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}): Call a given handler on track marks
  • on_wake_up (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called after the source is asked to get ready

Composition methods:

  • composition_type (of type (() -> string).{exchange : (string) -> string, set : (string) -> unit}): This source uses live composition by default.
  • on_leave (of type ({source : source('a), track_sensitive : bool}) -> unit): Called after switching away from this source in a switch operator, once the transition using the ending source has completed. Receives a record with source (the source being left) and track_sensitive (true if the ending source's last frame had a track mark, i.e. it finished naturally; false if it was preempted mid-track). This function must return quickly as it runs in the streaming thread. The default depends on the active composition profile: file sources (source.composition.file) skip the source when preempted mid-track so it starts fresh on its next selection, and do nothing when it finished naturally; live sources (source.composition.live) do nothing.
  • on_select (of type ({ending : source('a)?, replay_metadata : bool, starting : source('a)}) -> source('a)): Called when selecting this source in a switch operator. Receives a record with starting (the incoming source) and ending (the previous source, or null when the ending source reached a track boundary). Returns the source to use. By default, both file and live profiles fade out ending when non-null (up to 1 second). The default is looked up at runtime from the active composition profile (source.composition.file or source.composition.live depending on composition_type).
  • replay_metadata (of type {bool}): Whether to replay the latest metadata on this source when it is selected in a switch operator. Defaults to true. The value is looked up at runtime from the active composition profile (source.composition.file or source.composition.live depending on composition_type).
  • single (of type bool): Forbid the selection of this source for two consecutive tracks in switch operators. Defaults to false.
  • track_sensitive (of type {bool}): Whether this source insists on track boundaries in switch operators: when true, it prefers not to be interrupted mid-track and not to be started mid-track. A switch may only cut into a track that is still playing when at least one of the two sources involved has track_sensitive set to false; otherwise it waits for the playing source to reach a track boundary. File-based sources default to true; live network and hardware inputs default to false. The value is looked up at runtime from the active composition profile (source.composition.file or source.composition.live depending on composition_type).

input.harbor.dynamic​

Receive any number of source clients on the mountpoints a regexp matches. Each client is decoded with FFmpeg into a source of its own, handed to on_connect with the client's connection record. A source is single-use: a client that reconnects gets a new one. A source that no output uses within timeout is disconnected.

Type:

(?buffer : float, ?max : float, ?timeout : {float}, ?user : string,
?password : string, ?port : int, ?transport : http_transport, ?icy : bool,
?icy_metadata_charset : string?, ?metadata_charset : string?,
?replay_metadata : bool,
?auth : ((
{
address : string,
headers : [string * string],
method : string,
password : string,
query : [string * string],
uri : string,
user : string
}) -> bool)?,
?accept : ((
{
address : string,
headers : [string * string],
method : string,
password : string,
query : [string * string],
uri : string,
user : string
}) ->
{
refuse? :
{headers? : [string * string], reason : string, status : int
}?}?)?,
?dumpfile : string?, ?logfile : string?, ?debug : bool,
on_connect : ((
{
copy_encoder : (?string?, ?options : [string * string]) ->
format('a),
format : string?,
headers : [string * string],
mime_type : string?,
query : [string * string],
streams : [
{
channel_layout? : string,
channels? : int,
codec : string,
field : string,
frame_rate? : float?,
height? : int,
pixel_format? : string,
samplerate? : int,
type : string,
width? : int
}],
uri : string
}) ->
(source('a)
.{
buffer_length : () -> float,
buffered : () -> [string * float],
bytes_read : () -> int,
callbacks_count : () -> [string * int],
clear_last_metadata : () -> unit,
clock : clock,
connected_client : () -> string?,
duration : () -> float,
elapsed : () -> float,
fallible : bool,
generate_frame : () -> unit,
id : () -> string,
insert_metadata : (?override : bool, ?new_track : bool,
[string * string]) -> unit,
is_active : () -> bool,
is_ready : () -> bool,
is_up : () -> bool,
last_metadata : () -> [string * string]?,
log :
{
level : (() -> int)
.{exchange : (int) -> int, set : (int) -> unit
}
},
on_collect : (synchronous : bool, (() -> unit)) ->
{release : () -> unit},
on_connect : (synchronous : bool,
(([string * string]) -> unit)) ->
{release : () -> unit},
on_disconnect : (synchronous : bool, (() -> unit)) ->
{release : () -> unit},
on_frame : (?before : bool, synchronous : bool,
(() -> unit)) -> {release : () -> unit},
on_frame_checksum : (?before : ((string?) -> unit)?,
synchronous : bool,
((cache : string?, string) -> unit)) ->
{release : () -> unit},
on_leave : ({source : source('a), track_sensitive : bool}) ->
unit,
on_metadata : (synchronous : bool,
(([string * string]) -> unit)) ->
{release : () -> unit},
on_position : (position : {float}, ?remaining : bool,
?allow_partial : bool, synchronous : bool,
((float, [string * string]) -> unit)) ->
{release : () -> unit},
on_select : (
{
ending : source('a)?,
replay_metadata : bool,
starting : source('a)
}) -> source('a),
on_shutdown : (synchronous : bool, (() -> unit)) ->
{release : () -> unit},
on_track : (synchronous : bool,
(([string * string]) -> unit)) ->
{release : () -> unit},
on_wake_up : (synchronous : bool, (() -> unit)) ->
{release : () -> unit},
register_command : (?usage : string?, description : string,
string, ((string) -> string)) -> unit,
remaining : () -> float,
replay_metadata : {bool},
reset_last_metadata_on_track : (() -> bool)
.{exchange : (bool) -> bool, set : (bool) -> unit
},
seek : (float) -> float,
self_sync : () -> bool,
self_sync_description : () -> string,
single : bool,
skip : () -> unit,
status : () -> string,
stop : () -> unit,
time : () -> float,
track_sensitive : {bool}
}) -> unit),
string) -> unit

Arguments:

  • buffer (of type float, which defaults to 12.0): Duration of the pre-buffered data (in seconds). Default value is set to make it possible to use crossfade transitions with input.harbor. You might be able to reduce it but, in this case, make sure to not use the operator with crossfade or make sure that it has enough buffered data for it.
  • max (of type float, which defaults to 20.0): Maximum duration of the buffered data (in seconds).
  • timeout (of type {float}, which defaults to 30.0): Timeout for source connections, in seconds. input.harbor reads it when it is created, input.harbor.dynamic when each client connects.
  • user (of type string, which defaults to "source"): Source user.
  • password (of type string, which defaults to "hackme"): Source password.
  • port (of type int, which defaults to 8005): Port used to connect to the source.
  • transport (of type http_transport, which defaults to <unix_transport>): Http transport. Use http.transport.ssl, when available, to enable HTTPS output
  • icy (of type bool, which defaults to false): Enable ICY (shoutcast) protocol.
  • icy_metadata_charset (of type string?, which defaults to null): ICY (shoutcast) metadata charset. Guessed if null. Default for shoutcast is ISO-8859-1. Set to that value if all your clients send metadata using this charset and automatic detection is not working for you.
  • metadata_charset (of type string?, which defaults to null): Metadata charset for non-ICY (shoutcast) source protocols. Guessed if null.
  • replay_metadata (of type bool, which defaults to false): Replay last known metadata when switching back to this source. This helps when source has dropped due to temporary connection issues.
  • auth (of type (( { address : string, headers : [string * string], method : string, password : string, query : [string * string], uri : string, user : string }) -> bool)?, which defaults to null): Authentication function. Receives a record with: user, password, uri (request URI), query (URL query parameters as a list of key-value pairs), address (client network address) and method (connection method: "PUT" or "POST" for HTTP source connections, "SOURCE" for Xaudiocast/ICE sources, "ICY" for Shoutcast/ICY sources, "WEBSOCKET" for WebSocket sources, "GET" for ICY metadata updates), and headers (the request headers, lowercase names, empty for ICY sources) and returns true if the user should be granted access for this login. A request without credentials is refused unless accept is given, in which case it is passed empty ones. Override any other method if used.
  • accept (of type (( { address : string, headers : [string * string], method : string, password : string, query : [string * string], uri : string, user : string }) -> {refuse? : {headers? : [string * string], reason : string, status : int}?}?)?, which defaults to null): Admission of a source client that passed auth, with the same record. It also runs for the GET logins of ICY metadata updates. A decision with refuse = {status, reason, headers?} refuses the client with that reply and an empty body; null or no refuse admits it. A refusal whose status is outside 300 to 599, or with a line break in its reason or headers, and a function that raises, refuse with 403 Forbidden.
  • dumpfile (of type string?, which defaults to null): Dump stream to file, for debugging purpose. Disabled if null.
  • logfile (of type string?, which defaults to null): Log buffer status to file, for debugging purpose. Disabled if null.
  • debug (of type bool, which defaults to false): Run in debugging mode by not catching some exceptions.
  • on_connect (of type ( { copy_encoder : (?string?, ?options : [string * string]) -> format('a), format : string?, headers : [string * string], mime_type : string?, query : [string * string], streams : [ { channel_layout? : string, channels? : int, codec : string, field : string, frame_rate? : float?, height? : int, pixel_format? : string, samplerate? : int, type : string, width? : int }], uri : string }) -> (source('a) .{ buffer_length : () -> float, buffered : () -> [string * float], bytes_read : () -> int, callbacks_count : () -> [string * int], clear_last_metadata : () -> unit, clock : clock, connected_client : () -> string?, duration : () -> float, elapsed : () -> float, fallible : bool, generate_frame : () -> unit, id : () -> string, insert_metadata : (?override : bool, ?new_track : bool, [string * string]) -> unit, is_active : () -> bool, is_ready : () -> bool, is_up : () -> bool, last_metadata : () -> [string * string]?, log : {level : (() -> int).{exchange : (int) -> int, set : (int) -> unit} }, on_collect : (synchronous : bool, (() -> unit)) -> {release : () -> unit}, on_connect : (synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}, on_disconnect : (synchronous : bool, (() -> unit)) -> {release : () -> unit}, on_frame : (?before : bool, synchronous : bool, (() -> unit)) -> {release : () -> unit}, on_frame_checksum : (?before : ((string?) -> unit)?, synchronous : bool, ((cache : string?, string) -> unit)) -> {release : () -> unit}, on_leave : ({source : source('a), track_sensitive : bool}) -> unit, on_metadata : (synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}, on_position : (position : {float}, ?remaining : bool, ?allow_partial : bool, synchronous : bool, ((float, [string * string]) -> unit)) -> {release : () -> unit}, on_select : ( { ending : source('a)?, replay_metadata : bool, starting : source('a) }) -> source('a), on_shutdown : (synchronous : bool, (() -> unit)) -> {release : () -> unit}, on_track : (synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}, on_wake_up : (synchronous : bool, (() -> unit)) -> {release : () -> unit}, register_command : (?usage : string?, description : string, string, ((string) -> string)) -> unit, remaining : () -> float, replay_metadata : {bool}, reset_last_metadata_on_track : (() -> bool) .{exchange : (bool) -> bool, set : (bool) -> unit }, seek : (float) -> float, self_sync : () -> bool, self_sync_description : () -> string, single : bool, skip : () -> unit, status : () -> string, stop : () -> unit, time : () -> float, track_sensitive : {bool} }) -> unit): Called with the connection record of each client; returns the function given the client's source.
  • (unlabeled) (of type string): Mountpoint to look for.

input.harbor.dynamic.regexp​

Receive any number of source clients on the mountpoints a regexp matches. Each client is decoded with FFmpeg into a source of its own, handed to on_connect with the client's connection record. A source is single-use: a client that reconnects gets a new one. A source that no output uses within timeout is disconnected.

Type:

(?buffer : float, ?max : float, ?timeout : {float}, ?user : string,
?password : string, ?port : int, ?transport : http_transport, ?icy : bool,
?icy_metadata_charset : string?, ?metadata_charset : string?,
?replay_metadata : bool,
?auth : ((
{
address : string,
headers : [string * string],
method : string,
password : string,
query : [string * string],
uri : string,
user : string
}) -> bool)?,
?accept : ((
{
address : string,
headers : [string * string],
method : string,
password : string,
query : [string * string],
uri : string,
user : string
}) ->
{
refuse? :
{headers? : [string * string], reason : string, status : int
}?}?)?,
?dumpfile : string?, ?logfile : string?, ?debug : bool, regexp,
on_connect : ((
{
copy_encoder : (?string?, ?options : [string * string]) ->
format('a),
format : string?,
headers : [string * string],
mime_type : string?,
query : [string * string],
streams : [
{
channel_layout? : string,
channels? : int,
codec : string,
field : string,
frame_rate? : float?,
height? : int,
pixel_format? : string,
samplerate? : int,
type : string,
width? : int
}],
uri : string
}) ->
(source('a)
.{
buffer_length : () -> float,
buffered : () -> [string * float],
bytes_read : () -> int,
callbacks_count : () -> [string * int],
clear_last_metadata : () -> unit,
clock : clock,
connected_client : () -> string?,
duration : () -> float,
elapsed : () -> float,
fallible : bool,
generate_frame : () -> unit,
id : () -> string,
insert_metadata : (?override : bool, ?new_track : bool,
[string * string]) -> unit,
is_active : () -> bool,
is_ready : () -> bool,
is_up : () -> bool,
last_metadata : () -> [string * string]?,
log :
{
level : (() -> int)
.{exchange : (int) -> int, set : (int) -> unit
}
},
on_collect : (synchronous : bool, (() -> unit)) ->
{release : () -> unit},
on_connect : (synchronous : bool,
(([string * string]) -> unit)) ->
{release : () -> unit},
on_disconnect : (synchronous : bool, (() -> unit)) ->
{release : () -> unit},
on_frame : (?before : bool, synchronous : bool,
(() -> unit)) -> {release : () -> unit},
on_frame_checksum : (?before : ((string?) -> unit)?,
synchronous : bool,
((cache : string?, string) -> unit)) ->
{release : () -> unit},
on_leave : ({source : source('a), track_sensitive : bool}) ->
unit,
on_metadata : (synchronous : bool,
(([string * string]) -> unit)) ->
{release : () -> unit},
on_position : (position : {float}, ?remaining : bool,
?allow_partial : bool, synchronous : bool,
((float, [string * string]) -> unit)) ->
{release : () -> unit},
on_select : (
{
ending : source('a)?,
replay_metadata : bool,
starting : source('a)
}) -> source('a),
on_shutdown : (synchronous : bool, (() -> unit)) ->
{release : () -> unit},
on_track : (synchronous : bool,
(([string * string]) -> unit)) ->
{release : () -> unit},
on_wake_up : (synchronous : bool, (() -> unit)) ->
{release : () -> unit},
register_command : (?usage : string?, description : string,
string, ((string) -> string)) -> unit,
remaining : () -> float,
replay_metadata : {bool},
reset_last_metadata_on_track : (() -> bool)
.{exchange : (bool) -> bool, set : (bool) -> unit
},
seek : (float) -> float,
self_sync : () -> bool,
self_sync_description : () -> string,
single : bool,
skip : () -> unit,
status : () -> string,
stop : () -> unit,
time : () -> float,
track_sensitive : {bool}
}) -> unit)) -> unit

Arguments:

  • buffer (of type float, which defaults to 12.0): Duration of the pre-buffered data (in seconds). Default value is set to make it possible to use crossfade transitions with input.harbor. You might be able to reduce it but, in this case, make sure to not use the operator with crossfade or make sure that it has enough buffered data for it.
  • max (of type float, which defaults to 20.0): Maximum duration of the buffered data (in seconds).
  • timeout (of type {float}, which defaults to 30.0): Timeout for source connections, in seconds. input.harbor reads it when it is created, input.harbor.dynamic when each client connects.
  • user (of type string, which defaults to "source"): Source user.
  • password (of type string, which defaults to "hackme"): Source password.
  • port (of type int, which defaults to 8005): Port used to connect to the source.
  • transport (of type http_transport, which defaults to <unix_transport>): Http transport. Use http.transport.ssl, when available, to enable HTTPS output
  • icy (of type bool, which defaults to false): Enable ICY (shoutcast) protocol.
  • icy_metadata_charset (of type string?, which defaults to null): ICY (shoutcast) metadata charset. Guessed if null. Default for shoutcast is ISO-8859-1. Set to that value if all your clients send metadata using this charset and automatic detection is not working for you.
  • metadata_charset (of type string?, which defaults to null): Metadata charset for non-ICY (shoutcast) source protocols. Guessed if null.
  • replay_metadata (of type bool, which defaults to false): Replay last known metadata when switching back to this source. This helps when source has dropped due to temporary connection issues.
  • auth (of type (( { address : string, headers : [string * string], method : string, password : string, query : [string * string], uri : string, user : string }) -> bool)?, which defaults to null): Authentication function. Receives a record with: user, password, uri (request URI), query (URL query parameters as a list of key-value pairs), address (client network address) and method (connection method: "PUT" or "POST" for HTTP source connections, "SOURCE" for Xaudiocast/ICE sources, "ICY" for Shoutcast/ICY sources, "WEBSOCKET" for WebSocket sources, "GET" for ICY metadata updates), and headers (the request headers, lowercase names, empty for ICY sources) and returns true if the user should be granted access for this login. A request without credentials is refused unless accept is given, in which case it is passed empty ones. Override any other method if used.
  • accept (of type (( { address : string, headers : [string * string], method : string, password : string, query : [string * string], uri : string, user : string }) -> {refuse? : {headers? : [string * string], reason : string, status : int}?}?)?, which defaults to null): Admission of a source client that passed auth, with the same record. It also runs for the GET logins of ICY metadata updates. A decision with refuse = {status, reason, headers?} refuses the client with that reply and an empty body; null or no refuse admits it. A refusal whose status is outside 300 to 599, or with a line break in its reason or headers, and a function that raises, refuse with 403 Forbidden.
  • dumpfile (of type string?, which defaults to null): Dump stream to file, for debugging purpose. Disabled if null.
  • logfile (of type string?, which defaults to null): Log buffer status to file, for debugging purpose. Disabled if null.
  • debug (of type bool, which defaults to false): Run in debugging mode by not catching some exceptions.
  • (unlabeled) (of type regexp): Mountpoint to look for.
  • on_connect (of type ( { copy_encoder : (?string?, ?options : [string * string]) -> format('a), format : string?, headers : [string * string], mime_type : string?, query : [string * string], streams : [ { channel_layout? : string, channels? : int, codec : string, field : string, frame_rate? : float?, height? : int, pixel_format? : string, samplerate? : int, type : string, width? : int }], uri : string }) -> (source('a) .{ buffer_length : () -> float, buffered : () -> [string * float], bytes_read : () -> int, callbacks_count : () -> [string * int], clear_last_metadata : () -> unit, clock : clock, connected_client : () -> string?, duration : () -> float, elapsed : () -> float, fallible : bool, generate_frame : () -> unit, id : () -> string, insert_metadata : (?override : bool, ?new_track : bool, [string * string]) -> unit, is_active : () -> bool, is_ready : () -> bool, is_up : () -> bool, last_metadata : () -> [string * string]?, log : {level : (() -> int).{exchange : (int) -> int, set : (int) -> unit} }, on_collect : (synchronous : bool, (() -> unit)) -> {release : () -> unit}, on_connect : (synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}, on_disconnect : (synchronous : bool, (() -> unit)) -> {release : () -> unit}, on_frame : (?before : bool, synchronous : bool, (() -> unit)) -> {release : () -> unit}, on_frame_checksum : (?before : ((string?) -> unit)?, synchronous : bool, ((cache : string?, string) -> unit)) -> {release : () -> unit}, on_leave : ({source : source('a), track_sensitive : bool}) -> unit, on_metadata : (synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}, on_position : (position : {float}, ?remaining : bool, ?allow_partial : bool, synchronous : bool, ((float, [string * string]) -> unit)) -> {release : () -> unit}, on_select : ( { ending : source('a)?, replay_metadata : bool, starting : source('a) }) -> source('a), on_shutdown : (synchronous : bool, (() -> unit)) -> {release : () -> unit}, on_track : (synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}, on_wake_up : (synchronous : bool, (() -> unit)) -> {release : () -> unit}, register_command : (?usage : string?, description : string, string, ((string) -> string)) -> unit, remaining : () -> float, replay_metadata : {bool}, reset_last_metadata_on_track : (() -> bool) .{exchange : (bool) -> bool, set : (bool) -> unit }, seek : (float) -> float, self_sync : () -> bool, self_sync_description : () -> string, single : bool, skip : () -> unit, status : () -> string, stop : () -> unit, time : () -> float, track_sensitive : {bool} }) -> unit): Called with the connection record of each client; returns the function given the client's source.

input.hls​

Play an HLS stream.

Type:

(?id : string?, {string}) -> source('a)

Synchronization:

This source paces its clock while connected when self_sync is true.

Composition:

This source uses live composition by default.

Arguments:

  • id (of type string?, which defaults to null): Force the value of the source ID.
  • (unlabeled) (of type {string}): Playlist URI.

Methods:

  • buffered (of type () -> [string * float]): Length of buffered data.
  • callbacks_count (of type () -> [string * int]): Callbacks a script has registered on this source, as pairs of callback name and count. A count that keeps growing is a function registering on a source it is handed without releasing what it registered.
  • clear_last_metadata (of type () -> unit): Clear the last metadata from the source.
  • clock (of type clock): The source's clock
  • duration (of type () -> float): Estimation of the duration of the current track.
  • elapsed (of type () -> float): Elapsed time in the current track.
  • fallible (of type bool): Indicate if a source may fail, i.e. may not be ready to stream.
  • generate_frame (of type () -> unit): Generate a frame from the source without consuming it. This can be useful in advanced cases where generating a frame is required to trigger some side effect like calculating some metadata before making a decision. You should make sure that the source is available before calling this function and it should only be called inside synchronous streaming loop callback such as on_frame!
  • id (of type () -> string): Identifier of the source.
  • insert_metadata (of type (?override : bool, ?new_track : bool, [string * string]) -> unit): Dynamically insert metadata in a stream. Inserts a new track with the given metadata if new_track is true. When override is false, metadata that the source provides itself takes precedence over the inserted one.
  • is_active (of type () -> bool): true if the source is active, i.e. it is continuously animated by its own clock whenever it is ready. Typically, true for outputs and sources such as input.http.
  • is_ready (of type () -> bool): Indicate if a source is ready to stream. This does not mean that the source is currently streaming, just that its resources are all properly initialized.
  • is_started (of type () -> bool): true if the output or source is started.
  • is_up (of type () -> bool): Indicate that the source can be asked to produce some data at any time. This is true when the source is currently being used or if it could be used at any time, typically inside a switch or fallback.
  • last_metadata (of type () -> [string * string]?): Return the last metadata from the source.
  • log (of type {level : (() -> int).{exchange : (int) -> int, set : (int) -> unit}}): Get or set the source's log level, from 1 to 5.
  • register_command (of type (?usage : string?, description : string, string, ((string) -> string)) -> unit): Register a server command for this source. Command is registered under the source's id namespace when it gets up and de-registered when it gets down.
  • remaining (of type () -> float): Estimation of remaining time in the current track.
  • reset_last_metadata_on_track (of type (() -> bool).{exchange : (bool) -> bool, set : (bool) -> unit}): If true, the source's last_metadata is reset on each new track. If a metadata is present along with the track mark, then it becomes the new last_metadata, otherwise, last_metadata becomes null`.
  • seek (of type (float) -> float): Seek forward, in seconds (returns the amount of time effectively seeked).
  • self_sync (of type () -> bool): Is the source currently controlling its own real-time loop.
  • self_sync_description (of type () -> string): This source paces its clock while connected when self_sync is true.
  • set_url (of type ({string}) -> unit): Set the URL, used at the next connection.
  • skip (of type () -> unit): Skip to the next track.
  • start (of type () -> unit): Ask the source or output to start.
  • status (of type () -> string): Status: "stopped", "starting", "polling", "connected <url>", "stopping" or "failed".
  • stop (of type () -> unit): Ask the source or output to stop.
  • time (of type () -> float): Get a source's time, based on its assigned clock.
  • url (of type () -> string): Current URL.

Callbacks:

  • on_collect (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called when source is collected
  • on_connect (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler when connected, before the source plays the connection's data.
  • on_disconnect (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler when a connection whose on_connect callbacks ran ends.
  • on_error (of type (synchronous : bool, ((error) -> unit)) -> {release : () -> unit}): Call a given handler on each connection or feeding failure.
  • on_frame (of type (?before : bool, synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler on frame. When before is true, callback is executed before computing the frame and after otherwise
  • on_frame_checksum (of type (?before : ((string?) -> unit)?, synchronous : bool, ((cache : string?, string) -> unit)) -> {release : () -> unit}): Call a given handler Register callbacks to compute frame checksums for debugging purposes. This is useful to track frame content changes through the streaming pipeline. The before callback is called before computing the frame with the checksum of the cached frame (if any, null otherwise). The main callback is called after computing the frame with the checksum of the generated frame and the remaining cache (if any).
  • on_metadata (of type (synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}): Call a given handler to execute on each metadata
  • on_position (of type (position : {float}, ?remaining : bool, ?allow_partial : bool, synchronous : bool, ((float, [string * string]) -> unit)) -> {release : () -> unit}): Call a given handler on track position. If remaining is false, callback is executed when position in track is more or equal to position. If remaining is true, callback is executed when remaining time in the current track is less or equal to position. Keep in mind that elapsed time is exact while remaining time is always estimated. Remaining time is usually more accurate for file-based sources. When allow_partial is true, if the current track ends before the offset position is reached, callback is still executed
  • on_shutdown (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called when source shuts down
  • on_start (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler when source starts
  • on_stop (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler when source stops
  • on_track (of type (synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}): Call a given handler on track marks
  • on_wake_up (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called after the source is asked to get ready

Composition methods:

  • composition_type (of type (() -> string).{exchange : (string) -> string, set : (string) -> unit}): This source uses live composition by default.
  • on_leave (of type ({source : source('a), track_sensitive : bool}) -> unit): Called after switching away from this source in a switch operator, once the transition using the ending source has completed. Receives a record with source (the source being left) and track_sensitive (true if the ending source's last frame had a track mark, i.e. it finished naturally; false if it was preempted mid-track). This function must return quickly as it runs in the streaming thread. The default depends on the active composition profile: file sources (source.composition.file) skip the source when preempted mid-track so it starts fresh on its next selection, and do nothing when it finished naturally; live sources (source.composition.live) do nothing.
  • on_select (of type ({ending : source('a)?, replay_metadata : bool, starting : source('a)}) -> source('a)): Called when selecting this source in a switch operator. Receives a record with starting (the incoming source) and ending (the previous source, or null when the ending source reached a track boundary). Returns the source to use. By default, both file and live profiles fade out ending when non-null (up to 1 second). The default is looked up at runtime from the active composition profile (source.composition.file or source.composition.live depending on composition_type).
  • replay_metadata (of type {bool}): Whether to replay the latest metadata on this source when it is selected in a switch operator. Defaults to true. The value is looked up at runtime from the active composition profile (source.composition.file or source.composition.live depending on composition_type).
  • single (of type bool): Forbid the selection of this source for two consecutive tracks in switch operators. Defaults to false.
  • track_sensitive (of type {bool}): Whether this source insists on track boundaries in switch operators: when true, it prefers not to be interrupted mid-track and not to be started mid-track. A switch may only cut into a track that is still playing when at least one of the two sources involved has track_sensitive set to false; otherwise it waits for the playing source to reach a track boundary. File-based sources default to true; live network and hardware inputs default to false. The value is looked up at runtime from the active composition profile (source.composition.file or source.composition.live depending on composition_type).

input.hls.native​

Play an HLS stream.

Type:

(?id : string?, ?reload : float, string) -> source('a)
where 'a is a set of tracks to be muxed into a source

Composition:

This source uses file composition by default.

Arguments:

  • id (of type string?, which defaults to null): Force the value of the source ID.
  • reload (of type float, which defaults to 10.0): How often (in seconds) the playlist should be reloaded.
  • (unlabeled) (of type string): Playlist URI.

Methods:

  • buffered (of type () -> [string * float]): Length of buffered data.
  • callbacks_count (of type () -> [string * int]): Callbacks a script has registered on this source, as pairs of callback name and count. A count that keeps growing is a function registering on a source it is handed without releasing what it registered.
  • clear_last_metadata (of type () -> unit): Clear the last metadata from the source.
  • clock (of type clock): The source's clock
  • duration (of type () -> float): Estimation of the duration of the current track.
  • elapsed (of type () -> float): Elapsed time in the current track.
  • fallible (of type bool): Indicate if a source may fail, i.e. may not be ready to stream.
  • generate_frame (of type () -> unit): Generate a frame from the source without consuming it. This can be useful in advanced cases where generating a frame is required to trigger some side effect like calculating some metadata before making a decision. You should make sure that the source is available before calling this function and it should only be called inside synchronous streaming loop callback such as on_frame!
  • id (of type () -> string): Identifier of the source.
  • insert_metadata (of type (?override : bool, ?new_track : bool, [string * string]) -> unit): Dynamically insert metadata in a stream. Inserts a new track with the given metadata if new_track is true. When override is false, metadata that the source provides itself takes precedence over the inserted one.
  • is_active (of type () -> bool): true if the source is active, i.e. it is continuously animated by its own clock whenever it is ready. Typically, true for outputs and sources such as input.http.
  • is_ready (of type () -> bool): Indicate if a source is ready to stream. This does not mean that the source is currently streaming, just that its resources are all properly initialized.
  • is_up (of type () -> bool): Indicate that the source can be asked to produce some data at any time. This is true when the source is currently being used or if it could be used at any time, typically inside a switch or fallback.
  • last_metadata (of type () -> [string * string]?): Return the last metadata from the source.
  • log (of type {level : (() -> int).{exchange : (int) -> int, set : (int) -> unit}}): Get or set the source's log level, from 1 to 5.
  • register_command (of type (?usage : string?, description : string, string, ((string) -> string)) -> unit): Register a server command for this source. Command is registered under the source's id namespace when it gets up and de-registered when it gets down.
  • remaining (of type () -> float): Estimation of remaining time in the current track.
  • reset_last_metadata_on_track (of type (() -> bool).{exchange : (bool) -> bool, set : (bool) -> unit}): If true, the source's last_metadata is reset on each new track. If a metadata is present along with the track mark, then it becomes the new last_metadata, otherwise, last_metadata becomes null`.
  • seek (of type (float) -> float): Seek forward, in seconds (returns the amount of time effectively seeked).
  • self_sync (of type () -> bool): Is the source currently controlling its own real-time loop.
  • self_sync_description (of type () -> string)
  • skip (of type () -> unit): Skip to the next track.
  • time (of type () -> float): Get a source's time, based on its assigned clock.

Callbacks:

  • on_collect (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called when source is collected
  • on_frame (of type (?before : bool, synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler on frame. When before is true, callback is executed before computing the frame and after otherwise
  • on_frame_checksum (of type (?before : ((string?) -> unit)?, synchronous : bool, ((cache : string?, string) -> unit)) -> {release : () -> unit}): Call a given handler Register callbacks to compute frame checksums for debugging purposes. This is useful to track frame content changes through the streaming pipeline. The before callback is called before computing the frame with the checksum of the cached frame (if any, null otherwise). The main callback is called after computing the frame with the checksum of the generated frame and the remaining cache (if any).
  • on_metadata (of type (synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}): Call a given handler to execute on each metadata
  • on_position (of type (position : {float}, ?remaining : bool, ?allow_partial : bool, synchronous : bool, ((float, [string * string]) -> unit)) -> {release : () -> unit}): Call a given handler on track position. If remaining is false, callback is executed when position in track is more or equal to position. If remaining is true, callback is executed when remaining time in the current track is less or equal to position. Keep in mind that elapsed time is exact while remaining time is always estimated. Remaining time is usually more accurate for file-based sources. When allow_partial is true, if the current track ends before the offset position is reached, callback is still executed
  • on_shutdown (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called when source shuts down
  • on_track (of type (synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}): Call a given handler on track marks
  • on_wake_up (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called after the source is asked to get ready

Composition methods:

  • composition_type (of type (() -> string).{exchange : (string) -> string, set : (string) -> unit}): This source uses file composition by default.
  • on_leave (of type ({source : source('a), track_sensitive : bool}) -> unit where 'a is a set of tracks to be muxed into a source): Called after switching away from this source in a switch operator, once the transition using the ending source has completed. Receives a record with source (the source being left) and track_sensitive (true if the ending source's last frame had a track mark, i.e. it finished naturally; false if it was preempted mid-track). This function must return quickly as it runs in the streaming thread. The default depends on the active composition profile: file sources (source.composition.file) skip the source when preempted mid-track so it starts fresh on its next selection, and do nothing when it finished naturally; live sources (source.composition.live) do nothing.
  • on_select (of type ({ending : source('a)?, replay_metadata : bool, starting : source('a)}) -> source('a) where 'a is a set of tracks to be muxed into a source): Called when selecting this source in a switch operator. Receives a record with starting (the incoming source) and ending (the previous source, or null when the ending source reached a track boundary). Returns the source to use. By default, both file and live profiles fade out ending when non-null (up to 1 second). The default is looked up at runtime from the active composition profile (source.composition.file or source.composition.live depending on composition_type).
  • replay_metadata (of type {bool}): Whether to replay the latest metadata on this source when it is selected in a switch operator. Defaults to true. The value is looked up at runtime from the active composition profile (source.composition.file or source.composition.live depending on composition_type).
  • single (of type bool): Forbid the selection of this source for two consecutive tracks in switch operators. Defaults to false.
  • track_sensitive (of type {bool}): Whether this source insists on track boundaries in switch operators: when true, it prefers not to be interrupted mid-track and not to be started mid-track. A switch may only cut into a track that is still playing when at least one of the two sources involved has track_sensitive set to false; otherwise it waits for the playing source to reach a track boundary. File-based sources default to true; live network and hardware inputs default to false. The value is looked up at runtime from the active composition profile (source.composition.file or source.composition.live depending on composition_type).

This function is experimental.

input.http​

Read an HTTP stream with FFmpeg.

Type:

(?id : string?, ?debug : bool, ?deduplicate_metadata : bool,
?float_args : [string * float], ?format : string?,
?int_args : [string * int], ?max_buffer : float,
?metadata_filter : (([string * string]) -> [string * string])?,
?new_track_on_metadata : bool, ?poll_delay : float, ?self_sync : {bool?},
?start : bool, ?string_args : [string * string], ?timeout : float,
?trim_url : bool, ?user_agent : string, {string}) -> source('a)

Synchronization:

This source paces its clock while connected when self_sync is true.

Composition:

This source uses live composition by default.

Arguments:

  • id (of type string?, which defaults to null): Force the value of the source ID.
  • debug (of type bool, which defaults to false): Log every fault with its backtrace at error level.
  • deduplicate_metadata (of type bool, which defaults to true): Drop metadata equal to the previous one of the same connection.
  • float_args (of type [string * float], which defaults to []): FFmpeg options, each stored as a float option.
  • format (of type string?, which defaults to null): Input format short name.
  • int_args (of type [string * int], which defaults to []): FFmpeg options, each stored as an integer option.
  • max_buffer (of type float, which defaults to 5.0): Maximum decoded data held by the source, in seconds.
  • metadata_filter (of type (([string * string]) -> [string * string])?, which defaults to null): Metadata filter, replacing the default one, which drops the keys starting with id3v2_priv.
  • new_track_on_metadata (of type bool, which defaults to true): Start a new track at each metadata.
  • poll_delay (of type float, which defaults to 2.0): Delay before a retry after a failure, and interval of the URL check while failed, in seconds.
  • self_sync (of type {bool?}, which defaults to null): Pace the clock while connected. null: the clock keeps its own pace, with this source as its sync source when ICY headers were received.
  • start (of type bool, which defaults to true): Start input as soon as it is available.
  • string_args (of type [string * string], which defaults to []): FFmpeg options, each stored as a string option.
  • timeout (of type float, which defaults to 10.0): Longest a single blocking read may last, in seconds, on an input that is not listening.
  • trim_url (of type bool, which defaults to true): Strip leading and trailing whitespace from the URL.
  • user_agent (of type string, which defaults to "Liquidsoap/2.5.0+git@b15d610 (Unix; OCaml 5.5.2)"): User agent.
  • (unlabeled) (of type {string}): URL to read from.

Methods:

  • buffered (of type () -> [string * float]): Length of buffered data.
  • callbacks_count (of type () -> [string * int]): Callbacks a script has registered on this source, as pairs of callback name and count. A count that keeps growing is a function registering on a source it is handed without releasing what it registered.
  • clear_last_metadata (of type () -> unit): Clear the last metadata from the source.
  • clock (of type clock): The source's clock
  • duration (of type () -> float): Estimation of the duration of the current track.
  • elapsed (of type () -> float): Elapsed time in the current track.
  • fallible (of type bool): Indicate if a source may fail, i.e. may not be ready to stream.
  • generate_frame (of type () -> unit): Generate a frame from the source without consuming it. This can be useful in advanced cases where generating a frame is required to trigger some side effect like calculating some metadata before making a decision. You should make sure that the source is available before calling this function and it should only be called inside synchronous streaming loop callback such as on_frame!
  • id (of type () -> string): Identifier of the source.
  • insert_metadata (of type (?override : bool, ?new_track : bool, [string * string]) -> unit): Dynamically insert metadata in a stream. Inserts a new track with the given metadata if new_track is true. When override is false, metadata that the source provides itself takes precedence over the inserted one.
  • is_active (of type () -> bool): true if the source is active, i.e. it is continuously animated by its own clock whenever it is ready. Typically, true for outputs and sources such as input.http.
  • is_ready (of type () -> bool): Indicate if a source is ready to stream. This does not mean that the source is currently streaming, just that its resources are all properly initialized.
  • is_started (of type () -> bool): true if the output or source is started.
  • is_up (of type () -> bool): Indicate that the source can be asked to produce some data at any time. This is true when the source is currently being used or if it could be used at any time, typically inside a switch or fallback.
  • last_metadata (of type () -> [string * string]?): Return the last metadata from the source.
  • log (of type {level : (() -> int).{exchange : (int) -> int, set : (int) -> unit}}): Get or set the source's log level, from 1 to 5.
  • register_command (of type (?usage : string?, description : string, string, ((string) -> string)) -> unit): Register a server command for this source. Command is registered under the source's id namespace when it gets up and de-registered when it gets down.
  • remaining (of type () -> float): Estimation of remaining time in the current track.
  • reset_last_metadata_on_track (of type (() -> bool).{exchange : (bool) -> bool, set : (bool) -> unit}): If true, the source's last_metadata is reset on each new track. If a metadata is present along with the track mark, then it becomes the new last_metadata, otherwise, last_metadata becomes null`.
  • seek (of type (float) -> float): Seek forward, in seconds (returns the amount of time effectively seeked).
  • self_sync (of type () -> bool): Is the source currently controlling its own real-time loop.
  • self_sync_description (of type () -> string): This source paces its clock while connected when self_sync is true.
  • set_url (of type ({string}) -> unit): Set the URL, used at the next connection.
  • skip (of type () -> unit): Skip to the next track.
  • start (of type () -> unit): Ask the source or output to start.
  • status (of type () -> string): Status: "stopped", "starting", "polling", "connected <url>", "stopping" or "failed".
  • stop (of type () -> unit): Ask the source or output to stop.
  • time (of type () -> float): Get a source's time, based on its assigned clock.
  • url (of type () -> string): Current URL.

Callbacks:

  • on_collect (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called when source is collected
  • on_connect (of type (synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}): Call a given handler when connected, before the source plays the connection's data.
  • on_disconnect (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler when a connection whose on_connect callbacks ran ends.
  • on_error (of type (synchronous : bool, ((error) -> unit)) -> {release : () -> unit}): Call a given handler on each connection or feeding failure.
  • on_frame (of type (?before : bool, synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler on frame. When before is true, callback is executed before computing the frame and after otherwise
  • on_frame_checksum (of type (?before : ((string?) -> unit)?, synchronous : bool, ((cache : string?, string) -> unit)) -> {release : () -> unit}): Call a given handler Register callbacks to compute frame checksums for debugging purposes. This is useful to track frame content changes through the streaming pipeline. The before callback is called before computing the frame with the checksum of the cached frame (if any, null otherwise). The main callback is called after computing the frame with the checksum of the generated frame and the remaining cache (if any).
  • on_metadata (of type (synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}): Call a given handler to execute on each metadata
  • on_position (of type (position : {float}, ?remaining : bool, ?allow_partial : bool, synchronous : bool, ((float, [string * string]) -> unit)) -> {release : () -> unit}): Call a given handler on track position. If remaining is false, callback is executed when position in track is more or equal to position. If remaining is true, callback is executed when remaining time in the current track is less or equal to position. Keep in mind that elapsed time is exact while remaining time is always estimated. Remaining time is usually more accurate for file-based sources. When allow_partial is true, if the current track ends before the offset position is reached, callback is still executed
  • on_shutdown (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called when source shuts down
  • on_start (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler when source starts
  • on_stop (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler when source stops
  • on_track (of type (synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}): Call a given handler on track marks
  • on_wake_up (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called after the source is asked to get ready

Composition methods:

  • composition_type (of type (() -> string).{exchange : (string) -> string, set : (string) -> unit}): This source uses live composition by default.
  • on_leave (of type ({source : source('a), track_sensitive : bool}) -> unit): Called after switching away from this source in a switch operator, once the transition using the ending source has completed. Receives a record with source (the source being left) and track_sensitive (true if the ending source's last frame had a track mark, i.e. it finished naturally; false if it was preempted mid-track). This function must return quickly as it runs in the streaming thread. The default depends on the active composition profile: file sources (source.composition.file) skip the source when preempted mid-track so it starts fresh on its next selection, and do nothing when it finished naturally; live sources (source.composition.live) do nothing.
  • on_select (of type ({ending : source('a)?, replay_metadata : bool, starting : source('a)}) -> source('a)): Called when selecting this source in a switch operator. Receives a record with starting (the incoming source) and ending (the previous source, or null when the ending source reached a track boundary). Returns the source to use. By default, both file and live profiles fade out ending when non-null (up to 1 second). The default is looked up at runtime from the active composition profile (source.composition.file or source.composition.live depending on composition_type).
  • replay_metadata (of type {bool}): Whether to replay the latest metadata on this source when it is selected in a switch operator. Defaults to true. The value is looked up at runtime from the active composition profile (source.composition.file or source.composition.live depending on composition_type).
  • single (of type bool): Forbid the selection of this source for two consecutive tracks in switch operators. Defaults to false.
  • track_sensitive (of type {bool}): Whether this source insists on track boundaries in switch operators: when true, it prefers not to be interrupted mid-track and not to be started mid-track. A switch may only cut into a track that is still playing when at least one of the two sources involved has track_sensitive set to false; otherwise it waits for the playing source to reach a track boundary. File-based sources default to true; live network and hardware inputs default to false. The value is looked up at runtime from the active composition profile (source.composition.file or source.composition.live depending on composition_type).

input.jack​

Get stream from JACK.

Type:

(?id : string?, ?server : string?, ?start : bool) -> source(audio=pcm('a))

Composition:

This source uses live composition by default.

Arguments:

  • id (of type string?, which defaults to null): Force the value of the source ID.
  • server (of type string?, which defaults to null): JACK server to connect to.
  • start (of type bool, which defaults to true): Start input as soon as it is available.

Methods:

  • buffered (of type () -> [string * float]): Length of buffered data.
  • callbacks_count (of type () -> [string * int]): Callbacks a script has registered on this source, as pairs of callback name and count. A count that keeps growing is a function registering on a source it is handed without releasing what it registered.
  • clear_last_metadata (of type () -> unit): Clear the last metadata from the source.
  • clock (of type clock): The source's clock
  • connect (of type ('b .{ on_wake_up : (synchronous : bool, (() -> unit)) -> unit, ports : () -> [jack_output_port] }) -> unit): Connect the ports of this JACK input to the ports of a JACK output.
  • duration (of type () -> float): Estimation of the duration of the current track.
  • elapsed (of type () -> float): Elapsed time in the current track.
  • fallible (of type bool): Indicate if a source may fail, i.e. may not be ready to stream.
  • generate_frame (of type () -> unit): Generate a frame from the source without consuming it. This can be useful in advanced cases where generating a frame is required to trigger some side effect like calculating some metadata before making a decision. You should make sure that the source is available before calling this function and it should only be called inside synchronous streaming loop callback such as on_frame!
  • id (of type () -> string): Identifier of the source.
  • insert_metadata (of type (?override : bool, ?new_track : bool, [string * string]) -> unit): Dynamically insert metadata in a stream. Inserts a new track with the given metadata if new_track is true. When override is false, metadata that the source provides itself takes precedence over the inserted one.
  • is_active (of type () -> bool): true if the source is active, i.e. it is continuously animated by its own clock whenever it is ready. Typically, true for outputs and sources such as input.http.
  • is_ready (of type () -> bool): Indicate if a source is ready to stream. This does not mean that the source is currently streaming, just that its resources are all properly initialized.
  • is_started (of type () -> bool): true if the output or source is started.
  • is_up (of type () -> bool): Indicate that the source can be asked to produce some data at any time. This is true when the source is currently being used or if it could be used at any time, typically inside a switch or fallback.
  • last_metadata (of type () -> [string * string]?): Return the last metadata from the source.
  • log (of type {level : (() -> int).{exchange : (int) -> int, set : (int) -> unit}}): Get or set the source's log level, from 1 to 5.
  • ports (of type () -> [jack_input_port.{connect : (jack_output_port) -> unit, name : string}]): List of JACK input ports for this source.
  • register_command (of type (?usage : string?, description : string, string, ((string) -> string)) -> unit): Register a server command for this source. Command is registered under the source's id namespace when it gets up and de-registered when it gets down.
  • remaining (of type () -> float): Estimation of remaining time in the current track.
  • reset_last_metadata_on_track (of type (() -> bool).{exchange : (bool) -> bool, set : (bool) -> unit}): If true, the source's last_metadata is reset on each new track. If a metadata is present along with the track mark, then it becomes the new last_metadata, otherwise, last_metadata becomes null`.
  • seek (of type (float) -> float): Seek forward, in seconds (returns the amount of time effectively seeked).
  • self_sync (of type () -> bool): Is the source currently controlling its own real-time loop.
  • self_sync_description (of type () -> string)
  • skip (of type () -> unit): Skip to the next track.
  • start (of type () -> unit): Ask the source or output to start.
  • stop (of type () -> unit): Ask the source or output to stop.
  • time (of type () -> float): Get a source's time, based on its assigned clock.

Callbacks:

  • on_collect (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called when source is collected
  • on_frame (of type (?before : bool, synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler on frame. When before is true, callback is executed before computing the frame and after otherwise
  • on_frame_checksum (of type (?before : ((string?) -> unit)?, synchronous : bool, ((cache : string?, string) -> unit)) -> {release : () -> unit}): Call a given handler Register callbacks to compute frame checksums for debugging purposes. This is useful to track frame content changes through the streaming pipeline. The before callback is called before computing the frame with the checksum of the cached frame (if any, null otherwise). The main callback is called after computing the frame with the checksum of the generated frame and the remaining cache (if any).
  • on_metadata (of type (synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}): Call a given handler to execute on each metadata
  • on_position (of type (position : {float}, ?remaining : bool, ?allow_partial : bool, synchronous : bool, ((float, [string * string]) -> unit)) -> {release : () -> unit}): Call a given handler on track position. If remaining is false, callback is executed when position in track is more or equal to position. If remaining is true, callback is executed when remaining time in the current track is less or equal to position. Keep in mind that elapsed time is exact while remaining time is always estimated. Remaining time is usually more accurate for file-based sources. When allow_partial is true, if the current track ends before the offset position is reached, callback is still executed
  • on_shutdown (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called when source shuts down
  • on_start (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler when source starts
  • on_stop (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler when source stops
  • on_track (of type (synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}): Call a given handler on track marks
  • on_wake_up (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called after the source is asked to get ready

Composition methods:

  • composition_type (of type (() -> string).{exchange : (string) -> string, set : (string) -> unit}): This source uses live composition by default.
  • on_leave (of type ({source : source(audio=pcm('a)), track_sensitive : bool}) -> unit): Called after switching away from this source in a switch operator, once the transition using the ending source has completed. Receives a record with source (the source being left) and track_sensitive (true if the ending source's last frame had a track mark, i.e. it finished naturally; false if it was preempted mid-track). This function must return quickly as it runs in the streaming thread. The default depends on the active composition profile: file sources (source.composition.file) skip the source when preempted mid-track so it starts fresh on its next selection, and do nothing when it finished naturally; live sources (source.composition.live) do nothing.
  • on_select (of type ( { ending : source(audio=pcm('a))?, replay_metadata : bool, starting : source(audio=pcm('a)) }) -> source(audio=pcm('a))): Called when selecting this source in a switch operator. Receives a record with starting (the incoming source) and ending (the previous source, or null when the ending source reached a track boundary). Returns the source to use. By default, both file and live profiles fade out ending when non-null (up to 1 second). The default is looked up at runtime from the active composition profile (source.composition.file or source.composition.live depending on composition_type).
  • replay_metadata (of type {bool}): Whether to replay the latest metadata on this source when it is selected in a switch operator. Defaults to true. The value is looked up at runtime from the active composition profile (source.composition.file or source.composition.live depending on composition_type).
  • single (of type bool): Forbid the selection of this source for two consecutive tracks in switch operators. Defaults to false.
  • track_sensitive (of type {bool}): Whether this source insists on track boundaries in switch operators: when true, it prefers not to be interrupted mid-track and not to be started mid-track. A switch may only cut into a track that is still playing when at least one of the two sources involved has track_sensitive set to false; otherwise it waits for the playing source to reach a track boundary. File-based sources default to true; live network and hardware inputs default to false. The value is looked up at runtime from the active composition profile (source.composition.file or source.composition.live depending on composition_type).

input.keyboard.sdl​

Play notes from the keyboard.

Type:

(?id : string?, ?velocity : float) -> source(midi=midi('a))

Composition:

This source uses live composition by default.

Arguments:

  • id (of type string?, which defaults to null): Force the value of the source ID.
  • velocity (of type float, which defaults to 0.8): Velocity of notes.

Methods:

  • buffered (of type () -> [string * float]): Length of buffered data.
  • callbacks_count (of type () -> [string * int]): Callbacks a script has registered on this source, as pairs of callback name and count. A count that keeps growing is a function registering on a source it is handed without releasing what it registered.
  • clear_last_metadata (of type () -> unit): Clear the last metadata from the source.
  • clock (of type clock): The source's clock
  • duration (of type () -> float): Estimation of the duration of the current track.
  • elapsed (of type () -> float): Elapsed time in the current track.
  • fallible (of type bool): Indicate if a source may fail, i.e. may not be ready to stream.
  • generate_frame (of type () -> unit): Generate a frame from the source without consuming it. This can be useful in advanced cases where generating a frame is required to trigger some side effect like calculating some metadata before making a decision. You should make sure that the source is available before calling this function and it should only be called inside synchronous streaming loop callback such as on_frame!
  • id (of type () -> string): Identifier of the source.
  • insert_metadata (of type (?override : bool, ?new_track : bool, [string * string]) -> unit): Dynamically insert metadata in a stream. Inserts a new track with the given metadata if new_track is true. When override is false, metadata that the source provides itself takes precedence over the inserted one.
  • is_active (of type () -> bool): true if the source is active, i.e. it is continuously animated by its own clock whenever it is ready. Typically, true for outputs and sources such as input.http.
  • is_ready (of type () -> bool): Indicate if a source is ready to stream. This does not mean that the source is currently streaming, just that its resources are all properly initialized.
  • is_up (of type () -> bool): Indicate that the source can be asked to produce some data at any time. This is true when the source is currently being used or if it could be used at any time, typically inside a switch or fallback.
  • last_metadata (of type () -> [string * string]?): Return the last metadata from the source.
  • log (of type {level : (() -> int).{exchange : (int) -> int, set : (int) -> unit}}): Get or set the source's log level, from 1 to 5.
  • register_command (of type (?usage : string?, description : string, string, ((string) -> string)) -> unit): Register a server command for this source. Command is registered under the source's id namespace when it gets up and de-registered when it gets down.
  • remaining (of type () -> float): Estimation of remaining time in the current track.
  • reset_last_metadata_on_track (of type (() -> bool).{exchange : (bool) -> bool, set : (bool) -> unit}): If true, the source's last_metadata is reset on each new track. If a metadata is present along with the track mark, then it becomes the new last_metadata, otherwise, last_metadata becomes null`.
  • seek (of type (float) -> float): Seek forward, in seconds (returns the amount of time effectively seeked).
  • self_sync (of type () -> bool): Is the source currently controlling its own real-time loop.
  • self_sync_description (of type () -> string)
  • skip (of type () -> unit): Skip to the next track.
  • time (of type () -> float): Get a source's time, based on its assigned clock.

Callbacks:

  • on_collect (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called when source is collected
  • on_frame (of type (?before : bool, synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler on frame. When before is true, callback is executed before computing the frame and after otherwise
  • on_frame_checksum (of type (?before : ((string?) -> unit)?, synchronous : bool, ((cache : string?, string) -> unit)) -> {release : () -> unit}): Call a given handler Register callbacks to compute frame checksums for debugging purposes. This is useful to track frame content changes through the streaming pipeline. The before callback is called before computing the frame with the checksum of the cached frame (if any, null otherwise). The main callback is called after computing the frame with the checksum of the generated frame and the remaining cache (if any).
  • on_metadata (of type (synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}): Call a given handler to execute on each metadata
  • on_position (of type (position : {float}, ?remaining : bool, ?allow_partial : bool, synchronous : bool, ((float, [string * string]) -> unit)) -> {release : () -> unit}): Call a given handler on track position. If remaining is false, callback is executed when position in track is more or equal to position. If remaining is true, callback is executed when remaining time in the current track is less or equal to position. Keep in mind that elapsed time is exact while remaining time is always estimated. Remaining time is usually more accurate for file-based sources. When allow_partial is true, if the current track ends before the offset position is reached, callback is still executed
  • on_shutdown (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called when source shuts down
  • on_track (of type (synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}): Call a given handler on track marks
  • on_wake_up (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called after the source is asked to get ready

Composition methods:

  • composition_type (of type (() -> string).{exchange : (string) -> string, set : (string) -> unit}): This source uses live composition by default.
  • on_leave (of type ({source : source(midi=midi('a)), track_sensitive : bool}) -> unit): Called after switching away from this source in a switch operator, once the transition using the ending source has completed. Receives a record with source (the source being left) and track_sensitive (true if the ending source's last frame had a track mark, i.e. it finished naturally; false if it was preempted mid-track). This function must return quickly as it runs in the streaming thread. The default depends on the active composition profile: file sources (source.composition.file) skip the source when preempted mid-track so it starts fresh on its next selection, and do nothing when it finished naturally; live sources (source.composition.live) do nothing.
  • on_select (of type ( { ending : source(midi=midi('a))?, replay_metadata : bool, starting : source(midi=midi('a)) }) -> source(midi=midi('a))): Called when selecting this source in a switch operator. Receives a record with starting (the incoming source) and ending (the previous source, or null when the ending source reached a track boundary). Returns the source to use. By default, both file and live profiles fade out ending when non-null (up to 1 second). The default is looked up at runtime from the active composition profile (source.composition.file or source.composition.live depending on composition_type).
  • replay_metadata (of type {bool}): Whether to replay the latest metadata on this source when it is selected in a switch operator. Defaults to true. The value is looked up at runtime from the active composition profile (source.composition.file or source.composition.live depending on composition_type).
  • single (of type bool): Forbid the selection of this source for two consecutive tracks in switch operators. Defaults to false.
  • track_sensitive (of type {bool}): Whether this source insists on track boundaries in switch operators: when true, it prefers not to be interrupted mid-track and not to be started mid-track. A switch may only cut into a track that is still playing when at least one of the two sources involved has track_sensitive set to false; otherwise it waits for the playing source to reach a track boundary. File-based sources default to true; live network and hardware inputs default to false. The value is looked up at runtime from the active composition profile (source.composition.file or source.composition.live depending on composition_type).

This function is experimental.

input.oss​

Stream from an OSS input device.

Type:

(?id : string?, ?device : string, ?fallible : bool, ?self_sync : bool,
?start : bool) -> source(audio=pcm('a))

Synchronization:

This source uses the OSS hardware clock as synchronization source when self_sync=true and the device is open.

Composition:

This source uses live composition by default.

Arguments:

  • id (of type string?, which defaults to null): Force the value of the source ID.
  • device (of type string, which defaults to "/dev/dsp"): OSS device to use.
  • fallible (of type bool, which defaults to false): Allow the source to fail. If set to false, start must be true and stop method raises an error.
  • self_sync (of type bool, which defaults to true): Mark the source as being synchronized by the OSS driver.
  • start (of type bool, which defaults to true): Start input as soon as it is available.

Methods:

  • buffered (of type () -> [string * float]): Length of buffered data.
  • callbacks_count (of type () -> [string * int]): Callbacks a script has registered on this source, as pairs of callback name and count. A count that keeps growing is a function registering on a source it is handed without releasing what it registered.
  • clear_last_metadata (of type () -> unit): Clear the last metadata from the source.
  • clock (of type clock): The source's clock
  • duration (of type () -> float): Estimation of the duration of the current track.
  • elapsed (of type () -> float): Elapsed time in the current track.
  • fallible (of type bool): Indicate if a source may fail, i.e. may not be ready to stream.
  • generate_frame (of type () -> unit): Generate a frame from the source without consuming it. This can be useful in advanced cases where generating a frame is required to trigger some side effect like calculating some metadata before making a decision. You should make sure that the source is available before calling this function and it should only be called inside synchronous streaming loop callback such as on_frame!
  • id (of type () -> string): Identifier of the source.
  • insert_metadata (of type (?override : bool, ?new_track : bool, [string * string]) -> unit): Dynamically insert metadata in a stream. Inserts a new track with the given metadata if new_track is true. When override is false, metadata that the source provides itself takes precedence over the inserted one.
  • is_active (of type () -> bool): true if the source is active, i.e. it is continuously animated by its own clock whenever it is ready. Typically, true for outputs and sources such as input.http.
  • is_ready (of type () -> bool): Indicate if a source is ready to stream. This does not mean that the source is currently streaming, just that its resources are all properly initialized.
  • is_started (of type () -> bool): true if the output or source is started.
  • is_up (of type () -> bool): Indicate that the source can be asked to produce some data at any time. This is true when the source is currently being used or if it could be used at any time, typically inside a switch or fallback.
  • last_metadata (of type () -> [string * string]?): Return the last metadata from the source.
  • log (of type {level : (() -> int).{exchange : (int) -> int, set : (int) -> unit}}): Get or set the source's log level, from 1 to 5.
  • register_command (of type (?usage : string?, description : string, string, ((string) -> string)) -> unit): Register a server command for this source. Command is registered under the source's id namespace when it gets up and de-registered when it gets down.
  • remaining (of type () -> float): Estimation of remaining time in the current track.
  • reset_last_metadata_on_track (of type (() -> bool).{exchange : (bool) -> bool, set : (bool) -> unit}): If true, the source's last_metadata is reset on each new track. If a metadata is present along with the track mark, then it becomes the new last_metadata, otherwise, last_metadata becomes null`.
  • seek (of type (float) -> float): Seek forward, in seconds (returns the amount of time effectively seeked).
  • self_sync (of type () -> bool): Is the source currently controlling its own real-time loop.
  • self_sync_description (of type () -> string): This source uses the OSS hardware clock as synchronization source when self_sync=true and the device is open.
  • skip (of type () -> unit): Skip to the next track.
  • start (of type () -> unit): Ask the source or output to start.
  • stop (of type () -> unit): Ask the source or output to stop.
  • time (of type () -> float): Get a source's time, based on its assigned clock.

Callbacks:

  • on_collect (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called when source is collected
  • on_frame (of type (?before : bool, synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler on frame. When before is true, callback is executed before computing the frame and after otherwise
  • on_frame_checksum (of type (?before : ((string?) -> unit)?, synchronous : bool, ((cache : string?, string) -> unit)) -> {release : () -> unit}): Call a given handler Register callbacks to compute frame checksums for debugging purposes. This is useful to track frame content changes through the streaming pipeline. The before callback is called before computing the frame with the checksum of the cached frame (if any, null otherwise). The main callback is called after computing the frame with the checksum of the generated frame and the remaining cache (if any).
  • on_metadata (of type (synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}): Call a given handler to execute on each metadata
  • on_position (of type (position : {float}, ?remaining : bool, ?allow_partial : bool, synchronous : bool, ((float, [string * string]) -> unit)) -> {release : () -> unit}): Call a given handler on track position. If remaining is false, callback is executed when position in track is more or equal to position. If remaining is true, callback is executed when remaining time in the current track is less or equal to position. Keep in mind that elapsed time is exact while remaining time is always estimated. Remaining time is usually more accurate for file-based sources. When allow_partial is true, if the current track ends before the offset position is reached, callback is still executed
  • on_shutdown (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called when source shuts down
  • on_start (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler when source starts
  • on_stop (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler when source stops
  • on_track (of type (synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}): Call a given handler on track marks
  • on_wake_up (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called after the source is asked to get ready

Composition methods:

  • composition_type (of type (() -> string).{exchange : (string) -> string, set : (string) -> unit}): This source uses live composition by default.
  • on_leave (of type ({source : source(audio=pcm('a)), track_sensitive : bool}) -> unit): Called after switching away from this source in a switch operator, once the transition using the ending source has completed. Receives a record with source (the source being left) and track_sensitive (true if the ending source's last frame had a track mark, i.e. it finished naturally; false if it was preempted mid-track). This function must return quickly as it runs in the streaming thread. The default depends on the active composition profile: file sources (source.composition.file) skip the source when preempted mid-track so it starts fresh on its next selection, and do nothing when it finished naturally; live sources (source.composition.live) do nothing.
  • on_select (of type ( { ending : source(audio=pcm('a))?, replay_metadata : bool, starting : source(audio=pcm('a)) }) -> source(audio=pcm('a))): Called when selecting this source in a switch operator. Receives a record with starting (the incoming source) and ending (the previous source, or null when the ending source reached a track boundary). Returns the source to use. By default, both file and live profiles fade out ending when non-null (up to 1 second). The default is looked up at runtime from the active composition profile (source.composition.file or source.composition.live depending on composition_type).
  • replay_metadata (of type {bool}): Whether to replay the latest metadata on this source when it is selected in a switch operator. Defaults to true. The value is looked up at runtime from the active composition profile (source.composition.file or source.composition.live depending on composition_type).
  • single (of type bool): Forbid the selection of this source for two consecutive tracks in switch operators. Defaults to false.
  • track_sensitive (of type {bool}): Whether this source insists on track boundaries in switch operators: when true, it prefers not to be interrupted mid-track and not to be started mid-track. A switch may only cut into a track that is still playing when at least one of the two sources involved has track_sensitive set to false; otherwise it waits for the playing source to reach a track boundary. File-based sources default to true; live network and hardware inputs default to false. The value is looked up at runtime from the active composition profile (source.composition.file or source.composition.live depending on composition_type).

input.portaudio​

Stream from a portaudio input device.

Type:

(?id : string?, ?buflen : int, ?device_id : int?, ?device_name : string?,
?fallible : bool, ?latency : float?, ?self_sync : bool, ?start : bool) ->
source(audio=pcm('a))

Synchronization:

This source uses the PortAudio clock as synchronization source when self_sync=true and the stream is open.

Composition:

This source uses live composition by default.

Arguments:

  • id (of type string?, which defaults to null): Force the value of the source ID.
  • buflen (of type int, which defaults to 256): Length of a buffer in samples.
  • device_id (of type int?, which defaults to null): Device ID. Uses default device if null.
  • device_name (of type string?, which defaults to null): Device name.
  • fallible (of type bool, which defaults to false): Allow the source to fail. If set to false, start must be true and stop method raises an error.
  • latency (of type float?, which defaults to null): Device latency. Only used when specifying device ID.
  • self_sync (of type bool, which defaults to true): Mark the source as being synchronized by the portaudio driver.
  • start (of type bool, which defaults to true): Start input as soon as it is available.

Methods:

  • buffered (of type () -> [string * float]): Length of buffered data.
  • callbacks_count (of type () -> [string * int]): Callbacks a script has registered on this source, as pairs of callback name and count. A count that keeps growing is a function registering on a source it is handed without releasing what it registered.
  • clear_last_metadata (of type () -> unit): Clear the last metadata from the source.
  • clock (of type clock): The source's clock
  • duration (of type () -> float): Estimation of the duration of the current track.
  • elapsed (of type () -> float): Elapsed time in the current track.
  • fallible (of type bool): Indicate if a source may fail, i.e. may not be ready to stream.
  • generate_frame (of type () -> unit): Generate a frame from the source without consuming it. This can be useful in advanced cases where generating a frame is required to trigger some side effect like calculating some metadata before making a decision. You should make sure that the source is available before calling this function and it should only be called inside synchronous streaming loop callback such as on_frame!
  • id (of type () -> string): Identifier of the source.
  • insert_metadata (of type (?override : bool, ?new_track : bool, [string * string]) -> unit): Dynamically insert metadata in a stream. Inserts a new track with the given metadata if new_track is true. When override is false, metadata that the source provides itself takes precedence over the inserted one.
  • is_active (of type () -> bool): true if the source is active, i.e. it is continuously animated by its own clock whenever it is ready. Typically, true for outputs and sources such as input.http.
  • is_ready (of type () -> bool): Indicate if a source is ready to stream. This does not mean that the source is currently streaming, just that its resources are all properly initialized.
  • is_started (of type () -> bool): true if the output or source is started.
  • is_up (of type () -> bool): Indicate that the source can be asked to produce some data at any time. This is true when the source is currently being used or if it could be used at any time, typically inside a switch or fallback.
  • last_metadata (of type () -> [string * string]?): Return the last metadata from the source.
  • log (of type {level : (() -> int).{exchange : (int) -> int, set : (int) -> unit}}): Get or set the source's log level, from 1 to 5.
  • register_command (of type (?usage : string?, description : string, string, ((string) -> string)) -> unit): Register a server command for this source. Command is registered under the source's id namespace when it gets up and de-registered when it gets down.
  • remaining (of type () -> float): Estimation of remaining time in the current track.
  • reset_last_metadata_on_track (of type (() -> bool).{exchange : (bool) -> bool, set : (bool) -> unit}): If true, the source's last_metadata is reset on each new track. If a metadata is present along with the track mark, then it becomes the new last_metadata, otherwise, last_metadata becomes null`.
  • seek (of type (float) -> float): Seek forward, in seconds (returns the amount of time effectively seeked).
  • self_sync (of type () -> bool): Is the source currently controlling its own real-time loop.
  • self_sync_description (of type () -> string): This source uses the PortAudio clock as synchronization source when self_sync=true and the stream is open.
  • skip (of type () -> unit): Skip to the next track.
  • start (of type () -> unit): Ask the source or output to start.
  • stop (of type () -> unit): Ask the source or output to stop.
  • time (of type () -> float): Get a source's time, based on its assigned clock.

Callbacks:

  • on_collect (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called when source is collected
  • on_frame (of type (?before : bool, synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler on frame. When before is true, callback is executed before computing the frame and after otherwise
  • on_frame_checksum (of type (?before : ((string?) -> unit)?, synchronous : bool, ((cache : string?, string) -> unit)) -> {release : () -> unit}): Call a given handler Register callbacks to compute frame checksums for debugging purposes. This is useful to track frame content changes through the streaming pipeline. The before callback is called before computing the frame with the checksum of the cached frame (if any, null otherwise). The main callback is called after computing the frame with the checksum of the generated frame and the remaining cache (if any).
  • on_metadata (of type (synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}): Call a given handler to execute on each metadata
  • on_position (of type (position : {float}, ?remaining : bool, ?allow_partial : bool, synchronous : bool, ((float, [string * string]) -> unit)) -> {release : () -> unit}): Call a given handler on track position. If remaining is false, callback is executed when position in track is more or equal to position. If remaining is true, callback is executed when remaining time in the current track is less or equal to position. Keep in mind that elapsed time is exact while remaining time is always estimated. Remaining time is usually more accurate for file-based sources. When allow_partial is true, if the current track ends before the offset position is reached, callback is still executed
  • on_shutdown (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called when source shuts down
  • on_start (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler when source starts
  • on_stop (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler when source stops
  • on_track (of type (synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}): Call a given handler on track marks
  • on_wake_up (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called after the source is asked to get ready

Composition methods:

  • composition_type (of type (() -> string).{exchange : (string) -> string, set : (string) -> unit}): This source uses live composition by default.
  • on_leave (of type ({source : source(audio=pcm('a)), track_sensitive : bool}) -> unit): Called after switching away from this source in a switch operator, once the transition using the ending source has completed. Receives a record with source (the source being left) and track_sensitive (true if the ending source's last frame had a track mark, i.e. it finished naturally; false if it was preempted mid-track). This function must return quickly as it runs in the streaming thread. The default depends on the active composition profile: file sources (source.composition.file) skip the source when preempted mid-track so it starts fresh on its next selection, and do nothing when it finished naturally; live sources (source.composition.live) do nothing.
  • on_select (of type ( { ending : source(audio=pcm('a))?, replay_metadata : bool, starting : source(audio=pcm('a)) }) -> source(audio=pcm('a))): Called when selecting this source in a switch operator. Receives a record with starting (the incoming source) and ending (the previous source, or null when the ending source reached a track boundary). Returns the source to use. By default, both file and live profiles fade out ending when non-null (up to 1 second). The default is looked up at runtime from the active composition profile (source.composition.file or source.composition.live depending on composition_type).
  • replay_metadata (of type {bool}): Whether to replay the latest metadata on this source when it is selected in a switch operator. Defaults to true. The value is looked up at runtime from the active composition profile (source.composition.file or source.composition.live depending on composition_type).
  • single (of type bool): Forbid the selection of this source for two consecutive tracks in switch operators. Defaults to false.
  • track_sensitive (of type {bool}): Whether this source insists on track boundaries in switch operators: when true, it prefers not to be interrupted mid-track and not to be started mid-track. A switch may only cut into a track that is still playing when at least one of the two sources involved has track_sensitive set to false; otherwise it waits for the playing source to reach a track boundary. File-based sources default to true; live network and hardware inputs default to false. The value is looked up at runtime from the active composition profile (source.composition.file or source.composition.live depending on composition_type).

input.pulseaudio​

Stream from a pulseaudio input device.

Type:

(?id : string?, ?client : string, ?device : string?, ?fallible : bool,
?on_error : ((string) -> unit), ?retry_delay : float, ?self_sync : bool,
?start : bool) -> source(audio=pcm('a))

Synchronization:

This source uses the PulseAudio clock as synchronization source when self_sync=true and the stream is open.

Composition:

This source uses live composition by default.

Arguments:

  • id (of type string?, which defaults to null): Force the value of the source ID.
  • client (of type string, which defaults to "liquidsoap")
  • device (of type string?, which defaults to null): Device to use. Uses default if set to null.
  • fallible (of type bool, which defaults to true): Allow the source to fail. If set to false, start must be true and stop method raises an error.
  • on_error (of type (string) -> unit, which defaults to fun (_) -> ()): Function executed when an operation with the pulseaudio server returns an error.
  • retry_delay (of type float, which defaults to 1.0): When fallible, time to wait before trying to connect again.
  • self_sync (of type bool, which defaults to true): Use the PulseAudio clock as synchronization source. When false, delegate to the underlying source's synchronization.
  • start (of type bool, which defaults to true): Start input as soon as it is available.

Methods:

  • buffered (of type () -> [string * float]): Length of buffered data.
  • callbacks_count (of type () -> [string * int]): Callbacks a script has registered on this source, as pairs of callback name and count. A count that keeps growing is a function registering on a source it is handed without releasing what it registered.
  • clear_last_metadata (of type () -> unit): Clear the last metadata from the source.
  • clock (of type clock): The source's clock
  • duration (of type () -> float): Estimation of the duration of the current track.
  • elapsed (of type () -> float): Elapsed time in the current track.
  • fallible (of type bool): Indicate if a source may fail, i.e. may not be ready to stream.
  • generate_frame (of type () -> unit): Generate a frame from the source without consuming it. This can be useful in advanced cases where generating a frame is required to trigger some side effect like calculating some metadata before making a decision. You should make sure that the source is available before calling this function and it should only be called inside synchronous streaming loop callback such as on_frame!
  • id (of type () -> string): Identifier of the source.
  • insert_metadata (of type (?override : bool, ?new_track : bool, [string * string]) -> unit): Dynamically insert metadata in a stream. Inserts a new track with the given metadata if new_track is true. When override is false, metadata that the source provides itself takes precedence over the inserted one.
  • is_active (of type () -> bool): true if the source is active, i.e. it is continuously animated by its own clock whenever it is ready. Typically, true for outputs and sources such as input.http.
  • is_ready (of type () -> bool): Indicate if a source is ready to stream. This does not mean that the source is currently streaming, just that its resources are all properly initialized.
  • is_started (of type () -> bool): true if the output or source is started.
  • is_up (of type () -> bool): Indicate that the source can be asked to produce some data at any time. This is true when the source is currently being used or if it could be used at any time, typically inside a switch or fallback.
  • last_metadata (of type () -> [string * string]?): Return the last metadata from the source.
  • log (of type {level : (() -> int).{exchange : (int) -> int, set : (int) -> unit}}): Get or set the source's log level, from 1 to 5.
  • register_command (of type (?usage : string?, description : string, string, ((string) -> string)) -> unit): Register a server command for this source. Command is registered under the source's id namespace when it gets up and de-registered when it gets down.
  • remaining (of type () -> float): Estimation of remaining time in the current track.
  • reset_last_metadata_on_track (of type (() -> bool).{exchange : (bool) -> bool, set : (bool) -> unit}): If true, the source's last_metadata is reset on each new track. If a metadata is present along with the track mark, then it becomes the new last_metadata, otherwise, last_metadata becomes null`.
  • seek (of type (float) -> float): Seek forward, in seconds (returns the amount of time effectively seeked).
  • self_sync (of type () -> bool): Is the source currently controlling its own real-time loop.
  • self_sync_description (of type () -> string): This source uses the PulseAudio clock as synchronization source when self_sync=true and the stream is open.
  • skip (of type () -> unit): Skip to the next track.
  • start (of type () -> unit): Ask the source or output to start.
  • stop (of type () -> unit): Ask the source or output to stop.
  • time (of type () -> float): Get a source's time, based on its assigned clock.

Callbacks:

  • on_collect (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called when source is collected
  • on_frame (of type (?before : bool, synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler on frame. When before is true, callback is executed before computing the frame and after otherwise
  • on_frame_checksum (of type (?before : ((string?) -> unit)?, synchronous : bool, ((cache : string?, string) -> unit)) -> {release : () -> unit}): Call a given handler Register callbacks to compute frame checksums for debugging purposes. This is useful to track frame content changes through the streaming pipeline. The before callback is called before computing the frame with the checksum of the cached frame (if any, null otherwise). The main callback is called after computing the frame with the checksum of the generated frame and the remaining cache (if any).
  • on_metadata (of type (synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}): Call a given handler to execute on each metadata
  • on_position (of type (position : {float}, ?remaining : bool, ?allow_partial : bool, synchronous : bool, ((float, [string * string]) -> unit)) -> {release : () -> unit}): Call a given handler on track position. If remaining is false, callback is executed when position in track is more or equal to position. If remaining is true, callback is executed when remaining time in the current track is less or equal to position. Keep in mind that elapsed time is exact while remaining time is always estimated. Remaining time is usually more accurate for file-based sources. When allow_partial is true, if the current track ends before the offset position is reached, callback is still executed
  • on_shutdown (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called when source shuts down
  • on_start (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler when source starts
  • on_stop (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler when source stops
  • on_track (of type (synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}): Call a given handler on track marks
  • on_wake_up (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called after the source is asked to get ready

Composition methods:

  • composition_type (of type (() -> string).{exchange : (string) -> string, set : (string) -> unit}): This source uses live composition by default.
  • on_leave (of type ({source : source(audio=pcm('a)), track_sensitive : bool}) -> unit): Called after switching away from this source in a switch operator, once the transition using the ending source has completed. Receives a record with source (the source being left) and track_sensitive (true if the ending source's last frame had a track mark, i.e. it finished naturally; false if it was preempted mid-track). This function must return quickly as it runs in the streaming thread. The default depends on the active composition profile: file sources (source.composition.file) skip the source when preempted mid-track so it starts fresh on its next selection, and do nothing when it finished naturally; live sources (source.composition.live) do nothing.
  • on_select (of type ( { ending : source(audio=pcm('a))?, replay_metadata : bool, starting : source(audio=pcm('a)) }) -> source(audio=pcm('a))): Called when selecting this source in a switch operator. Receives a record with starting (the incoming source) and ending (the previous source, or null when the ending source reached a track boundary). Returns the source to use. By default, both file and live profiles fade out ending when non-null (up to 1 second). The default is looked up at runtime from the active composition profile (source.composition.file or source.composition.live depending on composition_type).
  • replay_metadata (of type {bool}): Whether to replay the latest metadata on this source when it is selected in a switch operator. Defaults to true. The value is looked up at runtime from the active composition profile (source.composition.file or source.composition.live depending on composition_type).
  • single (of type bool): Forbid the selection of this source for two consecutive tracks in switch operators. Defaults to false.
  • track_sensitive (of type {bool}): Whether this source insists on track boundaries in switch operators: when true, it prefers not to be interrupted mid-track and not to be started mid-track. A switch may only cut into a track that is still playing when at least one of the two sources involved has track_sensitive set to false; otherwise it waits for the playing source to reach a track boundary. File-based sources default to true; live network and hardware inputs default to false. The value is looked up at runtime from the active composition profile (source.composition.file or source.composition.live depending on composition_type).

input.rtmp​

Read an RTMP stream with FFmpeg, by default as a server waiting for a publisher.

Type:

(?id : string?, ?max_buffer : float, ?listen : bool, {string}) -> source('a)

Synchronization:

This source paces its clock while connected when self_sync is true.

Composition:

This source uses live composition by default.

Arguments:

  • id (of type string?, which defaults to null): Force the value of the source ID.
  • max_buffer (of type float, which defaults to 5.0): Maximum data buffered, in seconds.
  • listen (of type bool, which defaults to true): Wait for a publisher instead of connecting to a server.
  • (unlabeled) (of type {string}): RTMP URL, e.g. rtmp://0.0.0.0:1935/live/stream.

Methods:

  • buffered (of type () -> [string * float]): Length of buffered data.
  • callbacks_count (of type () -> [string * int]): Callbacks a script has registered on this source, as pairs of callback name and count. A count that keeps growing is a function registering on a source it is handed without releasing what it registered.
  • clear_last_metadata (of type () -> unit): Clear the last metadata from the source.
  • clock (of type clock): The source's clock
  • duration (of type () -> float): Estimation of the duration of the current track.
  • elapsed (of type () -> float): Elapsed time in the current track.
  • fallible (of type bool): Indicate if a source may fail, i.e. may not be ready to stream.
  • generate_frame (of type () -> unit): Generate a frame from the source without consuming it. This can be useful in advanced cases where generating a frame is required to trigger some side effect like calculating some metadata before making a decision. You should make sure that the source is available before calling this function and it should only be called inside synchronous streaming loop callback such as on_frame!
  • id (of type () -> string): Identifier of the source.
  • insert_metadata (of type (?override : bool, ?new_track : bool, [string * string]) -> unit): Dynamically insert metadata in a stream. Inserts a new track with the given metadata if new_track is true. When override is false, metadata that the source provides itself takes precedence over the inserted one.
  • is_active (of type () -> bool): true if the source is active, i.e. it is continuously animated by its own clock whenever it is ready. Typically, true for outputs and sources such as input.http.
  • is_ready (of type () -> bool): Indicate if a source is ready to stream. This does not mean that the source is currently streaming, just that its resources are all properly initialized.
  • is_started (of type () -> bool): true if the output or source is started.
  • is_up (of type () -> bool): Indicate that the source can be asked to produce some data at any time. This is true when the source is currently being used or if it could be used at any time, typically inside a switch or fallback.
  • last_metadata (of type () -> [string * string]?): Return the last metadata from the source.
  • log (of type {level : (() -> int).{exchange : (int) -> int, set : (int) -> unit}}): Get or set the source's log level, from 1 to 5.
  • register_command (of type (?usage : string?, description : string, string, ((string) -> string)) -> unit): Register a server command for this source. Command is registered under the source's id namespace when it gets up and de-registered when it gets down.
  • remaining (of type () -> float): Estimation of remaining time in the current track.
  • reset_last_metadata_on_track (of type (() -> bool).{exchange : (bool) -> bool, set : (bool) -> unit}): If true, the source's last_metadata is reset on each new track. If a metadata is present along with the track mark, then it becomes the new last_metadata, otherwise, last_metadata becomes null`.
  • seek (of type (float) -> float): Seek forward, in seconds (returns the amount of time effectively seeked).
  • self_sync (of type () -> bool): Is the source currently controlling its own real-time loop.
  • self_sync_description (of type () -> string): This source paces its clock while connected when self_sync is true.
  • set_url (of type ({string}) -> unit): Set the URL, used at the next connection.
  • skip (of type () -> unit): Skip to the next track.
  • start (of type () -> unit): Ask the source or output to start.
  • status (of type () -> string): Status: "stopped", "starting", "polling", "connected <url>", "stopping" or "failed".
  • stop (of type () -> unit): Ask the source or output to stop.
  • time (of type () -> float): Get a source's time, based on its assigned clock.
  • url (of type () -> string): Current URL.

Callbacks:

  • on_collect (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called when source is collected
  • on_connect (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler when connected, before the source plays the connection's data.
  • on_disconnect (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler when a connection whose on_connect callbacks ran ends.
  • on_error (of type (synchronous : bool, ((error) -> unit)) -> {release : () -> unit}): Call a given handler on each connection or feeding failure.
  • on_frame (of type (?before : bool, synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler on frame. When before is true, callback is executed before computing the frame and after otherwise
  • on_frame_checksum (of type (?before : ((string?) -> unit)?, synchronous : bool, ((cache : string?, string) -> unit)) -> {release : () -> unit}): Call a given handler Register callbacks to compute frame checksums for debugging purposes. This is useful to track frame content changes through the streaming pipeline. The before callback is called before computing the frame with the checksum of the cached frame (if any, null otherwise). The main callback is called after computing the frame with the checksum of the generated frame and the remaining cache (if any).
  • on_metadata (of type (synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}): Call a given handler to execute on each metadata
  • on_position (of type (position : {float}, ?remaining : bool, ?allow_partial : bool, synchronous : bool, ((float, [string * string]) -> unit)) -> {release : () -> unit}): Call a given handler on track position. If remaining is false, callback is executed when position in track is more or equal to position. If remaining is true, callback is executed when remaining time in the current track is less or equal to position. Keep in mind that elapsed time is exact while remaining time is always estimated. Remaining time is usually more accurate for file-based sources. When allow_partial is true, if the current track ends before the offset position is reached, callback is still executed
  • on_shutdown (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called when source shuts down
  • on_start (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler when source starts
  • on_stop (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler when source stops
  • on_track (of type (synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}): Call a given handler on track marks
  • on_wake_up (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called after the source is asked to get ready

Composition methods:

  • composition_type (of type (() -> string).{exchange : (string) -> string, set : (string) -> unit}): This source uses live composition by default.
  • on_leave (of type ({source : source('a), track_sensitive : bool}) -> unit): Called after switching away from this source in a switch operator, once the transition using the ending source has completed. Receives a record with source (the source being left) and track_sensitive (true if the ending source's last frame had a track mark, i.e. it finished naturally; false if it was preempted mid-track). This function must return quickly as it runs in the streaming thread. The default depends on the active composition profile: file sources (source.composition.file) skip the source when preempted mid-track so it starts fresh on its next selection, and do nothing when it finished naturally; live sources (source.composition.live) do nothing.
  • on_select (of type ({ending : source('a)?, replay_metadata : bool, starting : source('a)}) -> source('a)): Called when selecting this source in a switch operator. Receives a record with starting (the incoming source) and ending (the previous source, or null when the ending source reached a track boundary). Returns the source to use. By default, both file and live profiles fade out ending when non-null (up to 1 second). The default is looked up at runtime from the active composition profile (source.composition.file or source.composition.live depending on composition_type).
  • replay_metadata (of type {bool}): Whether to replay the latest metadata on this source when it is selected in a switch operator. Defaults to true. The value is looked up at runtime from the active composition profile (source.composition.file or source.composition.live depending on composition_type).
  • single (of type bool): Forbid the selection of this source for two consecutive tracks in switch operators. Defaults to false.
  • track_sensitive (of type {bool}): Whether this source insists on track boundaries in switch operators: when true, it prefers not to be interrupted mid-track and not to be started mid-track. A switch may only cut into a track that is still playing when at least one of the two sources involved has track_sensitive set to false; otherwise it waits for the playing source to reach a track boundary. File-based sources default to true; live network and hardware inputs default to false. The value is looked up at runtime from the active composition profile (source.composition.file or source.composition.live depending on composition_type).

input.srt​

Receive a SRT stream, as a listener or as a caller.

Type:

(?id : string?, ?bind_address : string, ?connection_timeout : float?,
?content_type : string, ?dump : string, ?enforced_encryption : bool?,
?host : string, ?ipv6only : bool?,
?listen_callback : ((hs_version : int, peeraddr : string,
streamid : string?, srt_socket
.{
bistats : (?clear : bool?, ?instantaneous : bool?) ->
{
byteAvailRcvBuf : int,
byteAvailSndBuf : int,
byteMSS : int,
byteRcvBuf : int,
byteRcvDrop : int,
byteRcvDropTotal : int,
byteRcvUndecrypt : int,
byteRcvUndecryptTotal : int,
byteRecv : int,
byteRecvTotal : int,
byteRetrans : int,
byteRetransTotal : int,
byteSent : int,
byteSentTotal : int,
byteSndBuf : int,
byteSndDrop : int,
byteSndDropTotal : int,
mbpsBandwidth : float,
mbpsMaxBW : float,
mbpsRecvRate : float,
mbpsSendRate : float,
msRTT : float,
msRcvBuf : int,
msRcvTsbPdDelay : int,
msSndBuf : int,
msSndTsbPdDelay : int,
msTimeStamp : int,
pktCongestionWindow : int,
pktFlightSize : int,
pktFlowWindow : int,
pktRcvAvgBelatedTime : float,
pktRcvBelated : int,
pktRcvBuf : int,
pktRcvDrop : int,
pktRcvDropTotal : int,
pktRcvFilterExtra : int,
pktRcvFilterExtraTotal : int,
pktRcvFilterLoss : int,
pktRcvFilterLossTotal : int,
pktRcvFilterSupply : int,
pktRcvFilterSupplyTotal : int,
pktRcvLoss : int,
pktRcvLossTotal : int,
pktRcvRetrans : int,
pktRcvUndecrypt : int,
pktRcvUndecryptTotal : int,
pktRecv : int,
pktRecvACK : int,
pktRecvACKTotal : int,
pktRecvNAK : int,
pktRecvNAKTotal : int,
pktRecvTotal : int,
pktReorderDistance : int,
pktRetrans : int,
pktRetransTotal : int,
pktSent : int,
pktSentACK : int,
pktSentACKTotal : int,
pktSentNAK : int,
pktSentNAKTotal : int,
pktSentTotal : int,
pktSndBuf : int,
pktSndDrop : int,
pktSndDropTotal : int,
pktSndFilterExtra : int,
pktSndFilterExtraTotal : int,
pktSndLoss : int,
pktSndLossTotal : int,
usPktSndPeriod : float,
usSndDuration : int,
usSndDurationTotal : int},
bstats : (?clear : bool?) ->
{
byteAvailRcvBuf : int,
byteAvailSndBuf : int,
byteMSS : int,
byteRcvBuf : int,
byteRcvDrop : int,
byteRcvDropTotal : int,
byteRcvUndecrypt : int,
byteRcvUndecryptTotal : int,
byteRecv : int,
byteRecvTotal : int,
byteRetrans : int,
byteRetransTotal : int,
byteSent : int,
byteSentTotal : int,
byteSndBuf : int,
byteSndDrop : int,
byteSndDropTotal : int,
mbpsBandwidth : float,
mbpsMaxBW : float,
mbpsRecvRate : float,
mbpsSendRate : float,
msRTT : float,
msRcvBuf : int,
msRcvTsbPdDelay : int,
msSndBuf : int,
msSndTsbPdDelay : int,
msTimeStamp : int,
pktCongestionWindow : int,
pktFlightSize : int,
pktFlowWindow : int,
pktRcvAvgBelatedTime : float,
pktRcvBelated : int,
pktRcvBuf : int,
pktRcvDrop : int,
pktRcvDropTotal : int,
pktRcvFilterExtra : int,
pktRcvFilterExtraTotal : int,
pktRcvFilterLoss : int,
pktRcvFilterLossTotal : int,
pktRcvFilterSupply : int,
pktRcvFilterSupplyTotal : int,
pktRcvLoss : int,
pktRcvLossTotal : int,
pktRcvRetrans : int,
pktRcvUndecrypt : int,
pktRcvUndecryptTotal : int,
pktRecv : int,
pktRecvACK : int,
pktRecvACKTotal : int,
pktRecvNAK : int,
pktRecvNAKTotal : int,
pktRecvTotal : int,
pktReorderDistance : int,
pktRetrans : int,
pktRetransTotal : int,
pktSent : int,
pktSentACK : int,
pktSentACKTotal : int,
pktSentNAK : int,
pktSentNAKTotal : int,
pktSentTotal : int,
pktSndBuf : int,
pktSndDrop : int,
pktSndDropTotal : int,
pktSndFilterExtra : int,
pktSndFilterExtraTotal : int,
pktSndLoss : int,
pktSndLossTotal : int,
usPktSndPeriod : float,
usSndDuration : int,
usSndDurationTotal : int},
close : () -> unit,
id : int,
ipv6only : () -> bool,
latency : () -> int,
pbkeylen : () -> int,
peerlatency : () -> int,
rcvbuf : () -> int,
rcvdata : () -> int,
rcvlatency : () -> int,
rcvsyn : () -> bool,
rcvtimeout : () -> int,
reuseaddr : () -> bool,
set_conntimeo : (int) -> unit,
set_enforced_encryption : (bool) -> unit,
set_ipv6only : (bool) -> unit,
set_latency : (int) -> unit,
set_messageapi : (bool) -> unit,
set_passphrase : (string) -> unit,
set_payloadsize : (int) -> unit,
set_pbkeylen : (int) -> unit,
set_peerlatency : (int) -> unit,
set_rcvbuf : (int) -> unit,
set_rcvlatency : (int) -> unit,
set_rcvsyn : (bool) -> unit,
set_rcvtimeout : (int) -> unit,
set_reuseaddr : (bool) -> unit,
set_sndbuf : (int) -> unit,
set_sndsyn : (bool) -> unit,
set_sndtimeout : (int) -> unit,
set_streamid : (string) -> unit,
set_tsbpdmode : (bool) -> unit,
set_udp_rcvbuf : (int) -> unit,
set_udp_sndbuf : (int) -> unit,
sndbuf : () -> int,
sndsyn : () -> bool,
sndtimeout : () -> int,
status : () -> string,
streamid : () -> string,
tsbpdmode : () -> bool,
udp_rcvbuf : () -> int,
udp_sndbuf : () -> int
}) -> bool)?,
?max : float, ?messageapi : bool, ?mode : string, ?passphrase : string?,
?payload_size : int, ?pbkeylen : int?, ?polling_delay : float, ?port : int,
?prefer_address : string?, ?read_timeout : float?, ?self_sync : bool,
?start : bool, ?streamid : string?, ?write_timeout : float?) -> source('a)

Composition:

This source uses live composition by default.

Arguments:

  • id (of type string?, which defaults to null): Force the value of the source ID.
  • bind_address (of type string, which defaults to "0.0.0.0"): Local address to bind. Used only in listener mode.
  • connection_timeout (of type float?, which defaults to null): Connection timeout, in seconds. null keeps libsrt's default. Used only in caller mode.
  • content_type (of type string, which defaults to "application/ffmpeg"): MIME type used to find a stream decoder.
  • dump (of type string, which defaults to ""): File receiving a copy of the received bytes; "" for none.
  • enforced_encryption (of type bool?, which defaults to null): Refuse connections whose encryption does not match. Defaults to settings.srt.enforced_encryption when null.
  • host (of type string, which defaults to "localhost"): Address to connect to. Used only in caller mode.
  • ipv6only (of type bool?, which defaults to null): Accept only IPv6 connections. Defaults to true when the bind address is IPv6. Used only in listener mode.
  • listen_callback (of type ((hs_version : int, peeraddr : string, streamid : string?, srt_socket .{ bistats : (?clear : bool?, ?instantaneous : bool?) -> { byteAvailRcvBuf : int, byteAvailSndBuf : int, byteMSS : int, byteRcvBuf : int, byteRcvDrop : int, byteRcvDropTotal : int, byteRcvUndecrypt : int, byteRcvUndecryptTotal : int, byteRecv : int, byteRecvTotal : int, byteRetrans : int, byteRetransTotal : int, byteSent : int, byteSentTotal : int, byteSndBuf : int, byteSndDrop : int, byteSndDropTotal : int, mbpsBandwidth : float, mbpsMaxBW : float, mbpsRecvRate : float, mbpsSendRate : float, msRTT : float, msRcvBuf : int, msRcvTsbPdDelay : int, msSndBuf : int, msSndTsbPdDelay : int, msTimeStamp : int, pktCongestionWindow : int, pktFlightSize : int, pktFlowWindow : int, pktRcvAvgBelatedTime : float, pktRcvBelated : int, pktRcvBuf : int, pktRcvDrop : int, pktRcvDropTotal : int, pktRcvFilterExtra : int, pktRcvFilterExtraTotal : int, pktRcvFilterLoss : int, pktRcvFilterLossTotal : int, pktRcvFilterSupply : int, pktRcvFilterSupplyTotal : int, pktRcvLoss : int, pktRcvLossTotal : int, pktRcvRetrans : int, pktRcvUndecrypt : int, pktRcvUndecryptTotal : int, pktRecv : int, pktRecvACK : int, pktRecvACKTotal : int, pktRecvNAK : int, pktRecvNAKTotal : int, pktRecvTotal : int, pktReorderDistance : int, pktRetrans : int, pktRetransTotal : int, pktSent : int, pktSentACK : int, pktSentACKTotal : int, pktSentNAK : int, pktSentNAKTotal : int, pktSentTotal : int, pktSndBuf : int, pktSndDrop : int, pktSndDropTotal : int, pktSndFilterExtra : int, pktSndFilterExtraTotal : int, pktSndLoss : int, pktSndLossTotal : int, usPktSndPeriod : float, usSndDuration : int, usSndDurationTotal : int}, bstats : (?clear : bool?) -> { byteAvailRcvBuf : int, byteAvailSndBuf : int, byteMSS : int, byteRcvBuf : int, byteRcvDrop : int, byteRcvDropTotal : int, byteRcvUndecrypt : int, byteRcvUndecryptTotal : int, byteRecv : int, byteRecvTotal : int, byteRetrans : int, byteRetransTotal : int, byteSent : int, byteSentTotal : int, byteSndBuf : int, byteSndDrop : int, byteSndDropTotal : int, mbpsBandwidth : float, mbpsMaxBW : float, mbpsRecvRate : float, mbpsSendRate : float, msRTT : float, msRcvBuf : int, msRcvTsbPdDelay : int, msSndBuf : int, msSndTsbPdDelay : int, msTimeStamp : int, pktCongestionWindow : int, pktFlightSize : int, pktFlowWindow : int, pktRcvAvgBelatedTime : float, pktRcvBelated : int, pktRcvBuf : int, pktRcvDrop : int, pktRcvDropTotal : int, pktRcvFilterExtra : int, pktRcvFilterExtraTotal : int, pktRcvFilterLoss : int, pktRcvFilterLossTotal : int, pktRcvFilterSupply : int, pktRcvFilterSupplyTotal : int, pktRcvLoss : int, pktRcvLossTotal : int, pktRcvRetrans : int, pktRcvUndecrypt : int, pktRcvUndecryptTotal : int, pktRecv : int, pktRecvACK : int, pktRecvACKTotal : int, pktRecvNAK : int, pktRecvNAKTotal : int, pktRecvTotal : int, pktReorderDistance : int, pktRetrans : int, pktRetransTotal : int, pktSent : int, pktSentACK : int, pktSentACKTotal : int, pktSentNAK : int, pktSentNAKTotal : int, pktSentTotal : int, pktSndBuf : int, pktSndDrop : int, pktSndDropTotal : int, pktSndFilterExtra : int, pktSndFilterExtraTotal : int, pktSndLoss : int, pktSndLossTotal : int, usPktSndPeriod : float, usSndDuration : int, usSndDurationTotal : int}, close : () -> unit, id : int, ipv6only : () -> bool, latency : () -> int, pbkeylen : () -> int, peerlatency : () -> int, rcvbuf : () -> int, rcvdata : () -> int, rcvlatency : () -> int, rcvsyn : () -> bool, rcvtimeout : () -> int, reuseaddr : () -> bool, set_conntimeo : (int) -> unit, set_enforced_encryption : (bool) -> unit, set_ipv6only : (bool) -> unit, set_latency : (int) -> unit, set_messageapi : (bool) -> unit, set_passphrase : (string) -> unit, set_payloadsize : (int) -> unit, set_pbkeylen : (int) -> unit, set_peerlatency : (int) -> unit, set_rcvbuf : (int) -> unit, set_rcvlatency : (int) -> unit, set_rcvsyn : (bool) -> unit, set_rcvtimeout : (int) -> unit, set_reuseaddr : (bool) -> unit, set_sndbuf : (int) -> unit, set_sndsyn : (bool) -> unit, set_sndtimeout : (int) -> unit, set_streamid : (string) -> unit, set_tsbpdmode : (bool) -> unit, set_udp_rcvbuf : (int) -> unit, set_udp_sndbuf : (int) -> unit, sndbuf : () -> int, sndsyn : () -> bool, sndtimeout : () -> int, status : () -> string, streamid : () -> string, tsbpdmode : () -> bool, udp_rcvbuf : () -> int, udp_sndbuf : () -> int }) -> bool)?, which defaults to null): Admission predicate called during each handshake with the handshake version, the peer's address, its stream id and the new socket: a connection is admitted when it returns true. Used only in listener mode. It runs on libsrt's single handshake thread: a slow callback delays every handshake of the process.
  • max (of type float, which defaults to 10.0): Maximum duration of the buffered data, in seconds.
  • messageapi (of type bool, which defaults to true): libsrt message API flag. Live mode requires true.
  • mode (of type string, which defaults to "listener"): Connection mode. One of: "listener" or "caller".
  • passphrase (of type string?, which defaults to null): Encryption passphrase, 10 to 79 characters. null or "" means no encryption.
  • payload_size (of type int, which defaults to 1316): libsrt payload size, and the size of every message an output sends.
  • pbkeylen (of type int?, which defaults to null): Encryption key length. One of: 0 (libsrt's default), 16, 24 or 32.
  • polling_delay (of type float, which defaults to 2.0): Delay, in seconds, between two tries after a failure.
  • port (of type int, which defaults to 8000): Port to bind in listener mode, or to connect to in caller mode.
  • prefer_address (of type string?, which defaults to null): Address family used when resolving hostnames. One of: "system", "ipv4" or "ipv6". Defaults to settings.srt.prefer_address when null.
  • read_timeout (of type float?, which defaults to 1.0): Longest wait for data, in seconds, while the input paces its clock. null means no limit. Used only by inputs.
  • self_sync (of type bool, which defaults to true): Pace the clock while a connected stream is delivered by sender timestamps.
  • start (of type bool, which defaults to true): Start input as soon as it is available.
  • streamid (of type string?, which defaults to null): Stream id sent in the handshake. Used only in caller mode.
  • write_timeout (of type float?, which defaults to 1.0): Longest time, in seconds, a peer may accept no data before it is dropped. null means no limit. Used only by outputs.

Methods:

  • buffered (of type () -> [string * float]): Length of buffered data.
  • callbacks_count (of type () -> [string * int]): Callbacks a script has registered on this source, as pairs of callback name and count. A count that keeps growing is a function registering on a source it is handed without releasing what it registered.
  • clear_last_metadata (of type () -> unit): Clear the last metadata from the source.
  • clock (of type clock): The source's clock
  • connect (of type () -> unit): Connect, or listen, when started.
  • disconnect (of type () -> unit): Disconnect every peer and stop connecting until connect.
  • duration (of type () -> float): Estimation of the duration of the current track.
  • elapsed (of type () -> float): Elapsed time in the current track.
  • fallible (of type bool): Indicate if a source may fail, i.e. may not be ready to stream.
  • generate_frame (of type () -> unit): Generate a frame from the source without consuming it. This can be useful in advanced cases where generating a frame is required to trigger some side effect like calculating some metadata before making a decision. You should make sure that the source is available before calling this function and it should only be called inside synchronous streaming loop callback such as on_frame!
  • id (of type () -> string): Identifier of the source.
  • insert_metadata (of type (?override : bool, ?new_track : bool, [string * string]) -> unit): Dynamically insert metadata in a stream. Inserts a new track with the given metadata if new_track is true. When override is false, metadata that the source provides itself takes precedence over the inserted one.
  • is_active (of type () -> bool): true if the source is active, i.e. it is continuously animated by its own clock whenever it is ready. Typically, true for outputs and sources such as input.http.
  • is_ready (of type () -> bool): Indicate if a source is ready to stream. This does not mean that the source is currently streaming, just that its resources are all properly initialized.
  • is_started (of type () -> bool): true if the output or source is started.
  • is_up (of type () -> bool): Indicate that the source can be asked to produce some data at any time. This is true when the source is currently being used or if it could be used at any time, typically inside a switch or fallback.
  • last_metadata (of type () -> [string * string]?): Return the last metadata from the source.
  • log (of type {level : (() -> int).{exchange : (int) -> int, set : (int) -> unit}}): Get or set the source's log level, from 1 to 5.
  • register_command (of type (?usage : string?, description : string, string, ((string) -> string)) -> unit): Register a server command for this source. Command is registered under the source's id namespace when it gets up and de-registered when it gets down.
  • remaining (of type () -> float): Estimation of remaining time in the current track.
  • reset_last_metadata_on_track (of type (() -> bool).{exchange : (bool) -> bool, set : (bool) -> unit}): If true, the source's last_metadata is reset on each new track. If a metadata is present along with the track mark, then it becomes the new last_metadata, otherwise, last_metadata becomes null`.
  • seek (of type (float) -> float): Seek forward, in seconds (returns the amount of time effectively seeked).
  • self_sync (of type () -> bool): Is the source currently controlling its own real-time loop.
  • self_sync_description (of type () -> string)
  • skip (of type () -> unit): Skip to the next track.
  • sockets (of type () -> [string * srt_socket .{ bistats : (?clear : bool?, ?instantaneous : bool?) -> { byteAvailRcvBuf : int, byteAvailSndBuf : int, byteMSS : int, byteRcvBuf : int, byteRcvDrop : int, byteRcvDropTotal : int, byteRcvUndecrypt : int, byteRcvUndecryptTotal : int, byteRecv : int, byteRecvTotal : int, byteRetrans : int, byteRetransTotal : int, byteSent : int, byteSentTotal : int, byteSndBuf : int, byteSndDrop : int, byteSndDropTotal : int, mbpsBandwidth : float, mbpsMaxBW : float, mbpsRecvRate : float, mbpsSendRate : float, msRTT : float, msRcvBuf : int, msRcvTsbPdDelay : int, msSndBuf : int, msSndTsbPdDelay : int, msTimeStamp : int, pktCongestionWindow : int, pktFlightSize : int, pktFlowWindow : int, pktRcvAvgBelatedTime : float, pktRcvBelated : int, pktRcvBuf : int, pktRcvDrop : int, pktRcvDropTotal : int, pktRcvFilterExtra : int, pktRcvFilterExtraTotal : int, pktRcvFilterLoss : int, pktRcvFilterLossTotal : int, pktRcvFilterSupply : int, pktRcvFilterSupplyTotal : int, pktRcvLoss : int, pktRcvLossTotal : int, pktRcvRetrans : int, pktRcvUndecrypt : int, pktRcvUndecryptTotal : int, pktRecv : int, pktRecvACK : int, pktRecvACKTotal : int, pktRecvNAK : int, pktRecvNAKTotal : int, pktRecvTotal : int, pktReorderDistance : int, pktRetrans : int, pktRetransTotal : int, pktSent : int, pktSentACK : int, pktSentACKTotal : int, pktSentNAK : int, pktSentNAKTotal : int, pktSentTotal : int, pktSndBuf : int, pktSndDrop : int, pktSndDropTotal : int, pktSndFilterExtra : int, pktSndFilterExtraTotal : int, pktSndLoss : int, pktSndLossTotal : int, usPktSndPeriod : float, usSndDuration : int, usSndDurationTotal : int}, bstats : (?clear : bool?) -> { byteAvailRcvBuf : int, byteAvailSndBuf : int, byteMSS : int, byteRcvBuf : int, byteRcvDrop : int, byteRcvDropTotal : int, byteRcvUndecrypt : int, byteRcvUndecryptTotal : int, byteRecv : int, byteRecvTotal : int, byteRetrans : int, byteRetransTotal : int, byteSent : int, byteSentTotal : int, byteSndBuf : int, byteSndDrop : int, byteSndDropTotal : int, mbpsBandwidth : float, mbpsMaxBW : float, mbpsRecvRate : float, mbpsSendRate : float, msRTT : float, msRcvBuf : int, msRcvTsbPdDelay : int, msSndBuf : int, msSndTsbPdDelay : int, msTimeStamp : int, pktCongestionWindow : int, pktFlightSize : int, pktFlowWindow : int, pktRcvAvgBelatedTime : float, pktRcvBelated : int, pktRcvBuf : int, pktRcvDrop : int, pktRcvDropTotal : int, pktRcvFilterExtra : int, pktRcvFilterExtraTotal : int, pktRcvFilterLoss : int, pktRcvFilterLossTotal : int, pktRcvFilterSupply : int, pktRcvFilterSupplyTotal : int, pktRcvLoss : int, pktRcvLossTotal : int, pktRcvRetrans : int, pktRcvUndecrypt : int, pktRcvUndecryptTotal : int, pktRecv : int, pktRecvACK : int, pktRecvACKTotal : int, pktRecvNAK : int, pktRecvNAKTotal : int, pktRecvTotal : int, pktReorderDistance : int, pktRetrans : int, pktRetransTotal : int, pktSent : int, pktSentACK : int, pktSentACKTotal : int, pktSentNAK : int, pktSentNAKTotal : int, pktSentTotal : int, pktSndBuf : int, pktSndDrop : int, pktSndDropTotal : int, pktSndFilterExtra : int, pktSndFilterExtraTotal : int, pktSndLoss : int, pktSndLossTotal : int, usPktSndPeriod : float, usSndDuration : int, usSndDurationTotal : int}, close : () -> unit, id : int, ipv6only : () -> bool, latency : () -> int, pbkeylen : () -> int, peerlatency : () -> int, rcvbuf : () -> int, rcvdata : () -> int, rcvlatency : () -> int, rcvsyn : () -> bool, rcvtimeout : () -> int, reuseaddr : () -> bool, set_conntimeo : (int) -> unit, set_enforced_encryption : (bool) -> unit, set_ipv6only : (bool) -> unit, set_latency : (int) -> unit, set_messageapi : (bool) -> unit, set_passphrase : (string) -> unit, set_payloadsize : (int) -> unit, set_pbkeylen : (int) -> unit, set_peerlatency : (int) -> unit, set_rcvbuf : (int) -> unit, set_rcvlatency : (int) -> unit, set_rcvsyn : (bool) -> unit, set_rcvtimeout : (int) -> unit, set_reuseaddr : (bool) -> unit, set_sndbuf : (int) -> unit, set_sndsyn : (bool) -> unit, set_sndtimeout : (int) -> unit, set_streamid : (string) -> unit, set_tsbpdmode : (bool) -> unit, set_udp_rcvbuf : (int) -> unit, set_udp_sndbuf : (int) -> unit, sndbuf : () -> int, sndsyn : () -> bool, sndtimeout : () -> int, status : () -> string, streamid : () -> string, tsbpdmode : () -> bool, udp_rcvbuf : () -> int, udp_sndbuf : () -> int }]): The connected peers, with their IP address.
  • start (of type () -> unit): Ask the source or output to start.
  • stop (of type () -> unit): Ask the source or output to stop.
  • time (of type () -> float): Get a source's time, based on its assigned clock.

Callbacks:

  • on_collect (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called when source is collected
  • on_connect (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler when a peer connects, before any data is exchanged with it
  • on_disconnect (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler when a peer that connected is disconnected
  • on_frame (of type (?before : bool, synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler on frame. When before is true, callback is executed before computing the frame and after otherwise
  • on_frame_checksum (of type (?before : ((string?) -> unit)?, synchronous : bool, ((cache : string?, string) -> unit)) -> {release : () -> unit}): Call a given handler Register callbacks to compute frame checksums for debugging purposes. This is useful to track frame content changes through the streaming pipeline. The before callback is called before computing the frame with the checksum of the cached frame (if any, null otherwise). The main callback is called after computing the frame with the checksum of the generated frame and the remaining cache (if any).
  • on_metadata (of type (synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}): Call a given handler to execute on each metadata
  • on_position (of type (position : {float}, ?remaining : bool, ?allow_partial : bool, synchronous : bool, ((float, [string * string]) -> unit)) -> {release : () -> unit}): Call a given handler on track position. If remaining is false, callback is executed when position in track is more or equal to position. If remaining is true, callback is executed when remaining time in the current track is less or equal to position. Keep in mind that elapsed time is exact while remaining time is always estimated. Remaining time is usually more accurate for file-based sources. When allow_partial is true, if the current track ends before the offset position is reached, callback is still executed
  • on_shutdown (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called when source shuts down
  • on_socket (of type (synchronous : bool, ((mode : string, srt_socket .{ bistats : (?clear : bool?, ?instantaneous : bool?) -> { byteAvailRcvBuf : int, byteAvailSndBuf : int, byteMSS : int, byteRcvBuf : int, byteRcvDrop : int, byteRcvDropTotal : int, byteRcvUndecrypt : int, byteRcvUndecryptTotal : int, byteRecv : int, byteRecvTotal : int, byteRetrans : int, byteRetransTotal : int, byteSent : int, byteSentTotal : int, byteSndBuf : int, byteSndDrop : int, byteSndDropTotal : int, mbpsBandwidth : float, mbpsMaxBW : float, mbpsRecvRate : float, mbpsSendRate : float, msRTT : float, msRcvBuf : int, msRcvTsbPdDelay : int, msSndBuf : int, msSndTsbPdDelay : int, msTimeStamp : int, pktCongestionWindow : int, pktFlightSize : int, pktFlowWindow : int, pktRcvAvgBelatedTime : float, pktRcvBelated : int, pktRcvBuf : int, pktRcvDrop : int, pktRcvDropTotal : int, pktRcvFilterExtra : int, pktRcvFilterExtraTotal : int, pktRcvFilterLoss : int, pktRcvFilterLossTotal : int, pktRcvFilterSupply : int, pktRcvFilterSupplyTotal : int, pktRcvLoss : int, pktRcvLossTotal : int, pktRcvRetrans : int, pktRcvUndecrypt : int, pktRcvUndecryptTotal : int, pktRecv : int, pktRecvACK : int, pktRecvACKTotal : int, pktRecvNAK : int, pktRecvNAKTotal : int, pktRecvTotal : int, pktReorderDistance : int, pktRetrans : int, pktRetransTotal : int, pktSent : int, pktSentACK : int, pktSentACKTotal : int, pktSentNAK : int, pktSentNAKTotal : int, pktSentTotal : int, pktSndBuf : int, pktSndDrop : int, pktSndDropTotal : int, pktSndFilterExtra : int, pktSndFilterExtraTotal : int, pktSndLoss : int, pktSndLossTotal : int, usPktSndPeriod : float, usSndDuration : int, usSndDurationTotal : int}, bstats : (?clear : bool?) -> { byteAvailRcvBuf : int, byteAvailSndBuf : int, byteMSS : int, byteRcvBuf : int, byteRcvDrop : int, byteRcvDropTotal : int, byteRcvUndecrypt : int, byteRcvUndecryptTotal : int, byteRecv : int, byteRecvTotal : int, byteRetrans : int, byteRetransTotal : int, byteSent : int, byteSentTotal : int, byteSndBuf : int, byteSndDrop : int, byteSndDropTotal : int, mbpsBandwidth : float, mbpsMaxBW : float, mbpsRecvRate : float, mbpsSendRate : float, msRTT : float, msRcvBuf : int, msRcvTsbPdDelay : int, msSndBuf : int, msSndTsbPdDelay : int, msTimeStamp : int, pktCongestionWindow : int, pktFlightSize : int, pktFlowWindow : int, pktRcvAvgBelatedTime : float, pktRcvBelated : int, pktRcvBuf : int, pktRcvDrop : int, pktRcvDropTotal : int, pktRcvFilterExtra : int, pktRcvFilterExtraTotal : int, pktRcvFilterLoss : int, pktRcvFilterLossTotal : int, pktRcvFilterSupply : int, pktRcvFilterSupplyTotal : int, pktRcvLoss : int, pktRcvLossTotal : int, pktRcvRetrans : int, pktRcvUndecrypt : int, pktRcvUndecryptTotal : int, pktRecv : int, pktRecvACK : int, pktRecvACKTotal : int, pktRecvNAK : int, pktRecvNAKTotal : int, pktRecvTotal : int, pktReorderDistance : int, pktRetrans : int, pktRetransTotal : int, pktSent : int, pktSentACK : int, pktSentACKTotal : int, pktSentNAK : int, pktSentNAKTotal : int, pktSentTotal : int, pktSndBuf : int, pktSndDrop : int, pktSndDropTotal : int, pktSndFilterExtra : int, pktSndFilterExtraTotal : int, pktSndLoss : int, pktSndLossTotal : int, usPktSndPeriod : float, usSndDuration : int, usSndDurationTotal : int}, close : () -> unit, id : int, ipv6only : () -> bool, latency : () -> int, pbkeylen : () -> int, peerlatency : () -> int, rcvbuf : () -> int, rcvdata : () -> int, rcvlatency : () -> int, rcvsyn : () -> bool, rcvtimeout : () -> int, reuseaddr : () -> bool, set_conntimeo : (int) -> unit, set_enforced_encryption : (bool) -> unit, set_ipv6only : (bool) -> unit, set_latency : (int) -> unit, set_messageapi : (bool) -> unit, set_passphrase : (string) -> unit, set_payloadsize : (int) -> unit, set_pbkeylen : (int) -> unit, set_peerlatency : (int) -> unit, set_rcvbuf : (int) -> unit, set_rcvlatency : (int) -> unit, set_rcvsyn : (bool) -> unit, set_rcvtimeout : (int) -> unit, set_reuseaddr : (bool) -> unit, set_sndbuf : (int) -> unit, set_sndsyn : (bool) -> unit, set_sndtimeout : (int) -> unit, set_streamid : (string) -> unit, set_tsbpdmode : (bool) -> unit, set_udp_rcvbuf : (int) -> unit, set_udp_sndbuf : (int) -> unit, sndbuf : () -> int, sndsyn : () -> bool, sndtimeout : () -> int, status : () -> string, streamid : () -> string, tsbpdmode : () -> bool, udp_rcvbuf : () -> int, udp_sndbuf : () -> int }) -> unit)) -> {release : () -> unit}): Call a given handler when a socket is created (mode "connect" or "listen"), accepted (mode "incoming"), or about to be closed (mode "close")
  • on_start (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler when input starts
  • on_stop (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler when input stops
  • on_track (of type (synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}): Call a given handler on track marks
  • on_wake_up (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called after the source is asked to get ready

Composition methods:

  • composition_type (of type (() -> string).{exchange : (string) -> string, set : (string) -> unit}): This source uses live composition by default.
  • on_leave (of type ({source : source('a), track_sensitive : bool}) -> unit): Called after switching away from this source in a switch operator, once the transition using the ending source has completed. Receives a record with source (the source being left) and track_sensitive (true if the ending source's last frame had a track mark, i.e. it finished naturally; false if it was preempted mid-track). This function must return quickly as it runs in the streaming thread. The default depends on the active composition profile: file sources (source.composition.file) skip the source when preempted mid-track so it starts fresh on its next selection, and do nothing when it finished naturally; live sources (source.composition.live) do nothing.
  • on_select (of type ({ending : source('a)?, replay_metadata : bool, starting : source('a)}) -> source('a)): Called when selecting this source in a switch operator. Receives a record with starting (the incoming source) and ending (the previous source, or null when the ending source reached a track boundary). Returns the source to use. By default, both file and live profiles fade out ending when non-null (up to 1 second). The default is looked up at runtime from the active composition profile (source.composition.file or source.composition.live depending on composition_type).
  • replay_metadata (of type {bool}): Whether to replay the latest metadata on this source when it is selected in a switch operator. Defaults to true. The value is looked up at runtime from the active composition profile (source.composition.file or source.composition.live depending on composition_type).
  • single (of type bool): Forbid the selection of this source for two consecutive tracks in switch operators. Defaults to false.
  • track_sensitive (of type {bool}): Whether this source insists on track boundaries in switch operators: when true, it prefers not to be interrupted mid-track and not to be started mid-track. A switch may only cut into a track that is still playing when at least one of the two sources involved has track_sensitive set to false; otherwise it waits for the playing source to reach a track boundary. File-based sources default to true; live network and hardware inputs default to false. The value is looked up at runtime from the active composition profile (source.composition.file or source.composition.live depending on composition_type).

input.v4l2​

Read a video4linux2 capture device with FFmpeg. A capture device paces its clock by default: a clock holds one sync source at a time, so a camera in the same clock as another sync source (a sound card, a second camera, a live network input with self_sync) raises the clock's sync error. Set self_sync=false on the camera, or wrap one side in buffer() to put it in its own clock.

Type:

(?id : string?, ?max_buffer : float, ?self_sync : bool, ?device : string) ->
source(video=yuv420p('a))

Arguments:

  • id (of type string?, which defaults to null): Force the value of the source ID.
  • max_buffer (of type float, which defaults to 0.5): Maximum data buffered, in seconds.
  • self_sync (of type bool, which defaults to true): Pace the clock with the device.
  • device (of type string, which defaults to "/dev/video0"): V4L2 device to use.

video.testsrc.ffmpeg​

A video test source, generated by FFmpeg's lavfi input.

Type:

(?id : string?, ?pattern : string, ?max_buffer : float, ?duration : 'a?) ->
source(video=yuv420p('b)) where 'a is a number type

Composition:

This source inherits composition from its effective source.

Arguments:

  • id (of type string?, which defaults to null): Force the value of the source ID.
  • pattern (of type string, which defaults to "testsrc"): FFmpeg video source filter: testsrc, testsrc2, smptebars, rgbtestsrc, etc.
  • max_buffer (of type float, which defaults to 0.5): Maximum data buffered, in seconds.
  • duration (of type 'a? where 'a is a number type, which defaults to null): Duration of the source, in seconds; null for an endless source.

Methods:

  • buffered (of type () -> [string * float]): Length of buffered data.
  • callbacks_count (of type () -> [string * int]): Callbacks a script has registered on this source, as pairs of callback name and count. A count that keeps growing is a function registering on a source it is handed without releasing what it registered.
  • clear_last_metadata (of type () -> unit): Clear the last metadata from the source.
  • clock (of type clock): The source's clock
  • duration (of type () -> float): Estimation of the duration of the current track.
  • elapsed (of type () -> float): Elapsed time in the current track.
  • fallible (of type bool): Indicate if a source may fail, i.e. may not be ready to stream.
  • generate_frame (of type () -> unit): Generate a frame from the source without consuming it. This can be useful in advanced cases where generating a frame is required to trigger some side effect like calculating some metadata before making a decision. You should make sure that the source is available before calling this function and it should only be called inside synchronous streaming loop callback such as on_frame!
  • id (of type () -> string): Identifier of the source.
  • insert_metadata (of type (?override : bool, ?new_track : bool, [string * string]) -> unit): Dynamically insert metadata in a stream. Inserts a new track with the given metadata if new_track is true. When override is false, metadata that the source provides itself takes precedence over the inserted one.
  • is_active (of type () -> bool): true if the source is active, i.e. it is continuously animated by its own clock whenever it is ready. Typically, true for outputs and sources such as input.http.
  • is_ready (of type () -> bool): Indicate if a source is ready to stream. This does not mean that the source is currently streaming, just that its resources are all properly initialized.
  • is_up (of type () -> bool): Indicate that the source can be asked to produce some data at any time. This is true when the source is currently being used or if it could be used at any time, typically inside a switch or fallback.
  • last_metadata (of type () -> [string * string]?): Return the last metadata from the source.
  • log (of type {level : (() -> int).{exchange : (int) -> int, set : (int) -> unit}}): Get or set the source's log level, from 1 to 5.
  • queue (of type () -> [source(video=yuv420p('b))]): Return the current sequence of source
  • register_command (of type (?usage : string?, description : string, string, ((string) -> string)) -> unit): Register a server command for this source. Command is registered under the source's id namespace when it gets up and de-registered when it gets down.
  • remaining (of type () -> float): Estimation of remaining time in the current track.
  • reset_last_metadata_on_track (of type (() -> bool).{exchange : (bool) -> bool, set : (bool) -> unit}): If true, the source's last_metadata is reset on each new track. If a metadata is present along with the track mark, then it becomes the new last_metadata, otherwise, last_metadata becomes null`.
  • seek (of type (float) -> float): Seek forward, in seconds (returns the amount of time effectively seeked).
  • self_sync (of type () -> bool): Is the source currently controlling its own real-time loop.
  • self_sync_description (of type () -> string)
  • skip (of type () -> unit): Skip to the next track.
  • time (of type () -> float): Get a source's time, based on its assigned clock.

Callbacks:

  • on_collect (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called when source is collected
  • on_frame (of type (?before : bool, synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler on frame. When before is true, callback is executed before computing the frame and after otherwise
  • on_frame_checksum (of type (?before : ((string?) -> unit)?, synchronous : bool, ((cache : string?, string) -> unit)) -> {release : () -> unit}): Call a given handler Register callbacks to compute frame checksums for debugging purposes. This is useful to track frame content changes through the streaming pipeline. The before callback is called before computing the frame with the checksum of the cached frame (if any, null otherwise). The main callback is called after computing the frame with the checksum of the generated frame and the remaining cache (if any).
  • on_metadata (of type (synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}): Call a given handler to execute on each metadata
  • on_position (of type (position : {float}, ?remaining : bool, ?allow_partial : bool, synchronous : bool, ((float, [string * string]) -> unit)) -> {release : () -> unit}): Call a given handler on track position. If remaining is false, callback is executed when position in track is more or equal to position. If remaining is true, callback is executed when remaining time in the current track is less or equal to position. Keep in mind that elapsed time is exact while remaining time is always estimated. Remaining time is usually more accurate for file-based sources. When allow_partial is true, if the current track ends before the offset position is reached, callback is still executed
  • on_shutdown (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called when source shuts down
  • on_track (of type (synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}): Call a given handler on track marks
  • on_wake_up (of type (synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called after the source is asked to get ready

Composition methods:

  • composition_type (of type (() -> string).{exchange : (string) -> string, set : (string) -> unit}): This source inherits composition from its effective source.
  • on_leave (of type ({source : source(video=yuv420p('b)), track_sensitive : bool}) -> unit): Called after switching away from this source in a switch operator, once the transition using the ending source has completed. Receives a record with source (the source being left) and track_sensitive (true if the ending source's last frame had a track mark, i.e. it finished naturally; false if it was preempted mid-track). This function must return quickly as it runs in the streaming thread. The default depends on the active composition profile: file sources (source.composition.file) skip the source when preempted mid-track so it starts fresh on its next selection, and do nothing when it finished naturally; live sources (source.composition.live) do nothing.
  • on_select (of type ( { ending : source(video=yuv420p('b))?, replay_metadata : bool, starting : source(video=yuv420p('b)) }) -> source(video=yuv420p('b))): Called when selecting this source in a switch operator. Receives a record with starting (the incoming source) and ending (the previous source, or null when the ending source reached a track boundary). Returns the source to use. By default, both file and live profiles fade out ending when non-null (up to 1 second). The default is looked up at runtime from the active composition profile (source.composition.file or source.composition.live depending on composition_type).
  • replay_metadata (of type {bool}): Whether to replay the latest metadata on this source when it is selected in a switch operator. Defaults to true. The value is looked up at runtime from the active composition profile (source.composition.file or source.composition.live depending on composition_type).
  • single (of type bool): Forbid the selection of this source for two consecutive tracks in switch operators. Defaults to false.
  • track_sensitive (of type {bool}): Whether this source insists on track boundaries in switch operators: when true, it prefers not to be interrupted mid-track and not to be started mid-track. A switch may only cut into a track that is still playing when at least one of the two sources involved has track_sensitive set to false; otherwise it waits for the playing source to reach a track boundary. File-based sources default to true; live network and hardware inputs default to false. The value is looked up at runtime from the active composition profile (source.composition.file or source.composition.live depending on composition_type).