rtci-sdp
SDP parsing and serialization (RFC 8866) with the attributes WebRTC negotiation uses. 10 public modules, 178 items at 0.5.0.
cargo add [email protected] · crates.io · docs.rs · README on GitHub· MSRV 1.89
README
SDP parsing and serialization as WebRTC uses it: session and media sections, and typed attributes for codecs (rtpmap, fmtp, rtcp-fb), ICE, DTLS fingerprints, header extension maps, grouping (BUNDLE, FID, LS), simulcast and RID, SSRC attributes and decoding dependencies.
Specifications
- RFC 8866, SDP; RFC 3264, the offer/answer model
- RFC 9429, JSEP, for the attributes it uses
- RFC 5576, source-specific attributes; RFC 5583, decoding dependencies; RFC 5888, grouping
- RFC 8285 (
extmap), RFC 8859 (attribute multiplexing categories), RFC 8888 (ccfb)
Clause-by-clause status, with the test that proves each clause: rfc8866, rfc3264, rfc5576, rfc5583, rfc8859.
Use
SessionDescription::unmarshal parses a description (ParseOptions names what else to accept), marshal writes it back, and the builders make one section by section. The JSEP logic (what an offer or answer contains) is in the root crate (rtci).
Sans-I/O
A parser and writer: strings in, typed descriptions out, and back. No I/O, no clock.
Licence
Licensed under either of the MIT licence or the Apache License, Version 2.0, at your option.
This crate is part of the rtci workspace, which descends from webrtc-rs/rtc and is developed independently; FORK.md lists what it carries over upstream. Upstream's licence and copyright notices are retained.
rtci_sdp
SDP parsing and serialization.
- mod
attributeTyped, validated attributes, and the RFC 8859 multiplexing categories. - mod
descriptionSession and media descriptions — thev=/m=structure of an SDP document. - mod
directionTransmission direction (sendrecv,sendonly,recvonly,inactive). - mod
extmapa=extmapRTP header-extension declarations and the well-known extension URIs. - mod
utilParsing helpers plus the codec and connection-role types shared across descriptions. - use
MediaDescriptionfromdescription::media::MediaDescriptionMediaDescription represents a media type. - use
ParseOptionsfromdescription::session::ParseOptionsWhatSessionDescription::unmarshal_with_optionsaccepts beyond the RFC 8866 grammar. - use
SdpDecimalfromdescription::session::SdpDecimalA decimal number of any length,1*DIGIT: the<sess-id>and<sess-version>of ano=line (RFC 8866 section 9). The grammar sets no upper bound, so a compliant description may carry values beyond 64 bits (RFC 9429 section 5.2.1 has a JSEP endpoint generate them within 64 bits, and section 5.8 has it accept compliant SDP that does not follow its generation rules). - use
SessionDescriptionfromdescription::session::SessionDescriptionSessionDescription is a a well-defined format for conveying sufficient information to discover and participate in a multimedia session.
rtci_sdp::attribute
Typed, validated attributes, and the RFC 8859 multiplexing categories.
- mod
muxThe RFC 8859 multiplexing category of every SDP attribute, as data. - struct
Candidatefromice::Candidatea=candidate:...(RFC 8839 section 5.1). - struct
Contentfromrtp::Contenta=content:<tag>[,<tag>...](RFC 4796 section 5): what a media stream shows. - struct
Dependfromgrouping::Dependa=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. - struct
Dependencyfromgrouping::DependencyOnedependent-fmt SP dependency-tagofa=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). - struct
Fingerprintfromsecurity::Fingerprinta=fingerprint:<hash-func> <fingerprint>(RFC 8122 section 5). - struct
Fmtpfromrtp::Fmtpa=fmtp:<format> <format specific parameters>(RFC 8866 section 6.15). - struct
Groupfromgrouping::Groupa=group:<semantics> *(SP <identification-tag>)(RFC 5888 section 5). - struct
IceOptionsfromice::IceOptionsa=ice-options:<tag> *(SP <tag>)(RFC 8839 section 5.6), each tag1*ice-char:trickle(RFC 8840),ice2(RFC 8445),renomination, ... - struct
IcePacingfromice::IcePacinga=ice-pacing:<ms>(RFC 8839 section 5.5):1*10DIGIT, the pacing of connectivity checks in milliseconds; 50 when the attribute is absent. - struct
Identityfromsecurity::Identitya=identity:<assertion> *(SP <extension>)(RFC 8827 section 5). - struct
ImageAttrfromrtp::ImageAttra=imageattr:<pt> (send|recv) <attr-list> [(send|recv) <attr-list>](RFC 6236 section 3.1). - struct
ImageAttrSetfromrtp::ImageAttrSetOne[x=...,y=...,...]set of ana=imageattrline. - struct
MaxMessageSizefromsctp::MaxMessageSizea=max-message-size:<octets>(RFC 8841 section 6):1*DIGITwithout leading zeroes. 0 means the endpoint handles messages of any size; an absent attribute means 64 kilobytes. - struct
Msidfromgrouping::Msida=msid:<msid-id> [SP <msid-appdata>](RFC 8830 section 2). - struct
MsidSemanticfromgrouping::MsidSemantica=msid-semantic:<semantic> *(SP <msid-id>). - struct
RemoteCandidatefromice::RemoteCandidateOnecomponent-id SP connection-address SP portof ana=remote-candidatesline. - struct
RemoteCandidatesfromice::RemoteCandidatesa=remote-candidates:<component> <address> <port> ...(RFC 8839 section 5.2): the remote candidates the controlling agent uses, one per component. - struct
Ridfromsimulcast::Rida=rid:<rid-id> <direction> [pt=<fmt-list>;]<restriction>=<value>;...(RFC 8851 section 10). - struct
Rtcpfromrtcp::Rtcpa=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. - struct
RtcpAddressfromrtcp::RtcpAddressThe address of ana=rtcpline. - struct
RtcpFbfromrtcp::RtcpFba=rtcp-fb:<pt> <id> [<param> [<rest>]](RFC 4585 section 4.2). - struct
RtcpXrfromrtcp::RtcpXra=rtcp-xr:[<xr-format> *(SP <xr-format>)](RFC 3611 section 5.1). An empty list turns extended reports off. - struct
RtpMapfromrtp::RtpMapa=rtpmap:<payload type> <encoding name>/<clock rate>[/<encoding params>](RFC 8866 section 6.6). - struct
SctpMapfromsctp::SctpMapa=sctpmap:<port> <app> [<streams>](draft-ietf-mmusic-sctp-sdp-05), what data sections carried beforea=sctp-port: the SCTP port, the application protocol (webrtc-datachannel) and the number of streams. - struct
SctpPortfromsctp::SctpPorta=sctp-port:<port>(RFC 8841 section 5):1*5(DIGIT), 0 to 65535, "leading zeroes MUST NOT be used". - struct
Setupfromsecurity::Setupa=setup:<role>(RFC 4145 section 4):active,passive,actpassorholdconn. - struct
Simulcastfromsimulcast::Simulcasta=simulcast:<direction> <streams> [<direction> <streams>](RFC 8853 section 5.1). - struct
SimulcastIdfromsimulcast::SimulcastIdOnesc-idof ana=simulcastline: a rid-id, with~in front when the stream is initially paused (RFC 8853 section 5.1, RFC 7728). - struct
Ssrcfromsource::Ssrca=ssrc:<ssrc-id> <attribute>[:<value>](RFC 5576 section 4.1): one source attribute of one synchronization source. - struct
SsrcGroupfromsource::SsrcGroupa=ssrc-group:<semantics> *(SP <ssrc-id>)(RFC 5576 section 4.2). - enum
DependencyTypefromgrouping::DependencyTypeA dependency type ofa=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"). - enum
ImageAttrListfromrtp::ImageAttrListThe attribute list of one direction of ana=imageattrline. - enum
ImageAttrRangefromrtp::ImageAttrRangeA range of ana=imageattrset:xyrangeforx=andy=,srangeforsar=. - enum
RidDirectionfromsimulcast::RidDirectionrid-dir: which way the restrictions of ana=ridline apply. - enum
RidIdGrammarfromsimulcast::RidIdGrammarTherid-idgrammar a line is read with. - enum
RtcpFbKindfromrtcp::RtcpFbKindWhat ana=rtcp-fbline stands for: the feedback messages the specifications define, andRtcpFbKind::Otherfor the rest. - enum
RtcpFbPayloadTypefromrtcp::RtcpFbPayloadTypertcp-fb-pt: the formats ana=rtcp-fbline applies to. - enum
RtcpXrFormatfromrtcp::RtcpXrFormatOnexr-formatof ana=rtcp-xrline. - enum
RtcpXrRttModefromrtcp::RtcpXrRttModercvr-rtt-mode. - enum
RtcpXrStatFlagfromrtcp::RtcpXrStatFlagstat-flag: a statistic of thestat-summaryreport block. - trait
TypedAttributeAn attribute with a value whose grammar this crate knows. - fn
check_attributefromvalidate::check_attributeChecks 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 … - use
ConferenceTypefrominformational::ConferenceType - use
FrameRatefromrtp::FrameRate - use
IcePwdfromice::IcePwd - use
IceUfragfromice::IceUfrag - use
MaxPtimefromrtp::MaxPtime - use
Midfromgrouping::Mid - use
Orientfrominformational::Orient - use
Ptimefromrtp::Ptime - use
Qualityfrominformational::Quality - use
TlsIdfromsecurity::TlsId - use
Toolfrominformational::Tool
rtci_sdp::attribute::mux
The RFC 8859 multiplexing category of every SDP attribute, as data.
- struct
AttributeInfoOne row of the table. - enum
AttributeLevelWhere an attribute may appear. - enum
MuxCategoryHow the values of an attribute in the m= sections of one BUNDLE group relate (RFC 8859 section 4). - fn
attributeThe row of the attributename, orNonefor an attribute without a registered multiplexing category (RFC 8859 section 4.9 treats those as TBD: not to be multiplexed until analysed; a WebRTC endpoint simply ignores an attribute it does not know). - fn
bandwidthThe category of ab=modifier (RFC 8859 section 6):CTis NORMAL;AS,RSandRRare SUM;TIASis SPECIAL. - fn
categoryThe multiplexing category of the attributename. - fn
contentThe category of ana=contentvalue (RFC 8859 section 12): all NORMAL. - fn
group_semanticsThe category of ana=groupsemantics (RFC 8859 section 8; RFC 9143 forBUNDLE):ANATis CAUTION, the others NORMAL. - fn
rtcp_fbThe category of ana=rtcp-fbline (RFC 8859 section 7): IDENTICAL-PER-PT forack,nack,trr-intandccmwith the parameters the RFC lists, SPECIAL forack appandnack app, IDENTICAL fornack ecn.Nonefor a feedback type RFC 8859 does not classify (goog-remb,transport-cc, ...); those follow the attribute's own category, IDENTICAL-PER-PT. - fn
source_attributeThe category of a source attribute, the ones written insidea=ssrc(RFC 8859 section 5.15):cnameandprevious-ssrcare NORMAL,fmtpis IDENTICAL-PER-PT. - fn
ssrc_group_semanticsThe category of ana=ssrc-groupsemantics (RFC 8859 section 9): all NORMAL.
rtci_sdp::description
Session and media descriptions — the v=/m= structure of an SDP document.
rtci_sdp::description::common
Field types shared by session and media descriptions (c=, b=, a=).
- struct
AddressAddress describes a structured address token from within the "c=" field. - struct
AttributeAttribute describes the "a=" field which represents the primary means for extending SDP. - struct
BandwidthBandwidth describes an optional field which denotes the proposed bandwidth to be used by the session or media. - struct
ConnectionInformationConnectionInformation defines the representation for the "c=" field containing connection data. - enum
BandwidthKindThe bandwidth modifiers (bwtype) the WebRTC specifications use. - type
EncryptionKeyEncryptionKey describes the "k=" line. RFC 8866 section 5.12 made it obsolete: it "MUST NOT be included in an SDP description and MUST be discarded if received", so the parser checks its syntax and drops it, and nothing writes one. - type
InformationInformation describes the "i=" field which provides textual information about the session.
rtci_sdp::description::media
The m= media description and its fields.
- struct
MediaDescriptionMediaDescription represents a media type. - struct
MediaNameMediaName describes the "m=" field storage structure. - struct
RangedPortRangedPort 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. - const
EXT_MAP_VALUE_TRANSPORT_CC_KEYConstants for extmap key - const
EXT_MAP_VALUE_TRANSPORT_CC_URIThe transport-wide congestion control header-extension URI.
rtci_sdp::description::session
The whole session description, plus the well-known attribute keys.
- struct
OriginOrigin defines the structure for the "o=" field which provides the originator of the session plus a session identifier and version number. - struct
ParseOptionsWhatSessionDescription::unmarshal_with_optionsaccepts beyond the RFC 8866 grammar. - struct
RepeatTimeRepeatTime describes the "r=" fields of the session description which represents the intervals and durations for repeated scheduled sessions. - struct
SdpDecimalA decimal number of any length,1*DIGIT: the<sess-id>and<sess-version>of ano=line (RFC 8866 section 9). The grammar sets no upper bound, so a compliant description may carry values beyond 64 bits (RFC 9429 section 5.2.1 has a JSEP endpoint generate them within 64 bits, and section 5.8 has it accept compliant SDP that does not follow its generation rules). - struct
SdpParseErrorA description that does not parse, and where: whatSessionDescription::parse_locatedreturns. - struct
SessionDescriptionSessionDescription is a a well-defined format for conveying sufficient information to discover and participate in a multimedia session. - struct
TimeDescriptionTimeDescription describes the "t=", "r=" and "z=" fields of the session description, which specify the start and stop times of a session, its repeat intervals and durations, and the time zone adjustments of those repetitions. - struct
TimeZoneTimeZone is one<adjustment time> <offset>pair of a "z=" line, which describes repeated sessions scheduling. - struct
TimingTiming defines the "t=" field's structured representation for the start and stop times. - enum
CharsetThe character set of a description's charset-dependent fields (s=,i=), from itsa=charset(RFC 8866 section 6.10). - type
EmailAddressEmailAddress describes a structured representations for the "e=" line which specifies email contact information for the person responsible for the conference. - type
PhoneNumberPhoneNumber describes a structured representations for the "p=" line specify phone contact information for the person responsible for the conference. - type
SessionNameSessionName describes a structured representations for the "s=" field and is the textual session name. - type
VersionVersion describes the value provided by the "v=" field which gives the version of the Session Description Protocol. - const
ATTR_KEY_BUNDLE_ONLYa=bundle-only: the section is used only inside its BUNDLE group (RFC 9143). - const
ATTR_KEY_CANDIDATEConstants for SDP attributes used in JSEP - const
ATTR_KEY_CHARSETThea=charsetattribute (RFC 8866 section 6.10). - const
ATTR_KEY_CONNECTION_SETUPa=setup: the DTLS role —active,passiveoractpass. - const
ATTR_KEY_CONTENTa=content: what a media stream shows (RFC 4796). - const
ATTR_KEY_CRYPTEXa=cryptex: RTP header extensions and CSRCs are encrypted (RFC 9335). - const
ATTR_KEY_END_OF_CANDIDATESa=end-of-candidates: ICE gathering for this section is complete. - const
ATTR_KEY_EXT_MAPa=extmap: maps an RTP header-extension URI to an id. - const
ATTR_KEY_EXTMAP_ALLOW_MIXEDa=extmap-allow-mixed: one- and two-byte header extensions may be mixed. - const
ATTR_KEY_FINGERPRINTa=fingerprint: a certificate fingerprint (RFC 8122). - const
ATTR_KEY_FMTPa=fmtp: format-specific parameters. - const
ATTR_KEY_FRAMERATEa=framerate: the maximum video frame rate. - const
ATTR_KEY_GROUPa=group: groups m-lines, as BUNDLE does. - const
ATTR_KEY_ICE_OPTIONSa=ice-options: the ICE options the agent supports. - const
ATTR_KEY_ICE_PACINGa=ice-pacing: the ICE pacing interval, in milliseconds. - const
ATTR_KEY_ICE_PWDa=ice-pwd: the ICE password. - const
ATTR_KEY_ICE_UFRAGa=ice-ufrag: the ICE user name fragment. - const
ATTR_KEY_ICELITEa=ice-lite: the endpoint is an ICE-lite implementation. - const
ATTR_KEY_IDENTITYa=identity: an identity assertion for the session. - const
ATTR_KEY_IMAGEATTRa=imageattr: image sizes a payload type sends or receives (RFC 6236). - const
ATTR_KEY_INACTIVEa=inactive: neither send nor receive. - const
ATTR_KEY_MAX_MESSAGE_SIZEa=max-message-size: the largest SCTP message this endpoint accepts. - const
ATTR_KEY_MAXPTIMEa=maxptime: the longest packet duration, in milliseconds. - const
ATTR_KEY_MIDa=mid: the media identification tag that names this m-line. - const
ATTR_KEY_MSIDa=msid: associates a track with a media stream. - const
ATTR_KEY_MSID_SEMANTICa=msid-semantic: declares the semantics used bya=msid. - const
ATTR_KEY_PTIMEa=ptime: the preferred packet duration, in milliseconds. - const
ATTR_KEY_RECV_ONLYa=recvonly: receive only. - const
ATTR_KEY_REMOTE_CANDIDATESa=remote-candidates: the remote candidates the controlling agent selected. - const
ATTR_KEY_RIDa=rid: an RTP stream identifier and its restrictions (RFC 8851). - const
ATTR_KEY_RTCPa=rtcp: the RTCP port and address (RFC 3605). - const
ATTR_KEY_RTCP_FBa=rtcp-fb: an RTCP feedback capability (RFC 4585). - const
ATTR_KEY_RTCP_XRa=rtcp-xr: RTCP extended reports (RFC 3611). - const
ATTR_KEY_RTCPMUXa=rtcp-mux: RTP and RTCP share one port. - const
ATTR_KEY_RTCPMUX_ONLYa=rtcp-mux-only: RTP and RTCP share one port and nothing else is supported (RFC 8858). - const
ATTR_KEY_RTCPRSIZEa=rtcp-rsize: reduced-size RTCP is supported. - const
ATTR_KEY_RTPMAPa=rtpmap: the codec of a payload type. - const
ATTR_KEY_SCTP_PORTa=sctp-port: the SCTP port (RFC 8841). - const
ATTR_KEY_SCTPMAPa=sctpmap: the SCTP association of an old-style data section (draft-ietf-mmusic-sctp-sdp-05; replaced bya=sctp-port). - const
ATTR_KEY_SEND_ONLYa=sendonly: send only. - const
ATTR_KEY_SEND_RECVa=sendrecv: send and receive. - const
ATTR_KEY_SIMULCASTa=simulcast: the simulcast streams of a media section (RFC 8853). - const
ATTR_KEY_SSRCa=ssrc: declares an SSRC and its attributes. - const
ATTR_KEY_SSRC_GROUPa=ssrc-group: relates SSRCs, such as an RTX stream to its primary. - const
ATTR_KEY_TLS_IDa=tls-id: the DTLS association identifier (RFC 8842). - const
MAX_ATTRIBUTES_PER_SECTIONThe mosta=linesSessionDescription::unmarshalaccepts at the session level, and in eachm=section. - const
MAX_FORMATS_PER_MEDIAThe most formatsSessionDescription::unmarshalaccepts on onem=line. RTP payload types are 7 bits, so 128 distinct values exist. - const
MAX_MEDIA_DESCRIPTIONSThe mostm=sectionsSessionDescription::unmarshalaccepts in one session description. - const
MAX_SDP_LINESThe most linesSessionDescription::unmarshalaccepts in one session description. - const
MAX_SDP_SIZEThe largest session description, in bytes,SessionDescription::unmarshalaccepts. Real offers and answers are a few to a few hundred kilobytes. - const
NTP_UNIX_EPOCH_OFFSET_SECSThe seconds from the NTP epoch (1900-01-01 UTC) to the Unix epoch: RFC 8866 section 5.2 recommends "a timestamp, in seconds since January 1, 1900 UTC" for<sess-id>and, "as with <sess-id>", for<sess-version>. - const
SEMANTIC_TOKEN_BUNDLEBUNDLE: the m= sections share one transport (RFC 9143). - const
SEMANTIC_TOKEN_FLOW_IDENTIFICATIONFID: flow identification — the SSRCs carry the same content, as RTX does. - const
SEMANTIC_TOKEN_FORWARD_ERROR_CORRECTIONFEC: one SSRC carries error-correction data for another. - const
SEMANTIC_TOKEN_FORWARD_ERROR_CORRECTION_FRAMEWORKFEC-FR: the FEC framework grouping semantic. - const
SEMANTIC_TOKEN_LIP_SYNCHRONIZATIONConstants for semantic tokens used in JSEP - const
SEMANTIC_TOKEN_WEBRTC_MEDIA_STREAMSWMS: WebRTC media streams, used witha=msid-semantic.
rtci_sdp::direction
Transmission direction (sendrecv, sendonly, recvonly, inactive).
- enum
DirectionDirection is a marker for transmission direction of an endpoint
rtci_sdp::extmap
a=extmap RTP header-extension declarations and the well-known extension URIs.
- struct
ExtMapExtMap represents the activation of a single RTP header extension:a=extmap:<value>["/"<direction>] <URI> [<extensionattributes>](RFC 8285 section 5). - const
ABS_SEND_TIME_URIThe absolute-send-time extension URI, used for bandwidth estimation. - const
AUDIO_LEVEL_URIThe audio-level extension URI, carrying per-packet loudness. - const
DEF_EXT_MAP_VALUE_ABS_SEND_TIMEDefault ext values - const
DEF_EXT_MAP_VALUE_SDES_MIDThe default id assigned to the SDESmidextension. - const
DEF_EXT_MAP_VALUE_SDES_RTP_STREAM_IDThe default id assigned to the SDES RTP stream id extension. - const
DEF_EXT_MAP_VALUE_TRANSPORT_CCThe default id this crate assigns to the transport-wide CC extension. - const
EXT_MAP_ANSWERER_ASSIGNED_MAXThe last of those ids. - const
EXT_MAP_ANSWERER_ASSIGNED_MINThe first of the ids an offerer uses for an extension it leaves the answerer to number (RFC 8285 section 6). - const
SDES_MID_URIThe SDESmidextension URI, which tags each packet with its m-line. - const
SDES_REPAIR_RTP_STREAM_ID_URIThe SDES repaired RTP stream id extension URI, which identifies an RTX layer's target. - const
SDES_RTP_STREAM_ID_URIThe SDES RTP stream id (RID) extension URI, which identifies a simulcast layer. - const
TRANSPORT_CC_URIThe transport-wide congestion control extension URI. - const
VIDEO_ORIENTATION_URIThe video-orientation (CVO) extension URI, carrying rotation flags.
rtci_sdp::util
Parsing helpers plus the codec and connection-role types shared across descriptions.
- struct
CodecOne codec offered by a media section, assembled from itsa=rtpmap,a=fmtpanda=rtcp-fbattributes. - enum
ConnectionRoleConnectionRole indicates which of the end points should initiate the connection establishment - const
ATTRIBUTE_KEYThea=line prefix.
Generated from the sources of rtci-sdp 0.5.0 at its release tag. Items made by macros and methods are on docs.rs.