sdp

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2018 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AttrKeyIdentity        = "identity"
	AttrKeyGroup           = "group"
	AttrKeySsrc            = "ssrc"
	AttrKeySsrcGroup       = "ssrc-group"
	AttrKeyMsidSemantic    = "msid-semantic"
	AttrKeyConnectionSetup = "setup"
	AttrKeyMID             = "mid"
	AttrKeyICELite         = "ice-lite"
	AttrKeyRtcpMux         = "rtcp-mux"
	AttrKeyRtcpRsize       = "rtcp-rsize"
)

Constants for SDP attributes used in JSEP

View Source
const (
	SemanticTokenLipSynchronization     = "LS"
	SemanticTokenFlowIdentification     = "FID"
	SemanticTokenForwardErrorCorrection = "FEC"
	SemanticTokenWebRTCMediaStreams     = "WMS"
)

Constants for semantic tokens used in JSEP

Variables

This section is empty.

Functions

func ICECandidateMarshal added in v1.1.0

func ICECandidateMarshal(c ice.Candidate) []string

ICECandidateMarshal takes a candidate and returns a string representation

func ICECandidateUnmarshal added in v1.1.0

func ICECandidateUnmarshal(raw string) ice.Candidate

ICECandidateUnmarshal takes a candidate strings and returns a ice.Candidate or nil if it fails to parse

Types

type Address added in v1.1.0

type Address struct {
	IP    net.IP
	TTL   *int
	Range *int
}

Address desribes a structured address token from within the "c=" field.

func (*Address) String added in v1.1.0

func (c *Address) String() string

type Attribute added in v1.1.0

type Attribute string

Attribute describes the "a=" field which represents the primary means for extending SDP.

func (*Attribute) String added in v1.1.0

func (a *Attribute) String() *string

type Bandwidth added in v1.1.0

type Bandwidth struct {
	Experimental bool
	Type         string
	Bandwidth    uint64
}

Bandwidth describes an optional field which denotes the proposed bandwidth to be used by the session or media.

func (*Bandwidth) String added in v1.1.0

func (b *Bandwidth) String() *string

type Codec added in v1.1.0

type Codec struct {
	PayloadType        uint8
	Name               string
	ClockRate          uint32
	EncodingParameters string
	Fmtp               string
}

Codec represents a codec

func (Codec) String added in v1.1.0

func (c Codec) String() string

type ConnectionInformation added in v1.1.0

type ConnectionInformation struct {
	NetworkType string
	AddressType string
	Address     *Address
}

ConnectionInformation defines the representation for the "c=" field containing connection data.

func (*ConnectionInformation) String added in v1.1.0

func (c *ConnectionInformation) String() *string

type ConnectionRole added in v1.1.0

type ConnectionRole int

ConnectionRole indicates which of the end points should initiate the connection establishment

const (
	// ConnectionRoleActive indicates the endpoint will initiate an outgoing connection.
	ConnectionRoleActive ConnectionRole = iota + 1

	// ConnectionRolePassive indicates the endpoint will accept an incoming connection.
	ConnectionRolePassive

	// ConnectionRoleActpass indicates the endpoint is willing to accept an incoming connection or to initiate an outgoing connection.
	ConnectionRoleActpass

	// ConnectionRoleHoldconn indicates the endpoint does not want the connection to be established for the time being.
	ConnectionRoleHoldconn
)

func (ConnectionRole) String added in v1.1.0

func (t ConnectionRole) String() string

type EmailAddress added in v1.1.0

type EmailAddress string

EmailAddress describes a structured representations for the "e=" line which specifies email contact information for the person responsible for the conference.

func (*EmailAddress) String added in v1.1.0

func (e *EmailAddress) String() *string

type EncryptionKey added in v1.1.0

type EncryptionKey string

EncryptionKey describes the "k=" which conveys encryption key information.

func (*EncryptionKey) String added in v1.1.0

func (s *EncryptionKey) String() *string

type Information added in v1.1.0

type Information string

Information describes the "i=" field which provides textual information about the session.

func (*Information) String added in v1.1.0

func (i *Information) String() *string

type MediaDescription

