ExFLV.Header (FLV muxer and demuxer v0.4.0)

View Source

Module describing an FLV header.

Summary

Functions

Creates a new header struct.

Parses the binary into a header struct.

Serializes the header struct into a binary.

Types

t()

@type t() :: %ExFLV.Header{
  audio?: boolean(),
  version: non_neg_integer(),
  video?: boolean()
}

Functions

new(version, audio?, video?)

@spec new(non_neg_integer(), boolean(), boolean()) :: t()

Creates a new header struct.

parse(arg1)

@spec parse(binary()) :: {:ok, t()} | {:error, :invalid_header}

Parses the binary into a header struct.

iex> ExFLV.Header.parse(<<70, 76, 86, 1, 5, 0, 0, 0, 9>>)
{:ok, %ExFLV.Header{version: 1, audio?: true, video?: true}}

iex> ExFLV.Header.parse(<<70, 76, 86, 1, 0, 0, 0, 0, 9>>)
{:ok, %ExFLV.Header{version: 1, audio?: false, video?: false}}

iex> ExFLV.Header.parse("INVALID")
{:error, :invalid_header}

serialize(header)

@spec serialize(t()) :: binary()

Serializes the header struct into a binary.

iex> ExFLV.Header.serialize(%ExFLV.Header{version: 1, audio?: true, video?: true})
<<70, 76, 86, 1, 5, 0, 0, 0, 9>>

iex> ExFLV.Header.serialize(%ExFLV.Header{version: 1, audio?: false, video?: false})
<<70, 76, 86, 1, 0, 0, 0, 0, 9>>