sdp: gortc.io/sdp Index | Files | Directories

package sdp

import "gortc.io/sdp"

Package sdp implements RFC 4566 SDP: Session Description Protocol.

Index

Package Files

decoder.go encoder.go fields.go message.go sdp.go

Variables

var ErrFailedToDecodeIP = errors.New("invalid IP")

ErrFailedToDecodeIP means that decoder failed to parse IP.

func NTPToTime Uses

func NTPToTime(v uint64) time.Time

NTPToTime converts NTP timestamp to time.Time with special case for Zero time, that is interpreted as 0 timestamp.

func TimeToNTP Uses

func TimeToNTP(t time.Time) uint64

TimeToNTP converts time.Time to NTP timestamp with special case for Zero time, that is interpreted as 0 timestamp.

type Attributes Uses

type Attributes map[string][]string

Attributes is set of k:v.

func (Attributes) Flag Uses

func (a Attributes) Flag(flag string) bool

Flag returns true if set.

func (Attributes) Value Uses

func (a Attributes) Value(attribute string) string

Value returns value of first attribute.

func (Attributes) Values Uses

func (a Attributes) Values(attribute string) []string

Values returns list of values associated to attribute.

type BandwidthType Uses

type BandwidthType string

BandwidthType is <bwtype> sub-field of Bandwidth field.

const (
    BandwidthConferenceTotal     BandwidthType = "CT"
    BandwidthApplicationSpecific BandwidthType = "AS"
)

Possible values for <bwtype> defined in section 5.8.

type Bandwidths Uses

type Bandwidths map[BandwidthType]int

Bandwidths is map of BandwidthsType and int (bytes per second).

type ConnectionData Uses

type ConnectionData struct {
    NetworkType string // <nettype>
    AddressType string // <addrtype>
    IP          net.IP // <base multicast address>
    TTL         byte   // <ttl>
    Addresses   byte   // <number of addresses>
}

ConnectionData is representation for Connection Data field. Only IP field is required. NetworkType and AddressType have sensible defaults.

func (ConnectionData) Blank Uses

func (c ConnectionData) Blank() bool

Blank determines if ConnectionData is blank value.

func (ConnectionData) ConnectionAddress Uses

func (c ConnectionData) ConnectionAddress() string

ConnectionAddress formats <connection-address> sub-field.

func (ConnectionData) Equal Uses

func (c ConnectionData) Equal(b ConnectionData) bool

Equal returns c == b.

func (ConnectionData) String Uses

func (c ConnectionData) String() string

type DecodeError Uses

type DecodeError struct {
    Reason string
    Place  string
}

DecodeError wraps Reason of error and occurrence Place.

func (DecodeError) Error Uses

func (e DecodeError) Error() string

type Decoder Uses

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

Decoder decodes session.

func NewDecoder Uses

func NewDecoder(s Session) Decoder

NewDecoder returns Decoder for Session.

func (*Decoder) Decode Uses

func (d *Decoder) Decode(m *Message) error

Decode message from session.

type Encryption Uses

type Encryption struct {
    Method string
    Key    string
}

Encryption wraps encryption Key and Method.

func (Encryption) Blank Uses

func (e Encryption) Blank() bool

Blank determines whether Encryption is blank value.

func (Encryption) Equal Uses

func (e Encryption) Equal(b Encryption) bool

Equal returns e == b.

type Line Uses

type Line struct {
    Type  Type
    Value []byte
}

Line of SDP session.

Form

<type>=<value>

Where <type> MUST be exactly one case-significant character and <value> is structured text whose format depends on <type>.

func (Line) AppendTo Uses

func (l Line) AppendTo(b []byte) []byte

AppendTo appends Line encoded value to b.

func (*Line) Decode Uses

func (l *Line) Decode(b []byte) error

Decode parses b into l and returns error if any.

Decode does not reuse b, so it is safe to corrupt it.

func (Line) Equal Uses

func (l Line) Equal(b Line) bool

Equal returns true if l == b.

func (Line) String Uses

func (l Line) String() string

type Media Uses

type Media struct {
    Title       string
    Description MediaDescription
    Connection  ConnectionData
    Attributes  Attributes
    Encryption  Encryption
    Bandwidths  Bandwidths
}

Media is media description and attributes.

func (*Media) AddAttribute Uses

