Documentation ¶
Overview ¶
Package sdp implements encoding and decoding of Session Description Protocol formatted data as specified in RFC 8866.
Example ¶
A simple Session describing transmission of uncompressed linear PCM audio in RTP starts by setting the mandatory fields Origin and Name. The Media field contains information about the audio such as the sample rate and the number of audio channels. The Session type implements fmt.Stringer; to encode a Session in the SDP text format, use Session.String().
package main import ( "fmt" "net/netip" "github.com/untangledco/streaming/rtp" "github.com/untangledco/streaming/sdp" ) func main() { session := sdp.Session{ Origin: sdp.Origin{ ID: 3930287268, // example only; use sdp.Now() Version: 3930287268, // example only; use sdp.Now() Address: netip.MustParseAddr("2001:db8::1"), }, Name: "A call from me to you", Media: []sdp.Media{ { Type: sdp.MediaTypeAudio, Port: 6969, Transport: sdp.ProtoRTP, Format: []string{rtp.PayloadL16Mono.String()}, Attributes: []string{ "rtpmap:" + rtp.PayloadL16Mono.String(), "L16/22050", }, }, }, } fmt.Printf("%s", session) }
Output: v=0 o=- 3930287268 3930287268 IN IP6 2001:db8::1 s=A call from me to you t=0 0 m=audio 6969 RTP/AVP 11 a=rtpmap:11 L16/22050
Index ¶
Examples ¶
Constants ¶
const ( BandwidthConferenceTotal = "CT" BandwidthAppSpecific = "AS" )
const NoUsername string = "-"
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Bandwidth ¶
type ConnInfo ¶
type ConnInfo struct { Address netip.Addr // TTL is the time-to-live of IPv4 multicast packets. TTL uint8 // Count is the number of subsequent IP addresses after // Address used in the session. Count int }
ConnInfo represents connection information.
type Media ¶
type Media struct { Type MediaType Port int // IP port PortCount int // count of subsequent ports from Port Transport TransportProto // Format describes the media format. Interpretation of the // entries depends on the value of Transport. For example, if // Transport is ProtoRTP, Format contains RTP payload type // numbers. For more, see the <fmt> description in section 5.14 // of RFC 8866. Format []string // Optional fields Title string Connection *ConnInfo Bandwidth *Bandwidth Attributes []string }
Media represents a media description.
type Origin ¶
type Origin struct { // Username is a named identity on the originating host. If unset, // the encoded value will be NoUsername. Username string // ID is a globally unique identifier for the session. // The recommended value is a timestamp from Now(). ID int // Version is a version number of the session. It should be // incremented each time the session is modified. The recommended // value is a timestamp from Now(). Version int // Address is the originating address of the session. Address netip.Addr }
Origin represents the originator of the session as described in RFC 8866 section 5.2.
type Repeat ¶
type Repeat struct { Interval time.Duration // duration between each repetition cycle Active time.Duration // planned duration of each session Offsets []time.Duration // duration(s) between each session }
Repeat represents a session's repetition cycle as described in RFC 8866 section 5.10.
type Session ¶
type Session struct { Origin Origin Name string Info string URI *url.URL Email *mail.Address Phone string Connection *ConnInfo Bandwidth *Bandwidth // Time holds the start time and stop time of the Session, at // the first and second index respectively. Time [2]time.Time // Repeat points to a repetition cycle describing for how long // and when the session may reoccur. Repeat *Repeat // Adjustments holds any time adjustments that may occur, for // example daylight savings, throughout the period a repetition // cycle is active. Adjustments []TimeAdjustment Attributes []string Media []Media }
type TimeAdjustment ¶
func (TimeAdjustment) String ¶
func (t TimeAdjustment) String() string
type TransportProto ¶
type TransportProto uint8
const ( ProtoUDP TransportProto = iota ProtoRTP ProtoRTPSecure ProtoRTPSecureFeedback )
func (TransportProto) String ¶
func (tp TransportProto) String() string