formats

package
v3.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2023 License: MIT Imports: 17 Imported by: 7

Documentation

Overview

Package formats contains RTP format definitions, decoders and encoders.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Format

type Format interface {
	// String returns a description of the format.
	String() string

	// ClockRate returns the clock rate.
	ClockRate() int

	// PayloadType returns the payload type.
	PayloadType() uint8

	// Marshal encodes the format in SDP format.
	Marshal() (string, map[string]string)

	// PTSEqualsDTS checks whether PTS is equal to DTS in RTP packets.
	PTSEqualsDTS(*rtp.Packet) bool
	// contains filtered or unexported methods
}

Format is a RTP format of a media. It defines a codec and a payload type used to transmit the media.

func Unmarshal

func Unmarshal(mediaType string, payloadType uint8, rtpMap string, fmtp map[string]string) (Format, error)

Unmarshal decodes a format from a media description.

type G711

type G711 struct {
	// whether to use mu-law. Otherwise, A-law is used.
	MULaw bool
}

G711 is a RTP format that uses the G711 codec, encoded with mu-law or A-law. Specification: https://datatracker.ietf.org/doc/html/rfc3551

func (*G711) ClockRate

func (f *G711) ClockRate() int

ClockRate implements Format.

func (*G711) CreateDecoder

func (f *G711) CreateDecoder() *rtpsimpleaudio.Decoder

CreateDecoder creates a decoder able to decode the content of the format.

func (*G711) CreateEncoder

func (f *G711) CreateEncoder() *rtpsimpleaudio.Encoder

CreateEncoder creates an encoder able to encode the content of the format.

func (*G711) Marshal

func (f *G711) Marshal() (string, map[string]string)

Marshal implements Format.

func (*G711) PTSEqualsDTS

func (f *G711) PTSEqualsDTS(*rtp.Packet) bool

PTSEqualsDTS implements Format.

func (*G711) PayloadType

func (f *G711) PayloadType() uint8

PayloadType implements Format.

func (*G711) String

func (f *G711) String() string

String implements Format.

type G722

type G722 struct{}

G722 is a RTP format that uses the G722 codec. Specification: https://datatracker.ietf.org/doc/html/rfc3551

func (*G722) ClockRate

func (f *G722) ClockRate() int

ClockRate implements Format.

func (*G722) CreateDecoder

func (f *G722) CreateDecoder() *rtpsimpleaudio.Decoder

CreateDecoder creates a decoder able to decode the content of the format.

func (*G722) CreateEncoder

func (f *G722) CreateEncoder() *rtpsimpleaudio.Encoder

CreateEncoder creates an encoder able to encode the content of the format.

func (*G722) Marshal

func (f *G722) Marshal() (string, map[string]string)

Marshal implements Format.

func (*G722) PTSEqualsDTS

func (f *G722) PTSEqualsDTS(*rtp.Packet) bool

PTSEqualsDTS implements Format.

func (*G722) PayloadType

func (f *G722) PayloadType() uint8

PayloadType implements Format.

func (*G722) String

func (f *G722) String() string

String implements Format.

type Generic

type Generic struct {
	PayloadTyp uint8
	RTPMap     string
	FMTP       map[string]string

	// clock rate of the format. Filled automatically.
	ClockRat int
}

Generic is a generic RTP format.

func (*Generic) ClockRate

func (f *Generic) ClockRate() int

ClockRate implements Format.

func (*Generic) Init

func (f *Generic) Init() error

Init computes the clock rate of the format. It it mandatory to call it.

func (*Generic) Marshal

func (f *Generic) Marshal() (string, map[string]string)

Marshal implements Format.

func (*Generic) PTSEqualsDTS

func (f *Generic) PTSEqualsDTS(*rtp.Packet) bool

PTSEqualsDTS implements Format.

func (*Generic) PayloadType

func (f *Generic) PayloadType() uint8

PayloadType implements Format.

func (*Generic) String

func (f *Generic) String() string

String returns a description of the format.

type H264

type H264 struct {
	PayloadTyp        uint8
	SPS               []byte
	PPS               []byte
	PacketizationMode int
	// contains filtered or unexported fields
}

H264 is a RTP format that uses the H264 codec, defined in MPEG-4 part 10. Specification: https://datatracker.ietf.org/doc/html/rfc6184

