Skip to main content

Module attribute

Module attribute 

Source
Expand description

Typed, validated attributes, and the RFC 8859 multiplexing categories. Typed, validated access to the attributes the WebRTC specifications use.

[SessionDescription::unmarshal] keeps every a= line as a name and a value: RFC 8866 section 5.13 has an attribute that is not understood ignored, and the parser cannot know which ones its caller understands. This module is where a value gets its grammar. Each type parses the value of one attribute against the ABNF of the RFC that defines it and prints it back in the form that RFC gives.

There are three ways in:

  • The accessors on [SessionDescription] and [MediaDescription]: mid(), rtpmaps(), candidates(), fingerprints(), simulcast() and so on. Each returns Err when the attribute is present and malformed, so a caller can tell “absent” from “broken”.
  • The generic typed::<T>() / typed_all::<T>() for any TypedAttribute.
  • [SessionDescription::validate], which checks every known attribute of a description at once, together with the level each may appear at.
AttributeTypeDefined in
groupGroupRFC 5888, RFC 9143
midMidRFC 5888
msid, msid-semanticMsid, MsidSemanticRFC 8830
ssrc, ssrc-groupSsrc, SsrcGroupRFC 5576
ridRidRFC 8851
simulcastSimulcastRFC 8853
extmapExtMapRFC 8285
rtcp, rtcp-fb, rtcp-xrRtcp, RtcpFb, RtcpXrRFC 3605, RFC 4585 / 5104, RFC 3611
rtpmap, fmtpRtpMap, FmtpRFC 8866
ptime, maxptime, frameratePtime, MaxPtime, FrameRateRFC 8866
imageattrImageAttrRFC 6236
contentContentRFC 4796
candidate, remote-candidatesCandidate, RemoteCandidatesRFC 8839
ice-ufrag, ice-pwd, ice-options, ice-pacingIceUfrag, IcePwd, IceOptions, IcePacingRFC 8839
fingerprintFingerprintRFC 8122
setupSetupRFC 4145, RFC 8842
tls-idTlsIdRFC 8842
identityIdentityRFC 8827
tool, type, orient, qualityTool, ConferenceType, Orient, QualityRFC 8866
sctp-port, max-message-size, sctpmapSctpPort, MaxMessageSize, SctpMapRFC 8841

Attributes without a value (rtcp-mux, rtcp-mux-only, rtcp-rsize, ice-lite, end-of-candidates, bundle-only, extmap-allow-mixed, cryptex and the four directions) are read with flag() or their named accessor, which refuses one that carries a value.

mux holds the RFC 8859 multiplexing category of every attribute.

Modules§

mux
The RFC 8859 multiplexing category of every SDP attribute, as data.

Structs§

