View Source Membrane.HTTPAdaptiveStream.Manifest.Track (Membrane HTTP Adaptive Stream plugin v0.18.4)

Struct representing a state of a single manifest track and functions to operate on it.

Summary

Functions

Recognizes if its regular or partial segment and then update the track appropriately. Returns Changeset.

Returns all segments present in the track, including stale segments.

Discontinue the track, indicating that parameters of the stream have changed.

Marks the track as finished and finalize last segment if needed. After this action, it won't be possible to add any new segments to the track.

Return new track with all stale segments restored, resulting in playback of historic data. Only works with 'persist?' option enabled.

Returns current header name

Tells whether the track is able to produce partial media segments.

Types

@type id_t() :: any()
@type segment_duration_t() :: Membrane.Time.t() | Ratio.t()
@type segment_metadata() :: %{
  payload: segment_payload_t(),
  complete?: boolean(),
  independent?: boolean(),
  last_chunk?: boolean(),
  duration: segment_duration_t(),
  size: segment_size_t()
}
@type segment_payload_t() :: binary()
@type segment_size_t() :: non_neg_integer()
@type t() :: %Membrane.HTTPAdaptiveStream.Manifest.Track{
  awaiting_discontinuity: term(),
  content_type: :audio | :video | :muxed,
  current_discontinuity_seq_num: non_neg_integer(),
  current_seq_num: non_neg_integer(),
  discontinuities_counter: non_neg_integer(),
  encoding:
    [Membrane.HTTPAdaptiveStream.Manifest.Track.Config.encoding_t()] | [],
  finished?: boolean(),
  header_extension: String.t(),
  header_name: String.t(),
  header_naming_fun: (t(), counter :: non_neg_integer() -> String.t()),
  id: id_t(),
  max_framerate: term(),
  mode: term(),
  next_segment_id: non_neg_integer(),
  partial_naming_fun: term(),
  partial_segment_duration: segment_duration_t() | nil,
  persist?: boolean(),
  resolution: {non_neg_integer(), non_neg_integer()} | nil,
  segment_duration: Membrane.Time.t(),
  segment_extension: String.t(),
  segment_naming_fun: (t() -> String.t()),
  segment_sequencer: {msn :: non_neg_integer(), part_sn :: non_neg_integer()},
  segments: segments_t(),
  stale_headers: term(),
  stale_segments: segments_t(),
  target_window_duration: Membrane.Time.t() | :infinity,
  track_name: String.t(),
  window_duration: non_neg_integer()
}

The struct representing a track.

Consists of all the fields from Config.t and also:

  • header_name - name of the header file
  • current_seq_num - the number to identify the next segment
  • current_discontinuity_seq_num - number of current discontinuity sequence.
  • segments - segments' names and durations
  • stale_segments - stale segments' names and durations, kept empty unless persist? is set to true
  • stale_headers - stale headers' names, kept empty unless persist? is set to true
  • finished? - determines whether the track is finished
  • window_duration - current window duration
  • discontinuities_counter - the number of discontinuities that happened so far
  • next_segment_id - the sequence number of the next segment that will be generated
  • segment_sequencer - keeps track of the current sequence number of a segment.

Functions

Link to this function

add_chunk(track, opts, attributes \\ [])

View Source

Recognizes if its regular or partial segment and then update the track appropriately. Returns Changeset.

@spec all_segments(t()) :: [segment_name :: String.t()]

Returns all segments present in the track, including stale segments.

Link to this function

default_header_naming_fun(track, counter)

View Source
@spec default_header_naming_fun(t(), non_neg_integer()) :: String.t()
Link to this function

default_partial_naming_fun(track, list)

View Source
@spec default_partial_naming_fun(t(), Keyword.t()) :: String.t()
Link to this function

default_segment_naming_fun(track)

View Source
@spec default_segment_naming_fun(t()) :: String.t()
@spec discontinue(t()) :: {header_name :: String.t(), t()}

Discontinue the track, indicating that parameters of the stream have changed.

New header has to be stored under the returned filename. For details on discontinuity, please refer to RFC 8216.

Marks the track as finished and finalize last segment if needed. After this action, it won't be possible to add any new segments to the track.

@spec from_beginning(t()) :: t()

Return new track with all stale segments restored, resulting in playback of historic data. Only works with 'persist?' option enabled.

@spec header(t()) :: String.t()

Returns current header name

@spec persisted?(t()) :: boolean()
Link to this function

supports_partial_segments?(track)

View Source
@spec supports_partial_segments?(t()) :: boolean()

Tells whether the track is able to produce partial media segments.