func (*H264) ClockRate

func (f *H264) ClockRate() int

ClockRate implements Formaf.

func (*H264) CreateDecoder

func (f *H264) CreateDecoder() *rtph264.Decoder

CreateDecoder creates a decoder able to decode the content of the format.

func (*H264) CreateEncoder

func (f *H264) CreateEncoder() *rtph264.Encoder

CreateEncoder creates an encoder able to encode the content of the format.

func (*H264) Marshal

func (f *H264) Marshal() (string, map[string]string)

Marshal implements Formaf.

func (*H264) PTSEqualsDTS

func (f *H264) PTSEqualsDTS(pkt *rtp.Packet) bool

PTSEqualsDTS implements Formaf.

func (*H264) PayloadType

func (f *H264) PayloadType() uint8

PayloadType implements Formaf.

func (*H264) SafeParams

func (f *H264) SafeParams() ([]byte, []byte)

SafeParams returns the codec parameters.

func (*H264) SafeSetParams

func (f *H264) SafeSetParams(sps []byte, pps []byte)

SafeSetParams sets the codec parameters.

func (*H264) String

func (f *H264) String() string

String implements Formaf.

type H265

type H265 struct {
	PayloadTyp uint8
	VPS        []byte
	SPS        []byte
	PPS        []byte
	MaxDONDiff int
	// contains filtered or unexported fields
}

H265 is a RTP format that uses the H265 codec. Specification: https://datatracker.ietf.org/doc/html/rfc7798

func (*H265) ClockRate

func (f *H265) ClockRate() int

ClockRate implements Formaf.

func (*H265) CreateDecoder

func (f *H265) CreateDecoder() *rtph265.Decoder

CreateDecoder creates a decoder able to decode the content of the format.

func (*H265) CreateEncoder

func (f *H265) CreateEncoder() *rtph265.Encoder

CreateEncoder creates an encoder able to encode the content of the format.

func (*H265) Marshal

func (f *H265) Marshal() (string, map[string]string)

Marshal implements Formaf.

func (*H265) PTSEqualsDTS

func (f *H265) PTSEqualsDTS(*rtp.Packet) bool

PTSEqualsDTS implements Formaf.

func (*H265) PayloadType

func (f *H265) PayloadType() uint8

PayloadType implements Formaf.

func (*H265) SafeParams

func (f *H265) SafeParams() ([]byte, []byte, []byte)

SafeParams returns the codec parameters.

func (*H265) SafeSetParams

func (f *H265) SafeSetParams(vps []byte, sps []byte, pps []byte)

SafeSetParams sets the codec parameters.

func (*H265) String

func (f *H265) String() string

String implements Formaf.

type LPCM

type LPCM struct {
	PayloadTyp   uint8
	BitDepth     int
	SampleRate   int
	ChannelCount int
}

LPCM is a RTP format that uses the uncompressed, Linear PCM codec. Specification: https://datatracker.ietf.org/doc/html/rfc3190

func (*LPCM) ClockRate

func (f *LPCM) ClockRate() int

ClockRate implements Format.

func (*LPCM) CreateDecoder

func (f *LPCM) CreateDecoder() *rtplpcm.Decoder

CreateDecoder creates a decoder able to decode the content of the format.

func (*LPCM) CreateEncoder

func (f *LPCM) CreateEncoder() *rtplpcm.Encoder

CreateEncoder creates an encoder able to encode the content of the format.

func (*LPCM) Marshal

func (f *LPCM) Marshal() (string, map[string]string)

Marshal implements Format.

func (*LPCM) PTSEqualsDTS

func (f *LPCM) PTSEqualsDTS(*rtp.Packet) bool

PTSEqualsDTS implements Format.

func (*LPCM) PayloadType

func (f *LPCM) PayloadType() uint8

PayloadType implements Format.

func (*LPCM) String

func (f *LPCM) String() string

String implements Format.

type MJPEG

type MJPEG struct{}

MJPEG is a RTP format that uses the Motion-JPEG codec. Specification: https://datatracker.ietf.org/doc/html/rfc2435

func (*MJPEG) ClockRate

func (f *MJPEG) ClockRate() int

ClockRate implements Format.

func (*MJPEG) CreateDecoder

func (f *MJPEG) CreateDecoder() *rtpmjpeg.Decoder

