Documentation
¶
Index ¶
- Variables
- func AnswerMedia(rtpListenerPort int, audio *AudioConfig, crypt *srtp.Profile) *sdp.MediaDescription
- func CodecByName(name string) media.Codecdeprecated
- func CodecByNameWith(s *media.CodecSet, name string) media.Codec
- func GetAudio(s *sdp.SessionDescription) *sdp.MediaDescription
- func GetAudioDest(s *sdp.SessionDescription, audio *sdp.MediaDescription) (netip.AddrPort, error)
- func SelectCrypto(offer, answer []srtp.Profile, swap bool) (*srtp.Config, *srtp.Profile, error)
- type Answer
- type AudioConfig
- type CodecInfo
- type Description
- type Encryption
- type MediaConfig
- type MediaDesc
- func OfferMedia(rtpListenerPort int, encrypted Encryption) (MediaDesc, *sdp.MediaDescription, error)deprecated
- func OfferMediaWith(s *media.CodecSet, rtpListenerPort int, encrypted Encryption) (MediaDesc, *sdp.MediaDescription, error)
- func ParseMedia(d *sdp.MediaDescription) (*MediaDesc, error)deprecated
- func ParseMediaWith(s *media.CodecSet, d *sdp.MediaDescription) (*MediaDesc, error)
- type Offer
- func NewOffer(publicIp netip.Addr, rtpListenerPort int, encrypted Encryption) (*Offer, error)deprecated
- func NewOfferWith(s *media.CodecSet, publicIp netip.Addr, rtpListenerPort int, ...) (*Offer, error)
- func ParseOffer(data []byte) (*Offer, error)deprecated
- func ParseOfferWith(s *media.CodecSet, data []byte) (*Offer, error)
Constants ¶
This section is empty.
Variables ¶
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 CodecByNameWith ¶
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 GetAudio ¶
func GetAudio(s *sdp.SessionDescription) *sdp.MediaDescription
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=.
Types ¶
type Answer ¶
type Answer Description
func ParseAnswer
deprecated
func ParseAnswerWith ¶
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 ¶
func OfferCodecs
deprecated
func OfferCodecs() []CodecInfo
OfferCodecs is the same as OfferCodecsWith called with media.GlobalCodecs().
Deprecated: use OfferCodecsWith
func OfferCodecsWith ¶
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
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 ¶
ParseMediaWith parses SDP media description based on the given codec set.
type Offer ¶
type Offer Description
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 ParseOfferWith ¶
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.