package sdp
import (
"strconv"
)
type Information string
func (i Information ) String () string {
return stringFromMarshal (i .marshalInto , i .marshalSize )
}
func (i Information ) marshalInto (b []byte ) []byte {
return append (b , i ...)
}
func (i Information ) marshalSize () (size int ) {
return len (i )
}
type ConnectionInformation struct {
NetworkType string
AddressType string
Address *Address
}
func (c ConnectionInformation ) String () string {
return stringFromMarshal (c .marshalInto , c .marshalSize )
}
func (c ConnectionInformation ) marshalInto (b []byte ) []byte {
b = append (append (b , c .NetworkType ...), ' ' )
b = append (b , c .AddressType ...)
if c .Address != nil {
b = append (b , ' ' )
b = c .Address .marshalInto (b )
}
return b
}
func (c ConnectionInformation ) marshalSize () (size int ) {
size = len (c .NetworkType )
size += 1 + len (c .AddressType )
if c .Address != nil {
size += 1 + c .Address .marshalSize ()
}
return
}
type Address struct {
Address string
TTL *int
Range *int
}
func (c *Address ) String () string {
return stringFromMarshal (c .marshalInto , c .marshalSize )
}
func (c *Address ) marshalInto (b []byte ) []byte {
b = append (b , c .Address ...)
if c .TTL != nil {
b = append (b , '/' )
b = strconv .AppendInt (b , int64 (*c .TTL ), 10 )
}
if c .Range != nil {
b = append (b , '/' )
b = strconv .AppendInt (b , int64 (*c .Range ), 10 )
}
return b
}
func (c Address ) marshalSize () (size int ) {
size = len (c .Address )
if c .TTL != nil {
size += 1 + lenUint (uint64 (*c .TTL ))
}
if c .Range != nil {
size += 1 + lenUint (uint64 (*c .Range ))
}
return
}
type Bandwidth struct {
Experimental bool
Type string
Bandwidth uint64
}
func (b Bandwidth ) String () string {
return stringFromMarshal (b .marshalInto , b .marshalSize )
}
func (b Bandwidth ) marshalInto (d []byte ) []byte {
if b .Experimental {
d = append (d , "X-" ...)
}
d = append (append (d , b .Type ...), ':' )
return strconv .AppendUint (d , b .Bandwidth , 10 )
}
func (b Bandwidth ) marshalSize () (size int ) {
if b .Experimental {
size += 2
}
size += len (b .Type ) + 1 + lenUint (b .Bandwidth )
return
}
type EncryptionKey string
func (e EncryptionKey ) String () string {
return stringFromMarshal (e .marshalInto , e .marshalSize )
}
func (e EncryptionKey ) marshalInto (b []byte ) []byte {
return append (b , e ...)
}
func (e EncryptionKey ) marshalSize () (size int ) {
return len (e )
}
type Attribute struct {
Key string
Value string
}
func NewPropertyAttribute (key string ) Attribute {
return Attribute {
Key : key ,
}
}
func NewAttribute (key , value string ) Attribute {
return Attribute {
Key : key ,
Value : value ,
}
}
func (a Attribute ) String () string {
return stringFromMarshal (a .marshalInto , a .marshalSize )
}
func (a Attribute ) marshalInto (b []byte ) []byte {
b = append (b , a .Key ...)
if len (a .Value ) > 0 {
b = append (append (b , ':' ), a .Value ...)
}
return b
}
func (a Attribute ) marshalSize () (size int ) {
size = len (a .Key )
if len (a .Value ) > 0 {
size += 1 + len (a .Value )
}
return size
}
func (a Attribute ) IsICECandidate () bool {
return a .Key == "candidate"
}
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 .