CreateDecoder creates a decoder able to decode the content of the format.

func (*MJPEG) CreateEncoder

func (f *MJPEG) CreateEncoder() *rtpmjpeg.Encoder

CreateEncoder creates an encoder able to encode the content of the format.

func (*MJPEG) Marshal

func (f *MJPEG) Marshal() (string, map[string]string)

Marshal implements Format.

func (*MJPEG) PTSEqualsDTS

func (f *MJPEG) PTSEqualsDTS(*rtp.Packet) bool

PTSEqualsDTS implements Format.

func (*MJPEG) PayloadType

func (f *MJPEG) PayloadType() uint8

PayloadType implements Format.

func (*MJPEG) String

func (f *MJPEG) String() string

String implements Format.

type MPEG2Audio

type MPEG2Audio struct{}

MPEG2Audio is a RTP format that uses a MPEG-1 or MPEG-2 audio codec. Specification: https://datatracker.ietf.org/doc/html/rfc2250

func (*MPEG2Audio) ClockRate

func (f *MPEG2Audio) ClockRate() int

ClockRate implements Format.

func (*MPEG2Audio) Marshal

func (f *MPEG2Audio) Marshal() (string, map[string]string)

Marshal implements Format.

func (*MPEG2Audio) PTSEqualsDTS

func (f *MPEG2Audio) PTSEqualsDTS(*rtp.Packet) bool

PTSEqualsDTS implements Format.

func (*MPEG2Audio) PayloadType

func (f *MPEG2Audio) PayloadType() uint8

PayloadType implements Format.

func (*MPEG2Audio) String

func (f *MPEG2Audio) String() string

String implements Format.

type MPEG2Video

type MPEG2Video struct{}

MPEG2Video is a RTP format that uses a MPEG-1 or MPEG-2 video codec. Specification: https://datatracker.ietf.org/doc/html/rfc2250

func (*MPEG2Video) ClockRate

func (f *MPEG2Video) ClockRate() int

ClockRate implements Format.

func (*MPEG2Video) Marshal

func (f *MPEG2Video) Marshal() (string, map[string]string)

Marshal implements Format.

func (*MPEG2Video) PTSEqualsDTS

func (f *MPEG2Video) PTSEqualsDTS(*rtp.Packet) bool

PTSEqualsDTS implements Format.

func (*MPEG2Video) PayloadType

func (f *MPEG2Video) PayloadType() uint8

PayloadType implements Format.

func (*MPEG2Video) String

func (f *MPEG2Video) String() string

String implements Format.

type MPEG4Audio

type MPEG4Audio = MPEG4AudioGeneric

MPEG4Audio is an alias for MPEG4AudioGeneric.

type MPEG4AudioGeneric added in v3.2.0

type MPEG4AudioGeneric struct {
	PayloadTyp       uint8
	Config           *mpeg4audio.Config
	SizeLength       int
	IndexLength      int
	IndexDeltaLength int
}

MPEG4AudioGeneric is a RTP format that uses a MPEG-4 audio codec. Specification: https://datatracker.ietf.org/doc/html/rfc3640

func (*MPEG4AudioGeneric) ClockRate added in v3.2.0

func (f *MPEG4AudioGeneric) ClockRate() int

ClockRate implements Format.

func (*MPEG4AudioGeneric) CreateDecoder added in v3.2.0

func (f *MPEG4AudioGeneric) CreateDecoder() *rtpmpeg4audio.Decoder

CreateDecoder creates a decoder able to decode the content of the format.

func (*MPEG4AudioGeneric) CreateEncoder added in v3.2.0

func (f *MPEG4AudioGeneric) CreateEncoder() *rtpmpeg4audio.Encoder

CreateEncoder creates an encoder able to encode the content of the format.

func (*MPEG4AudioGeneric) Marshal added in v3.2.0

func (f *MPEG4AudioGeneric) Marshal() (string, map[string]string)

Marshal implements Format.

func (*MPEG4AudioGeneric) PTSEqualsDTS added in v3.2.0

func (f *MPEG4AudioGeneric) PTSEqualsDTS(*rtp.Packet) bool

PTSEqualsDTS implements Format.

func (*MPEG4AudioGeneric) PayloadType added in v3.2.0

func (f *MPEG4AudioGeneric) PayloadType() uint8

