rtpmpeg4audio

package
v0.0.0-...-7860b57 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 7, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package rtpmpeg4audio contains a RTP/MPEG-4 Audio decoder and encoder.

Index

Constants

This section is empty.

Variables

View Source
var ErrMorePacketsNeeded = errors.New("need more packets")

ErrMorePacketsNeeded is returned when more packets are needed.

Functions

This section is empty.

Types

type Decoder

type Decoder struct {
	// sample rate of input packets.
	SampleRate int

	// The number of bits in which the AU-size field is encoded in the AU-header.
	SizeLength int

	// The number of bits in which the AU-Index is encoded in the first AU-header.
	IndexLength int

	// The number of bits in which the AU-Index-delta field is encoded in any non-first AU-header.
	IndexDeltaLength int
	// contains filtered or unexported fields
}

Decoder is a RTP/MPEG-4 Audio decoder. Specification: https://datatracker.ietf.org/doc/html/rfc3640

func (*Decoder) Decode

func (d *Decoder) Decode(pkt *rtp.Packet) ([][]byte, time.Duration, error)

Decode decodes AUs from a RTP packet. It returns the AUs and the PTS of the first AU. The PTS of subsequent AUs can be calculated by adding time.Second*mpeg4audio.SamplesPerAccessUnit/clockRate.

func (*Decoder) Init

func (d *Decoder) Init()

Init initializes the decoder.

type Encoder

type Encoder struct {
	// payload type of packets.
	PayloadType uint8

	// SSRC of packets (optional).
	// It defaults to a random value.
	SSRC *uint32

	// initial sequence number of packets (optional).
	// It defaults to a random value.
	InitialSequenceNumber *uint16

	// initial timestamp of packets (optional).
	// It defaults to a random value.
	InitialTimestamp *uint32

	// maximum size of packet payloads (optional).
	// It defaults to 1460.
	PayloadMaxSize int

	// sample rate of packets.
	SampleRate int

	// The number of bits in which the AU-size field is encoded in the AU-header.
	SizeLength int

	// The number of bits in which the AU-Index is encoded in the first AU-header.
	IndexLength int

	// The number of bits in which the AU-Index-delta field is encoded in any non-first AU-header.
	IndexDeltaLength int
	// contains filtered or unexported fields
}

Encoder is a RTP/MPEG4-audio encoder. Specification: https://datatracker.ietf.org/doc/html/rfc3640

func (*Encoder) Encode

func (e *Encoder) Encode(aus [][]byte, pts time.Duration) ([]*rtp.Packet, error)

Encode encodes AUs into RTP packets.

func (*Encoder) Init

func (e *Encoder) Init()

Init initializes the encoder.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL