// SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>// SPDX-License-Identifier: MITpackage sdpimport ()// MediaDescription represents a media type.// https://tools.ietf.org/html/rfc4566#section-5.14typeMediaDescriptionstruct {// 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}// Attribute returns the value of an attribute and if it exists.func ( *MediaDescription) ( string) (string, bool) {for , := range .Attributes {if .Key == {return .Value, true } }return"", false}// 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.typeRangedPortstruct { Value int Range *int}func ( *RangedPort) () string { := strconv.Itoa(.Value)if .Range != nil { += "/" + strconv.Itoa(*.Range) }return}func ( RangedPort) ( []byte) []byte { = strconv.AppendInt(, int64(.Value), 10)if .Range != nil { = append(, '/') = strconv.AppendInt(, int64(*.Range), 10) }return}func ( RangedPort) () ( int) { = lenInt(int64(.Value))if .Range != nil { += 1 + lenInt(int64(*.Range)) }return}// MediaName describes the "m=" field storage structure.typeMediaNamestruct { Media string Port RangedPort Protos []string Formats []string}func ( MediaName) () string {returnstringFromMarshal(.marshalInto, .marshalSize)}func ( MediaName) ( []byte) []byte { := func( []string, byte) {for , := range {if != 0 && != len() { = append(, ) } = append(, ...) } } = append(append(, .Media...), ' ') = append(.Port.marshalInto(), ' ') (.Protos, '/') = append(, ' ') (.Formats, ' ')return}func ( MediaName) () ( int) { := func( []string) {for , := range { += 1 + len() } } = len(.Media) += 1 + .Port.marshalSize() (.Protos) (.Formats)return}
The pages are generated with Goldsv0.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.