PayloadType implements Format.

func (*MPEG4AudioGeneric) String added in v3.2.0

func (f *MPEG4AudioGeneric) String() string

String implements Format.

type MPEG4AudioLATM added in v3.2.0

type MPEG4AudioLATM struct {
	PayloadTyp     uint8
	SampleRate     int
	Channels       int
	ProfileLevelID int
	Bitrate        *int
	Object         int
	CPresent       *bool
	Config         []byte
	SBREnabled     *bool
}

MPEG4AudioLATM is a RTP format that uses a MPEG-4 audio codec. Specification: https://datatracker.ietf.org/doc/html/rfc6416#section-7.3

func (*MPEG4AudioLATM) ClockRate added in v3.2.0

func (f *MPEG4AudioLATM) ClockRate() int

ClockRate implements Format.

func (*MPEG4AudioLATM) Marshal added in v3.2.0

func (f *MPEG4AudioLATM) Marshal() (string, map[string]string)

Marshal implements Format.

func (*MPEG4AudioLATM) PTSEqualsDTS added in v3.2.0

func (f *MPEG4AudioLATM) PTSEqualsDTS(*rtp.Packet) bool

PTSEqualsDTS implements Format.

func (*MPEG4AudioLATM) PayloadType added in v3.2.0

func (f *MPEG4AudioLATM) PayloadType() uint8

PayloadType implements Format.

func (*MPEG4AudioLATM) String added in v3.2.0

func (f *MPEG4AudioLATM) String() string

String implements Format.

type MPEG4Video added in v3.2.0

type MPEG4Video = MPEG4VideoES

MPEG4Video is an alias for MPEG4VideoES.

type MPEG4VideoES added in v3.2.0

type MPEG4VideoES struct {
	PayloadTyp     uint8
	ProfileLevelID int
	Config         []byte
}

MPEG4VideoES is a RTP format that uses the video codec defined in MPEG-4 part 2. Specification: https://datatracker.ietf.org/doc/html/rfc6416#section-7.1

func (*MPEG4VideoES) ClockRate added in v3.2.0

func (f *MPEG4VideoES) ClockRate() int

ClockRate implements Format.

func (*MPEG4VideoES) Marshal added in v3.2.0

func (f *MPEG4VideoES) Marshal() (string, map[string]string)

Marshal implements Format.

func (*MPEG4VideoES) PTSEqualsDTS added in v3.2.0

func (f *MPEG4VideoES) PTSEqualsDTS(*rtp.Packet) bool

PTSEqualsDTS implements Format.

func (*MPEG4VideoES) PayloadType added in v3.2.0

func (f *MPEG4VideoES) PayloadType() uint8

PayloadType implements Format.

func (*MPEG4VideoES) String added in v3.2.0

func (f *MPEG4VideoES) String() string

String implements Format.

type Opus

type Opus struct {
	PayloadTyp uint8
	IsStereo   bool
}

Opus is a RTP format that uses the Opus codec. Specification: https://datatracker.ietf.org/doc/html/rfc7587

func (*Opus) ClockRate

func (f *Opus) ClockRate() int

ClockRate implements Format.

func (*Opus) CreateDecoder

func (f *Opus) CreateDecoder() *rtpsimpleaudio.Decoder

CreateDecoder creates a decoder able to decode the content of the format.

func (*Opus) CreateEncoder

func (f *Opus) CreateEncoder() *rtpsimpleaudio.Encoder

CreateEncoder creates an encoder able to encode the content of the format.

func (*Opus) Marshal

func (f *Opus) Marshal() (string, map[string]string)

Marshal implements Format.

func (*Opus) PTSEqualsDTS

func (f *Opus) PTSEqualsDTS(*rtp.Packet) bool

PTSEqualsDTS implements Format.

func (*Opus) PayloadType

func (f *Opus) PayloadType() uint8

PayloadType implements Format.

func (*Opus) String

func (f *Opus) String() string

String implements Format.

type VP8

type VP8 struct {
	PayloadTyp uint8
	MaxFR      *int
	MaxFS      *int
}

VP8 is a RTP format that uses the VP8 codec. Specification: https://datatracker.ietf.org/doc/html/rfc7741

func (*VP8) ClockRate

func (f *VP8) ClockRate() int

ClockRate implements Format.

