format

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package format contains format definitions.

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 format of a media. It defines a codec and a payload type used to ship the media.

func Unmarshal

func Unmarshal(md *psdp.MediaDescription, payloadTypeStr 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 format that uses the G711 codec, encoded with mu-law or A-law.

func (*G711) ClockRate

func (t *G711) ClockRate() int

ClockRate implements Format.

func (*G711) CreateDecoder

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

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

func (*G711) CreateEncoder

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

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

func (*G711) Marshal

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

Marshal implements Format.

func (*G711) PTSEqualsDTS

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

PTSEqualsDTS implements Format.

func (*G711) PayloadType

func (t *G711) PayloadType() uint8

PayloadType implements Format.

func (*G711) String

func (t *G711) String() string

String implements Format.

type G722

type G722 struct{}

G722 is a format that uses the G722 codec.

func (*G722) ClockRate

func (t *G722) ClockRate() int

ClockRate implements Format.

func (*G722) CreateDecoder

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

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

func (*G722) CreateEncoder

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

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

func (*G722) Marshal

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

Marshal implements Format.

func (*G722) PTSEqualsDTS

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

PTSEqualsDTS implements Format.

func (*G722) PayloadType

func (t *G722) PayloadType() uint8

PayloadType implements Format.

func (*G722) String

func (t *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 format.

func (*Generic) ClockRate

func (t *Generic) ClockRate() int

ClockRate implements Format.

func (*Generic) Init

func (t *Generic) Init() error

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

func (*Generic) Marshal

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

Marshal implements Format.

func (*Generic) PTSEqualsDTS

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

PTSEqualsDTS implements Format.

func (*Generic) PayloadType

func (t *Generic) PayloadType() uint8

PayloadType implements Format.

func (*Generic) String

func (t *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 format that uses the H264 codec.

func (*H264) ClockRate

func (t *H264) ClockRate() int

ClockRate implements Format.

func (*H264) CreateDecoder

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

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

func (*H264) CreateEncoder

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

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

func (*H264) Marshal

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

Marshal implements Format.

func (*H264) PTSEqualsDTS

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

PTSEqualsDTS implements Format.

func (*H264) PayloadType

func (t *H264) PayloadType() uint8

PayloadType implements Format.

func (*H264) SafePPS

func (t *H264) SafePPS() []byte

SafePPS returns the format PPS.

func (*H264) SafeSPS

func (t *H264) SafeSPS() []byte

SafeSPS returns the format SPS.

func (*H264) SafeSetPPS

func (t *H264) SafeSetPPS(v []byte)

SafeSetPPS sets the format PPS.

func (*H264) SafeSetSPS

func (t *H264) SafeSetSPS(v []byte)

SafeSetSPS sets the format SPS.

func (*H264) String

func (t *H264) String() string

String implements Format.

type H265

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

H265 is a format that uses the H265 codec.

func (*H265) ClockRate

func (t *H265) ClockRate() int

ClockRate implements Format.

func (*H265) CreateDecoder

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

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

func (*H265) CreateEncoder

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

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

func (*H265) Marshal

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

Marshal implements Format.

func (*H265) PTSEqualsDTS

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

PTSEqualsDTS implements Format.

func (*H265) PayloadType

func (t *H265) PayloadType() uint8

PayloadType implements Format.

func (*H265) SafePPS

func (t *H265) SafePPS() []byte

SafePPS returns the format PPS.

func (*H265) SafeSPS

func (t *H265) SafeSPS() []byte

SafeSPS returns the format SPS.

func (*H265) SafeSetPPS

func (t *H265) SafeSetPPS(v []byte)

SafeSetPPS sets the format PPS.

func (*H265) SafeSetSPS

func (t *H265) SafeSetSPS(v []byte)

SafeSetSPS sets the format SPS.

func (*H265) SafeSetVPS

func (t *H265) SafeSetVPS(v []byte)

SafeSetVPS sets the format VPS.

func (*H265) SafeVPS

func (t *H265) SafeVPS() []byte

SafeVPS returns the format VPS.

func (*H265) String

func (t *H265) String() string

String implements Format.

type LPCM

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

LPCM is a format that uses the uncompressed, Linear PCM codec.

func (*LPCM) ClockRate

func (t *LPCM) ClockRate() int

ClockRate implements Format.

func (*LPCM) CreateDecoder

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

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

func (*LPCM) CreateEncoder

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

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

func (*LPCM) Marshal

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

Marshal implements Format.

func (*LPCM) PTSEqualsDTS

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

PTSEqualsDTS implements Format.

func (*LPCM) PayloadType

func (t *LPCM) PayloadType() uint8

PayloadType implements Format.

func (*LPCM) String

func (t *LPCM) String() string

String implements Format.

type MJPEG

type MJPEG struct{}

MJPEG is a format that uses the Motion-JPEG codec.

func (*MJPEG) ClockRate

func (t *MJPEG) ClockRate() int

ClockRate implements Format.

func (*MJPEG) CreateDecoder

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

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

func (*MJPEG) CreateEncoder

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

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

func (*MJPEG) Marshal

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

Marshal implements Format.

func (*MJPEG) PTSEqualsDTS

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

PTSEqualsDTS implements Format.

func (*MJPEG) PayloadType

func (t *MJPEG) PayloadType() uint8

PayloadType implements Format.

func (*MJPEG) String

func (t *MJPEG) String() string

String implements Format.

type MPEG2Audio

type MPEG2Audio struct{}

MPEG2Audio is a format that uses a MPEG-1 or MPEG-2 audio codec.

func (*MPEG2Audio) ClockRate

func (t *MPEG2Audio) ClockRate() int

ClockRate implements Format.

func (*MPEG2Audio) Marshal

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

Marshal implements Format.

func (*MPEG2Audio) PTSEqualsDTS

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

PTSEqualsDTS implements Format.

func (*MPEG2Audio) PayloadType

func (t *MPEG2Audio) PayloadType() uint8

PayloadType implements Format.

func (*MPEG2Audio) String

func (t *MPEG2Audio) String() string

String implements Format.

type MPEG2Video

type MPEG2Video struct{}

MPEG2Video is a format that uses a MPEG-1 or MPEG-2 video codec.

func (*MPEG2Video) ClockRate

func (t *MPEG2Video) ClockRate() int

ClockRate implements Format.

func (*MPEG2Video) Marshal

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

Marshal implements Format.

func (*MPEG2Video) PTSEqualsDTS

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

PTSEqualsDTS implements Format.

func (*MPEG2Video) PayloadType

func (t *MPEG2Video) PayloadType() uint8

PayloadType implements Format.

func (*MPEG2Video) String

func (t *MPEG2Video) String() string

String implements Format.

type MPEG4Audio

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

MPEG4Audio is a format that uses a MPEG-4 audio codec.

func (*MPEG4Audio) ClockRate

func (t *MPEG4Audio) ClockRate() int

ClockRate implements Format.

func (*MPEG4Audio) CreateDecoder

func (t *MPEG4Audio) CreateDecoder() *rtpmpeg4audio.Decoder

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

func (*MPEG4Audio) CreateEncoder

func (t *MPEG4Audio) CreateEncoder() *rtpmpeg4audio.Encoder

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

func (*MPEG4Audio) Marshal

func (t *MPEG4Audio) Marshal() (string, map[string]string)

Marshal implements Format.

func (*MPEG4Audio) PTSEqualsDTS

func (t *MPEG4Audio) PTSEqualsDTS(*rtp.Packet) bool

PTSEqualsDTS implements Format.

func (*MPEG4Audio) PayloadType

func (t *MPEG4Audio) PayloadType() uint8

PayloadType implements Format.

func (*MPEG4Audio) String

func (t *MPEG4Audio) String() string

String implements Format.

type Opus

type Opus struct {
	PayloadTyp uint8
	IsStereo   bool
}

Opus is a format that uses the Opus codec.

func (*Opus) ClockRate

func (t *Opus) ClockRate() int

ClockRate implements Format.

func (*Opus) CreateDecoder

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

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

func (*Opus) CreateEncoder

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

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

func (*Opus) Marshal

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

Marshal implements Format.

func (*Opus) PTSEqualsDTS

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

PTSEqualsDTS implements Format.

func (*Opus) PayloadType

func (t *Opus) PayloadType() uint8

PayloadType implements Format.

func (*Opus) String

func (t *Opus) String() string

String implements Format.

type VP8

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

VP8 is a format that uses the VP8 codec.

func (*VP8) ClockRate

func (t *VP8) ClockRate() int

ClockRate implements Format.

func (*VP8) CreateDecoder

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

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

func (*VP8) CreateEncoder

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

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

func (*VP8) Marshal

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

Marshal implements Format.

func (*VP8) PTSEqualsDTS

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

PTSEqualsDTS implements Format.

func (*VP8) PayloadType

func (t *VP8) PayloadType() uint8

PayloadType implements Format.

func (*VP8) String

func (t *VP8) String() string

String implements Format.

type VP9

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

VP9 is a format that uses the VP9 codec.

func (*VP9) ClockRate

func (t *VP9) ClockRate() int

ClockRate implements Format.

func (*VP9) CreateDecoder

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

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

func (*VP9) CreateEncoder

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

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

func (*VP9) Marshal

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

Marshal implements Format.

func (*VP9) PTSEqualsDTS

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

PTSEqualsDTS implements Format.

func (*VP9) PayloadType

func (t *VP9) PayloadType() uint8

PayloadType implements Format.

func (*VP9) String

func (t *VP9) String() string

String implements Format.

type Vorbis

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

Vorbis is a format that uses the Vorbis codec.

func (*Vorbis) ClockRate

func (t *Vorbis) ClockRate() int

ClockRate implements Format.

func (*Vorbis) Marshal

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

Marshal implements Format.

func (*Vorbis) PTSEqualsDTS

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

PTSEqualsDTS implements Format.

func (*Vorbis) PayloadType

func (t *Vorbis) PayloadType() uint8

PayloadType implements Format.

func (*Vorbis) String

func (t *Vorbis) String() string

String implements Format.

Jump to

Keyboard shortcuts

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