sdp

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 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

func ICECandidateMarshal(c ice.Candidate) []string

ICECandidateMarshal takes a candidate and returns a string representation

func ICECandidateUnmarshal

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

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

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

func (*Address) String

func (c *Address) String() string

type Attribute

type Attribute string

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

func (*Attribute) String

func (a *Attribute) String() *string

type Bandwidth

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

func (b *Bandwidth) String() *string

type Codec

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

Codec represents a codec

func (Codec) String

func (c Codec) String() string

type ConnectionInformation

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

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

func (*ConnectionInformation) String

func (c *ConnectionInformation) String() *string

type ConnectionRole

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

func (t ConnectionRole) String() string

type EmailAddress

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

func (e *EmailAddress) String() *string

type EncryptionKey

type EncryptionKey string

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

func (*EncryptionKey) String

func (s *EncryptionKey) String() *string

type Information

type Information string

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

func (*Information) String

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

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

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

WithCandidate adds an ICE candidate to the media description

func (*MediaDescription) WithCodec

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

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

WithICECredentials adds ICE credentials to the media description

func (*MediaDescription) WithMediaSource

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

WithMediaSource adds media source information to the media description

func (*MediaDescription) WithPropertyAttribute

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

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

func (*MediaDescription) WithValueAttribute

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

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

type MediaName

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

MediaName describes the "m=" field storage structure.

func (*MediaName) String

func (m *MediaName) String() *string

type Origin

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

func (o *Origin) String() *string

type PhoneNumber

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

func (p *PhoneNumber) String() *string

type RangedPort

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

func (p *RangedPort) String() string

type RepeatTime

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

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

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

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

WithMedia adds a media description to the session description

func (*SessionDescription) WithPropertyAttribute

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

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

func (*SessionDescription) WithValueAttribute

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

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

type SessionName

type SessionName string

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

func (*SessionName) String

func (s *SessionName) String() *string

type TimeDescription

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

type TimeZone struct {
	AdjustmentTime uint64
	Offset         int64
}

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

func (*TimeZone) String

func (z *TimeZone) String() string

type Timing

type Timing struct {
	StartTime uint64
	StopTime  uint64
}

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

func (*Timing) String

func (t *Timing) String() *string

type Version

type Version int

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

func (*Version) String

func (v *Version) String() *string

Jump to

Keyboard shortcuts

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