ExFLV.Tag.ExAudioData (FLV muxer and demuxer v0.4.0)

View Source

Module describing an enhanced audio data tag.

Summary

Functions

Parses the binary into an enhanced audio data tag.

Same as parse/1 but raises on error.

Types

channel()

@type channel() ::
  :front_left
  | :front_right
  | :front_center
  | :low_frequency1
  | :back_left
  | :back_right
  | :front_left_center
  | :front_right_center
  | :back_center
  | :side_left
  | :side_right
  | :top_center
  | :top_front_left
  | :top_front_center
  | :top_front_right
  | :top_back_left
  | :top_back_center
  | :top_back_right
  | :low_frequency2
  | :top_side_left
  | :top_side_right
  | :bottom_front_center
  | :bottom_front_left
  | :bottom_front_right
  | :unused
  | :unknown

channel_order()

@type channel_order() :: :unspecified | :native | :custom

codec_id()

@type codec_id() :: :ac3 | :eac3 | :opus | :mp3 | :flac | :aac

packet_type()

@type packet_type() ::
  :sequence_start
  | :coded_frames
  | :sequence_end
  | :multi_channel_config
  | :multi_track
  | :mod_ex

t()

@type t() :: %ExFLV.Tag.ExAudioData{
  channel_count: non_neg_integer() | nil,
  channel_order: channel_order() | nil,
  channels: [channel()] | nil,
  codec_id: codec_id(),
  data: iodata(),
  packet_type: packet_type()
}

Functions

parse(arg1)

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

Parses the binary into an enhanced audio data tag.

Examples

iex> ExFLV.Tag.ExAudioData.parse(<<148, 102, 76, 97, 67, 1, 2, 0, 0, 0, 3>>)
{:ok,
 %ExFLV.Tag.ExAudioData{
   packet_type: :multi_channel_config,
   codec_id: :flac,
   channel_order: :native,
   channel_count: 2,
   channels: [:front_left, :front_right],
   data: <<>>
 }}

iex> ExFLV.Tag.ExAudioData.parse(<<145, 109, 112, 52, 97, 255, 248, 89, 174, 0, 90, 78, 0>>)
{:ok,
 %ExFLV.Tag.ExAudioData{
   packet_type: :coded_frames,
   codec_id: :aac,
   channel_order: nil,
   channel_count: nil,
   channels: nil,
   data: <<255, 248, 89, 174, 0, 90, 78, 0>>
 }}

iex> ExFLV.Tag.ExAudioData.parse(<<144, 120, 120, 120, 120, 1, 2, 3>>)
{:error, "invalid fourcc: \"xxxx\""}

iex> ExFLV.Tag.ExAudioData.parse(<<80, 97, 99, 45, 51, 1, 2, 3>>)
{:error, :invalid_data}

parse!(data)

@spec parse!(binary()) :: t()

Same as parse/1 but raises on error.

iex> ExFLV.Tag.ExAudioData.parse!(<<148, 102, 76, 97, 67, 1, 2, 0, 0, 0, 3>>)
%ExFLV.Tag.ExAudioData{
  packet_type: :multi_channel_config,
  codec_id: :flac,
  channel_order: :native,
  channel_count: 2,
  channels: [:front_left, :front_right],
  data: <<>>
}