sdp

package
v0.0.0-...-18f3c65 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContentType = "application/sdp"
	MaxLength   = 1450
)

Variables

View Source
var (
	ULAWCodec = Codec{PT: 0, Name: "PCMU", Rate: 8000}
	DTMFCodec = Codec{PT: 101, Name: "telephone-event", Rate: 8000, Fmtp: "0-16"}
	Opus      = Codec{PT: 111, Name: "opus", Rate: 48000, Param: "2"}

	StandardCodecs = map[uint8]Codec{
		0:  ULAWCodec,
		3:  {PT: 3, Name: "GSM", Rate: 8000},
		4:  {PT: 4, Name: "G723", Rate: 8000},
		5:  {PT: 5, Name: "DVI4", Rate: 8000},
		6:  {PT: 6, Name: "DVI4", Rate: 16000},
		7:  {PT: 7, Name: "LPC", Rate: 8000},
		8:  {PT: 8, Name: "PCMA", Rate: 8000},
		9:  {PT: 9, Name: "G722", Rate: 8000},
		10: {PT: 10, Name: "L16", Rate: 44100, Param: "2"},
		11: {PT: 11, Name: "L16", Rate: 44100},
		12: {PT: 12, Name: "QCELP", Rate: 8000},
		13: {PT: 13, Name: "CN", Rate: 8000},
		14: {PT: 14, Name: "MPA", Rate: 90000},
		15: {PT: 15, Name: "G728", Rate: 8000},
		16: {PT: 16, Name: "DVI4", Rate: 11025},
		17: {PT: 17, Name: "DVI4", Rate: 22050},
		18: {PT: 18, Name: "G729", Rate: 8000},
		25: {PT: 25, Name: "CelB", Rate: 90000},
		26: {PT: 26, Name: "JPEG", Rate: 90000},
		28: {PT: 28, Name: "nv", Rate: 90000},
		31: {PT: 31, Name: "H261", Rate: 90000},
		32: {PT: 32, Name: "MPV", Rate: 90000},
		33: {PT: 33, Name: "MP2T", Rate: 90000},
		34: {PT: 34, Name: "H263", Rate: 90000},
	}
)

Functions

This section is empty.

Types

type Codec

type Codec struct {
	PT    uint8  // 7-bit payload type we need to put in our RTP packets
	Name  string // e.g. PCMU, G729, telephone-event, etc.
	Rate  int    // frequency in hertz.  usually 8000
	Param string // sometimes used to specify number of channels
	Fmtp  string // some extra info; i.e. dtmf might set as "0-16"
}

Codec describes one of the codec lines in an SDP. This data will be magically filled in if the rtpmap wasn't provided (assuming it's a well known codec having a payload type less than 96.)

func (*Codec) Append

func (codec *Codec) Append(b *bytes.Buffer)

type Media

type Media struct {
	Proto  string  // RTP, SRTP, UDP, UDPTL, TCP, TLS, etc.
	Port   uint16  // Port number (0 - 2^16-1)
	Codecs []Codec // Collection of codecs of a specific type.
}

Media is a high level representation of the c=/m=/a= lines for describing a specific type of media. Only "audio" and "video" are supported at this time.

func (*Media) Append

func (media *Media) Append(type_ string, b *bytes.Buffer)

type Origin

type Origin struct {
	User    string // First value in o= line
	ID      string // Second value in o= line
	Version string // Third value in o= line
	Addr    string // Tracks IP of original user-agent
}

Origin represents the session origin (o=) line of an SDP. Who knows what this is supposed to do.

func (*Origin) Append

func (origin *Origin) Append(b *bytes.Buffer)

type SDP

type SDP struct {
	Origin   Origin      // This must always be present
	Addr     string      // Connect to this IP; never blank (from c=)
	Audio    *Media      // Non-nil if we can establish audio
	Video    *Media      // Non-nil if we can establish video
	Session  string      // s= Session Name (default "-")
	Time     string      // t= Active Time (default "0 0")
	Ptime    int         // Transmit frame every N milliseconds (default 20)
	SendOnly bool        // True if 'a=sendonly' was specified in SDP
	RecvOnly bool        // True if 'a=recvonly' was specified in SDP
	Attrs    [][2]string // a= lines we don't recognize
	Other    [][2]string // Other description
}

SDP represents a Session Description Protocol SIP payload.

func New

func New(addr *net.UDPAddr, codecs ...Codec) *SDP

Easy way to create a basic, everyday SDP for VoIP.

func Parse

func Parse(s string) (sdp *SDP, err error)

parses sdp message text into a happy data structure

func (*SDP) Append

func (sdp *SDP) Append(b *bytes.Buffer)

func (*SDP) ContentType

func (sdp *SDP) ContentType() string

func (*SDP) Data

func (sdp *SDP) Data() []byte

func (*SDP) String

func (sdp *SDP) String() string

Jump to

Keyboard shortcuts

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