Documentation ¶
Overview ¶
Package sdp implements RFC 4566 SDP: Session Description Protocol.
Index ¶
- Variables
- func NTPToTime(v uint64) time.Time
- func TimeToNTP(t time.Time) uint64
- type Attribute
- type Attributes
- type BandwidthType
- type Bandwidths
- type ConnectionData
- type DecodeError
- type Decoder
- type Encryption
- type Line
- type Media
- type MediaDescription
- type Medias
- type Message
- type Origin
- type RtpMap
- type Session
- func (s Session) AddAttribute(attribute string, values ...string) Session
- func (s Session) AddBandwidth(t BandwidthType, bandwidth int) Session
- func (s Session) AddConnectionData(data ConnectionData) Session
- func (s Session) AddConnectionDataIP(ip net.IP) Session
- func (s Session) AddEmail(email string) Session
- func (s Session) AddEncryption(e Encryption) Session
- func (s Session) AddEncryptionKey(method, key string) Session
- func (s Session) AddEncryptionMethod(method string) Session
- func (s Session) AddFlag(attribute string) Session
- func (s Session) AddLine(t Type, v string) Session
- func (s Session) AddMediaDescription(m MediaDescription) Session
- func (s Session) AddOrigin(o Origin) Session
- func (s Session) AddPhone(phone string) Session
- func (s Session) AddRaw(k rune, v string) Session
- func (s Session) AddRepeatTimes(interval, duration time.Duration, offsets ...time.Duration) Session
- func (s Session) AddRepeatTimesCompact(interval, duration time.Duration, offsets ...time.Duration) Session
- func (s Session) AddSessionInfo(info string) Session
- func (s Session) AddSessionName(name string) Session
- func (s Session) AddTimeZones(zones ...TimeZone) Session
- func (s Session) AddTiming(start, end time.Time) Session
- func (s Session) AddTimingNTP(start, end uint64) Session
- func (s Session) AddURI(uri string) Session
- func (s Session) AddVersion(version int) Session
- func (s Session) AppendTo(b []byte) []byte
- func (s Session) Equal(b Session) bool
- type TimeZone
- type Timing
- type Type
Constants ¶
This section is empty.
Variables ¶
var ErrFailedToDecodeIP = errors.New("invalid IP")
ErrFailedToDecodeIP means that decoder failed to parse IP.
Functions ¶
Types ¶
type Attributes ¶
type Attributes []Attribute
Attributes is list of k:v.
func (Attributes) Value ¶
func (a Attributes) Value(attribute string) string
Value returns value of first attribute.
func (Attributes) Values ¶
func (a Attributes) Values(attribute string) []string
Values returns list of values associated to attribute.
type BandwidthType ¶
type BandwidthType string
BandwidthType is <bwtype> sub-field of Bandwidth field.
const ( BandwidthConferenceTotal BandwidthType = "CT" BandwidthApplicationSpecific BandwidthType = "AS" // defined in RFC 3890 BandwidthApplicationSpecificTransportIndependent BandwidthType = "TIAS" )
Possible values for <bwtype> defined in section 5.8.
type Bandwidths ¶
type Bandwidths map[BandwidthType]int
Bandwidths is map of BandwidthsType and int (bytes per second).
type ConnectionData ¶
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 ¶
func (c ConnectionData) Blank() bool
Blank determines if ConnectionData is blank value.
func (ConnectionData) ConnectionAddress ¶
func (c ConnectionData) ConnectionAddress() string
ConnectionAddress formats <connection-address> sub-field.
func (ConnectionData) Equal ¶
func (c ConnectionData) Equal(b ConnectionData) bool
Equal returns c == b.
func (ConnectionData) String ¶
func (c ConnectionData) String() string
type DecodeError ¶
DecodeError wraps Reason of error and occurrence Place.
func (DecodeError) Error ¶
func (e DecodeError) Error() string
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
Decoder decodes session.
type Encryption ¶
Encryption wraps encryption Key and Method.
func (Encryption) Blank ¶
func (e Encryption) Blank() bool
Blank determines whether Encryption is blank value.
type Line ¶
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>.
type Media ¶
type Media struct { Title string Description MediaDescription Connection ConnectionData Attributes Attributes Encryption Encryption Bandwidths Bandwidths }
Media is media description and attributes.
func (*Media) AddAttribute ¶
AddAttribute appends new k-v pair to attribute list.
func (*Media) PayloadFormat ¶
PayloadFormat returns payload format from a=rtpmap. See RFC 4566 Section 6.
type MediaDescription ¶
type MediaDescription struct { Type string Port int PortsNumber int Protocol string Formats []string }
MediaDescription represents Media Description field value.
func (MediaDescription) Equal ¶
func (m MediaDescription) Equal(b MediaDescription) bool
Equal returns true if b equals to m.
type Message ¶
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 ¶
AddAttribute appends new k-v pair to attribute list.
func (*Message) Append ¶
Append encodes message to Session and returns result.
See RFC 4566 Section 5.
type Origin ¶
type Origin struct { Username string // <username> SessionID int64 // <sess-id> SessionVersion int64 // <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.
type RtpMap ¶
func ParseRtpMap ¶
type Session ¶
type Session []Line
Session is set of Lines.
func DecodeSession ¶
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 ¶
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 ¶
func (s Session) AddBandwidth(t BandwidthType, bandwidth int) Session
AddBandwidth appends Bandwidth field to Session.
func (Session) AddConnectionData ¶
func (s Session) AddConnectionData(data ConnectionData) Session
AddConnectionData appends Connection Data field to Session using ConnectionData struct with sensible defaults.
func (Session) AddConnectionDataIP ¶
AddConnectionDataIP appends Connection Data field using only ip address.
func (Session) AddEncryption ¶
func (s Session) AddEncryption(e Encryption) Session
AddEncryption appends Encryption and is shorthand for AddEncryptionKey.
func (Session) AddEncryptionKey ¶
AddEncryptionKey appends Encryption Key field with method and key in "k=<method>:<encryption key>" format to Session.
func (Session) AddEncryptionMethod ¶
AddEncryptionMethod appends Encryption Key field with only method in "k=<method>" format to Session.
func (Session) AddMediaDescription ¶
func (s Session) AddMediaDescription(m MediaDescription) Session
AddMediaDescription appends Media Description field to Session.
func (Session) AddRepeatTimes ¶
AddRepeatTimes appends Repeat Times field to Session.
func (Session) AddRepeatTimesCompact ¶
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 ¶
AddSessionInfo appends Session Information field to Session.
func (Session) AddSessionName ¶
AddSessionName appends Session Name field to Session.
func (Session) AddTimeZones ¶
AddTimeZones append TimeZones field to Session.
func (Session) AddTiming ¶
AddTiming appends Timing field to Session. Both start and end can be zero.
func (Session) AddTimingNTP ¶
AddTimingNTP appends Timing field to Session with NTP timestamps as input. It is just wrapper for AddTiming and NTPToTime.
func (Session) AddVersion ¶
AddVersion appends Version field to Session.
type Timing ¶
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 ¶
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.