sdp

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2020 License: MIT Imports: 7 Imported by: 39

Documentation

Index

Constants

View Source
const (
	TypeIPv4 = "IP4"
	TypeIPv6 = "IP6"
)
View Source
const (
	SendRecv = "sendrecv"
	SendOnly = "sendonly"
	RecvOnly = "recvonly"
	Inactive = "inactive"
)

Streaming modes.

View Source
const ContentType = "application/sdp"

ContentType is the media type for an SDP session description.

View Source
const (
	NetworkInternet = "IN"
)

Variables

This section is empty.

Functions

func NegotiateMode

func NegotiateMode(local, remote string) string

NegotiateMode negotiates streaming mode.

Types

type Attr

type Attr struct {
	Name, Value string
}

Attr represents session or media attribute.

func NewAttr

func NewAttr(attr, value string) *Attr

NewAttr returns a=<attribute>:<value> attribute.

func NewAttrFlag

func NewAttrFlag(flag string) *Attr

NewAttrFlag returns a=<flag> attribute.

func (*Attr) String

func (a *Attr) String() string

type Attributes

type Attributes []*Attr

Attributes represent a list of SDP attributes.

func DeleteAttr

func DeleteAttr(attrs Attributes, name ...string) Attributes

DeleteAttr removes all elements with name from attrs.

func (Attributes) Get

func (a Attributes) Get(name string) string

Get returns first attribute value by name.

func (Attributes) Has

func (a Attributes) Has(name string) bool

Has returns presence of attribute by name.

type Bandwidth

type Bandwidth struct {
	Type  string
	Value int
}

Bandwidth contains session or media bandwidth information.

type Connection

type Connection struct {
	Network    string
	Type       string
	Address    string
	TTL        int
	AddressNum int
}

Connection contains connection data.

type Decoder

type Decoder struct {
	// contains filtered or unexported fields
}

A Decoder reads a session description from a stream.

func NewDecoder

func NewDecoder(r io.Reader) *Decoder

NewDecoder returns new decoder that reads from r.

func NewDecoderString

func NewDecoderString(s string) *Decoder

NewDecoderString returns new decoder that reads from s.

func (*Decoder) Decode

func (d *Decoder) Decode() (*Session, error)

Decode encodes the session description.

type Encoder

type Encoder struct {
	// contains filtered or unexported fields
}

An Encoder writes a session description to a buffer.

func NewEncoder

func NewEncoder(w io.Writer) *Encoder

NewEncoder returns a new encoder that writes to w.

func NewEncoderSize

func NewEncoderSize(w io.Writer, size int) *Encoder

NewEncoderSize returns a new encoder that writes to w.

func (*Encoder) Bytes

func (e *Encoder) Bytes() []byte

Bytes returns encoded bytes of the last session description. The bytes stop being valid at the next encoder call.

func (*Encoder) Encode

func (e *Encoder) Encode(s *Session) error

Encode encodes the session description.

func (*Encoder) Flush

func (e *Encoder) Flush() error

Flush writes encoded bytes to w.

func (*Encoder) Reset

func (e *Encoder) Reset()

Reset resets encoder state to be empty.

func (*Encoder) String

func (e *Encoder) String() string

Bytes returns the encoded session description as str.

type Format

type Format struct {
	Payload   uint8
	Name      string
	ClockRate int
	Channels  int
	Feedback  []string // "rtcp-fb" attributes
	Params    []string // "fmtp" attributes
}

Format is a media format description represented by "rtpmap" attributes.

func (*Format) String

func (f *Format) String() string

type Key

type Key struct {
	Method, Value string
}

Key contains a key exchange information. Deprecated. Use for backwards compatibility only.

type Media

type Media struct {
	Type        string
	Port        int
	PortNum     int
	Proto       string
	Information string        // Media Information ("i=")
	Connection  []*Connection // Connection Data ("c=")
	Bandwidth   []*Bandwidth  // Bandwidth ("b=")
	Key         []*Key        // Encryption Keys ("k=")
	Attributes                // Attributes ("a=")
	Mode        string        // Streaming mode ("sendrecv", "recvonly", "sendonly", or "inactive")
	Format      []*Format     // Media Format for RTP/AVP or RTP/SAVP protocols ("rtpmap", "fmtp", "rtcp-fb")
	FormatDescr string        // Media Format for other protocols
}

Media contains media description.

func (*Media) FormatByPayload

func (m *Media) FormatByPayload(payload uint8) *Format

FormatByPayload returns format description by payload type.

type Origin

type Origin struct {
	Username       string
	SessionID      int64
	SessionVersion int64
	Network        string
	Type           string
	Address        string
}

Origin represents an originator of the session.

type Repeat

type Repeat struct {
	Interval time.Duration
	Duration time.Duration
	Offsets  []time.Duration
}

Repeat specifies repeat times for a session.

type Session

type Session struct {
	Version     int          // Protocol Version ("v=")
	Origin      *Origin      // Origin ("o=")
	Name        string       // Session Name ("s=")
	Information string       // Session Information ("i=")
	URI         string       // URI ("u=")
	Email       []string     // Email Address ("e=")
	Phone       []string     // Phone Number ("p=")
	Connection  *Connection  // Connection Data ("c=")
	Bandwidth   []*Bandwidth // Bandwidth ("b=")
	TimeZone    []*TimeZone  // TimeZone ("z=")
	Key         []*Key       // Encryption Keys ("k=")
	Timing      *Timing      // Timing ("t=")
	Repeat      []*Repeat    // Repeat Times ("r=")
	Attributes  Attributes   // Session Attributes ("a=")
	Mode        string       // Streaming mode ("sendrecv", "recvonly", "sendonly", or "inactive")
	Media       []*Media     // Media Descriptions ("m=")
}

Session represents an SDP session description.

func Parse

func Parse(b []byte) (*Session, error)

Parse reads session description from the buffer.

func ParseString

func ParseString(s string) (*Session, error)

ParseString reads session description from the string.

func (*Session) Bytes

func (s *Session) Bytes() []byte

Bytes returns the encoded session description as buffer.

func (*Session) String

func (s *Session) String() string

String returns the encoded session description as string.

type TimeZone

type TimeZone struct {
	Time   time.Time
	Offset time.Duration
}

TimeZone represents a time zones change information for a repeated session.

type Timing

type Timing struct {
	Start time.Time
	Stop  time.Time
}

Timing specifies start and stop times for a session.

Jump to

Keyboard shortcuts

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