type MediaDescription struct {
	// m=<media> <port>/<number of ports> <proto> <fmt> ...
	// https://tools.ietf.org/html/rfc4566#section-5.14
	MediaName MediaName

	// i=<session description>
	// https://tools.ietf.org/html/rfc4566#section-5.4
	MediaTitle *Information

	// c=<nettype> <addrtype> <connection-address>
	// https://tools.ietf.org/html/rfc4566#section-5.7
	ConnectionInformation *ConnectionInformation

	// b=<bwtype>:<bandwidth>
	// https://tools.ietf.org/html/rfc4566#section-5.8
	Bandwidth []Bandwidth

	// k=<method>
	// k=<method>:<encryption key>
	// https://tools.ietf.org/html/rfc4566#section-5.12
	EncryptionKey *EncryptionKey

	// a=<attribute>
	// a=<attribute>:<value>
	// https://tools.ietf.org/html/rfc4566#section-5.13
	Attributes []Attribute
}

MediaDescription represents a media type. https://tools.ietf.org/html/rfc4566#section-5.14

func NewJSEPMediaDescription added in v1.1.0

func NewJSEPMediaDescription(codecType string, codecPrefs []string) *MediaDescription

NewJSEPMediaDescription creates a new MediaName with some settings that are required by the JSEP spec.

func (*MediaDescription) WithCandidate added in v1.1.0

func (d *MediaDescription) WithCandidate(value string) *MediaDescription

WithCandidate adds an ICE candidate to the media description

func (*MediaDescription) WithCodec added in v1.1.0

func (d *MediaDescription) WithCodec(payloadType uint8, name string, clockrate uint32, channels uint16, fmtp string) *MediaDescription

WithCodec adds codec information to the media description

func (*MediaDescription) WithICECredentials added in v1.1.0

func (d *MediaDescription) WithICECredentials(username, password string) *MediaDescription

WithICECredentials adds ICE credentials to the media description

func (*MediaDescription) WithMediaSource added in v1.1.0

func (d *MediaDescription) WithMediaSource(ssrc uint32, cname, streamLabel, label string) *MediaDescription

WithMediaSource adds media source information to the media description

func (*MediaDescription) WithPropertyAttribute added in v1.1.0

func (d *MediaDescription) WithPropertyAttribute(key string) *MediaDescription

WithPropertyAttribute adds a property attribute 'a=key' to the media description

func (*MediaDescription) WithValueAttribute added in v1.1.0

func (d *MediaDescription) WithValueAttribute(key, value string) *MediaDescription

WithValueAttribute adds a value attribute 'a=key:value' to the media description

type MediaName added in v1.1.0

type MediaName struct {
	Media   string
	Port    RangedPort
	Protos  []string
	Formats []int
}

MediaName describes the "m=" field storage structure.

func (*MediaName) String added in v1.1.0

func (m *MediaName) String() *string

type Origin added in v1.1.0

type Origin struct {
	Username       string
	SessionID      uint64
	SessionVersion uint64
	NetworkType    string
	AddressType    string
	UnicastAddress string
}

Origin defines the structure for the "o=" field which provides the originator of the session plus a session identifier and version number.

func (*Origin) String added in v1.1.0

func (o *Origin) String() *string

type PhoneNumber added in v1.1.0

type PhoneNumber string

PhoneNumber describes a structured representations for the "p=" line specify phone contact information for the person responsible for the conference.

func (*PhoneNumber) String added in v1.1.0

func (p *PhoneNumber) String() *string

type RangedPort added in v1.1.0

type RangedPort struct {
	Value int
	Range *int
}

RangedPort supports special format for the media field "m=" port value. If it may be necessary to specify multiple transport ports, the protocol allows to write it as: <port>/<number of ports> where number of ports is a an offsetting range.

func (*RangedPort) String added in v1.1.0

func (p *RangedPort) String() string

type RepeatTime added in v1.1.0

type RepeatTime struct {
	Interval int64
	Duration int64
	Offsets  []int64
}

RepeatTime describes the "r=" fields of the session description which represents the intervals and durations for repeated scheduled sessions.

func (*RepeatTime) String added in v1.1.0

func (r *RepeatTime) String() *string

type SessionDescription

