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

Source / Track processing

blank.detect

Calls a given handler when detecting a blank.

Type:

(?id : string?, ?max_blank : {float}, ?min_noise : {float},
?start_blank : bool, ?threshold : {float}, ?track_sensitive : {bool},
source(audio=pcm('a), 'b)) -> source(audio=pcm('a), 'b)

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.
  • max_blank (of type {float}, which defaults to 20.0): Maximum duration of silence allowed, in seconds.
  • min_noise (of type {float}, which defaults to 0.0): Minimum duration of noise required to end silence, in seconds.
  • start_blank (of type bool, which defaults to false): Start assuming we have blank.
  • threshold (of type {float}, which defaults to -40.0): Power in decibels under which the stream is considered silent.
  • track_sensitive (of type {bool}, which defaults to true): Reset blank counter at each track.
  • (unlabeled) (of type source(audio=pcm('a), 'b))

Methods:

  • buffered (of type () -> [string * float]): Length of buffered data.
  • clear_last_metadata (of type () -> unit): Clear the last metadata from the source.
  • clock (of type clock): The source's clock
  • dB_levels (of type () -> [float]?): Return the detected dB level for each channel.
  • 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_blank (of type () -> bool): Indicate whether blank was detected.
  • 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).{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).{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_blank (of type (synchronous : bool, (() -> unit)) -> unit): Call a given handler when detecting a blank.
  • on_collect (of type (synchronous : bool, (() -> unit)) -> unit): Call a given handler to be called when source is collected
  • on_frame (of type (?before : bool, synchronous : bool, (() -> unit)) -> 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)) -> 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)) -> unit): Call a given handler to execute on each metadata
  • on_noise (of type (synchronous : bool, (() -> unit)) -> unit): Call a given handler when noise is detected.
  • on_position (of type (position : {float}, ?remaining : bool, ?allow_partial : bool, synchronous : bool, ((float, [string * string]) -> unit)) -> 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)) -> unit): Call a given handler to be called when source shuts down
  • on_track (of type (synchronous : bool, (([string * string]) -> unit)) -> unit): Call a given handler on track marks
  • on_wake_up (of type (synchronous : bool, (() -> unit)) -> unit): Call a given handler to be called after the source is asked to get ready

Composition methods:

  • composition_type (of type (() -> string).{set : (string) -> unit}): This source inherits composition from its effective source.
  • on_leave (of type ({source : source(audio=pcm('B), '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('B), 'A)?, replay_metadata : bool, starting : source(audio=pcm('B), 'A) }) -> source(audio=pcm('B), '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).

blank.eat

Eat blanks, i.e., drop the contents of the stream until it is not blank anymore.

Type:

(?id : string?, ?at_beginning : bool, ?max_blank : {float},
?min_noise : {float}, ?start_blank : bool, ?threshold : {float},
?track_sensitive : {bool}, source(audio=pcm('a), 'b)) ->
source(audio=pcm('a), 'b)

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.
  • at_beginning (of type bool, which defaults to false): Only eat at the beginning of a track.
  • max_blank (of type {float}, which defaults to 20.0): Maximum duration of silence allowed, in seconds.
  • min_noise (of type {float}, which defaults to 0.0): Minimum duration of noise required to end silence, in seconds.
  • start_blank (of type bool, which defaults to false): Start assuming we have blank.
  • threshold (of type {float}, which defaults to -40.0): Power in decibels under which the stream is considered silent.
  • track_sensitive (of type {bool}, which defaults to true): Reset blank counter at each track.
  • (unlabeled) (of type source(audio=pcm('a), 'b))

Methods:

  • buffered (of type () -> [string * float]): Length of buffered data.
  • clear_last_metadata (of type () -> unit): Clear the last metadata from the source.
  • clock (of type clock): The source's clock
  • dB_levels (of type () -> [float]?): Return the detected dB level for each channel.
  • 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_blank (of type () -> bool): Indicate whether blank was detected.
  • 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).{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).{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)) -> unit): Call a given handler to be called when source is collected
  • on_frame (of type (?before : bool, synchronous : bool, (() -> unit)) -> 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)) -> 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)) -> 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)) -> 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)) -> unit): Call a given handler to be called when source shuts down
  • on_track (of type (synchronous : bool, (([string * string]) -> unit)) -> unit): Call a given handler on track marks
  • on_wake_up (of type (synchronous : bool, (() -> unit)) -> unit): Call a given handler to be called after the source is asked to get ready