func (m *Media) AddAttribute(k string, values ...string)

AddAttribute appends new k-v pair to attribute list.

func (*Media) AddFlag Uses

func (m *Media) AddFlag(f string)

AddFlag appends new flag to attribute list.

func (*Media) Attribute Uses

func (m *Media) Attribute(k string) string

Attribute returns string v.

func (*Media) Flag Uses

func (m *Media) Flag(f string) bool

Flag returns true if set.

func (*Media) PayloadFormat Uses

func (m *Media) PayloadFormat(payloadType string) string

PayloadFormat returns payload format from a=rtpmap. See RFC 4566 Section 6.

type MediaDescription Uses

type MediaDescription struct {
    Type        string
    Port        int
    PortsNumber int
    Protocol    string
    Formats     []string
}

MediaDescription represents Media Description field value.

func (MediaDescription) Equal Uses

func (m MediaDescription) Equal(b MediaDescription) bool

Equal returns true if b equals to m.

type Medias Uses

type Medias []Media

Medias is list of Media.

type Message Uses

type Message struct {
    Version       int
    Origin        Origin
    Name          string
    Info          string
    Email         string
    Phone         string
    URI           string
    Connection    ConnectionData
    Attributes    Attributes
    Medias        Medias
    Encryption    Encryption
    Bandwidths    map[BandwidthType]int
    BandwidthType BandwidthType
    Timing        []Timing
    TZAdjustments []TimeZone
}

Message is top level abstraction.

func (*Message) AddAttribute Uses

func (m *Message) AddAttribute(k, v string)

AddAttribute appends new k-v pair to attribute list.

func (*Message) AddFlag Uses

func (m *Message) AddFlag(f string)

AddFlag appends new flag to attribute list.

func (*Message) Append Uses

func (m *Message) Append(s Session) Session

Append encodes message to Session and returns result.

See RFC 4566 Section 5.

func (Message) Attribute Uses

func (m Message) Attribute(attribute string) string

Attribute returns string v.

func (Message) End Uses

func (m Message) End() time.Time

End returns end of session.

func (Message) Flag Uses

func (m Message) Flag(flag string) bool

Flag returns true if set.

func (Message) Start Uses

func (m Message) Start() time.Time

Start returns start of session.

type Origin Uses

type Origin struct {
    Username       string // <username>
    SessionID      int    // <sess-id>
    SessionVersion int    // <sess-version>
    NetworkType    string // <nettype>
    AddressType    string // <addrtype>
    Address        string // <unicast-address>
}

Origin is field defined in RFC4566 5.2. See https://tools.ietf.org/html/rfc4566#section-5.2.

func (Origin) Equal Uses

func (o Origin) Equal(b Origin) bool

Equal returns b == o.

type Session Uses

type Session []Line

Session is set of Lines.

func DecodeSession Uses

func DecodeSession(b []byte, s Session) (Session, error)

DecodeSession decodes Session from b, returning error if any. Blank lines and leading/trialing whitespace are ignored.

If s is passed, it will be reused with its lines. It is safe to mutate b.

func (Session) AddAttribute Uses

func (s Session) AddAttribute(attribute string, values ...string) Session

AddAttribute appends Attribute field to Session in a=<attribute>:<value>" form. If len(values) > 1, then "<value>" is "<val1> <val2> ... <valn>", and if len(values) == 0, then AddFlag method is used in "a=<flag>" form.

func (Session) AddBandwidth Uses

func (s Session) AddBandwidth(t BandwidthType, bandwidth int) Session

AddBandwidth appends Bandwidth field to Session.

func (Session) AddConnectionData Uses

func (s Session) AddConnectionData(data ConnectionData) Session

AddConnectionData appends Connection Data field to Session using ConnectionData struct with sensible defaults.

func (Session) AddConnectionDataIP Uses

func (s Session) AddConnectionDataIP(ip net.IP) Session

AddConnectionDataIP appends Connection Data field using only ip address.

func (Session) AddEmail Uses

func (s Session) AddEmail(email string) Session

AddEmail appends Email Address field to Session.

func (Session) AddEncryption Uses

func (s Session) AddEncryption(e Encryption) Session

AddEncryption appends Encryption and is shorthand for AddEncryptionKey.

func (Session) AddEncryptionKey Uses

