View Source Membrane.HTTPAdaptiveStream.Sink (Membrane HTTP Adaptive Stream plugin v0.9.0)

Sink for generating HTTP streaming manifests.

Uses Membrane.HTTPAdaptiveStream.Manifest for manifest serialization and Membrane.HTTPAdaptiveStream.Storage for saving files.

notifications

Notifications

  • {:track_playable, input_pad_id} - sent when the first segment of a track is stored, and thus the track is ready to be played
  • {:cleanup, cleanup_function :: (()-> :ok)} - sent when playback changes from playing to prepared. Invoking cleanup_function lambda results in removing all the files that remain after the streaming

examples

Examples

The following configuration:

%Membrane.HTTPAdaptiveStream.Sink{
  manifest_name: "manifest",
  manifest_module: Membrane.HTTPAdaptiveStream.HLS,
  storage: %Membrane.HTTPAdaptiveStream.Storages.FileStorage{directory: "output"}
}

will generate a HLS manifest in the output directory, playable from output/manifest.m3u8 file.

element-options

Element options

Passed via struct Membrane.HTTPAdaptiveStream.Sink.t/0

  • manifest_name

    String.t()

    Default value: "index"
    Name of the main manifest file.

  • manifest_module

    module

    Required
    Implementation of the Membrane.HTTPAdaptiveStream.Manifest behaviour.

  • storage

    Storage.config_t()

    Required
    Storage configuration. May be one of Membrane.HTTPAdaptiveStream.Storages.*. See Membrane.HTTPAdaptiveStream.Storage behaviour.

  • target_window_duration

    Membrane.Time.t() | :infinity

    Default value: 40000000000
    Manifest duration is keept above that time, while the oldest segments are removed whenever possible.

  • persist?

    any

    Default value: false
    If true, stale segments are removed from the manifest only. Once playback finishes, they are put back into the manifest.

  • mode

    :live | :vod

    Default value: :vod
    Tells if the session is live or a VOD type of broadcast. It can influence type of metadata inserted into the playlist's manifest.

  • header_naming_fun

    (Manifest.Track.t(), counter :: non_neg_integer -> String.t())

    Default value: &Membrane.HTTPAdaptiveStream.Manifest.Track.default_header_naming_fun/2
    A function that generates consequent header names for a given track.

  • segment_naming_fun

    (Manifest.Track.t() -> String.t())

    Default value: &Membrane.HTTPAdaptiveStream.Manifest.Track.default_segment_naming_fun/1
    A function that generates consequent segment names for a given track.

pads

Pads

input

:input

Availability :on_request
Caps Membrane.CMAF.Track
Demand mode :manual
Demand unit :buffers
Direction :input
Mode :pull
Name :input

Options:

  • track_name

    String.t() | nil

    Default value: nil
    Name that will be used to name the media playlist for the given track, as well as its header and segments files. It must not contain any URI reserved characters

  • segment_duration

    SegmentDuration.t()

    Required
    The expected minimum and target duration of media segment produced by this particular track.

    In case of regular paced streams the parameter may not have any impact but when partial segments gets used it may decide when regular segments gets finalized and new gets started.

  • target_partial_segment_duration

    Membrane.Time.t() | nil

    Default value: nil
    The target duration of partial segments.

    When set to nil then the track is not supposed to emit partial segments.

Link to this section Summary

Types

Options for pad :input

t()

Struct containing options for Membrane.HTTPAdaptiveStream.Sink

Functions

Returns pads descriptions for Membrane.HTTPAdaptiveStream.Sink

Returns description of options available for this module

Link to this section Types

@type input_pad_opts_t() :: [
  track_name: String.t() | nil,
  segment_duration: Membrane.HTTPAdaptiveStream.Sink.SegmentDuration.t(),
  target_partial_segment_duration: Membrane.Time.t() | nil
]

Options for pad :input

@type t() :: %Membrane.HTTPAdaptiveStream.Sink{
  header_naming_fun:
    (Membrane.HTTPAdaptiveStream.Manifest.Track.t(),
     counter :: non_neg_integer() ->
       String.t()),
  manifest_module: module(),
  manifest_name: String.t(),
  mode: :live | :vod,
  persist?: any(),
  segment_naming_fun:
    (Membrane.HTTPAdaptiveStream.Manifest.Track.t() -> String.t()),
  storage: Membrane.HTTPAdaptiveStream.Storage.config_t(),
  target_window_duration: Membrane.Time.t() | :infinity
}

Struct containing options for Membrane.HTTPAdaptiveStream.Sink

Link to this section Functions

@spec membrane_pads() :: [{Membrane.Pad.name_t(), Membrane.Pad.description_t()}]

Returns pads descriptions for Membrane.HTTPAdaptiveStream.Sink

@spec options() :: keyword()

Returns description of options available for this module