sdp

package
v0.0.0-...-67dd4ed Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2025 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

func CodecByName

func CodecByName(name string) media.Codec

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

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

func (*Answer) Apply

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

type AudioConfig

type AudioConfig struct {
	Codec    rtp.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

func OfferCodecs() []CodecInfo

type Description

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

func Parse

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

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
}

type MediaDesc

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

func OfferMedia

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

func ParseMedia

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

type Offer

type Offer Description

func NewOffer

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

func ParseOffer

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

func (*Offer) Answer

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

Jump to

Keyboard shortcuts

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