func (s Session) AddEncryptionKey(method, key string) Session

AddEncryptionKey appends Encryption Key field with method and key in "k=<method>:<encryption key>" format to Session.

func (Session) AddEncryptionMethod Uses

func (s Session) AddEncryptionMethod(method string) Session

AddEncryptionMethod appends Encryption Key field with only method in "k=<method>" format to Session.

func (Session) AddFlag Uses

func (s Session) AddFlag(attribute string) Session

AddFlag appends Attribute field to Session in "a=<flag>" form.

func (Session) AddLine Uses

func (s Session) AddLine(t Type, v string) Session

AddLine appends t=v to Session.

func (Session) AddMediaDescription Uses

func (s Session) AddMediaDescription(m MediaDescription) Session

AddMediaDescription appends Media Description field to Session.

func (Session) AddOrigin Uses

func (s Session) AddOrigin(o Origin) Session

AddOrigin appends Origin field to Session.

func (Session) AddPhone Uses

func (s Session) AddPhone(phone string) Session

AddPhone appends Phone Address field to Session.

func (Session) AddRaw Uses

func (s Session) AddRaw(k rune, v string) Session

AddRaw appends k=v to Session.

func (Session) AddRepeatTimes Uses

func (s Session) AddRepeatTimes(interval, duration time.Duration,
    offsets ...time.Duration) Session

AddRepeatTimes appends Repeat Times field to Session.

func (Session) AddRepeatTimesCompact Uses

func (s Session) AddRepeatTimesCompact(interval, duration time.Duration,
    offsets ...time.Duration) Session

AddRepeatTimesCompact appends Repeat Times field to Session using "compact" syntax.

func (Session) AddSessionInfo Uses

func (s Session) AddSessionInfo(info string) Session

AddSessionInfo appends Session Information field to Session.

func (Session) AddSessionName Uses

func (s Session) AddSessionName(name string) Session

AddSessionName appends Session Name field to Session.

func (Session) AddTimeZones Uses

func (s Session) AddTimeZones(zones ...TimeZone) Session

AddTimeZones append TimeZones field to Session.

func (Session) AddTiming Uses

func (s Session) AddTiming(start, end time.Time) Session

AddTiming appends Timing field to Session. Both start and end can be zero.

func (Session) AddTimingNTP Uses

func (s Session) AddTimingNTP(start, end uint64) Session

AddTimingNTP appends Timing field to Session with NTP timestamps as input. It is just wrapper for AddTiming and NTPToTime.

func (Session) AddURI Uses

func (s Session) AddURI(uri string) Session

AddURI appends Uniform Resource Identifier field to Session.

func (Session) AddVersion Uses

func (s Session) AddVersion(version int) Session

AddVersion appends Version field to Session.

func (Session) AppendTo Uses

func (s Session) AppendTo(b []byte) []byte

AppendTo appends all session lines to b and returns b.

func (Session) Equal Uses

func (s Session) Equal(b Session) bool

Equal returns true if b == s.

type TimeZone Uses

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

TimeZone is representation of <adjustment time> <offset> pair.

type Timing Uses

type Timing struct {
    Start   time.Time
    End     time.Time
    Repeat  time.Duration
    Active  time.Duration
    Offsets []time.Duration
}

Timing wraps "repeat times" and "timing" information.

type Type Uses

type Type rune

Type of SDP Line is exactly one case-significant character.

const (
    TypeProtocolVersion    Type = 'v'
    TypeOrigin             Type = 'o'
    TypeSessionName        Type = 's'
    TypeSessionInformation Type = 'i'
    TypeURI                Type = 'u'
    TypeEmail              Type = 'e'
    TypePhone              Type = 'p'
    TypeConnectionData     Type = 'c'
    TypeBandwidth          Type = 'b'
    TypeTiming             Type = 't'
    TypeRepeatTimes        Type = 'r'
    TypeTimeZones          Type = 'z'
    TypeEncryptionKey      Type = 'k'
    TypeAttribute          Type = 'a'
    TypeMediaDescription   Type = 'm'
)

Attribute types as described in RFC 4566.

func (Type) String Uses

func (t Type) String() string

Directories

PathSynopsis
e2e

Package sdp imports 10 packages (graph). Updated 2018-09-23. Refresh now. Tools for package owners.