Membrane.HTTPAdaptiveStream.Source (Membrane HTTP Adaptive Stream plugin v0.21.2)

Copy Markdown View Source

A Membrane Source element that fetches and demuxes HLS streams.

It uses the ExHLS library to handle the HLS protocol.

It is recommended to plug Membrane.H264.Parser and Membrane.AAC.Parser after this element to parse the video and audio streams respectively, because the stream formats returned by this element can differ depending on the type of the HLS stream (MPEG-TS or fMP4).

The source sends Membrane.HTTPAdaptiveStream.TDENEvent each time a TDEN (encoding timestamp) ID3v2.4 tag is encountered in MPEG-TS segment.

Element options

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

  • url

    String.t()

    Required
    URL of the HLS playlist manifest

  • variant_selection_policy

    variant_selection_policy()

    Default value: :highest_resolution
    The policy used to select a variant from the list of available variants.

    The policy can be one of the predefined ones or a custom function that takes a map of variant IDs to their descriptions and returns the ID of the selected variant.

    The predefined policies are:

    • :lowest_resolution - selects the variant with the lowest value of video width * height.
    • :highest_resolution - selects the variant with the highest value of video width * height.
    • :lowest_bandwidth - selects the variant with the lowest bandwidth.
    • :highest_bandwidth - selects the variant with the highest bandwidth.

    Defaults to :highest_resolution.

  • how_much_to_skip

    Membrane.Time.t()

    Default value: 0 |> Membrane.Time.days()
    Specifies how much time should be discarded from each of the tracks.

    Please note that an actual discarded part of the stream might be at most of that length because it needs to be aligned with HLS segments distribution. The source will send an Membrane.Event.Discontinuity event with :duration field representing duration of the discarded part of the stream.

  • live_edge_mode?

    boolean()

    Default value: false
    Turns on live edge mode of the source (please do not confuse it with the Low Latency HLS extension which is not supported by the source!).

    In this mode the source starts playing the playlist as fast as possible, and skips to the most recent segment. Please note that this is not compliant with the HLS specification and might cause playback stalls. The live edge mode is turned off by default.

Pads

:audio_output

Accepted formats:

AAC
%RemoteStream{content_format: AAC}
Direction::output
Availability::on_request
Flow control::manual
Demand unit::buffers

:video_output

Accepted formats:

H264
%RemoteStream{content_format: H264}
Direction::output
Availability::on_request
Flow control::manual
Demand unit::buffers

Summary

Types

Notification sent by Membrane.HTTPAdaptiveStream.Source to its parent when the element figures out what tracks are present in the HLS stream.

t()

Struct containing options for Membrane.HTTPAdaptiveStream.Source

The policy used to select a variant from the list of available variants.

Functions

Returns description of options available for this module

Types

new_tracks_notification()

@type new_tracks_notification() ::
  {:new_tracks,
   audio_output: Membrane.RemoteStream.t() | Membrane.AAC.t(),
   video_output: Membrane.RemoteStream.t() | Membrane.H264.t()}

Notification sent by Membrane.HTTPAdaptiveStream.Source to its parent when the element figures out what tracks are present in the HLS stream.

Contains pads that should be linked to the element and stream formats that will be sent via those pads.

If pads are linked before the element enters the :playing playback, the notification will not be sent, but the pads will have to match the tracks in the HLS stream.

t()

@type t() :: %Membrane.HTTPAdaptiveStream.Source{
  how_much_to_skip: Membrane.Time.t(),
  live_edge_mode?: boolean(),
  url: String.t(),
  variant_selection_policy: variant_selection_policy()
}

Struct containing options for Membrane.HTTPAdaptiveStream.Source

variant_selection_policy()

@type variant_selection_policy() ::
  :lowest_resolution
  | :highest_resolution
  | :lowest_bandwidth
  | :highest_bandwidth
  | (variants_map :: %{
       required(integer()) => ExHLS.Client.variant_description()
     } ->
       variant_id :: integer())

The policy used to select a variant from the list of available variants.

The policy can be one of the predefined ones or a custom function that takes a map of variant IDs to their descriptions and returns the ID of the selected variant.

The predefined policies are:

  • :lowest_resolution - selects the variant with the lowest value of video width * height.
  • :highest_resolution - selects the variant with the highest value of video width * height.
  • :lowest_bandwidth - selects the variant with the lowest bandwidth.
  • :highest_bandwidth - selects the variant with the highest bandwidth.

Functions

options()

@spec options() :: keyword()

Returns description of options available for this module