type SessionDescription struct {
	// v=0
	// https://tools.ietf.org/html/rfc4566#section-5.1
	Version Version

	// o=<username> <sess-id> <sess-version> <nettype> <addrtype> <unicast-address>
	// https://tools.ietf.org/html/rfc4566#section-5.2
	Origin Origin

	// s=<session name>
	// https://tools.ietf.org/html/rfc4566#section-5.3
	SessionName SessionName

	// i=<session description>
	// https://tools.ietf.org/html/rfc4566#section-5.4
	SessionInformation *Information

	// u=<uri>
	// https://tools.ietf.org/html/rfc4566#section-5.5
	URI *url.URL

	// e=<email-address>
	// https://tools.ietf.org/html/rfc4566#section-5.6
	EmailAddress *EmailAddress

	// p=<phone-number>
	// https://tools.ietf.org/html/rfc4566#section-5.6
	PhoneNumber *PhoneNumber

	// c=<nettype> <addrtype> <connection-address>
	// https://tools.ietf.org/html/rfc4566#section-5.7
	ConnectionInformation *ConnectionInformation

	// b=<bwtype>:<bandwidth>
	// https://tools.ietf.org/html/rfc4566#section-5.8
	Bandwidth []Bandwidth

	// https://tools.ietf.org/html/rfc4566#section-5.9
	// https://tools.ietf.org/html/rfc4566#section-5.10
	TimeDescriptions []TimeDescription

	// z=<adjustment time> <offset> <adjustment time> <offset> ...
	// https://tools.ietf.org/html/rfc4566#section-5.11
	TimeZones []TimeZone

	// k=<method>
	// k=<method>:<encryption key>
	// https://tools.ietf.org/html/rfc4566#section-5.12
	EncryptionKey *EncryptionKey

	// a=<attribute>
	// a=<attribute>:<value>
	// https://tools.ietf.org/html/rfc4566#section-5.13
	Attributes []Attribute

	// https://tools.ietf.org/html/rfc4566#section-5.14
	MediaDescriptions []*MediaDescription
}

SessionDescription is a a well-defined format for conveying sufficient information to discover and participate in a multimedia session.

func NewJSEPSessionDescription added in v1.1.0

func NewJSEPSessionDescription(fingerprint string, identity bool) *SessionDescription

NewJSEPSessionDescription creates a new SessionDescription with some settings that are required by the JSEP spec.

func (*SessionDescription) GetCodecForPayloadType added in v1.1.0

func (s *SessionDescription) GetCodecForPayloadType(payloadType uint8) (Codec, error)

GetCodecForPayloadType scans the SessionDescription for the given payloadType and returns the codec

func (*SessionDescription) Marshal

func (s *SessionDescription) Marshal() (raw string)

Marshal takes a SDP struct to text https://tools.ietf.org/html/rfc4566#section-5 Session description

v=  (protocol version)
o=  (originator and session identifier)
s=  (session name)
i=* (session information)
u=* (URI of description)
e=* (email address)
p=* (phone number)
c=* (connection information -- not required if included in
     all media)
b=* (zero or more bandwidth information lines)
One or more time descriptions ("t=" and "r=" lines; see below)
z=* (time zone adjustments)
k=* (encryption key)
a=* (zero or more session attribute lines)
Zero or more media descriptions

Time description

t=  (time the session is active)
r=* (zero or more repeat times)

Media description, if present

m=  (media name and transport address)
i=* (media title)
c=* (connection information -- optional if included at
     session level)
b=* (zero or more bandwidth information lines)
k=* (encryption key)
a=* (zero or more media attribute lines)

func (*SessionDescription) Unmarshal

func (s *SessionDescription) Unmarshal(value string) error

Unmarshal is the primary function that deserializes the session description message and stores it inside of a structured SessionDescription object.

The States Sransition Table describes the computation flow between functions (namely s1, s2, s3, ...) for a parsing procedure that complies with the specifications laid out by the rfc4566#section-5 as well as by JavaScript Session Establishment Protocol draft. Links:

https://tools.ietf.org/html/rfc4566#section-5
https://tools.ietf.org/html/draft-ietf-rtcweb-jsep-24

https://tools.ietf.org/html/rfc4566#section-5 Session description

v=  (protocol version)
o=  (originator and session identifier)
s=  (session name)
i=* (session information)
u=* (URI of description)
e=* (email address)
p=* (phone number)
c=* (connection information -- not required if included in
     all media)
b=* (zero or more bandwidth information lines)
One or more time descriptions ("t=" and "r=" lines; see below)
z=* (time zone adjustments)
k=* (encryption key)
a=* (zero or more session attribute lines)
Zero or more media descriptions

Time description

t=  (time the session is active)
r=* (zero or more repeat times)

