package sdp
import (
"net/url"
"strconv"
)
type SessionDescription struct {
Version Version
Origin Origin
SessionName SessionName
SessionInformation *Information
URI *url .URL
EmailAddress *EmailAddress
PhoneNumber *PhoneNumber
ConnectionInformation *ConnectionInformation
Bandwidth []Bandwidth
TimeDescriptions []TimeDescription
TimeZones []TimeZone
EncryptionKey *EncryptionKey
Attributes []Attribute
MediaDescriptions []*MediaDescription
}
func (s *SessionDescription ) Attribute (key string ) (string , bool ) {
for _ , a := range s .Attributes {
if a .Key == key {
return a .Value , true
}
}
return "" , false
}
type Version int
func (v Version ) String () string {
return stringFromMarshal (v .marshalInto , v .marshalSize )
}
func (v Version ) marshalInto (b []byte ) []byte {
return strconv .AppendInt (b , int64 (v ), 10 )
}
func (v Version ) marshalSize () (size int ) {
return lenInt (int64 (v ))
}
type Origin struct {
Username string
SessionID uint64
SessionVersion uint64
NetworkType string
AddressType string
UnicastAddress string
}
func (o Origin ) String () string {
return stringFromMarshal (o .marshalInto , o .marshalSize )
}
func (o Origin ) marshalInto (b []byte ) []byte {
b = append (append (b , o .Username ...), ' ' )
b = append (strconv .AppendUint (b , o .SessionID , 10 ), ' ' )
b = append (strconv .AppendUint (b , o .SessionVersion , 10 ), ' ' )
b = append (append (b , o .NetworkType ...), ' ' )
b = append (append (b , o .AddressType ...), ' ' )
return append (b , o .UnicastAddress ...)
}
func (o Origin ) marshalSize () (size int ) {
return len (o .Username ) +
lenUint (o .SessionID ) +
lenUint (o .SessionVersion ) +
len (o .NetworkType ) +
len (o .AddressType ) +
len (o .UnicastAddress ) +
5
}
type SessionName string
func (s SessionName ) String () string {
return stringFromMarshal (s .marshalInto , s .marshalSize )
}
func (s SessionName ) marshalInto (b []byte ) []byte {
return append (b , s ...)
}
func (s SessionName ) marshalSize () (size int ) {
return len (s )
}
type EmailAddress string
func (e EmailAddress ) String () string {
return stringFromMarshal (e .marshalInto , e .marshalSize )
}
func (e EmailAddress ) marshalInto (b []byte ) []byte {
return append (b , e ...)
}
func (e EmailAddress ) marshalSize () (size int ) {
return len (e )
}
type PhoneNumber string
func (p PhoneNumber ) String () string {
return stringFromMarshal (p .marshalInto , p .marshalSize )
}
func (p PhoneNumber ) marshalInto (b []byte ) []byte {
return append (b , p ...)
}
func (p PhoneNumber ) marshalSize () (size int ) {
return len (p )
}
type TimeZone struct {
AdjustmentTime uint64
Offset int64
}
func (z TimeZone ) String () string {
return stringFromMarshal (z .marshalInto , z .marshalSize )
}
func (z TimeZone ) marshalInto (b []byte ) []byte {
b = strconv .AppendUint (b , z .AdjustmentTime , 10 )
b = append (b , ' ' )
return strconv .AppendInt (b , z .Offset , 10 )
}
func (z TimeZone ) marshalSize () (size int ) {
return lenUint (z .AdjustmentTime ) + 1 + lenInt (z .Offset )
}
The pages are generated with Golds v0.8.2 . (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu .
PR and bug reports are welcome and can be submitted to the issue list .
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds .