sdp

package
v0.0.0-...-7962ebb Latest Latest
Warning

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

Go to latest
Published: May 27, 2026 License: Apache-2.0 Imports: 15 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoCommonMedia  = errors.New("common audio codec not found")
	ErrNoCommonCrypto = errors.New("no common encryption profiles")
)

Functions

func AnswerMedia

func AnswerMedia(rtpListenerPort int, audio *AudioConfig, crypt *srtp.Profile) *sdp.MediaDescription

AnswerMedia creates a new SDP media description for an answer.

func CodecByName deprecated

func CodecByName(name string) media.Codec

CodecByName finds the codec with a given SDP name.

Deprecated: use CodecByNameWith

func CodecByNameWith

func CodecByNameWith(s *media.CodecSet, name string) media.Codec

CodecByNameWith finds the codec with a given SDP name. If the codec is not found or disabled in the codec set, it returns nil.

func GetAudioDest

func GetAudioDest(s *sdp.SessionDescription, audio *sdp.MediaDescription) (netip.AddrPort, error)

GetAudioDest returns the RTP dst address:port for an audio m= it first uses media-level c=, then session-level c=.

func SelectCrypto

func SelectCrypto(offer, answer []srtp.Profile, swap bool) (*srtp.Config, *srtp.Profile, error)

Types

type Answer

type Answer Description

func ParseAnswer deprecated

func ParseAnswer(data []byte) (*Answer, error)

ParseAnswer parses the SDP answer.

Deprecated: use ParseAnswerWith

func ParseAnswerWith

func ParseAnswerWith(s *media.CodecSet, data []byte) (*Answer, error)

ParseAnswerWith parses the SDP answer using the codecs from the codec set.

func (*Answer) Apply

func (d *Answer) Apply(offer *Offer, enc Encryption) (*MediaConfig, error)

Apply the SDP offer to generate the final media config.

func (*Answer) ApplyWithLocal

func (d *Answer) ApplyWithLocal(offer *Offer, enc Encryption) (*MediaConfig, *sdp.SessionDescription, error)

Applies the answer to the offer and returns the negotiated MediaConfig and the offerer's local SDP bytes.

type AudioConfig

type AudioConfig struct {
	Codec    media.AudioCodec
	Type     byte
	DTMFType byte
}

func SelectAudio

func SelectAudio(desc MediaDesc, answer bool) (*AudioConfig, error)

type CodecInfo

type CodecInfo struct {
	Type  byte
	Codec media.Codec
}

func OfferCodecs deprecated

func OfferCodecs() []CodecInfo

OfferCodecs is the same as OfferCodecsWith called with media.GlobalCodecs().

Deprecated: use OfferCodecsWith

func OfferCodecsWith

func OfferCodecsWith(s *media.CodecSet) []CodecInfo

OfferCodecsWith lists enabled codecs in the set for the SDP offer and assigns payload types to them.

type Description

type Description struct {
	SDP  sdp.SessionDescription
	Addr netip.AddrPort
	MediaDesc
}

func Parse deprecated

func Parse(data []byte) (*Description, error)

Parse the SDP description. This is a helper that is called by both ParseOffer and ParseAnswer.

Deprecated: use ParseWith

func ParseWith

func ParseWith(s *media.CodecSet, data []byte) (*Description, error)

ParseWith parses the SDP description using the codecs from the codec set.

This is a helper that is called by both ParseOfferWith and ParseAnswerWith.

type Encryption

type Encryption int
const (
	EncryptionNone Encryption = iota
	EncryptionAllow
	EncryptionRequire
)

type MediaConfig

type MediaConfig struct {
	Local  netip.AddrPort
	Remote netip.AddrPort
	Audio  AudioConfig
	Crypto *srtp.Config
}

MediaConfig is the canonical representation of the negotiated session.

type MediaDesc

type MediaDesc struct {
	Codecs         []CodecInfo
	DTMFType       byte // set to 0 if there's no DTMF
	CryptoProfiles []srtp.Profile
}

func OfferMedia deprecated

func OfferMedia(rtpListenerPort int, encrypted Encryption) (MediaDesc, *sdp.MediaDescription, error)

OfferMedia creates a new SDP media description.

Deprecated: use OfferMediaWith

func OfferMediaWith

func OfferMediaWith(s *media.CodecSet, rtpListenerPort int, encrypted Encryption) (MediaDesc, *sdp.MediaDescription, error)

OfferMediaWith creates a new SDP media description with a given codec set, public IP address and listening port.

func ParseMedia deprecated

func ParseMedia(d *sdp.MediaDescription) (*MediaDesc, error)

ParseMedia parses SDP media description.

Deprecated: use ParseMediaWith

func ParseMediaWith

func ParseMediaWith(s *media.CodecSet, d *sdp.MediaDescription) (*MediaDesc, error)

ParseMediaWith parses SDP media description based on the given codec set.

type Offer

type Offer Description

func NewOffer deprecated

func NewOffer(publicIp netip.Addr, rtpListenerPort int, encrypted Encryption) (*Offer, error)

NewOffer creates a new SDP offer.

Deprecated: use NewOfferWith

func NewOfferWith

func NewOfferWith(s *media.CodecSet, publicIp netip.Addr, rtpListenerPort int, encrypted Encryption) (*Offer, error)

NewOfferWith creates a new SDP offer with a given codec set, public IP address and listening port.

func ParseOffer deprecated

func ParseOffer(data []byte) (*Offer, error)

ParseOffer parses the SDP offer.

Deprecated: use ParseOfferWith

func ParseOfferWith

func ParseOfferWith(s *media.CodecSet, data []byte) (*Offer, error)

ParseOfferWith parses the SDP offer using the codecs from the codec set.

func (*Offer) Answer

func (d *Offer) Answer(publicIp netip.Addr, rtpListenerPort int, enc Encryption) (*Answer, *MediaConfig, error)

Answer generates an SDP answer for an offer.

Jump to

Keyboard shortcuts

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