func (*VP8) CreateDecoder

func (f *VP8) CreateDecoder() *rtpvp8.Decoder

CreateDecoder creates a decoder able to decode the content of the format.

func (*VP8) CreateEncoder

func (f *VP8) CreateEncoder() *rtpvp8.Encoder

CreateEncoder creates an encoder able to encode the content of the format.

func (*VP8) Marshal

func (f *VP8) Marshal() (string, map[string]string)

Marshal implements Format.

func (*VP8) PTSEqualsDTS

func (f *VP8) PTSEqualsDTS(*rtp.Packet) bool

PTSEqualsDTS implements Format.

func (*VP8) PayloadType

func (f *VP8) PayloadType() uint8

PayloadType implements Format.

func (*VP8) String

func (f *VP8) String() string

String implements Format.

type VP9

type VP9 struct {
	PayloadTyp uint8
	MaxFR      *int
	MaxFS      *int
	ProfileID  *int
}

VP9 is a RTP format that uses the VP9 codec. Specification: https://datatracker.ietf.org/doc/html/draft-ietf-payload-vp9-16

func (*VP9) ClockRate

func (f *VP9) ClockRate() int

ClockRate implements Format.

func (*VP9) CreateDecoder

func (f *VP9) CreateDecoder() *rtpvp9.Decoder

CreateDecoder creates a decoder able to decode the content of the format.

func (*VP9) CreateEncoder

func (f *VP9) CreateEncoder() *rtpvp9.Encoder

CreateEncoder creates an encoder able to encode the content of the format.

func (*VP9) Marshal

func (f *VP9) Marshal() (string, map[string]string)

Marshal implements Format.

func (*VP9) PTSEqualsDTS

func (f *VP9) PTSEqualsDTS(*rtp.Packet) bool

PTSEqualsDTS implements Format.

func (*VP9) PayloadType

func (f *VP9) PayloadType() uint8

PayloadType implements Format.

func (*VP9) String

func (f *VP9) String() string

String implements Format.

type Vorbis

type Vorbis struct {
	PayloadTyp    uint8
	SampleRate    int
	ChannelCount  int
	Configuration []byte
}

Vorbis is a RTP format that uses the Vorbis codec. Specification: https://datatracker.ietf.org/doc/html/rfc5215

func (*Vorbis) ClockRate

func (f *Vorbis) ClockRate() int

ClockRate implements Format.

func (*Vorbis) Marshal

func (f *Vorbis) Marshal() (string, map[string]string)

Marshal implements Format.

func (*Vorbis) PTSEqualsDTS

func (f *Vorbis) PTSEqualsDTS(*rtp.Packet) bool

PTSEqualsDTS implements Format.

func (*Vorbis) PayloadType

func (f *Vorbis) PayloadType() uint8

PayloadType implements Format.

func (*Vorbis) String

func (f *Vorbis) String() string

String implements Format.

Directories

Path Synopsis
Package rtph264 contains a RTP/H264 decoder and encoder.
Package rtph264 contains a RTP/H264 decoder and encoder.
Package rtph265 contains a RTP/H265 decoder and encoder.
Package rtph265 contains a RTP/H265 decoder and encoder.
Package rtplpcm contains a RTP/LPCM decoder and encoder.
Package rtplpcm contains a RTP/LPCM decoder and encoder.
Package rtpmjpeg contains a RTP/M-JPEG decoder and encoder.
Package rtpmjpeg contains a RTP/M-JPEG decoder and encoder.
headers
Package headers contains RTP/M-JPEG headers.
Package headers contains RTP/M-JPEG headers.
Package rtpmpeg4audio contains a RTP/MPEG4-audio decoder and encoder.
Package rtpmpeg4audio contains a RTP/MPEG4-audio decoder and encoder.
Package rtpsimpleaudio contains a RTP decoder and encoder for audio codecs that fit in a single packet.
Package rtpsimpleaudio contains a RTP decoder and encoder for audio codecs that fit in a single packet.
Package rtpvp8 contains a RTP/VP8 decoder and encoder.
Package rtpvp8 contains a RTP/VP8 decoder and encoder.
Package rtpvp9 contains a RTP/VP9 decoder and encoder.
Package rtpvp9 contains a RTP/VP9 decoder and encoder.

Jump to

Keyboard shortcuts

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