Candidate
a=candidate:... (RFC 8839 section 5.1).
ConferenceType
a=type:<conference type> (RFC 8866 section 6.9, session level): broadcast, meeting, moderated, test or H332, case-sensitive.
Content
a=content:<tag>[,<tag>...] (RFC 4796 section 5): what a media stream shows.
Depend
a=depend:<dependent-fmt> <dependency-tag> *(";" SP <dependent-fmt> <dependency-tag>) (RFC 5583 section 5.2.2, the ABNF of the section’s code block). “There MUST be exactly one dependency-tag indicated per dependent-fmt”: a value naming a format twice is refused.
Dependency
One dependent-fmt SP dependency-tag of a=depend (RFC 5583 section 5.2.2): the format of this media description, its dependency type, and at most one identification tag with the formats of that media description it depends on (any of them suffices).
Fingerprint
a=fingerprint:<hash-func> <fingerprint> (RFC 8122 section 5).
Fmtp
a=fmtp:<format> <format specific parameters> (RFC 8866 section 6.15).
FrameRate
a=framerate:<frame rate> (RFC 8866 section 6.13): the maximum video frame rate, in frames per second.
Group
a=group:<semantics> *(SP <identification-tag>) (RFC 5888 section 5).
IceOptions
a=ice-options:<tag> *(SP <tag>) (RFC 8839 section 5.6), each tag 1*ice-char: trickle (RFC 8840), ice2 (RFC 8445), renomination, …
IcePacing
a=ice-pacing:<ms> (RFC 8839 section 5.5): 1*10DIGIT, the pacing of connectivity checks in milliseconds; 50 when the attribute is absent.
IcePwd
a=ice-pwd:<password> (RFC 8839 section 5.4): 22*256ice-char.
IceUfrag
a=ice-ufrag:<ufrag> (RFC 8839 section 5.4): 4*256ice-char.
Identity
a=identity:<assertion> *(SP <extension>) (RFC 8827 section 5).
ImageAttr
a=imageattr:<pt> (send|recv) <attr-list> [(send|recv) <attr-list>] (RFC 6236 section 3.1).
ImageAttrSet
One [x=...,y=...,...] set of an a=imageattr line.
MaxMessageSize
a=max-message-size:<octets> (RFC 8841 section 6): 1*DIGIT without leading zeroes. 0 means the endpoint handles messages of any size; an absent attribute means 64 kilobytes.
MaxPtime
a=maxptime:<maximum packet time> (RFC 8866 section 6.5): the most media a packet may carry, in milliseconds.
Mid
a=mid:<identification-tag> (RFC 5888 section 4): a token.
Msid
a=msid:<msid-id> [SP <msid-appdata>] (RFC 8830 section 2).
MsidSemantic
a=msid-semantic:<semantic> *(SP <msid-id>).
Orient
a=orient:<orientation> (RFC 8866 section 6.8, media level): the orientation of a whiteboard or presentation workspace, portrait, landscape or seascape, case-sensitive.
Ptime
a=ptime:<packet time> (RFC 8866 section 6.4): the length of media in a packet the receiver prefers, in milliseconds.
Quality
a=quality:<quality> (RFC 8866 section 6.14, media level): a suggested encoding quality, zero-based-integer (0 to 10 for video, 5 being the default behaviour).
RemoteCandidate
One component-id SP connection-address SP port of an a=remote-candidates line.
RemoteCandidates
a=remote-candidates:<component> <address> <port> ... (RFC 8839 section 5.2): the remote candidates the controlling agent uses, one per component.
Rid
a=rid:<rid-id> <direction> [pt=<fmt-list>;]<restriction>=<value>;... (RFC 8851 section 10).
Rtcp
a=rtcp:<port> [<nettype> <addrtype> <connection-address>] (RFC 3605 section 2.1): the port, and optionally the address, RTCP is sent to when it is not the one after the RTP port.
RtcpAddress
The address of an a=rtcp line.
RtcpFb
a=rtcp-fb:<pt> <id> [<param> [<rest>]] (RFC 4585 section 4.2).
RtcpXr
a=rtcp-xr:[<xr-format> *(SP <xr-format>)] (RFC 3611 section 5.1). An empty list turns extended reports off.
RtpMap
a=rtpmap:<payload type> <encoding name>/<clock rate>[/<encoding params>] (RFC 8866 section 6.6).
SctpMap
a=sctpmap:<port> <app> [<streams>] (draft-ietf-mmusic-sctp-sdp-05), what data sections carried before a=sctp-port: the SCTP port, the application protocol (webrtc-datachannel) and the number of streams.
SctpPort
a=sctp-port:<port> (RFC 8841 section 5): 1*5(DIGIT), 0 to 65535, “leading zeroes MUST NOT be used”.
Setup
a=setup:<role> (RFC 4145 section 4): active, passive, actpass or holdconn.
Simulcast
a=simulcast:<direction> <streams> [<direction> <streams>] (RFC 8853 section 5.1).
SimulcastId
One sc-id of an a=simulcast line: a rid-id, with ~ in front when the stream is initially paused (RFC 8853 section 5.1, RFC 7728).
Ssrc
a=ssrc:<ssrc-id> <attribute>[:<value>] (RFC 5576 section 4.1): one source attribute of one synchronization source.
SsrcGroup
a=ssrc-group:<semantics> *(SP <ssrc-id>) (RFC 5576 section 4.2).
TlsId
a=tls-id:<id> (RFC 8842 section 4): 20*255(tls-id-char), tls-id-char = ALPHA / DIGIT / "+" / "/" / "-" / "_".
Tool
a=tool:<name and version> (RFC 8866 section 6.3, session level): the tool that created the description. text, any byte-string.

Enums§

DependencyType
A dependency type of a=depend (RFC 5583 section 5.2.2): lay (layered), mdc (multiple description), or another token (“dependency types MUST be defined in a Standards-Track document”).
ImageAttrList
The attribute list of one direction of an a=imageattr line.
ImageAttrRange
A range of an a=imageattr set: xyrange for x= and y=, srange for sar=.
RidDirection
rid-dir: which way the restrictions of an a=rid line apply.
RidIdGrammar
The rid-id grammar a line is read with.
RtcpFbKind
What an a=rtcp-fb line stands for: the feedback messages the specifications define, and RtcpFbKind::Other for the rest.
RtcpFbPayloadType
rtcp-fb-pt: the formats an a=rtcp-fb line applies to.
RtcpXrFormat
One xr-format of an a=rtcp-xr line.
RtcpXrRttMode
rcvr-rtt-mode.
RtcpXrStatFlag
stat-flag: a statistic of the stat-summary report block.

Traits§

TypedAttribute
An attribute with a value whose grammar this crate knows.

Functions§

check_attribute
Checks one attribute’s value against the grammar of its name (RFC 9429 section 5.8: a line that is not well formed rejects the description “even if the value is to be discarded”): a known attribute’s value must parse as its type, a property attribute (rtcp-mux, sendrecv, …) must have none, and an unknown one needs only a token name and a value without NUL, CR or LF (RFC 8866 section 5.13). The checks across lines and levels of SessionDescription::validate are not made.