Composition methods:

  • composition_type (of type (() -> string).{set : (string) -> unit}): This source inherits composition from its effective source.
  • on_leave (of type ({source : source(audio=pcm('B), '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('B), 'A)?, replay_metadata : bool, starting : source(audio=pcm('B), 'A) }) -> source(audio=pcm('B), '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).

blank.strip

Make the source unavailable when it is streaming blank. This is an active operator, meaning that the source used in this operator will be consumed continuously, even when it is not actively used.

Type:

(?id : string?, ?max_blank : {float}, ?min_noise : {float},
?start_blank : bool, ?threshold : {float}, ?track_sensitive : {bool},
source(audio=pcm('a), 'b)) -> source(audio=pcm('a), 'b)

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.
  • max_blank (of type {float}, which defaults to 20.0): Maximum duration of silence allowed, in seconds.
  • min_noise (of type {float}, which defaults to 0.0): Minimum duration of noise required to end silence, in seconds.
  • start_blank (of type bool, which defaults to false): Start assuming we have blank.
  • threshold (of type {float}, which defaults to -40.0): Power in decibels under which the stream is considered silent.
  • track_sensitive (of type {bool}, which defaults to true): Reset blank counter at each track.
  • (unlabeled) (of type source(audio=pcm('a), 'b))

Methods:

  • buffered (of type () -> [string * float]): Length of buffered data.
  • clear_last_metadata (of type () -> unit): Clear the last metadata from the source.
  • clock (of type clock): The source's clock
  • dB_levels (of type () -> [float]?): Return the detected dB level for each channel.
  • 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_blank (of type () -> bool): Indicate whether blank was detected.
  • 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).{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).{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)) -> unit): Call a given handler to be called when source is collected
  • on_frame (of type (?before : bool, synchronous : bool, (() -> unit)) -> 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)) -> 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)) -> 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)) -> 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)) -> unit): Call a given handler to be called when source shuts down
  • on_track (of type (synchronous : bool, (([string * string]) -> unit)) -> unit): Call a given handler on track marks
  • on_wake_up (of type (synchronous : bool, (() -> unit)) -> unit): Call a given handler to be called after the source is asked to get ready

Composition methods:

  • composition_type (of type (() -> string).{set : (string) -> unit}): This source inherits composition from its effective source.
  • on_leave (of type ({source : source(audio=pcm('B), '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('B), 'A)?, replay_metadata : bool, starting : source(audio=pcm('B), 'A) }) -> source(audio=pcm('B), '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).

delay

Make the source unavailable for a given time between tracks. Because delay controls when its source advances by leaving it unavailable between tracks, it must be applied to a leaf source that it animates on its own, such as a dedicated playlist or single: an active source or a source shared with another operator would make it inconsistent.

Type:

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

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.
  • initial (of type bool, which defaults to false): Start in unavailable state, as if a track had just finished.
  • (unlabeled) (of type {float}): The source won't be ready less than this amount of seconds after any end of track
  • (unlabeled) (of type source('a))

Methods:

  • buffered (of type () -> [string * float]): Length of buffered data.
  • 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).{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).{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)) -> unit): Call a given handler to be called when source is collected
  • on_frame (of type (?before : bool, synchronous : bool, (() -> unit)) -> 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)) -> 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)) -> 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)) -> 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)) -> unit): Call a given handler to be called when source shuts down
  • on_track (of type (synchronous : bool, (([string * string]) -> unit)) -> unit): Call a given handler on track marks
  • on_wake_up (of type (synchronous : bool, (() -> unit)) -> unit): Call a given handler to be called after the source is asked to get ready

Composition methods:

  • composition_type (of type (() -> string).{set : (string) -> unit}): This source inherits composition from its effective source.
  • 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).

delay_line

Delay the source by a given amount of time.

Type:

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

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.
  • (unlabeled) (of type {float}): Duration of the delay in seconds.
  • (unlabeled) (of type source('a))

Methods:

  • buffered (of type () -> [string * float]): Length of buffered data.
  • 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).{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).{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)) -> unit): Call a given handler to be called when source is collected
  • on_frame (of type (?before : bool, synchronous : bool, (() -> unit)) -> 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)) -> 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)) -> 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)) -> 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)) -> unit): Call a given handler to be called when source shuts down
  • on_track (of type (synchronous : bool, (([string * string]) -> unit)) -> unit): Call a given handler on track marks
  • on_wake_up (of type (synchronous : bool, (() -> unit)) -> unit): Call a given handler to be called after the source is asked to get ready

Composition methods:

  • composition_type (of type (() -> string).{set : (string) -> unit}): This source inherits composition from its effective source.
  • 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).

max_duration

Limit source duration

Type:

(?id : string?, ?override : string, float, source('a)) -> source('a)

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.
  • override (of type string, which defaults to "liq_remaining"): Metadata field which, if present and containing a float, overrides the remaining play time.
  • (unlabeled) (of type float): Maximum duration
  • (unlabeled) (of type source('a))

Methods:

  • buffered (of type () -> [string * float]): Length of buffered data.
  • 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).{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).{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)) -> unit): Call a given handler to be called when source is collected
  • on_frame (of type (?before : bool, synchronous : bool, (() -> unit)) -> 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)) -> 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)) -> 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)) -> 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)) -> unit): Call a given handler to be called when source shuts down
  • on_track (of type (synchronous : bool, (([string * string]) -> unit)) -> unit): Call a given handler on track marks
  • on_wake_up (of type (synchronous : bool, (() -> unit)) -> unit): Call a given handler to be called after the source is asked to get ready

Composition methods:

  • composition_type (of type (() -> string).{set : (string) -> unit}): This source inherits composition from its effective source.
  • 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).

sequence

Play a sequence of sources. By default, play one track per source, except for the last one which is played as much as available.

Type:

(?id : string?, ?merge : bool, ?single_track : bool, [source('a)]) ->
source('a)

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.
  • merge (of type bool, which defaults to false): Merge tracks when advancing from one source to the next one. This will NOT merge consecutive tracks from the last source; see merge_tracks() if you need that too.
  • single_track (of type bool, which defaults to true): Advance to the new track in the sequence on new track. Set to false to play each source until it becomes unavailable.
  • (unlabeled) (of type [source('a)])

Methods:

  • buffered (of type () -> [string * float]): Length of buffered data.
  • 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).{set : (int) -> unit}}): Get or set the source's log level, from 1 to 5.
  • queue (of type () -> [source('A)]): 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).{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)) -> unit): Call a given handler to be called when source is collected
  • on_frame (of type (?before : bool, synchronous : bool, (() -> unit)) -> 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)) -> 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)) -> 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)) -> 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)) -> unit): Call a given handler to be called when source shuts down
  • on_track (of type (synchronous : bool, (([string * string]) -> unit)) -> unit): Call a given handler on track marks
  • on_wake_up (of type (synchronous : bool, (() -> unit)) -> unit): Call a given handler to be called after the source is asked to get ready

Composition methods:

  • composition_type (of type (() -> string).{set : (string) -> unit}): This source inherits composition from its effective source.
  • 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).

source.available

Change the availability of a source depending on a predicate.

Type:

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

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.
  • override (of type bool, which defaults to false): Don't take availability of original source in account (this can be dangerous and should be avoided).
  • track_sensitive (of type {bool}, which defaults to false): Change availability only on end of tracks.
  • (unlabeled) (of type source('a)): Source of which the availability should be changed.
  • (unlabeled) (of type {bool}): Predicate indicating whether the source should be available or not.

Methods:

  • buffered (of type () -> [string * float]): Length of buffered data.
  • 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).{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).{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)) -> unit): Call a given handler to be called when source is collected
  • on_frame (of type (?before : bool, synchronous : bool, (() -> unit)) -> 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)) -> 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)) -> 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)) -> 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)) -> unit): Call a given handler to be called when source shuts down
  • on_track (of type (synchronous : bool, (([string * string]) -> unit)) -> unit): Call a given handler on track marks
  • on_wake_up (of type (synchronous : bool, (() -> unit)) -> unit): Call a given handler to be called after the source is asked to get ready

Composition methods:

  • composition_type (of type (() -> string).{set : (string) -> unit}): This source inherits composition from its effective source.
  • 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).

source.dynamic

Dynamically change the underlying source: it can either be changed by the function given as argument, which returns the source to be played, or by calling the set method.

Type:

(?id : string?, ?infallible : bool, ?init : source('a)?, ?merge : {bool},
?self_sync : bool?, ?track_sensitive : {bool},
(() -> source('a).{activation? : activation}?)) -> source('a)

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.
  • infallible (of type bool, which defaults to false): Whether the source is infallible or not (be careful when setting this, it will not be checked by the typing system).
  • init (of type source('a)?, which defaults to null): Initial value for the source
  • merge (of type {bool}, which defaults to false): Set or return true to merge subsequent tracks.
  • self_sync (of type bool?, which defaults to null): For the source's self_sync property.
  • track_sensitive (of type {bool}, which defaults to false): Whether the source should only be updated on track change.
  • (unlabeled) (of type () -> source('a).{activation? : activation}?): Function returning the source to be used, null means keep current source.

Methods:

  • buffered (of type () -> [string * float]): Length of buffered data.
  • clear_last_metadata (of type () -> unit): Clear the last metadata from the source.
  • clock (of type clock): The source's clock
  • current_source (of type () -> source('A)?): Return the source currently selected.
  • 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).{set : (int) -> unit}}): Get or set the source's log level, from 1 to 5.
  • prepare (of type (source('A)) -> source('A).{activation : activation}): Prepare a source that will be returned later. Returned source has new activation attached to it and should be used to submit to the source later.
  • 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).{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)) -> unit): Call a given handler to be called when source is collected
  • on_frame (of type (?before : bool, synchronous : bool, (() -> unit)) -> 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)) -> 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)) -> 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)) -> 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)) -> unit): Call a given handler to be called when source shuts down
  • on_track (of type (synchronous : bool, (([string * string]) -> unit)) -> unit): Call a given handler on track marks
  • on_wake_up (of type (synchronous : bool, (() -> unit)) -> unit): Call a given handler to be called after the source is asked to get ready

