Source / Input / Active
input
Input an audio stream using the default operator.
Type:
(?id : string?, ?start : bool, ?fallible : bool) -> source(audio=pcm('A))
Synchronization:
This source uses the PulseAudio clock as synchronization source when self_sync=true and the stream is open.
Composition:
This source uses live composition by default.
Arguments:
id(of typestring?, which defaults tonull): Force the value of the source ID.start(of typebool, which defaults totrue): Automatically start outputting whenever possible. Iftrue, an infallible (normal) output will start outputting as soon as it is created, and a fallible output will (re)start as soon as its source becomes available for streaming.fallible(of typebool, which defaults tofalse): Allow the child source to fail, in which case the output will be (temporarily) stopped.
Methods:
buffered(of type() -> [string * float]): Length of buffered data.callbacks_count(of type() -> [string * int]): Callbacks a script has registered on this source, as pairs of callback name and count. A count that keeps growing is a function registering on a source it is handed without releasing what it registered.clear_last_metadata(of type() -> unit): Clear the last metadata from the source.clock(of typeclock): The source's clockduration(of type() -> float): Estimation of the duration of the current track.elapsed(of type() -> float): Elapsed time in the current track.fallible(of typebool): 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 ason_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 ifnew_trackistrue. Whenoverrideisfalse, metadata that the source provides itself takes precedence over the inserted one.is_active(of type() -> bool):trueif the source is active, i.e. it is continuously animated by its own clock whenever it is ready. Typically,truefor outputs and sources such asinput.http.is_ready(of type() -> bool): Indicate if a source is ready to stream. This does not mean that the source is currently streaming, just that its resources are all properly initialized.is_started(of type() -> bool):trueif the output or source is started.is_up(of type() -> bool): Indicate that the source can be asked to produce some data at any time. This istruewhen the source is currently being used or if it could be used at any time, typically inside aswitchorfallback.last_metadata(of type() -> [string * string]?): Return the last metadata from the source.log(of type{level : (() -> int).{exchange : (int) -> int, set : (int) -> unit}}): Get or set the source's log level, from1to5.register_command(of type(?usage : string?, description : string, string, ((string) -> string)) -> unit): Register a server command for this source. Command is registered under the source's id namespace when it gets up and de-registered when it gets down.remaining(of type() -> float): Estimation of remaining time in the current track.reset_last_metadata_on_track(of type(() -> bool).{exchange : (bool) -> bool, set : (bool) -> unit}): Iftrue, the source'slast_metadatais reset on each new track. If a metadata is present along with the track mark, then it becomes the newlast_metadata, otherwise,last_metadata becomesnull`.seek(of type(float) -> float): Seek forward, in seconds (returns the amount of time effectively seeked).self_sync(of type() -> bool): Is the source currently controlling its own real-time loop.self_sync_description(of type() -> string): This source uses the PulseAudio clock as synchronization source whenself_sync=trueand the stream is open.skip(of type() -> unit): Skip to the next track.start(of type() -> unit): Ask the source or output to start.stop(of type() -> unit): Ask the source or output to stop.time(of type() -> float): Get a source's time, based on its assigned clock.
Callbacks:
on_collect(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called when source is collectedon_frame(of type(?before : bool, synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler on frame. Whenbeforeistrue, callback is executed before computing the frame and after otherwiseon_frame_checksum(of type(?before : ((string?) -> unit)?, synchronous : bool, ((cache : string?, string) -> unit)) -> {release : () -> unit}): Call a given handler Register callbacks to compute frame checksums for debugging purposes. This is useful to track frame content changes through the streaming pipeline. Thebeforecallback is called before computing the frame with the checksum of the cached frame (if any,nullotherwise). The main callback is called after computing the frame with the checksum of the generated frame and the remaining cache (if any).on_metadata(of type(synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}): Call a given handler to execute on each metadataon_position(of type(position : {float}, ?remaining : bool, ?allow_partial : bool, synchronous : bool, ((float, [string * string]) -> unit)) -> {release : () -> unit}): Call a given handler on track position. Ifremainingisfalse, callback is executed when position in track is more or equal toposition. Ifremainingistrue, callback is executed when remaining time in the current track is less or equal toposition. Keep in mind that elapsed time is exact while remaining time is always estimated. Remaining time is usually more accurate for file-based sources. Whenallow_partialistrue, if the current track ends before theoffsetposition is reached, callback is still executedon_shutdown(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called when source shuts downon_start(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler when source startson_stop(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler when source stopson_track(of type(synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}): Call a given handler on track markson_wake_up(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called after the source is asked to get ready
Composition methods:
composition_type(of type(() -> string).{exchange : (string) -> string, set : (string) -> unit}): This source uses live composition by default.on_leave(of type({source : source(audio=pcm('A)), track_sensitive : bool}) -> unit): Called after switching away from this source in a switch operator, once the transition using the ending source has completed. Receives a record withsource(the source being left) andtrack_sensitive(trueif the ending source's last frame had a track mark, i.e. it finished naturally;falseif it was preempted mid-track). This function must return quickly as it runs in the streaming thread. The default depends on the active composition profile: file sources (source.composition.file) skip the source when preempted mid-track so it starts fresh on its next selection, and do nothing when it finished naturally; live sources (source.composition.live) do nothing.on_select(of type( { ending : source(audio=pcm('A))?, replay_metadata : bool, starting : source(audio=pcm('A)) }) -> source(audio=pcm('A))): Called when selecting this source in a switch operator. Receives a record withstarting(the incoming source) andending(the previous source, ornullwhen the ending source reached a track boundary). Returns the source to use. By default, both file and live profiles fade outendingwhen non-null (up to 1 second). The default is looked up at runtime from the active composition profile (source.composition.fileorsource.composition.livedepending oncomposition_type).replay_metadata(of type{bool}): Whether to replay the latest metadata on this source when it is selected in a switch operator. Defaults totrue. The value is looked up at runtime from the active composition profile (source.composition.fileorsource.composition.livedepending oncomposition_type).single(of typebool): Forbid the selection of this source for two consecutive tracks in switch operators. Defaults tofalse.track_sensitive(of type{bool}): Whether this source insists on track boundaries in switch operators: whentrue, 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 hastrack_sensitiveset tofalse; otherwise it waits for the playing source to reach a track boundary. File-based sources default totrue; live network and hardware inputs default tofalse. The value is looked up at runtime from the active composition profile (source.composition.fileorsource.composition.livedepending oncomposition_type).
input.alsa
Stream from an ALSA input device.
Type:
(?id : string?, ?buffer_size : float?, ?device : string, ?fallible : bool,
?self_sync : bool, ?start : bool) -> source(audio=pcm('a))
Synchronization:
This source uses the ALSA hardware clock as synchronization source when self_sync=true and the device is open.
Composition:
This source uses live composition by default.
Arguments:
id(of typestring?, which defaults tonull): Force the value of the source ID.buffer_size(of typefloat?, which defaults tonull): ALSA buffer size in seconds. Defaults to frame duration whennull.device(of typestring, which defaults to"default"): Alsa device to usefallible(of typebool, which defaults tofalse): Allow the source to fail. If set tofalse,startmust betrueandstopmethod raises an error.self_sync(of typebool, which defaults totrue): Mark the source as being synchronized by the ALSA driver.start(of typebool, which defaults totrue): Start input as soon as it is available.
Methods:
buffered(of type() -> [string * float]): Length of buffered data.callbacks_count(of type() -> [string * int]): Callbacks a script has registered on this source, as pairs of callback name and count. A count that keeps growing is a function registering on a source it is handed without releasing what it registered.clear_last_metadata(of type() -> unit): Clear the last metadata from the source.clock(of typeclock): The source's clockduration(of type() -> float): Estimation of the duration of the current track.elapsed(of type() -> float): Elapsed time in the current track.fallible(of typebool): 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 ason_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 ifnew_trackistrue. Whenoverrideisfalse, metadata that the source provides itself takes precedence over the inserted one.is_active(of type() -> bool):trueif the source is active, i.e. it is continuously animated by its own clock whenever it is ready. Typically,truefor outputs and sources such asinput.http.is_ready(of type() -> bool): Indicate if a source is ready to stream. This does not mean that the source is currently streaming, just that its resources are all properly initialized.is_started(of type() -> bool):trueif the output or source is started.is_up(of type() -> bool): Indicate that the source can be asked to produce some data at any time. This istruewhen the source is currently being used or if it could be used at any time, typically inside aswitchorfallback.last_metadata(of type() -> [string * string]?): Return the last metadata from the source.log(of type{level : (() -> int).{exchange : (int) -> int, set : (int) -> unit}}): Get or set the source's log level, from1to5.register_command(of type(?usage : string?, description : string, string, ((string) -> string)) -> unit): Register a server command for this source. Command is registered under the source's id namespace when it gets up and de-registered when it gets down.remaining(of type() -> float): Estimation of remaining time in the current track.reset_last_metadata_on_track(of type(() -> bool).{exchange : (bool) -> bool, set : (bool) -> unit}): Iftrue, the source'slast_metadatais reset on each new track. If a metadata is present along with the track mark, then it becomes the newlast_metadata, otherwise,last_metadata becomesnull`.seek(of type(float) -> float): Seek forward, in seconds (returns the amount of time effectively seeked).self_sync(of type() -> bool): Is the source currently controlling its own real-time loop.self_sync_description(of type() -> string): This source uses the ALSA hardware clock as synchronization source whenself_sync=trueand the device is open.skip(of type() -> unit): Skip to the next track.start(of type() -> unit): Ask the source or output to start.stop(of type() -> unit): Ask the source or output to stop.time(of type() -> float): Get a source's time, based on its assigned clock.
Callbacks:
on_collect(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called when source is collectedon_frame(of type(?before : bool, synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler on frame. Whenbeforeistrue, callback is executed before computing the frame and after otherwiseon_frame_checksum(of type(?before : ((string?) -> unit)?, synchronous : bool, ((cache : string?, string) -> unit)) -> {release : () -> unit}): Call a given handler Register callbacks to compute frame checksums for debugging purposes. This is useful to track frame content changes through the streaming pipeline. Thebeforecallback is called before computing the frame with the checksum of the cached frame (if any,nullotherwise). The main callback is called after computing the frame with the checksum of the generated frame and the remaining cache (if any).on_metadata(of type(synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}): Call a given handler to execute on each metadataon_position(of type(position : {float}, ?remaining : bool, ?allow_partial : bool, synchronous : bool, ((float, [string * string]) -> unit)) -> {release : () -> unit}): Call a given handler on track position. Ifremainingisfalse, callback is executed when position in track is more or equal toposition. Ifremainingistrue, callback is executed when remaining time in the current track is less or equal toposition. Keep in mind that elapsed time is exact while remaining time is always estimated. Remaining time is usually more accurate for file-based sources. Whenallow_partialistrue, if the current track ends before theoffsetposition is reached, callback is still executedon_shutdown(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called when source shuts downon_start(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler when source startson_stop(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler when source stopson_track(of type(synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}): Call a given handler on track markson_wake_up(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called after the source is asked to get ready
Composition methods:
composition_type(of type(() -> string).{exchange : (string) -> string, set : (string) -> unit}): This source uses live composition by default.on_leave(of type({source : source(audio=pcm('a)), track_sensitive : bool}) -> unit): Called after switching away from this source in a switch operator, once the transition using the ending source has completed. Receives a record withsource(the source being left) andtrack_sensitive(trueif the ending source's last frame had a track mark, i.e. it finished naturally;falseif it was preempted mid-track). This function must return quickly as it runs in the streaming thread. The default depends on the active composition profile: file sources (source.composition.file) skip the source when preempted mid-track so it starts fresh on its next selection, and do nothing when it finished naturally; live sources (source.composition.live) do nothing.on_select(of type( { ending : source(audio=pcm('a))?, replay_metadata : bool, starting : source(audio=pcm('a)) }) -> source(audio=pcm('a))): Called when selecting this source in a switch operator. Receives a record withstarting(the incoming source) andending(the previous source, ornullwhen the ending source reached a track boundary). Returns the source to use. By default, both file and live profiles fade outendingwhen non-null (up to 1 second). The default is looked up at runtime from the active composition profile (source.composition.fileorsource.composition.livedepending oncomposition_type).replay_metadata(of type{bool}): Whether to replay the latest metadata on this source when it is selected in a switch operator. Defaults totrue. The value is looked up at runtime from the active composition profile (source.composition.fileorsource.composition.livedepending oncomposition_type).single(of typebool): Forbid the selection of this source for two consecutive tracks in switch operators. Defaults tofalse.track_sensitive(of type{bool}): Whether this source insists on track boundaries in switch operators: whentrue, 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 hastrack_sensitiveset tofalse; otherwise it waits for the playing source to reach a track boundary. File-based sources default totrue; live network and hardware inputs default tofalse. The value is looked up at runtime from the active composition profile (source.composition.fileorsource.composition.livedepending oncomposition_type).
input.ffmpeg
Read a stream from a URL or a device with FFmpeg.
Type:
(?id : string?, ?debug : bool, ?deduplicate_metadata : bool,
?float_args : [string * float], ?format : string?,
?int_args : [string * int], ?max_buffer : float,
?metadata_filter : (([string * string]) -> [string * string])?,
?new_track_on_metadata : bool, ?poll_delay : float, ?self_sync : {bool},
?start : bool, ?string_args : [string * string], ?timeout : float,
?trim_url : bool, {string}) -> source('a)
Synchronization:
This source paces its clock while connected when self_sync is true.
Composition:
This source uses live composition by default.
Arguments:
id(of typestring?, which defaults tonull): Force the value of the source ID.debug(of typebool, which defaults tofalse): Log every fault with its backtrace at error level.deduplicate_metadata(of typebool, which defaults totrue): Drop metadata equal to the previous one of the same connection.float_args(of type[string * float], which defaults to[]): FFmpeg options, each stored as a float option.format(of typestring?, which defaults tonull): Input format short name.int_args(of type[string * int], which defaults to[]): FFmpeg options, each stored as an integer option.max_buffer(of typefloat, which defaults to5.0): Maximum decoded data held by the source, in seconds.metadata_filter(of type(([string * string]) -> [string * string])?, which defaults tonull): Metadata filter, replacing the default one, which drops the keys starting withid3v2_priv.new_track_on_metadata(of typebool, which defaults totrue): Start a new track at each metadata.poll_delay(of typefloat, which defaults to2.0): Delay before a retry after a failure, and interval of the URL check while failed, in seconds.self_sync(of type{bool}, which defaults tofalse): Pace the clock while connected. For live URLs only: on an input whose reads do not block (a file, a generator) the clock then runs as fast as the reads return.start(of typebool, which defaults totrue): Start input as soon as it is available.string_args(of type[string * string], which defaults to[]): FFmpeg options, each stored as a string option.timeout(of typefloat, which defaults to10.0): Longest a single blocking read may last, in seconds, on an input that is not listening.trim_url(of typebool, which defaults totrue): Strip leading and trailing whitespace from the URL.(unlabeled)(of type{string}): URL to read from.
Methods:
buffered(of type() -> [string * float]): Length of buffered data.callbacks_count(of type() -> [string * int]): Callbacks a script has registered on this source, as pairs of callback name and count. A count that keeps growing is a function registering on a source it is handed without releasing what it registered.clear_last_metadata(of type() -> unit): Clear the last metadata from the source.clock(of typeclock): The source's clockduration(of type() -> float): Estimation of the duration of the current track.elapsed(of type() -> float): Elapsed time in the current track.fallible(of typebool): 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 ason_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 ifnew_trackistrue. Whenoverrideisfalse, metadata that the source provides itself takes precedence over the inserted one.is_active(of type() -> bool):trueif the source is active, i.e. it is continuously animated by its own clock whenever it is ready. Typically,truefor outputs and sources such asinput.http.is_ready(of type() -> bool): Indicate if a source is ready to stream. This does not mean that the source is currently streaming, just that its resources are all properly initialized.is_started(of type() -> bool):trueif the output or source is started.is_up(of type() -> bool): Indicate that the source can be asked to produce some data at any time. This istruewhen the source is currently being used or if it could be used at any time, typically inside aswitchorfallback.last_metadata(of type() -> [string * string]?): Return the last metadata from the source.log(of type{level : (() -> int).{exchange : (int) -> int, set : (int) -> unit}}): Get or set the source's log level, from1to5.register_command(of type(?usage : string?, description : string, string, ((string) -> string)) -> unit): Register a server command for this source. Command is registered under the source's id namespace when it gets up and de-registered when it gets down.remaining(of type() -> float): Estimation of remaining time in the current track.reset_last_metadata_on_track(of type(() -> bool).{exchange : (bool) -> bool, set : (bool) -> unit}): Iftrue, the source'slast_metadatais reset on each new track. If a metadata is present along with the track mark, then it becomes the newlast_metadata, otherwise,last_metadata becomesnull`.seek(of type(float) -> float): Seek forward, in seconds (returns the amount of time effectively seeked).self_sync(of type() -> bool): Is the source currently controlling its own real-time loop.self_sync_description(of type() -> string): This source paces its clock while connected whenself_syncis true.set_url(of type({string}) -> unit): Set the URL, used at the next connection.skip(of type() -> unit): Skip to the next track.start(of type() -> unit): Ask the source or output to start.status(of type() -> string): Status:"stopped","starting","polling","connected <url>","stopping"or"failed".stop(of type() -> unit): Ask the source or output to stop.time(of type() -> float): Get a source's time, based on its assigned clock.url(of type() -> string): Current URL.
Callbacks:
on_collect(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called when source is collectedon_connect(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler when connected, before the source plays the connection's data.on_disconnect(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler when a connection whoseon_connectcallbacks ran ends.on_error(of type(synchronous : bool, ((error) -> unit)) -> {release : () -> unit}): Call a given handler on each connection or feeding failure.on_frame(of type(?before : bool, synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler on frame. Whenbeforeistrue, callback is executed before computing the frame and after otherwiseon_frame_checksum(of type(?before : ((string?) -> unit)?, synchronous : bool, ((cache : string?, string) -> unit)) -> {release : () -> unit}): Call a given handler Register callbacks to compute frame checksums for debugging purposes. This is useful to track frame content changes through the streaming pipeline. Thebeforecallback is called before computing the frame with the checksum of the cached frame (if any,nullotherwise). The main callback is called after computing the frame with the checksum of the generated frame and the remaining cache (if any).on_metadata(of type(synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}): Call a given handler to execute on each metadataon_position(of type(position : {float}, ?remaining : bool, ?allow_partial : bool, synchronous : bool, ((float, [string * string]) -> unit)) -> {release : () -> unit}): Call a given handler on track position. Ifremainingisfalse, callback is executed when position in track is more or equal toposition. Ifremainingistrue, callback is executed when remaining time in the current track is less or equal toposition. Keep in mind that elapsed time is exact while remaining time is always estimated. Remaining time is usually more accurate for file-based sources. Whenallow_partialistrue, if the current track ends before theoffsetposition is reached, callback is still executedon_shutdown(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called when source shuts downon_start(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler when source startson_stop(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler when source stopson_track(of type(synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}): Call a given handler on track markson_wake_up(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called after the source is asked to get ready
Composition methods:
composition_type(of type(() -> string).{exchange : (string) -> string, set : (string) -> unit}): This source uses live composition by default.on_leave(of type({source : source('a), track_sensitive : bool}) -> unit): Called after switching away from this source in a switch operator, once the transition using the ending source has completed. Receives a record withsource(the source being left) andtrack_sensitive(trueif the ending source's last frame had a track mark, i.e. it finished naturally;falseif 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 withstarting(the incoming source) andending(the previous source, ornullwhen the ending source reached a track boundary). Returns the source to use. By default, both file and live profiles fade outendingwhen non-null (up to 1 second). The default is looked up at runtime from the active composition profile (source.composition.fileorsource.composition.livedepending oncomposition_type).replay_metadata(of type{bool}): Whether to replay the latest metadata on this source when it is selected in a switch operator. Defaults totrue. The value is looked up at runtime from the active composition profile (source.composition.fileorsource.composition.livedepending oncomposition_type).single(of typebool): Forbid the selection of this source for two consecutive tracks in switch operators. Defaults tofalse.track_sensitive(of type{bool}): Whether this source insists on track boundaries in switch operators: whentrue, 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 hastrack_sensitiveset tofalse; otherwise it waits for the playing source to reach a track boundary. File-based sources default totrue; live network and hardware inputs default tofalse. The value is looked up at runtime from the active composition profile (source.composition.fileorsource.composition.livedepending oncomposition_type).
input.harbor
Create a source that receives a http/icecast stream and forwards it as a stream.
Type:
(?id : string?,
?accept : ((
{
address : string,
headers : [string * string],
method : string,
password : string,
query : [string * string],
uri : string,
user : string
}) ->
{
refuse? :
{headers? : [string * string], reason : string, status : int
}?}?)?,
?auth : ((
{
address : string,
headers : [string * string],
method : string,
password : string,
query : [string * string],
uri : string,
user : string
}) -> bool)?,
?buffer : float, ?debug : bool, ?dumpfile : string?, ?icy : bool,
?icy_metadata_charset : string?, ?logfile : string?, ?max : float,
?metadata_charset : string?, ?password : string, ?port : int,
?replay_metadata : bool, ?timeout : {float}, ?transport : http_transport,
?user : string, string) -> source('a)
Composition:
This source uses live composition by default.
Arguments:
id(of typestring?, which defaults tonull): Force the value of the source ID.accept(of type(( { address : string, headers : [string * string], method : string, password : string, query : [string * string], uri : string, user : string }) -> {refuse? : {headers? : [string * string], reason : string, status : int}?}?)?, which defaults tonull): Admission of a source client that passedauth, with the same record. It also runs for theGETlogins of ICY metadata updates. A decision withrefuse = {status, reason, headers?}refuses the client with that reply and an empty body;nullor norefuseadmits it. A refusal whose status is outside 300 to 599, or with a line break in its reason or headers, and a function that raises, refuse with403 Forbidden.auth(of type(( { address : string, headers : [string * string], method : string, password : string, query : [string * string], uri : string, user : string }) -> bool)?, which defaults tonull): Authentication function. Receives a record with:user,password,uri(request URI),query(URL query parameters as a list of key-value pairs),address(client network address) andmethod(connection method:"PUT"or"POST"for HTTP source connections,"SOURCE"for Xaudiocast/ICE sources,"ICY"for Shoutcast/ICY sources,"WEBSOCKET"for WebSocket sources,"GET"for ICY metadata updates), andheaders(the request headers, lowercase names, empty for ICY sources) and returnstrueif the user should be granted access for this login. A request without credentials is refused unlessacceptis given, in which case it is passed empty ones. Override any other method if used.buffer(of typefloat, which defaults to12.0): Duration of the pre-buffered data (in seconds). Default value is set to make it possible to usecrossfadetransitions withinput.harbor. You might be able to reduce it but, in this case, make sure to not use the operator withcrossfadeor make sure that it has enough buffered data for it.debug(of typebool, which defaults tofalse): Run in debugging mode by not catching some exceptions.dumpfile(of typestring?, which defaults tonull): Dump stream to file, for debugging purpose. Disabled if null.icy(of typebool, which defaults tofalse): Enable ICY (shoutcast) protocol.icy_metadata_charset(of typestring?, which defaults tonull): ICY (shoutcast) metadata charset. Guessed if null. Default for shoutcast is ISO-8859-1. Set to that value if all your clients send metadata using this charset and automatic detection is not working for you.logfile(of typestring?, which defaults tonull): Log buffer status to file, for debugging purpose. Disabled if null.max(of typefloat, which defaults to20.0): Maximum duration of the buffered data (in seconds).metadata_charset(of typestring?, which defaults tonull): Metadata charset for non-ICY (shoutcast) source protocols. Guessed if null.password(of typestring, which defaults to"hackme"): Source password.port(of typeint, which defaults to8005): Port used to connect to the source.replay_metadata(of typebool, which defaults tofalse): Replay last known metadata when switching back to this source. This helps when source has dropped due to temporary connection issues.timeout(of type{float}, which defaults to30.0): Timeout for source connections, in seconds.input.harborreads it when it is created,input.harbor.dynamicwhen each client connects.transport(of typehttp_transport, which defaults to<unix_transport>): Http transport. Usehttp.transport.ssl, when available, to enable HTTPS outputuser(of typestring, which defaults to"source"): Source user.(unlabeled)(of typestring): Mountpoint to look for.
Methods:
buffer_length(of type() -> float): Length of the buffer (in seconds).buffered(of type() -> [string * float]): Length of buffered data.bytes_read(of type() -> int): Bytes read from source clients since the input was created.callbacks_count(of type() -> [string * int]): Callbacks a script has registered on this source, as pairs of callback name and count. A count that keeps growing is a function registering on a source it is handed without releasing what it registered.clear_last_metadata(of type() -> unit): Clear the last metadata from the source.clock(of typeclock): The source's clockconnected_client(of type() -> string?): Returns the address of the client currently connected, if there is one.duration(of type() -> float): Estimation of the duration of the current track.elapsed(of type() -> float): Elapsed time in the current track.fallible(of typebool): 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 ason_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 ifnew_trackistrue. Whenoverrideisfalse, metadata that the source provides itself takes precedence over the inserted one.is_active(of type() -> bool):trueif the source is active, i.e. it is continuously animated by its own clock whenever it is ready. Typically,truefor outputs and sources such asinput.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 istruewhen the source is currently being used or if it could be used at any time, typically inside aswitchorfallback.last_metadata(of type() -> [string * string]?): Return the last metadata from the source.log(of type{level : (() -> int).{exchange : (int) -> int, set : (int) -> unit}}): Get or set the source's log level, from1to5.register_command(of type(?usage : string?, description : string, string, ((string) -> string)) -> unit): Register a server command for this source. Command is registered under the source's id namespace when it gets up and de-registered when it gets down.remaining(of type() -> float): Estimation of remaining time in the current track.reset_last_metadata_on_track(of type(() -> bool).{exchange : (bool) -> bool, set : (bool) -> unit}): Iftrue, the source'slast_metadatais reset on each new track. If a metadata is present along with the track mark, then it becomes the newlast_metadata, otherwise,last_metadata becomesnull`.seek(of type(float) -> float): Seek forward, in seconds (returns the amount of time effectively seeked).self_sync(of type() -> bool): Is the source currently controlling its own real-time loop.self_sync_description(of type() -> string)skip(of type() -> unit): Skip to the next track.status(of type() -> string): Current status of the input.stop(of type() -> unit): Disconnect the client currently connected to the harbor. Does nothing if no client is connected.time(of type() -> float): Get a source's time, based on its assigned clock.
Callbacks:
on_collect(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called when source is collectedon_connect(of type(synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}): Call a given handler when a source is connected. Its receives the list of headers, of the form: (on_disconnect(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler when a source is disconnected.on_frame(of type(?before : bool, synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler on frame. Whenbeforeistrue, callback is executed before computing the frame and after otherwiseon_frame_checksum(of type(?before : ((string?) -> unit)?, synchronous : bool, ((cache : string?, string) -> unit)) -> {release : () -> unit}): Call a given handler Register callbacks to compute frame checksums for debugging purposes. This is useful to track frame content changes through the streaming pipeline. Thebeforecallback is called before computing the frame with the checksum of the cached frame (if any,nullotherwise). The main callback is called after computing the frame with the checksum of the generated frame and the remaining cache (if any).on_metadata(of type(synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}): Call a given handler to execute on each metadataon_position(of type(position : {float}, ?remaining : bool, ?allow_partial : bool, synchronous : bool, ((float, [string * string]) -> unit)) -> {release : () -> unit}): Call a given handler on track position. Ifremainingisfalse, callback is executed when position in track is more or equal toposition. Ifremainingistrue, callback is executed when remaining time in the current track is less or equal toposition. Keep in mind that elapsed time is exact while remaining time is always estimated. Remaining time is usually more accurate for file-based sources. Whenallow_partialistrue, if the current track ends before theoffsetposition is reached, callback is still executedon_shutdown(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called when source shuts downon_track(of type(synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}): Call a given handler on track markson_wake_up(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called after the source is asked to get ready
Composition methods:
composition_type(of type(() -> string).{exchange : (string) -> string, set : (string) -> unit}): This source uses live composition by default.on_leave(of type({source : source('a), track_sensitive : bool}) -> unit): Called after switching away from this source in a switch operator, once the transition using the ending source has completed. Receives a record withsource(the source being left) andtrack_sensitive(trueif the ending source's last frame had a track mark, i.e. it finished naturally;falseif 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 withstarting(the incoming source) andending(the previous source, ornullwhen the ending source reached a track boundary). Returns the source to use. By default, both file and live profiles fade outendingwhen non-null (up to 1 second). The default is looked up at runtime from the active composition profile (source.composition.fileorsource.composition.livedepending oncomposition_type).replay_metadata(of type{bool}): Whether to replay the latest metadata on this source when it is selected in a switch operator. Defaults totrue. The value is looked up at runtime from the active composition profile (source.composition.fileorsource.composition.livedepending oncomposition_type).single(of typebool): Forbid the selection of this source for two consecutive tracks in switch operators. Defaults tofalse.track_sensitive(of type{bool}): Whether this source insists on track boundaries in switch operators: whentrue, 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 hastrack_sensitiveset tofalse; otherwise it waits for the playing source to reach a track boundary. File-based sources default totrue; live network and hardware inputs default tofalse. The value is looked up at runtime from the active composition profile (source.composition.fileorsource.composition.livedepending oncomposition_type).
input.harbor.dynamic
Receive any number of source clients on the mountpoints a regexp matches. Each client is decoded with FFmpeg into a source of its own, handed to on_connect with the client's connection record. A source is single-use: a client that reconnects gets a new one. A source that no output uses within timeout is disconnected.
Type:
(?buffer : float, ?max : float, ?timeout : {float}, ?user : string,
?password : string, ?port : int, ?transport : http_transport, ?icy : bool,
?icy_metadata_charset : string?, ?metadata_charset : string?,
?replay_metadata : bool,
?auth : ((
{
address : string,
headers : [string * string],
method : string,
password : string,
query : [string * string],
uri : string,
user : string
}) -> bool)?,
?accept : ((
{
address : string,
headers : [string * string],
method : string,
password : string,
query : [string * string],
uri : string,
user : string
}) ->
{
refuse? :
{headers? : [string * string], reason : string, status : int
}?}?)?,
?dumpfile : string?, ?logfile : string?, ?debug : bool,
on_connect : ((
{
copy_encoder : (?string?, ?options : [string * string]) ->
format('a),
format : string?,
headers : [string * string],
mime_type : string?,
query : [string * string],
streams : [
{
channel_layout? : string,
channels? : int,
codec : string,
field : string,
frame_rate? : float?,
height? : int,
pixel_format? : string,
samplerate? : int,
type : string,
width? : int
}],
uri : string
}) ->
(source('a)
.{
buffer_length : () -> float,
buffered : () -> [string * float],
bytes_read : () -> int,
callbacks_count : () -> [string * int],
clear_last_metadata : () -> unit,
clock : clock,
connected_client : () -> string?,
duration : () -> float,
elapsed : () -> float,
fallible : bool,
generate_frame : () -> unit,
id : () -> string,
insert_metadata : (?override : bool, ?new_track : bool,
[string * string]) -> unit,
is_active : () -> bool,
is_ready : () -> bool,
is_up : () -> bool,
last_metadata : () -> [string * string]?,
log :
{
level : (() -> int)
.{exchange : (int) -> int, set : (int) -> unit
}
},
on_collect : (synchronous : bool, (() -> unit)) ->
{release : () -> unit},
on_connect : (synchronous : bool,
(([string * string]) -> unit)) ->
{release : () -> unit},
on_disconnect : (synchronous : bool, (() -> unit)) ->
{release : () -> unit},
on_frame : (?before : bool, synchronous : bool,
(() -> unit)) -> {release : () -> unit},
on_frame_checksum : (?before : ((string?) -> unit)?,
synchronous : bool,
((cache : string?, string) -> unit)) ->
{release : () -> unit},
on_leave : ({source : source('a), track_sensitive : bool}) ->
unit,
on_metadata : (synchronous : bool,
(([string * string]) -> unit)) ->
{release : () -> unit},
on_position : (position : {float}, ?remaining : bool,
?allow_partial : bool, synchronous : bool,
((float, [string * string]) -> unit)) ->
{release : () -> unit},
on_select : (
{
ending : source('a)?,
replay_metadata : bool,
starting : source('a)
}) -> source('a),
on_shutdown : (synchronous : bool, (() -> unit)) ->
{release : () -> unit},
on_track : (synchronous : bool,
(([string * string]) -> unit)) ->
{release : () -> unit},
on_wake_up : (synchronous : bool, (() -> unit)) ->
{release : () -> unit},
register_command : (?usage : string?, description : string,
string, ((string) -> string)) -> unit,
remaining : () -> float,
replay_metadata : {bool},
reset_last_metadata_on_track : (() -> bool)
.{exchange : (bool) -> bool, set : (bool) -> unit
},
seek : (float) -> float,
self_sync : () -> bool,
self_sync_description : () -> string,
single : bool,
skip : () -> unit,
status : () -> string,
stop : () -> unit,
time : () -> float,
track_sensitive : {bool}
}) -> unit),
string) -> unit
Arguments:
buffer(of typefloat, which defaults to12.0): Duration of the pre-buffered data (in seconds). Default value is set to make it possible to usecrossfadetransitions withinput.harbor. You might be able to reduce it but, in this case, make sure to not use the operator withcrossfadeor make sure that it has enough buffered data for it.max(of typefloat, which defaults to20.0): Maximum duration of the buffered data (in seconds).timeout(of type{float}, which defaults to30.0): Timeout for source connections, in seconds.input.harborreads it when it is created,input.harbor.dynamicwhen each client connects.user(of typestring, which defaults to"source"): Source user.password(of typestring, which defaults to"hackme"): Source password.port(of typeint, which defaults to8005): Port used to connect to the source.transport(of typehttp_transport, which defaults to<unix_transport>): Http transport. Usehttp.transport.ssl, when available, to enable HTTPS outputicy(of typebool, which defaults tofalse): Enable ICY (shoutcast) protocol.icy_metadata_charset(of typestring?, which defaults tonull): ICY (shoutcast) metadata charset. Guessed if null. Default for shoutcast is ISO-8859-1. Set to that value if all your clients send metadata using this charset and automatic detection is not working for you.metadata_charset(of typestring?, which defaults tonull): Metadata charset for non-ICY (shoutcast) source protocols. Guessed if null.replay_metadata(of typebool, which defaults tofalse): Replay last known metadata when switching back to this source. This helps when source has dropped due to temporary connection issues.auth(of type(( { address : string, headers : [string * string], method : string, password : string, query : [string * string], uri : string, user : string }) -> bool)?, which defaults tonull): Authentication function. Receives a record with:user,password,uri(request URI),query(URL query parameters as a list of key-value pairs),address(client network address) andmethod(connection method:"PUT"or"POST"for HTTP source connections,"SOURCE"for Xaudiocast/ICE sources,"ICY"for Shoutcast/ICY sources,"WEBSOCKET"for WebSocket sources,"GET"for ICY metadata updates), andheaders(the request headers, lowercase names, empty for ICY sources) and returnstrueif the user should be granted access for this login. A request without credentials is refused unlessacceptis given, in which case it is passed empty ones. Override any other method if used.accept(of type(( { address : string, headers : [string * string], method : string, password : string, query : [string * string], uri : string, user : string }) -> {refuse? : {headers? : [string * string], reason : string, status : int}?}?)?, which defaults tonull): Admission of a source client that passedauth, with the same record. It also runs for theGETlogins of ICY metadata updates. A decision withrefuse = {status, reason, headers?}refuses the client with that reply and an empty body;nullor norefuseadmits it. A refusal whose status is outside 300 to 599, or with a line break in its reason or headers, and a function that raises, refuse with403 Forbidden.dumpfile(of typestring?, which defaults tonull): Dump stream to file, for debugging purpose. Disabled if null.logfile(of typestring?, which defaults tonull): Log buffer status to file, for debugging purpose. Disabled if null.debug(of typebool, which defaults tofalse): Run in debugging mode by not catching some exceptions.on_connect(of type( { copy_encoder : (?string?, ?options : [string * string]) -> format('a), format : string?, headers : [string * string], mime_type : string?, query : [string * string], streams : [ { channel_layout? : string, channels? : int, codec : string, field : string, frame_rate? : float?, height? : int, pixel_format? : string, samplerate? : int, type : string, width? : int }], uri : string }) -> (source('a) .{ buffer_length : () -> float, buffered : () -> [string * float], bytes_read : () -> int, callbacks_count : () -> [string * int], clear_last_metadata : () -> unit, clock : clock, connected_client : () -> string?, duration : () -> float, elapsed : () -> float, fallible : bool, generate_frame : () -> unit, id : () -> string, insert_metadata : (?override : bool, ?new_track : bool, [string * string]) -> unit, is_active : () -> bool, is_ready : () -> bool, is_up : () -> bool, last_metadata : () -> [string * string]?, log : {level : (() -> int).{exchange : (int) -> int, set : (int) -> unit} }, on_collect : (synchronous : bool, (() -> unit)) -> {release : () -> unit}, on_connect : (synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}, on_disconnect : (synchronous : bool, (() -> unit)) -> {release : () -> unit}, on_frame : (?before : bool, synchronous : bool, (() -> unit)) -> {release : () -> unit}, on_frame_checksum : (?before : ((string?) -> unit)?, synchronous : bool, ((cache : string?, string) -> unit)) -> {release : () -> unit}, on_leave : ({source : source('a), track_sensitive : bool}) -> unit, on_metadata : (synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}, on_position : (position : {float}, ?remaining : bool, ?allow_partial : bool, synchronous : bool, ((float, [string * string]) -> unit)) -> {release : () -> unit}, on_select : ( { ending : source('a)?, replay_metadata : bool, starting : source('a) }) -> source('a), on_shutdown : (synchronous : bool, (() -> unit)) -> {release : () -> unit}, on_track : (synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}, on_wake_up : (synchronous : bool, (() -> unit)) -> {release : () -> unit}, register_command : (?usage : string?, description : string, string, ((string) -> string)) -> unit, remaining : () -> float, replay_metadata : {bool}, reset_last_metadata_on_track : (() -> bool) .{exchange : (bool) -> bool, set : (bool) -> unit }, seek : (float) -> float, self_sync : () -> bool, self_sync_description : () -> string, single : bool, skip : () -> unit, status : () -> string, stop : () -> unit, time : () -> float, track_sensitive : {bool} }) -> unit): Called with the connection record of each client; returns the function given the client's source.(unlabeled)(of typestring): Mountpoint to look for.
input.harbor.dynamic.regexp
Receive any number of source clients on the mountpoints a regexp matches. Each client is decoded with FFmpeg into a source of its own, handed to on_connect with the client's connection record. A source is single-use: a client that reconnects gets a new one. A source that no output uses within timeout is disconnected.
Type:
(?buffer : float, ?max : float, ?timeout : {float}, ?user : string,
?password : string, ?port : int, ?transport : http_transport, ?icy : bool,
?icy_metadata_charset : string?, ?metadata_charset : string?,
?replay_metadata : bool,
?auth : ((
{
address : string,
headers : [string * string],
method : string,
password : string,
query : [string * string],
uri : string,
user : string
}) -> bool)?,
?accept : ((
{
address : string,
headers : [string * string],
method : string,
password : string,
query : [string * string],
uri : string,
user : string
}) ->
{
refuse? :
{headers? : [string * string], reason : string, status : int
}?}?)?,
?dumpfile : string?, ?logfile : string?, ?debug : bool, regexp,
on_connect : ((
{
copy_encoder : (?string?, ?options : [string * string]) ->
format('a),
format : string?,
headers : [string * string],
mime_type : string?,
query : [string * string],
streams : [
{
channel_layout? : string,
channels? : int,
codec : string,
field : string,
frame_rate? : float?,
height? : int,
pixel_format? : string,
samplerate? : int,
type : string,
width? : int
}],
uri : string
}) ->
(source('a)
.{
buffer_length : () -> float,
buffered : () -> [string * float],
bytes_read : () -> int,
callbacks_count : () -> [string * int],
clear_last_metadata : () -> unit,
clock : clock,
connected_client : () -> string?,
duration : () -> float,
elapsed : () -> float,
fallible : bool,
generate_frame : () -> unit,
id : () -> string,
insert_metadata : (?override : bool, ?new_track : bool,
[string * string]) -> unit,
is_active : () -> bool,
is_ready : () -> bool,
is_up : () -> bool,
last_metadata : () -> [string * string]?,
log :
{
level : (() -> int)
.{exchange : (int) -> int, set : (int) -> unit
}
},
on_collect : (synchronous : bool, (() -> unit)) ->
{release : () -> unit},
on_connect : (synchronous : bool,
(([string * string]) -> unit)) ->
{release : () -> unit},
on_disconnect : (synchronous : bool, (() -> unit)) ->
{release : () -> unit},
on_frame : (?before : bool, synchronous : bool,
(() -> unit)) -> {release : () -> unit},
on_frame_checksum : (?before : ((string?) -> unit)?,
synchronous : bool,
((cache : string?, string) -> unit)) ->
{release : () -> unit},
on_leave : ({source : source('a), track_sensitive : bool}) ->
unit,
on_metadata : (synchronous : bool,
(([string * string]) -> unit)) ->
{release : () -> unit},
on_position : (position : {float}, ?remaining : bool,
?allow_partial : bool, synchronous : bool,
((float, [string * string]) -> unit)) ->
{release : () -> unit},
on_select : (
{
ending : source('a)?,
replay_metadata : bool,
starting : source('a)
}) -> source('a),
on_shutdown : (synchronous : bool, (() -> unit)) ->
{release : () -> unit},
on_track : (synchronous : bool,
(([string * string]) -> unit)) ->
{release : () -> unit},
on_wake_up : (synchronous : bool, (() -> unit)) ->
{release : () -> unit},
register_command : (?usage : string?, description : string,
string, ((string) -> string)) -> unit,
remaining : () -> float,
replay_metadata : {bool},
reset_last_metadata_on_track : (() -> bool)
.{exchange : (bool) -> bool, set : (bool) -> unit
},
seek : (float) -> float,
self_sync : () -> bool,
self_sync_description : () -> string,
single : bool,
skip : () -> unit,
status : () -> string,
stop : () -> unit,
time : () -> float,
track_sensitive : {bool}
}) -> unit)) -> unit
Arguments:
buffer(of typefloat, which defaults to12.0): Duration of the pre-buffered data (in seconds). Default value is set to make it possible to usecrossfadetransitions withinput.harbor. You might be able to reduce it but, in this case, make sure to not use the operator withcrossfadeor make sure that it has enough buffered data for it.max(of typefloat, which defaults to20.0): Maximum duration of the buffered data (in seconds).timeout(of type{float}, which defaults to30.0): Timeout for source connections, in seconds.input.harborreads it when it is created,input.harbor.dynamicwhen each client connects.user(of typestring, which defaults to"source"): Source user.password(of typestring, which defaults to"hackme"): Source password.port(of typeint, which defaults to8005): Port used to connect to the source.transport(of typehttp_transport, which defaults to<unix_transport>): Http transport. Usehttp.transport.ssl, when available, to enable HTTPS outputicy(of typebool, which defaults tofalse): Enable ICY (shoutcast) protocol.icy_metadata_charset(of typestring?, which defaults tonull): ICY (shoutcast) metadata charset. Guessed if null. Default for shoutcast is ISO-8859-1. Set to that value if all your clients send metadata using this charset and automatic detection is not working for you.metadata_charset(of typestring?, which defaults tonull): Metadata charset for non-ICY (shoutcast) source protocols. Guessed if null.replay_metadata(of typebool, which defaults tofalse): Replay last known metadata when switching back to this source. This helps when source has dropped due to temporary connection issues.auth(of type(( { address : string, headers : [string * string], method : string, password : string, query : [string * string], uri : string, user : string }) -> bool)?, which defaults tonull): Authentication function. Receives a record with:user,password,uri(request URI),query(URL query parameters as a list of key-value pairs),address(client network address) andmethod(connection method:"PUT"or"POST"for HTTP source connections,"SOURCE"for Xaudiocast/ICE sources,"ICY"for Shoutcast/ICY sources,"WEBSOCKET"for WebSocket sources,"GET"for ICY metadata updates), andheaders(the request headers, lowercase names, empty for ICY sources) and returnstrueif the user should be granted access for this login. A request without credentials is refused unlessacceptis given, in which case it is passed empty ones. Override any other method if used.accept(of type(( { address : string, headers : [string * string], method : string, password : string, query : [string * string], uri : string, user : string }) -> {refuse? : {headers? : [string * string], reason : string, status : int}?}?)?, which defaults tonull): Admission of a source client that passedauth, with the same record. It also runs for theGETlogins of ICY metadata updates. A decision withrefuse = {status, reason, headers?}refuses the client with that reply and an empty body;nullor norefuseadmits it. A refusal whose status is outside 300 to 599, or with a line break in its reason or headers, and a function that raises, refuse with403 Forbidden.dumpfile(of typestring?, which defaults tonull): Dump stream to file, for debugging purpose. Disabled if null.logfile(of typestring?, which defaults tonull): Log buffer status to file, for debugging purpose. Disabled if null.debug(of typebool, which defaults tofalse): Run in debugging mode by not catching some exceptions.(unlabeled)(of typeregexp): Mountpoint to look for.on_connect(of type( { copy_encoder : (?string?, ?options : [string * string]) -> format('a), format : string?, headers : [string * string], mime_type : string?, query : [string * string], streams : [ { channel_layout? : string, channels? : int, codec : string, field : string, frame_rate? : float?, height? : int, pixel_format? : string, samplerate? : int, type : string, width? : int }], uri : string }) -> (source('a) .{ buffer_length : () -> float, buffered : () -> [string * float], bytes_read : () -> int, callbacks_count : () -> [string * int], clear_last_metadata : () -> unit, clock : clock, connected_client : () -> string?, duration : () -> float, elapsed : () -> float, fallible : bool, generate_frame : () -> unit, id : () -> string, insert_metadata : (?override : bool, ?new_track : bool, [string * string]) -> unit, is_active : () -> bool, is_ready : () -> bool, is_up : () -> bool, last_metadata : () -> [string * string]?, log : {level : (() -> int).{exchange : (int) -> int, set : (int) -> unit} }, on_collect : (synchronous : bool, (() -> unit)) -> {release : () -> unit}, on_connect : (synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}, on_disconnect : (synchronous : bool, (() -> unit)) -> {release : () -> unit}, on_frame : (?before : bool, synchronous : bool, (() -> unit)) -> {release : () -> unit}, on_frame_checksum : (?before : ((string?) -> unit)?, synchronous : bool, ((cache : string?, string) -> unit)) -> {release : () -> unit}, on_leave : ({source : source('a), track_sensitive : bool}) -> unit, on_metadata : (synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}, on_position : (position : {float}, ?remaining : bool, ?allow_partial : bool, synchronous : bool, ((float, [string * string]) -> unit)) -> {release : () -> unit}, on_select : ( { ending : source('a)?, replay_metadata : bool, starting : source('a) }) -> source('a), on_shutdown : (synchronous : bool, (() -> unit)) -> {release : () -> unit}, on_track : (synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}, on_wake_up : (synchronous : bool, (() -> unit)) -> {release : () -> unit}, register_command : (?usage : string?, description : string, string, ((string) -> string)) -> unit, remaining : () -> float, replay_metadata : {bool}, reset_last_metadata_on_track : (() -> bool) .{exchange : (bool) -> bool, set : (bool) -> unit }, seek : (float) -> float, self_sync : () -> bool, self_sync_description : () -> string, single : bool, skip : () -> unit, status : () -> string, stop : () -> unit, time : () -> float, track_sensitive : {bool} }) -> unit): Called with the connection record of each client; returns the function given the client's source.
input.hls
Play an HLS stream.
Type:
(?id : string?, {string}) -> source('a)
Synchronization:
This source paces its clock while connected when self_sync is true.
Composition:
This source uses live composition by default.
Arguments:
id(of typestring?, which defaults tonull): Force the value of the source ID.(unlabeled)(of type{string}): Playlist URI.
Methods:
buffered(of type() -> [string * float]): Length of buffered data.callbacks_count(of type() -> [string * int]): Callbacks a script has registered on this source, as pairs of callback name and count. A count that keeps growing is a function registering on a source it is handed without releasing what it registered.clear_last_metadata(of type() -> unit): Clear the last metadata from the source.clock(of typeclock): The source's clockduration(of type() -> float): Estimation of the duration of the current track.elapsed(of type() -> float): Elapsed time in the current track.fallible(of typebool): 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 ason_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 ifnew_trackistrue. Whenoverrideisfalse, metadata that the source provides itself takes precedence over the inserted one.is_active(of type() -> bool):trueif the source is active, i.e. it is continuously animated by its own clock whenever it is ready. Typically,truefor outputs and sources such asinput.http.is_ready(of type() -> bool): Indicate if a source is ready to stream. This does not mean that the source is currently streaming, just that its resources are all properly initialized.is_started(of type() -> bool):trueif the output or source is started.is_up(of type() -> bool): Indicate that the source can be asked to produce some data at any time. This istruewhen the source is currently being used or if it could be used at any time, typically inside aswitchorfallback.last_metadata(of type() -> [string * string]?): Return the last metadata from the source.log(of type{level : (() -> int).{exchange : (int) -> int, set : (int) -> unit}}): Get or set the source's log level, from1to5.register_command(of type(?usage : string?, description : string, string, ((string) -> string)) -> unit): Register a server command for this source. Command is registered under the source's id namespace when it gets up and de-registered when it gets down.remaining(of type() -> float): Estimation of remaining time in the current track.reset_last_metadata_on_track(of type(() -> bool).{exchange : (bool) -> bool, set : (bool) -> unit}): Iftrue, the source'slast_metadatais reset on each new track. If a metadata is present along with the track mark, then it becomes the newlast_metadata, otherwise,last_metadata becomesnull`.seek(of type(float) -> float): Seek forward, in seconds (returns the amount of time effectively seeked).self_sync(of type() -> bool): Is the source currently controlling its own real-time loop.self_sync_description(of type() -> string): This source paces its clock while connected whenself_syncis true.set_url(of type({string}) -> unit): Set the URL, used at the next connection.skip(of type() -> unit): Skip to the next track.start(of type() -> unit): Ask the source or output to start.status(of type() -> string): Status:"stopped","starting","polling","connected <url>","stopping"or"failed".stop(of type() -> unit): Ask the source or output to stop.time(of type() -> float): Get a source's time, based on its assigned clock.url(of type() -> string): Current URL.
Callbacks:
on_collect(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called when source is collectedon_connect(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler when connected, before the source plays the connection's data.on_disconnect(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler when a connection whoseon_connectcallbacks ran ends.on_error(of type(synchronous : bool, ((error) -> unit)) -> {release : () -> unit}): Call a given handler on each connection or feeding failure.on_frame(of type(?before : bool, synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler on frame. Whenbeforeistrue, callback is executed before computing the frame and after otherwiseon_frame_checksum(of type(?before : ((string?) -> unit)?, synchronous : bool, ((cache : string?, string) -> unit)) -> {release : () -> unit}): Call a given handler Register callbacks to compute frame checksums for debugging purposes. This is useful to track frame content changes through the streaming pipeline. Thebeforecallback is called before computing the frame with the checksum of the cached frame (if any,nullotherwise). The main callback is called after computing the frame with the checksum of the generated frame and the remaining cache (if any).on_metadata(of type(synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}): Call a given handler to execute on each metadataon_position(of type(position : {float}, ?remaining : bool, ?allow_partial : bool, synchronous : bool, ((float, [string * string]) -> unit)) -> {release : () -> unit}): Call a given handler on track position. Ifremainingisfalse, callback is executed when position in track is more or equal toposition. Ifremainingistrue, callback is executed when remaining time in the current track is less or equal toposition. Keep in mind that elapsed time is exact while remaining time is always estimated. Remaining time is usually more accurate for file-based sources. Whenallow_partialistrue, if the current track ends before theoffsetposition is reached, callback is still executedon_shutdown(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called when source shuts downon_start(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler when source startson_stop(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler when source stopson_track(of type(synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}): Call a given handler on track markson_wake_up(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called after the source is asked to get ready
Composition methods:
composition_type(of type(() -> string).{exchange : (string) -> string, set : (string) -> unit}): This source uses live composition by default.on_leave(of type({source : source('a), track_sensitive : bool}) -> unit): Called after switching away from this source in a switch operator, once the transition using the ending source has completed. Receives a record withsource(the source being left) andtrack_sensitive(trueif the ending source's last frame had a track mark, i.e. it finished naturally;falseif 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 withstarting(the incoming source) andending(the previous source, ornullwhen the ending source reached a track boundary). Returns the source to use. By default, both file and live profiles fade outendingwhen non-null (up to 1 second). The default is looked up at runtime from the active composition profile (source.composition.fileorsource.composition.livedepending oncomposition_type).replay_metadata(of type{bool}): Whether to replay the latest metadata on this source when it is selected in a switch operator. Defaults totrue. The value is looked up at runtime from the active composition profile (source.composition.fileorsource.composition.livedepending oncomposition_type).single(of typebool): Forbid the selection of this source for two consecutive tracks in switch operators. Defaults tofalse.track_sensitive(of type{bool}): Whether this source insists on track boundaries in switch operators: whentrue, 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 hastrack_sensitiveset tofalse; otherwise it waits for the playing source to reach a track boundary. File-based sources default totrue; live network and hardware inputs default tofalse. The value is looked up at runtime from the active composition profile (source.composition.fileorsource.composition.livedepending oncomposition_type).
input.hls.native
Play an HLS stream.
Type:
(?id : string?, ?reload : float, string) -> source('a)
where 'a is a set of tracks to be muxed into a source
Composition:
This source uses file composition by default.
Arguments:
id(of typestring?, which defaults tonull): Force the value of the source ID.reload(of typefloat, which defaults to10.0): How often (in seconds) the playlist should be reloaded.(unlabeled)(of typestring): Playlist URI.
Methods:
buffered(of type() -> [string * float]): Length of buffered data.callbacks_count(of type() -> [string * int]): Callbacks a script has registered on this source, as pairs of callback name and count. A count that keeps growing is a function registering on a source it is handed without releasing what it registered.clear_last_metadata(of type() -> unit): Clear the last metadata from the source.clock(of typeclock): The source's clockduration(of type() -> float): Estimation of the duration of the current track.elapsed(of type() -> float): Elapsed time in the current track.fallible(of typebool): 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 ason_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 ifnew_trackistrue. Whenoverrideisfalse, metadata that the source provides itself takes precedence over the inserted one.is_active(of type() -> bool):trueif the source is active, i.e. it is continuously animated by its own clock whenever it is ready. Typically,truefor outputs and sources such asinput.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 istruewhen the source is currently being used or if it could be used at any time, typically inside aswitchorfallback.last_metadata(of type() -> [string * string]?): Return the last metadata from the source.log(of type{level : (() -> int).{exchange : (int) -> int, set : (int) -> unit}}): Get or set the source's log level, from1to5.register_command(of type(?usage : string?, description : string, string, ((string) -> string)) -> unit): Register a server command for this source. Command is registered under the source's id namespace when it gets up and de-registered when it gets down.remaining(of type() -> float): Estimation of remaining time in the current track.reset_last_metadata_on_track(of type(() -> bool).{exchange : (bool) -> bool, set : (bool) -> unit}): Iftrue, the source'slast_metadatais reset on each new track. If a metadata is present along with the track mark, then it becomes the newlast_metadata, otherwise,last_metadata becomesnull`.seek(of type(float) -> float): Seek forward, in seconds (returns the amount of time effectively seeked).self_sync(of type() -> bool): Is the source currently controlling its own real-time loop.self_sync_description(of type() -> string)skip(of type() -> unit): Skip to the next track.time(of type() -> float): Get a source's time, based on its assigned clock.
Callbacks:
on_collect(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called when source is collectedon_frame(of type(?before : bool, synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler on frame. Whenbeforeistrue, callback is executed before computing the frame and after otherwiseon_frame_checksum(of type(?before : ((string?) -> unit)?, synchronous : bool, ((cache : string?, string) -> unit)) -> {release : () -> unit}): Call a given handler Register callbacks to compute frame checksums for debugging purposes. This is useful to track frame content changes through the streaming pipeline. Thebeforecallback is called before computing the frame with the checksum of the cached frame (if any,nullotherwise). The main callback is called after computing the frame with the checksum of the generated frame and the remaining cache (if any).on_metadata(of type(synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}): Call a given handler to execute on each metadataon_position(of type(position : {float}, ?remaining : bool, ?allow_partial : bool, synchronous : bool, ((float, [string * string]) -> unit)) -> {release : () -> unit}): Call a given handler on track position. Ifremainingisfalse, callback is executed when position in track is more or equal toposition. Ifremainingistrue, callback is executed when remaining time in the current track is less or equal toposition. Keep in mind that elapsed time is exact while remaining time is always estimated. Remaining time is usually more accurate for file-based sources. Whenallow_partialistrue, if the current track ends before theoffsetposition is reached, callback is still executedon_shutdown(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called when source shuts downon_track(of type(synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}): Call a given handler on track markson_wake_up(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called after the source is asked to get ready
Composition methods:
composition_type(of type(() -> string).{exchange : (string) -> string, set : (string) -> unit}): This source uses file composition by default.on_leave(of type({source : source('a), track_sensitive : bool}) -> unit where 'a is a set of tracks to be muxed into a source): Called after switching away from this source in a switch operator, once the transition using the ending source has completed. Receives a record withsource(the source being left) andtrack_sensitive(trueif the ending source's last frame had a track mark, i.e. it finished naturally;falseif it was preempted mid-track). This function must return quickly as it runs in the streaming thread. The default depends on the active composition profile: file sources (source.composition.file) skip the source when preempted mid-track so it starts fresh on its next selection, and do nothing when it finished naturally; live sources (source.composition.live) do nothing.on_select(of type({ending : source('a)?, replay_metadata : bool, starting : source('a)}) -> source('a) where 'a is a set of tracks to be muxed into a source): Called when selecting this source in a switch operator. Receives a record withstarting(the incoming source) andending(the previous source, ornullwhen the ending source reached a track boundary). Returns the source to use. By default, both file and live profiles fade outendingwhen non-null (up to 1 second). The default is looked up at runtime from the active composition profile (source.composition.fileorsource.composition.livedepending oncomposition_type).replay_metadata(of type{bool}): Whether to replay the latest metadata on this source when it is selected in a switch operator. Defaults totrue. The value is looked up at runtime from the active composition profile (source.composition.fileorsource.composition.livedepending oncomposition_type).single(of typebool): Forbid the selection of this source for two consecutive tracks in switch operators. Defaults tofalse.track_sensitive(of type{bool}): Whether this source insists on track boundaries in switch operators: whentrue, 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 hastrack_sensitiveset tofalse; otherwise it waits for the playing source to reach a track boundary. File-based sources default totrue; live network and hardware inputs default tofalse. The value is looked up at runtime from the active composition profile (source.composition.fileorsource.composition.livedepending oncomposition_type).
This function is experimental.
input.http
Read an HTTP stream with FFmpeg.
Type:
(?id : string?, ?debug : bool, ?deduplicate_metadata : bool,
?float_args : [string * float], ?format : string?,
?int_args : [string * int], ?max_buffer : float,
?metadata_filter : (([string * string]) -> [string * string])?,
?new_track_on_metadata : bool, ?poll_delay : float, ?self_sync : {bool?},
?start : bool, ?string_args : [string * string], ?timeout : float,
?trim_url : bool, ?user_agent : string, {string}) -> source('a)
Synchronization:
This source paces its clock while connected when self_sync is true.
Composition:
This source uses live composition by default.
Arguments:
id(of typestring?, which defaults tonull): Force the value of the source ID.debug(of typebool, which defaults tofalse): Log every fault with its backtrace at error level.deduplicate_metadata(of typebool, which defaults totrue): Drop metadata equal to the previous one of the same connection.float_args(of type[string * float], which defaults to[]): FFmpeg options, each stored as a float option.format(of typestring?, which defaults tonull): Input format short name.int_args(of type[string * int], which defaults to[]): FFmpeg options, each stored as an integer option.max_buffer(of typefloat, which defaults to5.0): Maximum decoded data held by the source, in seconds.metadata_filter(of type(([string * string]) -> [string * string])?, which defaults tonull): Metadata filter, replacing the default one, which drops the keys starting withid3v2_priv.new_track_on_metadata(of typebool, which defaults totrue): Start a new track at each metadata.poll_delay(of typefloat, which defaults to2.0): Delay before a retry after a failure, and interval of the URL check while failed, in seconds.self_sync(of type{bool?}, which defaults tonull): Pace the clock while connected.null: the clock keeps its own pace, with this source as its sync source when ICY headers were received.start(of typebool, which defaults totrue): Start input as soon as it is available.string_args(of type[string * string], which defaults to[]): FFmpeg options, each stored as a string option.timeout(of typefloat, which defaults to10.0): Longest a single blocking read may last, in seconds, on an input that is not listening.trim_url(of typebool, which defaults totrue): Strip leading and trailing whitespace from the URL.user_agent(of typestring, which defaults to"Liquidsoap/2.5.0+git@b15d610 (Unix; OCaml 5.5.2)"): User agent.(unlabeled)(of type{string}): URL to read from.
Methods:
buffered(of type() -> [string * float]): Length of buffered data.callbacks_count(of type() -> [string * int]): Callbacks a script has registered on this source, as pairs of callback name and count. A count that keeps growing is a function registering on a source it is handed without releasing what it registered.clear_last_metadata(of type() -> unit): Clear the last metadata from the source.clock(of typeclock): The source's clockduration(of type() -> float): Estimation of the duration of the current track.elapsed(of type() -> float): Elapsed time in the current track.fallible(of typebool): 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 ason_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 ifnew_trackistrue. Whenoverrideisfalse, metadata that the source provides itself takes precedence over the inserted one.is_active(of type() -> bool):trueif the source is active, i.e. it is continuously animated by its own clock whenever it is ready. Typically,truefor outputs and sources such asinput.http.is_ready(of type() -> bool): Indicate if a source is ready to stream. This does not mean that the source is currently streaming, just that its resources are all properly initialized.is_started(of type() -> bool):trueif the output or source is started.is_up(of type() -> bool): Indicate that the source can be asked to produce some data at any time. This istruewhen the source is currently being used or if it could be used at any time, typically inside aswitchorfallback.last_metadata(of type() -> [string * string]?): Return the last metadata from the source.log(of type{level : (() -> int).{exchange : (int) -> int, set : (int) -> unit}}): Get or set the source's log level, from1to5.register_command(of type(?usage : string?, description : string, string, ((string) -> string)) -> unit): Register a server command for this source. Command is registered under the source's id namespace when it gets up and de-registered when it gets down.remaining(of type() -> float): Estimation of remaining time in the current track.reset_last_metadata_on_track(of type(() -> bool).{exchange : (bool) -> bool, set : (bool) -> unit}): Iftrue, the source'slast_metadatais reset on each new track. If a metadata is present along with the track mark, then it becomes the newlast_metadata, otherwise,last_metadata becomesnull`.seek(of type(float) -> float): Seek forward, in seconds (returns the amount of time effectively seeked).self_sync(of type() -> bool): Is the source currently controlling its own real-time loop.self_sync_description(of type() -> string): This source paces its clock while connected whenself_syncis true.set_url(of type({string}) -> unit): Set the URL, used at the next connection.skip(of type() -> unit): Skip to the next track.start(of type() -> unit): Ask the source or output to start.status(of type() -> string): Status:"stopped","starting","polling","connected <url>","stopping"or"failed".stop(of type() -> unit): Ask the source or output to stop.time(of type() -> float): Get a source's time, based on its assigned clock.url(of type() -> string): Current URL.
Callbacks:
on_collect(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called when source is collectedon_connect(of type(synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}): Call a given handler when connected, before the source plays the connection's data.on_disconnect(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler when a connection whoseon_connectcallbacks ran ends.on_error(of type(synchronous : bool, ((error) -> unit)) -> {release : () -> unit}): Call a given handler on each connection or feeding failure.on_frame(of type(?before : bool, synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler on frame. Whenbeforeistrue, callback is executed before computing the frame and after otherwiseon_frame_checksum(of type(?before : ((string?) -> unit)?, synchronous : bool, ((cache : string?, string) -> unit)) -> {release : () -> unit}): Call a given handler Register callbacks to compute frame checksums for debugging purposes. This is useful to track frame content changes through the streaming pipeline. Thebeforecallback is called before computing the frame with the checksum of the cached frame (if any,nullotherwise). The main callback is called after computing the frame with the checksum of the generated frame and the remaining cache (if any).on_metadata(of type(synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}): Call a given handler to execute on each metadataon_position(of type(position : {float}, ?remaining : bool, ?allow_partial : bool, synchronous : bool, ((float, [string * string]) -> unit)) -> {release : () -> unit}): Call a given handler on track position. Ifremainingisfalse, callback is executed when position in track is more or equal toposition. Ifremainingistrue, callback is executed when remaining time in the current track is less or equal toposition. Keep in mind that elapsed time is exact while remaining time is always estimated. Remaining time is usually more accurate for file-based sources. Whenallow_partialistrue, if the current track ends before theoffsetposition is reached, callback is still executedon_shutdown(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called when source shuts downon_start(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler when source startson_stop(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler when source stopson_track(of type(synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}): Call a given handler on track markson_wake_up(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called after the source is asked to get ready
Composition methods:
composition_type(of type(() -> string).{exchange : (string) -> string, set : (string) -> unit}): This source uses live composition by default.on_leave(of type({source : source('a), track_sensitive : bool}) -> unit): Called after switching away from this source in a switch operator, once the transition using the ending source has completed. Receives a record withsource(the source being left) andtrack_sensitive(trueif the ending source's last frame had a track mark, i.e. it finished naturally;falseif 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 withstarting(the incoming source) andending(the previous source, ornullwhen the ending source reached a track boundary). Returns the source to use. By default, both file and live profiles fade outendingwhen non-null (up to 1 second). The default is looked up at runtime from the active composition profile (source.composition.fileorsource.composition.livedepending oncomposition_type).replay_metadata(of type{bool}): Whether to replay the latest metadata on this source when it is selected in a switch operator. Defaults totrue. The value is looked up at runtime from the active composition profile (source.composition.fileorsource.composition.livedepending oncomposition_type).single(of typebool): Forbid the selection of this source for two consecutive tracks in switch operators. Defaults tofalse.track_sensitive(of type{bool}): Whether this source insists on track boundaries in switch operators: whentrue, 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 hastrack_sensitiveset tofalse; otherwise it waits for the playing source to reach a track boundary. File-based sources default totrue; live network and hardware inputs default tofalse. The value is looked up at runtime from the active composition profile (source.composition.fileorsource.composition.livedepending oncomposition_type).
input.jack
Get stream from JACK.
Type:
(?id : string?, ?server : string?, ?start : bool) -> source(audio=pcm('a))
Composition:
This source uses live composition by default.
Arguments:
id(of typestring?, which defaults tonull): Force the value of the source ID.server(of typestring?, which defaults tonull): JACK server to connect to.start(of typebool, which defaults totrue): Start input as soon as it is available.
Methods:
buffered(of type() -> [string * float]): Length of buffered data.callbacks_count(of type() -> [string * int]): Callbacks a script has registered on this source, as pairs of callback name and count. A count that keeps growing is a function registering on a source it is handed without releasing what it registered.clear_last_metadata(of type() -> unit): Clear the last metadata from the source.clock(of typeclock): The source's clockconnect(of type('b .{ on_wake_up : (synchronous : bool, (() -> unit)) -> unit, ports : () -> [jack_output_port] }) -> unit): Connect the ports of this JACK input to the ports of a JACK output.duration(of type() -> float): Estimation of the duration of the current track.elapsed(of type() -> float): Elapsed time in the current track.fallible(of typebool): 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 ason_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 ifnew_trackistrue. Whenoverrideisfalse, metadata that the source provides itself takes precedence over the inserted one.is_active(of type() -> bool):trueif the source is active, i.e. it is continuously animated by its own clock whenever it is ready. Typically,truefor outputs and sources such asinput.http.is_ready(of type() -> bool): Indicate if a source is ready to stream. This does not mean that the source is currently streaming, just that its resources are all properly initialized.is_started(of type() -> bool):trueif the output or source is started.is_up(of type() -> bool): Indicate that the source can be asked to produce some data at any time. This istruewhen the source is currently being used or if it could be used at any time, typically inside aswitchorfallback.last_metadata(of type() -> [string * string]?): Return the last metadata from the source.log(of type{level : (() -> int).{exchange : (int) -> int, set : (int) -> unit}}): Get or set the source's log level, from1to5.ports(of type() -> [jack_input_port.{connect : (jack_output_port) -> unit, name : string}]): List of JACK input ports for this source.register_command(of type(?usage : string?, description : string, string, ((string) -> string)) -> unit): Register a server command for this source. Command is registered under the source's id namespace when it gets up and de-registered when it gets down.remaining(of type() -> float): Estimation of remaining time in the current track.reset_last_metadata_on_track(of type(() -> bool).{exchange : (bool) -> bool, set : (bool) -> unit}): Iftrue, the source'slast_metadatais reset on each new track. If a metadata is present along with the track mark, then it becomes the newlast_metadata, otherwise,last_metadata becomesnull`.seek(of type(float) -> float): Seek forward, in seconds (returns the amount of time effectively seeked).self_sync(of type() -> bool): Is the source currently controlling its own real-time loop.self_sync_description(of type() -> string)skip(of type() -> unit): Skip to the next track.start(of type() -> unit): Ask the source or output to start.stop(of type() -> unit): Ask the source or output to stop.time(of type() -> float): Get a source's time, based on its assigned clock.
Callbacks:
on_collect(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called when source is collectedon_frame(of type(?before : bool, synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler on frame. Whenbeforeistrue, callback is executed before computing the frame and after otherwiseon_frame_checksum(of type(?before : ((string?) -> unit)?, synchronous : bool, ((cache : string?, string) -> unit)) -> {release : () -> unit}): Call a given handler Register callbacks to compute frame checksums for debugging purposes. This is useful to track frame content changes through the streaming pipeline. Thebeforecallback is called before computing the frame with the checksum of the cached frame (if any,nullotherwise). The main callback is called after computing the frame with the checksum of the generated frame and the remaining cache (if any).on_metadata(of type(synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}): Call a given handler to execute on each metadataon_position(of type(position : {float}, ?remaining : bool, ?allow_partial : bool, synchronous : bool, ((float, [string * string]) -> unit)) -> {release : () -> unit}): Call a given handler on track position. Ifremainingisfalse, callback is executed when position in track is more or equal toposition. Ifremainingistrue, callback is executed when remaining time in the current track is less or equal toposition. Keep in mind that elapsed time is exact while remaining time is always estimated. Remaining time is usually more accurate for file-based sources. Whenallow_partialistrue, if the current track ends before theoffsetposition is reached, callback is still executedon_shutdown(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called when source shuts downon_start(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler when source startson_stop(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler when source stopson_track(of type(synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}): Call a given handler on track markson_wake_up(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called after the source is asked to get ready
Composition methods:
composition_type(of type(() -> string).{exchange : (string) -> string, set : (string) -> unit}): This source uses live composition by default.on_leave(of type({source : source(audio=pcm('a)), track_sensitive : bool}) -> unit): Called after switching away from this source in a switch operator, once the transition using the ending source has completed. Receives a record withsource(the source being left) andtrack_sensitive(trueif the ending source's last frame had a track mark, i.e. it finished naturally;falseif it was preempted mid-track). This function must return quickly as it runs in the streaming thread. The default depends on the active composition profile: file sources (source.composition.file) skip the source when preempted mid-track so it starts fresh on its next selection, and do nothing when it finished naturally; live sources (source.composition.live) do nothing.on_select(of type( { ending : source(audio=pcm('a))?, replay_metadata : bool, starting : source(audio=pcm('a)) }) -> source(audio=pcm('a))): Called when selecting this source in a switch operator. Receives a record withstarting(the incoming source) andending(the previous source, ornullwhen the ending source reached a track boundary). Returns the source to use. By default, both file and live profiles fade outendingwhen non-null (up to 1 second). The default is looked up at runtime from the active composition profile (source.composition.fileorsource.composition.livedepending oncomposition_type).replay_metadata(of type{bool}): Whether to replay the latest metadata on this source when it is selected in a switch operator. Defaults totrue. The value is looked up at runtime from the active composition profile (source.composition.fileorsource.composition.livedepending oncomposition_type).single(of typebool): Forbid the selection of this source for two consecutive tracks in switch operators. Defaults tofalse.track_sensitive(of type{bool}): Whether this source insists on track boundaries in switch operators: whentrue, 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 hastrack_sensitiveset tofalse; otherwise it waits for the playing source to reach a track boundary. File-based sources default totrue; live network and hardware inputs default tofalse. The value is looked up at runtime from the active composition profile (source.composition.fileorsource.composition.livedepending oncomposition_type).
input.keyboard.sdl
Play notes from the keyboard.
Type:
(?id : string?, ?velocity : float) -> source(midi=midi('a))
Composition:
This source uses live composition by default.
Arguments:
id(of typestring?, which defaults tonull): Force the value of the source ID.velocity(of typefloat, which defaults to0.8): Velocity of notes.
Methods:
buffered(of type() -> [string * float]): Length of buffered data.callbacks_count(of type() -> [string * int]): Callbacks a script has registered on this source, as pairs of callback name and count. A count that keeps growing is a function registering on a source it is handed without releasing what it registered.clear_last_metadata(of type() -> unit): Clear the last metadata from the source.clock(of typeclock): The source's clockduration(of type() -> float): Estimation of the duration of the current track.elapsed(of type() -> float): Elapsed time in the current track.fallible(of typebool): 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 ason_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 ifnew_trackistrue. Whenoverrideisfalse, metadata that the source provides itself takes precedence over the inserted one.is_active(of type() -> bool):trueif the source is active, i.e. it is continuously animated by its own clock whenever it is ready. Typically,truefor outputs and sources such asinput.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 istruewhen the source is currently being used or if it could be used at any time, typically inside aswitchorfallback.last_metadata(of type() -> [string * string]?): Return the last metadata from the source.log(of type{level : (() -> int).{exchange : (int) -> int, set : (int) -> unit}}): Get or set the source's log level, from1to5.register_command(of type(?usage : string?, description : string, string, ((string) -> string)) -> unit): Register a server command for this source. Command is registered under the source's id namespace when it gets up and de-registered when it gets down.remaining(of type() -> float): Estimation of remaining time in the current track.reset_last_metadata_on_track(of type(() -> bool).{exchange : (bool) -> bool, set : (bool) -> unit}): Iftrue, the source'slast_metadatais reset on each new track. If a metadata is present along with the track mark, then it becomes the newlast_metadata, otherwise,last_metadata becomesnull`.seek(of type(float) -> float): Seek forward, in seconds (returns the amount of time effectively seeked).self_sync(of type() -> bool): Is the source currently controlling its own real-time loop.self_sync_description(of type() -> string)skip(of type() -> unit): Skip to the next track.time(of type() -> float): Get a source's time, based on its assigned clock.
Callbacks:
on_collect(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called when source is collectedon_frame(of type(?before : bool, synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler on frame. Whenbeforeistrue, callback is executed before computing the frame and after otherwiseon_frame_checksum(of type(?before : ((string?) -> unit)?, synchronous : bool, ((cache : string?, string) -> unit)) -> {release : () -> unit}): Call a given handler Register callbacks to compute frame checksums for debugging purposes. This is useful to track frame content changes through the streaming pipeline. Thebeforecallback is called before computing the frame with the checksum of the cached frame (if any,nullotherwise). The main callback is called after computing the frame with the checksum of the generated frame and the remaining cache (if any).on_metadata(of type(synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}): Call a given handler to execute on each metadataon_position(of type(position : {float}, ?remaining : bool, ?allow_partial : bool, synchronous : bool, ((float, [string * string]) -> unit)) -> {release : () -> unit}): Call a given handler on track position. Ifremainingisfalse, callback is executed when position in track is more or equal toposition. Ifremainingistrue, callback is executed when remaining time in the current track is less or equal toposition. Keep in mind that elapsed time is exact while remaining time is always estimated. Remaining time is usually more accurate for file-based sources. Whenallow_partialistrue, if the current track ends before theoffsetposition is reached, callback is still executedon_shutdown(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called when source shuts downon_track(of type(synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}): Call a given handler on track markson_wake_up(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called after the source is asked to get ready
Composition methods:
composition_type(of type(() -> string).{exchange : (string) -> string, set : (string) -> unit}): This source uses live composition by default.on_leave(of type({source : source(midi=midi('a)), track_sensitive : bool}) -> unit): Called after switching away from this source in a switch operator, once the transition using the ending source has completed. Receives a record withsource(the source being left) andtrack_sensitive(trueif the ending source's last frame had a track mark, i.e. it finished naturally;falseif it was preempted mid-track). This function must return quickly as it runs in the streaming thread. The default depends on the active composition profile: file sources (source.composition.file) skip the source when preempted mid-track so it starts fresh on its next selection, and do nothing when it finished naturally; live sources (source.composition.live) do nothing.on_select(of type( { ending : source(midi=midi('a))?, replay_metadata : bool, starting : source(midi=midi('a)) }) -> source(midi=midi('a))): Called when selecting this source in a switch operator. Receives a record withstarting(the incoming source) andending(the previous source, ornullwhen the ending source reached a track boundary). Returns the source to use. By default, both file and live profiles fade outendingwhen non-null (up to 1 second). The default is looked up at runtime from the active composition profile (source.composition.fileorsource.composition.livedepending oncomposition_type).replay_metadata(of type{bool}): Whether to replay the latest metadata on this source when it is selected in a switch operator. Defaults totrue. The value is looked up at runtime from the active composition profile (source.composition.fileorsource.composition.livedepending oncomposition_type).single(of typebool): Forbid the selection of this source for two consecutive tracks in switch operators. Defaults tofalse.track_sensitive(of type{bool}): Whether this source insists on track boundaries in switch operators: whentrue, 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 hastrack_sensitiveset tofalse; otherwise it waits for the playing source to reach a track boundary. File-based sources default totrue; live network and hardware inputs default tofalse. The value is looked up at runtime from the active composition profile (source.composition.fileorsource.composition.livedepending oncomposition_type).
This function is experimental.
input.oss
Stream from an OSS input device.
Type:
(?id : string?, ?device : string, ?fallible : bool, ?self_sync : bool,
?start : bool) -> source(audio=pcm('a))
Synchronization:
This source uses the OSS hardware clock as synchronization source when self_sync=true and the device is open.
Composition:
This source uses live composition by default.
Arguments:
id(of typestring?, which defaults tonull): Force the value of the source ID.device(of typestring, which defaults to"/dev/dsp"): OSS device to use.fallible(of typebool, which defaults tofalse): Allow the source to fail. If set tofalse,startmust betrueandstopmethod raises an error.self_sync(of typebool, which defaults totrue): Mark the source as being synchronized by the OSS driver.start(of typebool, which defaults totrue): Start input as soon as it is available.
Methods:
buffered(of type() -> [string * float]): Length of buffered data.callbacks_count(of type() -> [string * int]): Callbacks a script has registered on this source, as pairs of callback name and count. A count that keeps growing is a function registering on a source it is handed without releasing what it registered.clear_last_metadata(of type() -> unit): Clear the last metadata from the source.clock(of typeclock): The source's clockduration(of type() -> float): Estimation of the duration of the current track.elapsed(of type() -> float): Elapsed time in the current track.fallible(of typebool): 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 ason_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 ifnew_trackistrue. Whenoverrideisfalse, metadata that the source provides itself takes precedence over the inserted one.is_active(of type() -> bool):trueif the source is active, i.e. it is continuously animated by its own clock whenever it is ready. Typically,truefor outputs and sources such asinput.http.is_ready(of type() -> bool): Indicate if a source is ready to stream. This does not mean that the source is currently streaming, just that its resources are all properly initialized.is_started(of type() -> bool):trueif the output or source is started.is_up(of type() -> bool): Indicate that the source can be asked to produce some data at any time. This istruewhen the source is currently being used or if it could be used at any time, typically inside aswitchorfallback.last_metadata(of type() -> [string * string]?): Return the last metadata from the source.log(of type{level : (() -> int).{exchange : (int) -> int, set : (int) -> unit}}): Get or set the source's log level, from1to5.register_command(of type(?usage : string?, description : string, string, ((string) -> string)) -> unit): Register a server command for this source. Command is registered under the source's id namespace when it gets up and de-registered when it gets down.remaining(of type() -> float): Estimation of remaining time in the current track.reset_last_metadata_on_track(of type(() -> bool).{exchange : (bool) -> bool, set : (bool) -> unit}): Iftrue, the source'slast_metadatais reset on each new track. If a metadata is present along with the track mark, then it becomes the newlast_metadata, otherwise,last_metadata becomesnull`.seek(of type(float) -> float): Seek forward, in seconds (returns the amount of time effectively seeked).self_sync(of type() -> bool): Is the source currently controlling its own real-time loop.self_sync_description(of type() -> string): This source uses the OSS hardware clock as synchronization source whenself_sync=trueand the device is open.skip(of type() -> unit): Skip to the next track.start(of type() -> unit): Ask the source or output to start.stop(of type() -> unit): Ask the source or output to stop.time(of type() -> float): Get a source's time, based on its assigned clock.
Callbacks:
on_collect(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called when source is collectedon_frame(of type(?before : bool, synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler on frame. Whenbeforeistrue, callback is executed before computing the frame and after otherwiseon_frame_checksum(of type(?before : ((string?) -> unit)?, synchronous : bool, ((cache : string?, string) -> unit)) -> {release : () -> unit}): Call a given handler Register callbacks to compute frame checksums for debugging purposes. This is useful to track frame content changes through the streaming pipeline. Thebeforecallback is called before computing the frame with the checksum of the cached frame (if any,nullotherwise). The main callback is called after computing the frame with the checksum of the generated frame and the remaining cache (if any).on_metadata(of type(synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}): Call a given handler to execute on each metadataon_position(of type(position : {float}, ?remaining : bool, ?allow_partial : bool, synchronous : bool, ((float, [string * string]) -> unit)) -> {release : () -> unit}): Call a given handler on track position. Ifremainingisfalse, callback is executed when position in track is more or equal toposition. Ifremainingistrue, callback is executed when remaining time in the current track is less or equal toposition. Keep in mind that elapsed time is exact while remaining time is always estimated. Remaining time is usually more accurate for file-based sources. Whenallow_partialistrue, if the current track ends before theoffsetposition is reached, callback is still executedon_shutdown(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called when source shuts downon_start(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler when source startson_stop(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler when source stopson_track(of type(synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}): Call a given handler on track markson_wake_up(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called after the source is asked to get ready
Composition methods:
composition_type(of type(() -> string).{exchange : (string) -> string, set : (string) -> unit}): This source uses live composition by default.on_leave(of type({source : source(audio=pcm('a)), track_sensitive : bool}) -> unit): Called after switching away from this source in a switch operator, once the transition using the ending source has completed. Receives a record withsource(the source being left) andtrack_sensitive(trueif the ending source's last frame had a track mark, i.e. it finished naturally;falseif it was preempted mid-track). This function must return quickly as it runs in the streaming thread. The default depends on the active composition profile: file sources (source.composition.file) skip the source when preempted mid-track so it starts fresh on its next selection, and do nothing when it finished naturally; live sources (source.composition.live) do nothing.on_select(of type( { ending : source(audio=pcm('a))?, replay_metadata : bool, starting : source(audio=pcm('a)) }) -> source(audio=pcm('a))): Called when selecting this source in a switch operator. Receives a record withstarting(the incoming source) andending(the previous source, ornullwhen the ending source reached a track boundary). Returns the source to use. By default, both file and live profiles fade outendingwhen non-null (up to 1 second). The default is looked up at runtime from the active composition profile (source.composition.fileorsource.composition.livedepending oncomposition_type).replay_metadata(of type{bool}): Whether to replay the latest metadata on this source when it is selected in a switch operator. Defaults totrue. The value is looked up at runtime from the active composition profile (source.composition.fileorsource.composition.livedepending oncomposition_type).single(of typebool): Forbid the selection of this source for two consecutive tracks in switch operators. Defaults tofalse.track_sensitive(of type{bool}): Whether this source insists on track boundaries in switch operators: whentrue, 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 hastrack_sensitiveset tofalse; otherwise it waits for the playing source to reach a track boundary. File-based sources default totrue; live network and hardware inputs default tofalse. The value is looked up at runtime from the active composition profile (source.composition.fileorsource.composition.livedepending oncomposition_type).
input.portaudio
Stream from a portaudio input device.
Type:
(?id : string?, ?buflen : int, ?device_id : int?, ?device_name : string?,
?fallible : bool, ?latency : float?, ?self_sync : bool, ?start : bool) ->
source(audio=pcm('a))
Synchronization:
This source uses the PortAudio clock as synchronization source when self_sync=true and the stream is open.
Composition:
This source uses live composition by default.
Arguments:
id(of typestring?, which defaults tonull): Force the value of the source ID.buflen(of typeint, which defaults to256): Length of a buffer in samples.device_id(of typeint?, which defaults tonull): Device ID. Uses default device ifnull.device_name(of typestring?, which defaults tonull): Device name.fallible(of typebool, which defaults tofalse): Allow the source to fail. If set tofalse,startmust betrueandstopmethod raises an error.latency(of typefloat?, which defaults tonull): Device latency. Only used when specifying device ID.self_sync(of typebool, which defaults totrue): Mark the source as being synchronized by the portaudio driver.start(of typebool, which defaults totrue): Start input as soon as it is available.
Methods:
buffered(of type() -> [string * float]): Length of buffered data.callbacks_count(of type() -> [string * int]): Callbacks a script has registered on this source, as pairs of callback name and count. A count that keeps growing is a function registering on a source it is handed without releasing what it registered.clear_last_metadata(of type() -> unit): Clear the last metadata from the source.clock(of typeclock): The source's clockduration(of type() -> float): Estimation of the duration of the current track.elapsed(of type() -> float): Elapsed time in the current track.fallible(of typebool): 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 ason_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 ifnew_trackistrue. Whenoverrideisfalse, metadata that the source provides itself takes precedence over the inserted one.is_active(of type() -> bool):trueif the source is active, i.e. it is continuously animated by its own clock whenever it is ready. Typically,truefor outputs and sources such asinput.http.is_ready(of type() -> bool): Indicate if a source is ready to stream. This does not mean that the source is currently streaming, just that its resources are all properly initialized.is_started(of type() -> bool):trueif the output or source is started.is_up(of type() -> bool): Indicate that the source can be asked to produce some data at any time. This istruewhen the source is currently being used or if it could be used at any time, typically inside aswitchorfallback.last_metadata(of type() -> [string * string]?): Return the last metadata from the source.log(of type{level : (() -> int).{exchange : (int) -> int, set : (int) -> unit}}): Get or set the source's log level, from1to5.register_command(of type(?usage : string?, description : string, string, ((string) -> string)) -> unit): Register a server command for this source. Command is registered under the source's id namespace when it gets up and de-registered when it gets down.remaining(of type() -> float): Estimation of remaining time in the current track.reset_last_metadata_on_track(of type(() -> bool).{exchange : (bool) -> bool, set : (bool) -> unit}): Iftrue, the source'slast_metadatais reset on each new track. If a metadata is present along with the track mark, then it becomes the newlast_metadata, otherwise,last_metadata becomesnull`.seek(of type(float) -> float): Seek forward, in seconds (returns the amount of time effectively seeked).self_sync(of type() -> bool): Is the source currently controlling its own real-time loop.self_sync_description(of type() -> string): This source uses the PortAudio clock as synchronization source whenself_sync=trueand the stream is open.skip(of type() -> unit): Skip to the next track.start(of type() -> unit): Ask the source or output to start.stop(of type() -> unit): Ask the source or output to stop.time(of type() -> float): Get a source's time, based on its assigned clock.
Callbacks:
on_collect(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called when source is collectedon_frame(of type(?before : bool, synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler on frame. Whenbeforeistrue, callback is executed before computing the frame and after otherwiseon_frame_checksum(of type(?before : ((string?) -> unit)?, synchronous : bool, ((cache : string?, string) -> unit)) -> {release : () -> unit}): Call a given handler Register callbacks to compute frame checksums for debugging purposes. This is useful to track frame content changes through the streaming pipeline. Thebeforecallback is called before computing the frame with the checksum of the cached frame (if any,nullotherwise). The main callback is called after computing the frame with the checksum of the generated frame and the remaining cache (if any).on_metadata(of type(synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}): Call a given handler to execute on each metadataon_position(of type(position : {float}, ?remaining : bool, ?allow_partial : bool, synchronous : bool, ((float, [string * string]) -> unit)) -> {release : () -> unit}): Call a given handler on track position. Ifremainingisfalse, callback is executed when position in track is more or equal toposition. Ifremainingistrue, callback is executed when remaining time in the current track is less or equal toposition. Keep in mind that elapsed time is exact while remaining time is always estimated. Remaining time is usually more accurate for file-based sources. Whenallow_partialistrue, if the current track ends before theoffsetposition is reached, callback is still executedon_shutdown(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called when source shuts downon_start(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler when source startson_stop(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler when source stopson_track(of type(synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}): Call a given handler on track markson_wake_up(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called after the source is asked to get ready
Composition methods:
composition_type(of type(() -> string).{exchange : (string) -> string, set : (string) -> unit}): This source uses live composition by default.on_leave(of type({source : source(audio=pcm('a)), track_sensitive : bool}) -> unit): Called after switching away from this source in a switch operator, once the transition using the ending source has completed. Receives a record withsource(the source being left) andtrack_sensitive(trueif the ending source's last frame had a track mark, i.e. it finished naturally;falseif it was preempted mid-track). This function must return quickly as it runs in the streaming thread. The default depends on the active composition profile: file sources (source.composition.file) skip the source when preempted mid-track so it starts fresh on its next selection, and do nothing when it finished naturally; live sources (source.composition.live) do nothing.on_select(of type( { ending : source(audio=pcm('a))?, replay_metadata : bool, starting : source(audio=pcm('a)) }) -> source(audio=pcm('a))): Called when selecting this source in a switch operator. Receives a record withstarting(the incoming source) andending(the previous source, ornullwhen the ending source reached a track boundary). Returns the source to use. By default, both file and live profiles fade outendingwhen non-null (up to 1 second). The default is looked up at runtime from the active composition profile (source.composition.fileorsource.composition.livedepending oncomposition_type).replay_metadata(of type{bool}): Whether to replay the latest metadata on this source when it is selected in a switch operator. Defaults totrue. The value is looked up at runtime from the active composition profile (source.composition.fileorsource.composition.livedepending oncomposition_type).single(of typebool): Forbid the selection of this source for two consecutive tracks in switch operators. Defaults tofalse.track_sensitive(of type{bool}): Whether this source insists on track boundaries in switch operators: whentrue, 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 hastrack_sensitiveset tofalse; otherwise it waits for the playing source to reach a track boundary. File-based sources default totrue; live network and hardware inputs default tofalse. The value is looked up at runtime from the active composition profile (source.composition.fileorsource.composition.livedepending oncomposition_type).
input.pulseaudio
Stream from a pulseaudio input device.
Type:
(?id : string?, ?client : string, ?device : string?, ?fallible : bool,
?on_error : ((string) -> unit), ?retry_delay : float, ?self_sync : bool,
?start : bool) -> source(audio=pcm('a))
Synchronization:
This source uses the PulseAudio clock as synchronization source when self_sync=true and the stream is open.
Composition:
This source uses live composition by default.
Arguments:
id(of typestring?, which defaults tonull): Force the value of the source ID.client(of typestring, which defaults to"liquidsoap")device(of typestring?, which defaults tonull): Device to use. Uses default if set tonull.fallible(of typebool, which defaults totrue): Allow the source to fail. If set tofalse,startmust betrueandstopmethod raises an error.on_error(of type(string) -> unit, which defaults tofun (_) -> ()): Function executed when an operation with the pulseaudio server returns an error.retry_delay(of typefloat, which defaults to1.0): When fallible, time to wait before trying to connect again.self_sync(of typebool, which defaults totrue): Use the PulseAudio clock as synchronization source. Whenfalse, delegate to the underlying source's synchronization.start(of typebool, which defaults totrue): Start input as soon as it is available.
Methods:
buffered(of type() -> [string * float]): Length of buffered data.callbacks_count(of type() -> [string * int]): Callbacks a script has registered on this source, as pairs of callback name and count. A count that keeps growing is a function registering on a source it is handed without releasing what it registered.clear_last_metadata(of type() -> unit): Clear the last metadata from the source.clock(of typeclock): The source's clockduration(of type() -> float): Estimation of the duration of the current track.elapsed(of type() -> float): Elapsed time in the current track.fallible(of typebool): 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 ason_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 ifnew_trackistrue. Whenoverrideisfalse, metadata that the source provides itself takes precedence over the inserted one.is_active(of type() -> bool):trueif the source is active, i.e. it is continuously animated by its own clock whenever it is ready. Typically,truefor outputs and sources such asinput.http.is_ready(of type() -> bool): Indicate if a source is ready to stream. This does not mean that the source is currently streaming, just that its resources are all properly initialized.is_started(of type() -> bool):trueif the output or source is started.is_up(of type() -> bool): Indicate that the source can be asked to produce some data at any time. This istruewhen the source is currently being used or if it could be used at any time, typically inside aswitchorfallback.last_metadata(of type() -> [string * string]?): Return the last metadata from the source.log(of type{level : (() -> int).{exchange : (int) -> int, set : (int) -> unit}}): Get or set the source's log level, from1to5.register_command(of type(?usage : string?, description : string, string, ((string) -> string)) -> unit): Register a server command for this source. Command is registered under the source's id namespace when it gets up and de-registered when it gets down.remaining(of type() -> float): Estimation of remaining time in the current track.reset_last_metadata_on_track(of type(() -> bool).{exchange : (bool) -> bool, set : (bool) -> unit}): Iftrue, the source'slast_metadatais reset on each new track. If a metadata is present along with the track mark, then it becomes the newlast_metadata, otherwise,last_metadata becomesnull`.seek(of type(float) -> float): Seek forward, in seconds (returns the amount of time effectively seeked).self_sync(of type() -> bool): Is the source currently controlling its own real-time loop.self_sync_description(of type() -> string): This source uses the PulseAudio clock as synchronization source whenself_sync=trueand the stream is open.skip(of type() -> unit): Skip to the next track.start(of type() -> unit): Ask the source or output to start.stop(of type() -> unit): Ask the source or output to stop.time(of type() -> float): Get a source's time, based on its assigned clock.
Callbacks:
on_collect(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called when source is collectedon_frame(of type(?before : bool, synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler on frame. Whenbeforeistrue, callback is executed before computing the frame and after otherwiseon_frame_checksum(of type(?before : ((string?) -> unit)?, synchronous : bool, ((cache : string?, string) -> unit)) -> {release : () -> unit}): Call a given handler Register callbacks to compute frame checksums for debugging purposes. This is useful to track frame content changes through the streaming pipeline. Thebeforecallback is called before computing the frame with the checksum of the cached frame (if any,nullotherwise). The main callback is called after computing the frame with the checksum of the generated frame and the remaining cache (if any).on_metadata(of type(synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}): Call a given handler to execute on each metadataon_position(of type(position : {float}, ?remaining : bool, ?allow_partial : bool, synchronous : bool, ((float, [string * string]) -> unit)) -> {release : () -> unit}): Call a given handler on track position. Ifremainingisfalse, callback is executed when position in track is more or equal toposition. Ifremainingistrue, callback is executed when remaining time in the current track is less or equal toposition. Keep in mind that elapsed time is exact while remaining time is always estimated. Remaining time is usually more accurate for file-based sources. Whenallow_partialistrue, if the current track ends before theoffsetposition is reached, callback is still executedon_shutdown(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called when source shuts downon_start(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler when source startson_stop(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler when source stopson_track(of type(synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}): Call a given handler on track markson_wake_up(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called after the source is asked to get ready
Composition methods:
composition_type(of type(() -> string).{exchange : (string) -> string, set : (string) -> unit}): This source uses live composition by default.on_leave(of type({source : source(audio=pcm('a)), track_sensitive : bool}) -> unit): Called after switching away from this source in a switch operator, once the transition using the ending source has completed. Receives a record withsource(the source being left) andtrack_sensitive(trueif the ending source's last frame had a track mark, i.e. it finished naturally;falseif it was preempted mid-track). This function must return quickly as it runs in the streaming thread. The default depends on the active composition profile: file sources (source.composition.file) skip the source when preempted mid-track so it starts fresh on its next selection, and do nothing when it finished naturally; live sources (source.composition.live) do nothing.on_select(of type( { ending : source(audio=pcm('a))?, replay_metadata : bool, starting : source(audio=pcm('a)) }) -> source(audio=pcm('a))): Called when selecting this source in a switch operator. Receives a record withstarting(the incoming source) andending(the previous source, ornullwhen the ending source reached a track boundary). Returns the source to use. By default, both file and live profiles fade outendingwhen non-null (up to 1 second). The default is looked up at runtime from the active composition profile (source.composition.fileorsource.composition.livedepending oncomposition_type).replay_metadata(of type{bool}): Whether to replay the latest metadata on this source when it is selected in a switch operator. Defaults totrue. The value is looked up at runtime from the active composition profile (source.composition.fileorsource.composition.livedepending oncomposition_type).single(of typebool): Forbid the selection of this source for two consecutive tracks in switch operators. Defaults tofalse.track_sensitive(of type{bool}): Whether this source insists on track boundaries in switch operators: whentrue, 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 hastrack_sensitiveset tofalse; otherwise it waits for the playing source to reach a track boundary. File-based sources default totrue; live network and hardware inputs default tofalse. The value is looked up at runtime from the active composition profile (source.composition.fileorsource.composition.livedepending oncomposition_type).
input.rtmp
Read an RTMP stream with FFmpeg, by default as a server waiting for a publisher.
Type:
(?id : string?, ?max_buffer : float, ?listen : bool, {string}) -> source('a)
Synchronization:
This source paces its clock while connected when self_sync is true.
Composition:
This source uses live composition by default.
Arguments:
id(of typestring?, which defaults tonull): Force the value of the source ID.max_buffer(of typefloat, which defaults to5.0): Maximum data buffered, in seconds.listen(of typebool, which defaults totrue): Wait for a publisher instead of connecting to a server.(unlabeled)(of type{string}): RTMP URL, e.g.rtmp://0.0.0.0:1935/live/stream.
Methods:
buffered(of type() -> [string * float]): Length of buffered data.callbacks_count(of type() -> [string * int]): Callbacks a script has registered on this source, as pairs of callback name and count. A count that keeps growing is a function registering on a source it is handed without releasing what it registered.clear_last_metadata(of type() -> unit): Clear the last metadata from the source.clock(of typeclock): The source's clockduration(of type() -> float): Estimation of the duration of the current track.elapsed(of type() -> float): Elapsed time in the current track.fallible(of typebool): 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 ason_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 ifnew_trackistrue. Whenoverrideisfalse, metadata that the source provides itself takes precedence over the inserted one.is_active(of type() -> bool):trueif the source is active, i.e. it is continuously animated by its own clock whenever it is ready. Typically,truefor outputs and sources such asinput.http.is_ready(of type() -> bool): Indicate if a source is ready to stream. This does not mean that the source is currently streaming, just that its resources are all properly initialized.is_started(of type() -> bool):trueif the output or source is started.is_up(of type() -> bool): Indicate that the source can be asked to produce some data at any time. This istruewhen the source is currently being used or if it could be used at any time, typically inside aswitchorfallback.last_metadata(of type() -> [string * string]?): Return the last metadata from the source.log(of type{level : (() -> int).{exchange : (int) -> int, set : (int) -> unit}}): Get or set the source's log level, from1to5.register_command(of type(?usage : string?, description : string, string, ((string) -> string)) -> unit): Register a server command for this source. Command is registered under the source's id namespace when it gets up and de-registered when it gets down.remaining(of type() -> float): Estimation of remaining time in the current track.reset_last_metadata_on_track(of type(() -> bool).{exchange : (bool) -> bool, set : (bool) -> unit}): Iftrue, the source'slast_metadatais reset on each new track. If a metadata is present along with the track mark, then it becomes the newlast_metadata, otherwise,last_metadata becomesnull`.seek(of type(float) -> float): Seek forward, in seconds (returns the amount of time effectively seeked).self_sync(of type() -> bool): Is the source currently controlling its own real-time loop.self_sync_description(of type() -> string): This source paces its clock while connected whenself_syncis true.set_url(of type({string}) -> unit): Set the URL, used at the next connection.skip(of type() -> unit): Skip to the next track.start(of type() -> unit): Ask the source or output to start.status(of type() -> string): Status:"stopped","starting","polling","connected <url>","stopping"or"failed".stop(of type() -> unit): Ask the source or output to stop.time(of type() -> float): Get a source's time, based on its assigned clock.url(of type() -> string): Current URL.
Callbacks:
on_collect(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called when source is collectedon_connect(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler when connected, before the source plays the connection's data.on_disconnect(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler when a connection whoseon_connectcallbacks ran ends.on_error(of type(synchronous : bool, ((error) -> unit)) -> {release : () -> unit}): Call a given handler on each connection or feeding failure.on_frame(of type(?before : bool, synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler on frame. Whenbeforeistrue, callback is executed before computing the frame and after otherwiseon_frame_checksum(of type(?before : ((string?) -> unit)?, synchronous : bool, ((cache : string?, string) -> unit)) -> {release : () -> unit}): Call a given handler Register callbacks to compute frame checksums for debugging purposes. This is useful to track frame content changes through the streaming pipeline. Thebeforecallback is called before computing the frame with the checksum of the cached frame (if any,nullotherwise). The main callback is called after computing the frame with the checksum of the generated frame and the remaining cache (if any).on_metadata(of type(synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}): Call a given handler to execute on each metadataon_position(of type(position : {float}, ?remaining : bool, ?allow_partial : bool, synchronous : bool, ((float, [string * string]) -> unit)) -> {release : () -> unit}): Call a given handler on track position. Ifremainingisfalse, callback is executed when position in track is more or equal toposition. Ifremainingistrue, callback is executed when remaining time in the current track is less or equal toposition. Keep in mind that elapsed time is exact while remaining time is always estimated. Remaining time is usually more accurate for file-based sources. Whenallow_partialistrue, if the current track ends before theoffsetposition is reached, callback is still executedon_shutdown(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called when source shuts downon_start(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler when source startson_stop(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler when source stopson_track(of type(synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}): Call a given handler on track markson_wake_up(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called after the source is asked to get ready
Composition methods:
composition_type(of type(() -> string).{exchange : (string) -> string, set : (string) -> unit}): This source uses live composition by default.on_leave(of type({source : source('a), track_sensitive : bool}) -> unit): Called after switching away from this source in a switch operator, once the transition using the ending source has completed. Receives a record withsource(the source being left) andtrack_sensitive(trueif the ending source's last frame had a track mark, i.e. it finished naturally;falseif 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 withstarting(the incoming source) andending(the previous source, ornullwhen the ending source reached a track boundary). Returns the source to use. By default, both file and live profiles fade outendingwhen non-null (up to 1 second). The default is looked up at runtime from the active composition profile (source.composition.fileorsource.composition.livedepending oncomposition_type).replay_metadata(of type{bool}): Whether to replay the latest metadata on this source when it is selected in a switch operator. Defaults totrue. The value is looked up at runtime from the active composition profile (source.composition.fileorsource.composition.livedepending oncomposition_type).single(of typebool): Forbid the selection of this source for two consecutive tracks in switch operators. Defaults tofalse.track_sensitive(of type{bool}): Whether this source insists on track boundaries in switch operators: whentrue, 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 hastrack_sensitiveset tofalse; otherwise it waits for the playing source to reach a track boundary. File-based sources default totrue; live network and hardware inputs default tofalse. The value is looked up at runtime from the active composition profile (source.composition.fileorsource.composition.livedepending oncomposition_type).
input.srt
Receive a SRT stream, as a listener or as a caller.
Type:
(?id : string?, ?bind_address : string, ?connection_timeout : float?,
?content_type : string, ?dump : string, ?enforced_encryption : bool?,
?host : string, ?ipv6only : bool?,
?listen_callback : ((hs_version : int, peeraddr : string,
streamid : string?, srt_socket
.{
bistats : (?clear : bool?, ?instantaneous : bool?) ->
{
byteAvailRcvBuf : int,
byteAvailSndBuf : int,
byteMSS : int,
byteRcvBuf : int,
byteRcvDrop : int,
byteRcvDropTotal : int,
byteRcvUndecrypt : int,
byteRcvUndecryptTotal : int,
byteRecv : int,
byteRecvTotal : int,
byteRetrans : int,
byteRetransTotal : int,
byteSent : int,
byteSentTotal : int,
byteSndBuf : int,
byteSndDrop : int,
byteSndDropTotal : int,
mbpsBandwidth : float,
mbpsMaxBW : float,
mbpsRecvRate : float,
mbpsSendRate : float,
msRTT : float,
msRcvBuf : int,
msRcvTsbPdDelay : int,
msSndBuf : int,
msSndTsbPdDelay : int,
msTimeStamp : int,
pktCongestionWindow : int,
pktFlightSize : int,
pktFlowWindow : int,
pktRcvAvgBelatedTime : float,
pktRcvBelated : int,
pktRcvBuf : int,
pktRcvDrop : int,
pktRcvDropTotal : int,
pktRcvFilterExtra : int,
pktRcvFilterExtraTotal : int,
pktRcvFilterLoss : int,
pktRcvFilterLossTotal : int,
pktRcvFilterSupply : int,
pktRcvFilterSupplyTotal : int,
pktRcvLoss : int,
pktRcvLossTotal : int,
pktRcvRetrans : int,
pktRcvUndecrypt : int,
pktRcvUndecryptTotal : int,
pktRecv : int,
pktRecvACK : int,
pktRecvACKTotal : int,
pktRecvNAK : int,
pktRecvNAKTotal : int,
pktRecvTotal : int,
pktReorderDistance : int,
pktRetrans : int,
pktRetransTotal : int,
pktSent : int,
pktSentACK : int,
pktSentACKTotal : int,
pktSentNAK : int,
pktSentNAKTotal : int,
pktSentTotal : int,
pktSndBuf : int,
pktSndDrop : int,
pktSndDropTotal : int,
pktSndFilterExtra : int,
pktSndFilterExtraTotal : int,
pktSndLoss : int,
pktSndLossTotal : int,
usPktSndPeriod : float,
usSndDuration : int,
usSndDurationTotal : int},
bstats : (?clear : bool?) ->
{
byteAvailRcvBuf : int,
byteAvailSndBuf : int,
byteMSS : int,
byteRcvBuf : int,
byteRcvDrop : int,
byteRcvDropTotal : int,
byteRcvUndecrypt : int,
byteRcvUndecryptTotal : int,
byteRecv : int,
byteRecvTotal : int,
byteRetrans : int,
byteRetransTotal : int,
byteSent : int,
byteSentTotal : int,
byteSndBuf : int,
byteSndDrop : int,
byteSndDropTotal : int,
mbpsBandwidth : float,
mbpsMaxBW : float,
mbpsRecvRate : float,
mbpsSendRate : float,
msRTT : float,
msRcvBuf : int,
msRcvTsbPdDelay : int,
msSndBuf : int,
msSndTsbPdDelay : int,
msTimeStamp : int,
pktCongestionWindow : int,
pktFlightSize : int,
pktFlowWindow : int,
pktRcvAvgBelatedTime : float,
pktRcvBelated : int,
pktRcvBuf : int,
pktRcvDrop : int,
pktRcvDropTotal : int,
pktRcvFilterExtra : int,
pktRcvFilterExtraTotal : int,
pktRcvFilterLoss : int,
pktRcvFilterLossTotal : int,
pktRcvFilterSupply : int,
pktRcvFilterSupplyTotal : int,
pktRcvLoss : int,
pktRcvLossTotal : int,
pktRcvRetrans : int,
pktRcvUndecrypt : int,
pktRcvUndecryptTotal : int,
pktRecv : int,
pktRecvACK : int,
pktRecvACKTotal : int,
pktRecvNAK : int,
pktRecvNAKTotal : int,
pktRecvTotal : int,
pktReorderDistance : int,
pktRetrans : int,
pktRetransTotal : int,
pktSent : int,
pktSentACK : int,
pktSentACKTotal : int,
pktSentNAK : int,
pktSentNAKTotal : int,
pktSentTotal : int,
pktSndBuf : int,
pktSndDrop : int,
pktSndDropTotal : int,
pktSndFilterExtra : int,
pktSndFilterExtraTotal : int,
pktSndLoss : int,
pktSndLossTotal : int,
usPktSndPeriod : float,
usSndDuration : int,
usSndDurationTotal : int},
close : () -> unit,
id : int,
ipv6only : () -> bool,
latency : () -> int,
pbkeylen : () -> int,
peerlatency : () -> int,
rcvbuf : () -> int,
rcvdata : () -> int,
rcvlatency : () -> int,
rcvsyn : () -> bool,
rcvtimeout : () -> int,
reuseaddr : () -> bool,
set_conntimeo : (int) -> unit,
set_enforced_encryption : (bool) -> unit,
set_ipv6only : (bool) -> unit,
set_latency : (int) -> unit,
set_messageapi : (bool) -> unit,
set_passphrase : (string) -> unit,
set_payloadsize : (int) -> unit,
set_pbkeylen : (int) -> unit,
set_peerlatency : (int) -> unit,
set_rcvbuf : (int) -> unit,
set_rcvlatency : (int) -> unit,
set_rcvsyn : (bool) -> unit,
set_rcvtimeout : (int) -> unit,
set_reuseaddr : (bool) -> unit,
set_sndbuf : (int) -> unit,
set_sndsyn : (bool) -> unit,
set_sndtimeout : (int) -> unit,
set_streamid : (string) -> unit,
set_tsbpdmode : (bool) -> unit,
set_udp_rcvbuf : (int) -> unit,
set_udp_sndbuf : (int) -> unit,
sndbuf : () -> int,
sndsyn : () -> bool,
sndtimeout : () -> int,
status : () -> string,
streamid : () -> string,
tsbpdmode : () -> bool,
udp_rcvbuf : () -> int,
udp_sndbuf : () -> int
}) -> bool)?,
?max : float, ?messageapi : bool, ?mode : string, ?passphrase : string?,
?payload_size : int, ?pbkeylen : int?, ?polling_delay : float, ?port : int,
?prefer_address : string?, ?read_timeout : float?, ?self_sync : bool,
?start : bool, ?streamid : string?, ?write_timeout : float?) -> source('a)
Composition:
This source uses live composition by default.
Arguments:
id(of typestring?, which defaults tonull): Force the value of the source ID.bind_address(of typestring, which defaults to"0.0.0.0"): Local address to bind. Used only in listener mode.connection_timeout(of typefloat?, which defaults tonull): Connection timeout, in seconds.nullkeeps libsrt's default. Used only in caller mode.content_type(of typestring, which defaults to"application/ffmpeg"): MIME type used to find a stream decoder.dump(of typestring, which defaults to""): File receiving a copy of the received bytes;""for none.enforced_encryption(of typebool?, which defaults tonull): Refuse connections whose encryption does not match. Defaults tosettings.srt.enforced_encryptionwhennull.host(of typestring, which defaults to"localhost"): Address to connect to. Used only in caller mode.ipv6only(of typebool?, which defaults tonull): Accept only IPv6 connections. Defaults totruewhen the bind address is IPv6. Used only in listener mode.listen_callback(of type((hs_version : int, peeraddr : string, streamid : string?, srt_socket .{ bistats : (?clear : bool?, ?instantaneous : bool?) -> { byteAvailRcvBuf : int, byteAvailSndBuf : int, byteMSS : int, byteRcvBuf : int, byteRcvDrop : int, byteRcvDropTotal : int, byteRcvUndecrypt : int, byteRcvUndecryptTotal : int, byteRecv : int, byteRecvTotal : int, byteRetrans : int, byteRetransTotal : int, byteSent : int, byteSentTotal : int, byteSndBuf : int, byteSndDrop : int, byteSndDropTotal : int, mbpsBandwidth : float, mbpsMaxBW : float, mbpsRecvRate : float, mbpsSendRate : float, msRTT : float, msRcvBuf : int, msRcvTsbPdDelay : int, msSndBuf : int, msSndTsbPdDelay : int, msTimeStamp : int, pktCongestionWindow : int, pktFlightSize : int, pktFlowWindow : int, pktRcvAvgBelatedTime : float, pktRcvBelated : int, pktRcvBuf : int, pktRcvDrop : int, pktRcvDropTotal : int, pktRcvFilterExtra : int, pktRcvFilterExtraTotal : int, pktRcvFilterLoss : int, pktRcvFilterLossTotal : int, pktRcvFilterSupply : int, pktRcvFilterSupplyTotal : int, pktRcvLoss : int, pktRcvLossTotal : int, pktRcvRetrans : int, pktRcvUndecrypt : int, pktRcvUndecryptTotal : int, pktRecv : int, pktRecvACK : int, pktRecvACKTotal : int, pktRecvNAK : int, pktRecvNAKTotal : int, pktRecvTotal : int, pktReorderDistance : int, pktRetrans : int, pktRetransTotal : int, pktSent : int, pktSentACK : int, pktSentACKTotal : int, pktSentNAK : int, pktSentNAKTotal : int, pktSentTotal : int, pktSndBuf : int, pktSndDrop : int, pktSndDropTotal : int, pktSndFilterExtra : int, pktSndFilterExtraTotal : int, pktSndLoss : int, pktSndLossTotal : int, usPktSndPeriod : float, usSndDuration : int, usSndDurationTotal : int}, bstats : (?clear : bool?) -> { byteAvailRcvBuf : int, byteAvailSndBuf : int, byteMSS : int, byteRcvBuf : int, byteRcvDrop : int, byteRcvDropTotal : int, byteRcvUndecrypt : int, byteRcvUndecryptTotal : int, byteRecv : int, byteRecvTotal : int, byteRetrans : int, byteRetransTotal : int, byteSent : int, byteSentTotal : int, byteSndBuf : int, byteSndDrop : int, byteSndDropTotal : int, mbpsBandwidth : float, mbpsMaxBW : float, mbpsRecvRate : float, mbpsSendRate : float, msRTT : float, msRcvBuf : int, msRcvTsbPdDelay : int, msSndBuf : int, msSndTsbPdDelay : int, msTimeStamp : int, pktCongestionWindow : int, pktFlightSize : int, pktFlowWindow : int, pktRcvAvgBelatedTime : float, pktRcvBelated : int, pktRcvBuf : int, pktRcvDrop : int, pktRcvDropTotal : int, pktRcvFilterExtra : int, pktRcvFilterExtraTotal : int, pktRcvFilterLoss : int, pktRcvFilterLossTotal : int, pktRcvFilterSupply : int, pktRcvFilterSupplyTotal : int, pktRcvLoss : int, pktRcvLossTotal : int, pktRcvRetrans : int, pktRcvUndecrypt : int, pktRcvUndecryptTotal : int, pktRecv : int, pktRecvACK : int, pktRecvACKTotal : int, pktRecvNAK : int, pktRecvNAKTotal : int, pktRecvTotal : int, pktReorderDistance : int, pktRetrans : int, pktRetransTotal : int, pktSent : int, pktSentACK : int, pktSentACKTotal : int, pktSentNAK : int, pktSentNAKTotal : int, pktSentTotal : int, pktSndBuf : int, pktSndDrop : int, pktSndDropTotal : int, pktSndFilterExtra : int, pktSndFilterExtraTotal : int, pktSndLoss : int, pktSndLossTotal : int, usPktSndPeriod : float, usSndDuration : int, usSndDurationTotal : int}, close : () -> unit, id : int, ipv6only : () -> bool, latency : () -> int, pbkeylen : () -> int, peerlatency : () -> int, rcvbuf : () -> int, rcvdata : () -> int, rcvlatency : () -> int, rcvsyn : () -> bool, rcvtimeout : () -> int, reuseaddr : () -> bool, set_conntimeo : (int) -> unit, set_enforced_encryption : (bool) -> unit, set_ipv6only : (bool) -> unit, set_latency : (int) -> unit, set_messageapi : (bool) -> unit, set_passphrase : (string) -> unit, set_payloadsize : (int) -> unit, set_pbkeylen : (int) -> unit, set_peerlatency : (int) -> unit, set_rcvbuf : (int) -> unit, set_rcvlatency : (int) -> unit, set_rcvsyn : (bool) -> unit, set_rcvtimeout : (int) -> unit, set_reuseaddr : (bool) -> unit, set_sndbuf : (int) -> unit, set_sndsyn : (bool) -> unit, set_sndtimeout : (int) -> unit, set_streamid : (string) -> unit, set_tsbpdmode : (bool) -> unit, set_udp_rcvbuf : (int) -> unit, set_udp_sndbuf : (int) -> unit, sndbuf : () -> int, sndsyn : () -> bool, sndtimeout : () -> int, status : () -> string, streamid : () -> string, tsbpdmode : () -> bool, udp_rcvbuf : () -> int, udp_sndbuf : () -> int }) -> bool)?, which defaults tonull): Admission predicate called during each handshake with the handshake version, the peer's address, its stream id and the new socket: a connection is admitted when it returnstrue. Used only in listener mode. It runs on libsrt's single handshake thread: a slow callback delays every handshake of the process.max(of typefloat, which defaults to10.0): Maximum duration of the buffered data, in seconds.messageapi(of typebool, which defaults totrue): libsrt message API flag. Live mode requirestrue.mode(of typestring, which defaults to"listener"): Connection mode. One of:"listener"or"caller".passphrase(of typestring?, which defaults tonull): Encryption passphrase, 10 to 79 characters.nullor""means no encryption.payload_size(of typeint, which defaults to1316): libsrt payload size, and the size of every message an output sends.pbkeylen(of typeint?, which defaults tonull): Encryption key length. One of: 0 (libsrt's default), 16, 24 or 32.polling_delay(of typefloat, which defaults to2.0): Delay, in seconds, between two tries after a failure.port(of typeint, which defaults to8000): Port to bind in listener mode, or to connect to in caller mode.prefer_address(of typestring?, which defaults tonull): Address family used when resolving hostnames. One of:"system","ipv4"or"ipv6". Defaults tosettings.srt.prefer_addresswhennull.read_timeout(of typefloat?, which defaults to1.0): Longest wait for data, in seconds, while the input paces its clock.nullmeans no limit. Used only by inputs.self_sync(of typebool, which defaults totrue): Pace the clock while a connected stream is delivered by sender timestamps.start(of typebool, which defaults totrue): Start input as soon as it is available.streamid(of typestring?, which defaults tonull): Stream id sent in the handshake. Used only in caller mode.write_timeout(of typefloat?, which defaults to1.0): Longest time, in seconds, a peer may accept no data before it is dropped.nullmeans no limit. Used only by outputs.
Methods:
buffered(of type() -> [string * float]): Length of buffered data.callbacks_count(of type() -> [string * int]): Callbacks a script has registered on this source, as pairs of callback name and count. A count that keeps growing is a function registering on a source it is handed without releasing what it registered.clear_last_metadata(of type() -> unit): Clear the last metadata from the source.clock(of typeclock): The source's clockconnect(of type() -> unit): Connect, or listen, when started.disconnect(of type() -> unit): Disconnect every peer and stop connecting untilconnect.duration(of type() -> float): Estimation of the duration of the current track.elapsed(of type() -> float): Elapsed time in the current track.fallible(of typebool): 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 ason_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 ifnew_trackistrue. Whenoverrideisfalse, metadata that the source provides itself takes precedence over the inserted one.is_active(of type() -> bool):trueif the source is active, i.e. it is continuously animated by its own clock whenever it is ready. Typically,truefor outputs and sources such asinput.http.is_ready(of type() -> bool): Indicate if a source is ready to stream. This does not mean that the source is currently streaming, just that its resources are all properly initialized.is_started(of type() -> bool):trueif the output or source is started.is_up(of type() -> bool): Indicate that the source can be asked to produce some data at any time. This istruewhen the source is currently being used or if it could be used at any time, typically inside aswitchorfallback.last_metadata(of type() -> [string * string]?): Return the last metadata from the source.log(of type{level : (() -> int).{exchange : (int) -> int, set : (int) -> unit}}): Get or set the source's log level, from1to5.register_command(of type(?usage : string?, description : string, string, ((string) -> string)) -> unit): Register a server command for this source. Command is registered under the source's id namespace when it gets up and de-registered when it gets down.remaining(of type() -> float): Estimation of remaining time in the current track.reset_last_metadata_on_track(of type(() -> bool).{exchange : (bool) -> bool, set : (bool) -> unit}): Iftrue, the source'slast_metadatais reset on each new track. If a metadata is present along with the track mark, then it becomes the newlast_metadata, otherwise,last_metadata becomesnull`.seek(of type(float) -> float): Seek forward, in seconds (returns the amount of time effectively seeked).self_sync(of type() -> bool): Is the source currently controlling its own real-time loop.self_sync_description(of type() -> string)skip(of type() -> unit): Skip to the next track.sockets(of type() -> [string * srt_socket .{ bistats : (?clear : bool?, ?instantaneous : bool?) -> { byteAvailRcvBuf : int, byteAvailSndBuf : int, byteMSS : int, byteRcvBuf : int, byteRcvDrop : int, byteRcvDropTotal : int, byteRcvUndecrypt : int, byteRcvUndecryptTotal : int, byteRecv : int, byteRecvTotal : int, byteRetrans : int, byteRetransTotal : int, byteSent : int, byteSentTotal : int, byteSndBuf : int, byteSndDrop : int, byteSndDropTotal : int, mbpsBandwidth : float, mbpsMaxBW : float, mbpsRecvRate : float, mbpsSendRate : float, msRTT : float, msRcvBuf : int, msRcvTsbPdDelay : int, msSndBuf : int, msSndTsbPdDelay : int, msTimeStamp : int, pktCongestionWindow : int, pktFlightSize : int, pktFlowWindow : int, pktRcvAvgBelatedTime : float, pktRcvBelated : int, pktRcvBuf : int, pktRcvDrop : int, pktRcvDropTotal : int, pktRcvFilterExtra : int, pktRcvFilterExtraTotal : int, pktRcvFilterLoss : int, pktRcvFilterLossTotal : int, pktRcvFilterSupply : int, pktRcvFilterSupplyTotal : int, pktRcvLoss : int, pktRcvLossTotal : int, pktRcvRetrans : int, pktRcvUndecrypt : int, pktRcvUndecryptTotal : int, pktRecv : int, pktRecvACK : int, pktRecvACKTotal : int, pktRecvNAK : int, pktRecvNAKTotal : int, pktRecvTotal : int, pktReorderDistance : int, pktRetrans : int, pktRetransTotal : int, pktSent : int, pktSentACK : int, pktSentACKTotal : int, pktSentNAK : int, pktSentNAKTotal : int, pktSentTotal : int, pktSndBuf : int, pktSndDrop : int, pktSndDropTotal : int, pktSndFilterExtra : int, pktSndFilterExtraTotal : int, pktSndLoss : int, pktSndLossTotal : int, usPktSndPeriod : float, usSndDuration : int, usSndDurationTotal : int}, bstats : (?clear : bool?) -> { byteAvailRcvBuf : int, byteAvailSndBuf : int, byteMSS : int, byteRcvBuf : int, byteRcvDrop : int, byteRcvDropTotal : int, byteRcvUndecrypt : int, byteRcvUndecryptTotal : int, byteRecv : int, byteRecvTotal : int, byteRetrans : int, byteRetransTotal : int, byteSent : int, byteSentTotal : int, byteSndBuf : int, byteSndDrop : int, byteSndDropTotal : int, mbpsBandwidth : float, mbpsMaxBW : float, mbpsRecvRate : float, mbpsSendRate : float, msRTT : float, msRcvBuf : int, msRcvTsbPdDelay : int, msSndBuf : int, msSndTsbPdDelay : int, msTimeStamp : int, pktCongestionWindow : int, pktFlightSize : int, pktFlowWindow : int, pktRcvAvgBelatedTime : float, pktRcvBelated : int, pktRcvBuf : int, pktRcvDrop : int, pktRcvDropTotal : int, pktRcvFilterExtra : int, pktRcvFilterExtraTotal : int, pktRcvFilterLoss : int, pktRcvFilterLossTotal : int, pktRcvFilterSupply : int, pktRcvFilterSupplyTotal : int, pktRcvLoss : int, pktRcvLossTotal : int, pktRcvRetrans : int, pktRcvUndecrypt : int, pktRcvUndecryptTotal : int, pktRecv : int, pktRecvACK : int, pktRecvACKTotal : int, pktRecvNAK : int, pktRecvNAKTotal : int, pktRecvTotal : int, pktReorderDistance : int, pktRetrans : int, pktRetransTotal : int, pktSent : int, pktSentACK : int, pktSentACKTotal : int, pktSentNAK : int, pktSentNAKTotal : int, pktSentTotal : int, pktSndBuf : int, pktSndDrop : int, pktSndDropTotal : int, pktSndFilterExtra : int, pktSndFilterExtraTotal : int, pktSndLoss : int, pktSndLossTotal : int, usPktSndPeriod : float, usSndDuration : int, usSndDurationTotal : int}, close : () -> unit, id : int, ipv6only : () -> bool, latency : () -> int, pbkeylen : () -> int, peerlatency : () -> int, rcvbuf : () -> int, rcvdata : () -> int, rcvlatency : () -> int, rcvsyn : () -> bool, rcvtimeout : () -> int, reuseaddr : () -> bool, set_conntimeo : (int) -> unit, set_enforced_encryption : (bool) -> unit, set_ipv6only : (bool) -> unit, set_latency : (int) -> unit, set_messageapi : (bool) -> unit, set_passphrase : (string) -> unit, set_payloadsize : (int) -> unit, set_pbkeylen : (int) -> unit, set_peerlatency : (int) -> unit, set_rcvbuf : (int) -> unit, set_rcvlatency : (int) -> unit, set_rcvsyn : (bool) -> unit, set_rcvtimeout : (int) -> unit, set_reuseaddr : (bool) -> unit, set_sndbuf : (int) -> unit, set_sndsyn : (bool) -> unit, set_sndtimeout : (int) -> unit, set_streamid : (string) -> unit, set_tsbpdmode : (bool) -> unit, set_udp_rcvbuf : (int) -> unit, set_udp_sndbuf : (int) -> unit, sndbuf : () -> int, sndsyn : () -> bool, sndtimeout : () -> int, status : () -> string, streamid : () -> string, tsbpdmode : () -> bool, udp_rcvbuf : () -> int, udp_sndbuf : () -> int }]): The connected peers, with their IP address.start(of type() -> unit): Ask the source or output to start.stop(of type() -> unit): Ask the source or output to stop.time(of type() -> float): Get a source's time, based on its assigned clock.
Callbacks:
on_collect(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called when source is collectedon_connect(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler when a peer connects, before any data is exchanged with iton_disconnect(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler when a peer that connected is disconnectedon_frame(of type(?before : bool, synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler on frame. Whenbeforeistrue, callback is executed before computing the frame and after otherwiseon_frame_checksum(of type(?before : ((string?) -> unit)?, synchronous : bool, ((cache : string?, string) -> unit)) -> {release : () -> unit}): Call a given handler Register callbacks to compute frame checksums for debugging purposes. This is useful to track frame content changes through the streaming pipeline. Thebeforecallback is called before computing the frame with the checksum of the cached frame (if any,nullotherwise). The main callback is called after computing the frame with the checksum of the generated frame and the remaining cache (if any).on_metadata(of type(synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}): Call a given handler to execute on each metadataon_position(of type(position : {float}, ?remaining : bool, ?allow_partial : bool, synchronous : bool, ((float, [string * string]) -> unit)) -> {release : () -> unit}): Call a given handler on track position. Ifremainingisfalse, callback is executed when position in track is more or equal toposition. Ifremainingistrue, callback is executed when remaining time in the current track is less or equal toposition. Keep in mind that elapsed time is exact while remaining time is always estimated. Remaining time is usually more accurate for file-based sources. Whenallow_partialistrue, if the current track ends before theoffsetposition is reached, callback is still executedon_shutdown(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called when source shuts downon_socket(of type(synchronous : bool, ((mode : string, srt_socket .{ bistats : (?clear : bool?, ?instantaneous : bool?) -> { byteAvailRcvBuf : int, byteAvailSndBuf : int, byteMSS : int, byteRcvBuf : int, byteRcvDrop : int, byteRcvDropTotal : int, byteRcvUndecrypt : int, byteRcvUndecryptTotal : int, byteRecv : int, byteRecvTotal : int, byteRetrans : int, byteRetransTotal : int, byteSent : int, byteSentTotal : int, byteSndBuf : int, byteSndDrop : int, byteSndDropTotal : int, mbpsBandwidth : float, mbpsMaxBW : float, mbpsRecvRate : float, mbpsSendRate : float, msRTT : float, msRcvBuf : int, msRcvTsbPdDelay : int, msSndBuf : int, msSndTsbPdDelay : int, msTimeStamp : int, pktCongestionWindow : int, pktFlightSize : int, pktFlowWindow : int, pktRcvAvgBelatedTime : float, pktRcvBelated : int, pktRcvBuf : int, pktRcvDrop : int, pktRcvDropTotal : int, pktRcvFilterExtra : int, pktRcvFilterExtraTotal : int, pktRcvFilterLoss : int, pktRcvFilterLossTotal : int, pktRcvFilterSupply : int, pktRcvFilterSupplyTotal : int, pktRcvLoss : int, pktRcvLossTotal : int, pktRcvRetrans : int, pktRcvUndecrypt : int, pktRcvUndecryptTotal : int, pktRecv : int, pktRecvACK : int, pktRecvACKTotal : int, pktRecvNAK : int, pktRecvNAKTotal : int, pktRecvTotal : int, pktReorderDistance : int, pktRetrans : int, pktRetransTotal : int, pktSent : int, pktSentACK : int, pktSentACKTotal : int, pktSentNAK : int, pktSentNAKTotal : int, pktSentTotal : int, pktSndBuf : int, pktSndDrop : int, pktSndDropTotal : int, pktSndFilterExtra : int, pktSndFilterExtraTotal : int, pktSndLoss : int, pktSndLossTotal : int, usPktSndPeriod : float, usSndDuration : int, usSndDurationTotal : int}, bstats : (?clear : bool?) -> { byteAvailRcvBuf : int, byteAvailSndBuf : int, byteMSS : int, byteRcvBuf : int, byteRcvDrop : int, byteRcvDropTotal : int, byteRcvUndecrypt : int, byteRcvUndecryptTotal : int, byteRecv : int, byteRecvTotal : int, byteRetrans : int, byteRetransTotal : int, byteSent : int, byteSentTotal : int, byteSndBuf : int, byteSndDrop : int, byteSndDropTotal : int, mbpsBandwidth : float, mbpsMaxBW : float, mbpsRecvRate : float, mbpsSendRate : float, msRTT : float, msRcvBuf : int, msRcvTsbPdDelay : int, msSndBuf : int, msSndTsbPdDelay : int, msTimeStamp : int, pktCongestionWindow : int, pktFlightSize : int, pktFlowWindow : int, pktRcvAvgBelatedTime : float, pktRcvBelated : int, pktRcvBuf : int, pktRcvDrop : int, pktRcvDropTotal : int, pktRcvFilterExtra : int, pktRcvFilterExtraTotal : int, pktRcvFilterLoss : int, pktRcvFilterLossTotal : int, pktRcvFilterSupply : int, pktRcvFilterSupplyTotal : int, pktRcvLoss : int, pktRcvLossTotal : int, pktRcvRetrans : int, pktRcvUndecrypt : int, pktRcvUndecryptTotal : int, pktRecv : int, pktRecvACK : int, pktRecvACKTotal : int, pktRecvNAK : int, pktRecvNAKTotal : int, pktRecvTotal : int, pktReorderDistance : int, pktRetrans : int, pktRetransTotal : int, pktSent : int, pktSentACK : int, pktSentACKTotal : int, pktSentNAK : int, pktSentNAKTotal : int, pktSentTotal : int, pktSndBuf : int, pktSndDrop : int, pktSndDropTotal : int, pktSndFilterExtra : int, pktSndFilterExtraTotal : int, pktSndLoss : int, pktSndLossTotal : int, usPktSndPeriod : float, usSndDuration : int, usSndDurationTotal : int}, close : () -> unit, id : int, ipv6only : () -> bool, latency : () -> int, pbkeylen : () -> int, peerlatency : () -> int, rcvbuf : () -> int, rcvdata : () -> int, rcvlatency : () -> int, rcvsyn : () -> bool, rcvtimeout : () -> int, reuseaddr : () -> bool, set_conntimeo : (int) -> unit, set_enforced_encryption : (bool) -> unit, set_ipv6only : (bool) -> unit, set_latency : (int) -> unit, set_messageapi : (bool) -> unit, set_passphrase : (string) -> unit, set_payloadsize : (int) -> unit, set_pbkeylen : (int) -> unit, set_peerlatency : (int) -> unit, set_rcvbuf : (int) -> unit, set_rcvlatency : (int) -> unit, set_rcvsyn : (bool) -> unit, set_rcvtimeout : (int) -> unit, set_reuseaddr : (bool) -> unit, set_sndbuf : (int) -> unit, set_sndsyn : (bool) -> unit, set_sndtimeout : (int) -> unit, set_streamid : (string) -> unit, set_tsbpdmode : (bool) -> unit, set_udp_rcvbuf : (int) -> unit, set_udp_sndbuf : (int) -> unit, sndbuf : () -> int, sndsyn : () -> bool, sndtimeout : () -> int, status : () -> string, streamid : () -> string, tsbpdmode : () -> bool, udp_rcvbuf : () -> int, udp_sndbuf : () -> int }) -> unit)) -> {release : () -> unit}): Call a given handler when a socket is created (mode"connect"or"listen"), accepted (mode"incoming"), or about to be closed (mode"close")on_start(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler when input startson_stop(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler when input stopson_track(of type(synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}): Call a given handler on track markson_wake_up(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called after the source is asked to get ready
Composition methods:
composition_type(of type(() -> string).{exchange : (string) -> string, set : (string) -> unit}): This source uses live composition by default.on_leave(of type({source : source('a), track_sensitive : bool}) -> unit): Called after switching away from this source in a switch operator, once the transition using the ending source has completed. Receives a record withsource(the source being left) andtrack_sensitive(trueif the ending source's last frame had a track mark, i.e. it finished naturally;falseif 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 withstarting(the incoming source) andending(the previous source, ornullwhen the ending source reached a track boundary). Returns the source to use. By default, both file and live profiles fade outendingwhen non-null (up to 1 second). The default is looked up at runtime from the active composition profile (source.composition.fileorsource.composition.livedepending oncomposition_type).replay_metadata(of type{bool}): Whether to replay the latest metadata on this source when it is selected in a switch operator. Defaults totrue. The value is looked up at runtime from the active composition profile (source.composition.fileorsource.composition.livedepending oncomposition_type).single(of typebool): Forbid the selection of this source for two consecutive tracks in switch operators. Defaults tofalse.track_sensitive(of type{bool}): Whether this source insists on track boundaries in switch operators: whentrue, 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 hastrack_sensitiveset tofalse; otherwise it waits for the playing source to reach a track boundary. File-based sources default totrue; live network and hardware inputs default tofalse. The value is looked up at runtime from the active composition profile (source.composition.fileorsource.composition.livedepending oncomposition_type).
input.v4l2
Read a video4linux2 capture device with FFmpeg. A capture device paces its clock by default: a clock holds one sync source at a time, so a camera in the same clock as another sync source (a sound card, a second camera, a live network input with self_sync) raises the clock's sync error. Set self_sync=false on the camera, or wrap one side in buffer() to put it in its own clock.
Type:
(?id : string?, ?max_buffer : float, ?self_sync : bool, ?device : string) ->
source(video=yuv420p('a))
Arguments:
id(of typestring?, which defaults tonull): Force the value of the source ID.max_buffer(of typefloat, which defaults to0.5): Maximum data buffered, in seconds.self_sync(of typebool, which defaults totrue): Pace the clock with the device.device(of typestring, which defaults to"/dev/video0"): V4L2 device to use.
video.testsrc.ffmpeg
A video test source, generated by FFmpeg's lavfi input.
Type:
(?id : string?, ?pattern : string, ?max_buffer : float, ?duration : 'a?) ->
source(video=yuv420p('b)) where 'a is a number type
Composition:
This source inherits composition from its effective source.
Arguments:
id(of typestring?, which defaults tonull): Force the value of the source ID.pattern(of typestring, which defaults to"testsrc"): FFmpeg video source filter:testsrc,testsrc2,smptebars,rgbtestsrc, etc.max_buffer(of typefloat, which defaults to0.5): Maximum data buffered, in seconds.duration(of type'a? where 'a is a number type, which defaults tonull): Duration of the source, in seconds;nullfor an endless source.
Methods:
buffered(of type() -> [string * float]): Length of buffered data.callbacks_count(of type() -> [string * int]): Callbacks a script has registered on this source, as pairs of callback name and count. A count that keeps growing is a function registering on a source it is handed without releasing what it registered.clear_last_metadata(of type() -> unit): Clear the last metadata from the source.clock(of typeclock): The source's clockduration(of type() -> float): Estimation of the duration of the current track.elapsed(of type() -> float): Elapsed time in the current track.fallible(of typebool): 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 ason_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 ifnew_trackistrue. Whenoverrideisfalse, metadata that the source provides itself takes precedence over the inserted one.is_active(of type() -> bool):trueif the source is active, i.e. it is continuously animated by its own clock whenever it is ready. Typically,truefor outputs and sources such asinput.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 istruewhen the source is currently being used or if it could be used at any time, typically inside aswitchorfallback.last_metadata(of type() -> [string * string]?): Return the last metadata from the source.log(of type{level : (() -> int).{exchange : (int) -> int, set : (int) -> unit}}): Get or set the source's log level, from1to5.queue(of type() -> [source(video=yuv420p('b))]): Return the current sequence of sourceregister_command(of type(?usage : string?, description : string, string, ((string) -> string)) -> unit): Register a server command for this source. Command is registered under the source's id namespace when it gets up and de-registered when it gets down.remaining(of type() -> float): Estimation of remaining time in the current track.reset_last_metadata_on_track(of type(() -> bool).{exchange : (bool) -> bool, set : (bool) -> unit}): Iftrue, the source'slast_metadatais reset on each new track. If a metadata is present along with the track mark, then it becomes the newlast_metadata, otherwise,last_metadata becomesnull`.seek(of type(float) -> float): Seek forward, in seconds (returns the amount of time effectively seeked).self_sync(of type() -> bool): Is the source currently controlling its own real-time loop.self_sync_description(of type() -> string)skip(of type() -> unit): Skip to the next track.time(of type() -> float): Get a source's time, based on its assigned clock.
Callbacks:
on_collect(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called when source is collectedon_frame(of type(?before : bool, synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler on frame. Whenbeforeistrue, callback is executed before computing the frame and after otherwiseon_frame_checksum(of type(?before : ((string?) -> unit)?, synchronous : bool, ((cache : string?, string) -> unit)) -> {release : () -> unit}): Call a given handler Register callbacks to compute frame checksums for debugging purposes. This is useful to track frame content changes through the streaming pipeline. Thebeforecallback is called before computing the frame with the checksum of the cached frame (if any,nullotherwise). The main callback is called after computing the frame with the checksum of the generated frame and the remaining cache (if any).on_metadata(of type(synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}): Call a given handler to execute on each metadataon_position(of type(position : {float}, ?remaining : bool, ?allow_partial : bool, synchronous : bool, ((float, [string * string]) -> unit)) -> {release : () -> unit}): Call a given handler on track position. Ifremainingisfalse, callback is executed when position in track is more or equal toposition. Ifremainingistrue, callback is executed when remaining time in the current track is less or equal toposition. Keep in mind that elapsed time is exact while remaining time is always estimated. Remaining time is usually more accurate for file-based sources. Whenallow_partialistrue, if the current track ends before theoffsetposition is reached, callback is still executedon_shutdown(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called when source shuts downon_track(of type(synchronous : bool, (([string * string]) -> unit)) -> {release : () -> unit}): Call a given handler on track markson_wake_up(of type(synchronous : bool, (() -> unit)) -> {release : () -> unit}): Call a given handler to be called after the source is asked to get ready
Composition methods:
composition_type(of type(() -> string).{exchange : (string) -> string, set : (string) -> unit}): This source inherits composition from its effective source.on_leave(of type({source : source(video=yuv420p('b)), track_sensitive : bool}) -> unit): Called after switching away from this source in a switch operator, once the transition using the ending source has completed. Receives a record withsource(the source being left) andtrack_sensitive(trueif the ending source's last frame had a track mark, i.e. it finished naturally;falseif it was preempted mid-track). This function must return quickly as it runs in the streaming thread. The default depends on the active composition profile: file sources (source.composition.file) skip the source when preempted mid-track so it starts fresh on its next selection, and do nothing when it finished naturally; live sources (source.composition.live) do nothing.on_select(of type( { ending : source(video=yuv420p('b))?, replay_metadata : bool, starting : source(video=yuv420p('b)) }) -> source(video=yuv420p('b))): Called when selecting this source in a switch operator. Receives a record withstarting(the incoming source) andending(the previous source, ornullwhen the ending source reached a track boundary). Returns the source to use. By default, both file and live profiles fade outendingwhen non-null (up to 1 second). The default is looked up at runtime from the active composition profile (source.composition.fileorsource.composition.livedepending oncomposition_type).replay_metadata(of type{bool}): Whether to replay the latest metadata on this source when it is selected in a switch operator. Defaults totrue. The value is looked up at runtime from the active composition profile (source.composition.fileorsource.composition.livedepending oncomposition_type).single(of typebool): Forbid the selection of this source for two consecutive tracks in switch operators. Defaults tofalse.track_sensitive(of type{bool}): Whether this source insists on track boundaries in switch operators: whentrue, 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 hastrack_sensitiveset tofalse; otherwise it waits for the playing source to reach a track boundary. File-based sources default totrue; live network and hardware inputs default tofalse. The value is looked up at runtime from the active composition profile (source.composition.fileorsource.composition.livedepending oncomposition_type).