Media description, if present

m=  (media name and transport address)
i=* (media title)
c=* (connection information -- optional if included at
     session level)
b=* (zero or more bandwidth information lines)
k=* (encryption key)
a=* (zero or more media attribute lines)

In order to generate the following state table and draw subsequent deterministic finite-state automota ("DFA") the following regex was used to derive the DFA:

vosi?u?e?p?c?b*(tr*)+z?k?a*(mi?c?b*k?a*)*

Please pay close attention to the `k`, and `a` parsing states. In the table below in order to distinguish between the states belonging to the media description as opposed to the session description, the states are marked with an asterisk ("a*", "k*"). +--------+----+-------+----+-----+----+-----+---+----+----+---+---+-----+---+---+----+---+----+ | STATES | a* | a*,k* | a | a,k | b | b,c | e | i | m | o | p | r,t | s | t | u | v | z | +--------+----+-------+----+-----+----+-----+---+----+----+---+---+-----+---+---+----+---+----+ | s1 | | | | | | | | | | | | | | | | 2 | | | s2 | | | | | | | | | | 3 | | | | | | | | | s3 | | | | | | | | | | | | | 4 | | | | | | s4 | | | | | | 5 | 6 | 7 | | | 8 | | | 9 | 10 | | | | s5 | | | | | 5 | | | | | | | | | 9 | | | | | s6 | | | | | | 5 | | | | | 8 | | | 9 | | | | | s7 | | | | | | 5 | 6 | | | | 8 | | | 9 | 10 | | | | s8 | | | | | | 5 | | | | | | | | 9 | | | | | s9 | | | | 11 | | | | | 12 | | | 9 | | | | | 13 | | s10 | | | | | | 5 | 6 | | | | 8 | | | 9 | | | | | s11 | | | 11 | | | | | | 12 | | | | | | | | | | s12 | | 14 | | | | 15 | | 16 | 12 | | | | | | | | | | s13 | | | | 11 | | | | | 12 | | | | | | | | | | s14 | 14 | | | | | | | | 12 | | | | | | | | | | s15 | | 14 | | | 15 | | | | 12 | | | | | | | | | | s16 | | 14 | | | | 15 | | | 12 | | | | | | | | | +--------+----+-------+----+-----+----+-----+---+----+----+---+---+-----+---+---+----+---+----+

func (*SessionDescription) WithMedia added in v1.1.0

WithMedia adds a media description to the session description

func (*SessionDescription) WithPropertyAttribute added in v1.1.0

func (s *SessionDescription) WithPropertyAttribute(key string) *SessionDescription

WithPropertyAttribute adds a property attribute 'a=key' to the session description

func (*SessionDescription) WithValueAttribute added in v1.1.0

func (s *SessionDescription) WithValueAttribute(key, value string) *SessionDescription

WithValueAttribute adds a value attribute 'a=key:value' to the session description

type SessionName added in v1.1.0

type SessionName string

SessionName describes a structured representations for the "s=" field and is the textual session name.

func (*SessionName) String added in v1.1.0

func (s *SessionName) String() *string

type TimeDescription added in v1.1.0

type TimeDescription struct {
	// t=<start-time> <stop-time>
	// https://tools.ietf.org/html/rfc4566#section-5.9
	Timing Timing

	// r=<repeat interval> <active duration> <offsets from start-time>
	// https://tools.ietf.org/html/rfc4566#section-5.10
	RepeatTimes []RepeatTime
}

TimeDescription describes "t=", "r=" fields of the session description which are used to specify the start and stop times for a session as well as repeat intervals and durations for the scheduled session.

type TimeZone added in v1.1.0

type TimeZone struct {
	AdjustmentTime uint64
	Offset         int64
}

TimeZone defines the structured object for "z=" line which describes repeated sessions scheduling.

func (*TimeZone) String added in v1.1.0

func (z *TimeZone) String() string

type Timing added in v1.1.0

type Timing struct {
	StartTime uint64
	StopTime  uint64
}

Timing defines the "t=" field's structured representation for the start and stop times.

func (*Timing) String added in v1.1.0

func (t *Timing) String() *string

type Version added in v1.1.0

type Version int

Version describes the value provided by the "v=" field which gives the version of the Session Description Protocol.

func (*Version) String added in v1.1.0

func (v *Version) String() *string

Jump to

Keyboard shortcuts

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