Composition methods:

  • composition_type (of type (() -> string).{set : (string) -> unit}): This source inherits composition from its effective source.
  • 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).

source.frame.duration

Compute the duration of the last frame.

Type:

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

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.
  • (unlabeled) (of type source('a))

Methods:

  • buffered (of type () -> [string * float]): Length of buffered data.
  • 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.
  • frame_duration (of type float): Compute the duration of the last frame.
  • 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).{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).{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)) -> unit): Call a given handler to be called when source is collected
  • on_frame (of type (?before : bool, synchronous : bool, (() -> unit)) -> 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)) -> 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)) -> 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)) -> 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)) -> unit): Call a given handler to be called when source shuts down
  • on_track (of type (synchronous : bool, (([string * string]) -> unit)) -> unit): Call a given handler on track marks
  • on_wake_up (of type (synchronous : bool, (() -> unit)) -> unit): Call a given handler to be called after the source is asked to get ready

Composition methods:

  • composition_type (of type (() -> string).{set : (string) -> unit}): This source inherits composition from its effective source.
  • on_leave (of type ({source : source(frame_duration=float, '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(frame_duration=float, 'A)?, replay_metadata : bool, starting : source(frame_duration=float, 'A) }) -> source(frame_duration=float, '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).

source.frame.rms

Compute the rms of the last frame.

Type:

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

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.
  • (unlabeled) (of type source('a))

Methods:

  • buffered (of type () -> [string * float]): Length of buffered data.
  • 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.
  • frame_rms (of type float): Compute the rms of the last frame.
  • 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).{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).{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)) -> unit): Call a given handler to be called when source is collected
  • on_frame (of type (?before : bool, synchronous : bool, (() -> unit)) -> 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)) -> 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)) -> 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)) -> 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)) -> unit): Call a given handler to be called when source shuts down
  • on_track (of type (synchronous : bool, (([string * string]) -> unit)) -> unit): Call a given handler on track marks
  • on_wake_up (of type (synchronous : bool, (() -> unit)) -> unit): Call a given handler to be called after the source is asked to get ready

Composition methods:

  • composition_type (of type (() -> string).{set : (string) -> unit}): This source inherits composition from its effective source.
  • on_leave (of type ({source : source(frame_rms=float, '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(frame_rms=float, 'A)?, replay_metadata : bool, starting : source(frame_rms=float, 'A) }) -> source(frame_rms=float, '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).

source.tracks

Return the tracks of a given source.

Type:

(source('a)) -> 'a

Arguments:

  • (unlabeled) (of type source('a))

Methods:

  • metadata (of type metadata)
  • track_marks (of type track_marks)

switch

At the beginning of a track, select the first source whose predicate is true.

Type:

(?id : string?, ?all_predicates : bool,
[(() -> bool) * source('a)
.{
on_leave? : ({source : source('a), track_sensitive : bool}) -> unit,
on_select? : (
{
ending : source('a)?,
replay_metadata : bool,
starting : source('a)
}) -> source('a),
replay_metadata? : {bool},
single? : bool,
track_sensitive? : {bool}
}]) -> source('a)

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.
  • all_predicates (of type bool, which defaults to false): Always evaluate all predicates when re-selecting.
  • (unlabeled) (of type [(() -> bool) * source('a) .{ on_leave? : ({source : source('a), track_sensitive : bool}) -> unit, on_select? : ( { ending : source('a)?, replay_metadata : bool, starting : source('a) }) -> source('a), replay_metadata? : {bool}, single? : bool, track_sensitive? : {bool} }]): Sources with the predicate telling when they can be played.

Methods:

  • buffered (of type () -> [string * float]): Length of buffered data.
  • 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).{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).{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).
  • selected (of type () -> source('A)?): Currently selected source.
  • 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)) -> unit): Call a given handler to be called when source is collected
  • on_frame (of type (?before : bool, synchronous : bool, (() -> unit)) -> 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)) -> 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)) -> 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)) -> 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)) -> unit): Call a given handler to be called when source shuts down
  • on_track (of type (synchronous : bool, (([string * string]) -> unit)) -> unit): Call a given handler on track marks
  • on_wake_up (of type (synchronous : bool, (() -> unit)) -> unit): Call a given handler to be called after the source is asked to get ready

Composition methods:

  • composition_type (of type (() -> string).{set : (string) -> unit}): This source inherits composition from its effective source.
  • 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).