ExFLV.Tag.VideoData.AVC (FLV muxer and demuxer v0.4.0)

View Source

Module describing an AVCVIDEOPACKET tag.

Summary

Functions

Creates a new AVCVIDEOPACKET tag.

Parses the binary into an AVCVIDEOPACKET tag.

Same as parse/1 but raises on error.

Types

packet_type()

@type packet_type() :: :sequence_header | :nalu | :end_of_sequence

t()

@type t() :: %ExFLV.Tag.VideoData.AVC{
  composition_time: integer(),
  data: iodata(),
  packet_type: packet_type()
}

Functions

new(data, packet_type, composition_time)

@spec new(iodata(), packet_type(), integer()) :: t()

Creates a new AVCVIDEOPACKET tag.

Examples

iex> ExFLV.Tag.VideoData.AVC.new(<<1, 2, 3>>, :nalu, 0)
%ExFLV.Tag.VideoData.AVC{
  packet_type: :nalu,
  composition_time: 0,
  data: <<1, 2, 3>>
}

parse(tag)

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

Parses the binary into an AVCVIDEOPACKET tag.

iex> ExFLV.Tag.VideoData.AVC.parse(<<1, 0, 0, 0, 1, 2, 3>>)
{:ok,
 %ExFLV.Tag.VideoData.AVC{
   packet_type: :nalu,
   composition_time: 0,
   data: <<1, 2, 3>>
 }}

iex> ExFLV.Tag.VideoData.AVC.parse(<<0, 0, 0, 0, 4, 5, 6>>)
{:ok,
 %ExFLV.Tag.VideoData.AVC{
   packet_type: :sequence_header,
   composition_time: 0,
   data: <<4, 5, 6>>
 }}

iex> ExFLV.Tag.VideoData.AVC.parse(<<2, 255, 255, 255>>)
{:ok,
 %ExFLV.Tag.VideoData.AVC{
   packet_type: :end_of_sequence,
   composition_time: -1,
   data: ""
 }}

iex> ExFLV.Tag.VideoData.AVC.parse(<<3, 0, 0, 0, 7, 8, 9>>)
{:error, :invalid_data}

parse!(data)

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

Same as parse/1 but raises on error.

iex> ExFLV.Tag.VideoData.AVC.parse!(<<1, 0, 0, 0, 1, 2, 3>>)
%ExFLV.Tag.VideoData.AVC{
  packet_type: :nalu,
  composition_time: 0,
  data: <<1, 2, 3>>
}