问题
In SDP, colon(':') and slash('/') are used in many attribute values (both the standard and a= extensions). Here are just a few of them:
b=AS:41
a=rtpmap:96 AMR-WB/16000/1
a=fmtp:96 mode-change-capability=2; max-red=80
I want to know (both for parsing and generating SDP), if space is allowed around them. All examples point to not having a space around them. I think Section 9 of RFC 4566 which gives the grammar for SDP is not clear about this.
回答1:
I would say, that usually, SDP don't like whitespace. The first rule from rfc4566 is not answering your question, but it's a start:
An SDP session description consists of a number of lines of text of
the form:
<type>=<value>
where <type> MUST be exactly one case-significant character and
<value> is structured text whose format depends on <type>. In
general, <value> is either a number of fields delimited by a single
space character or a free format string, and is case-significant
unless a specific field defines otherwise. Whitespace MUST NOT be
used on either side of the "=" sign.
Let's start with the bandwidth parameter where the definition exists in rfc4566
bandwidth-fields = *(%x62 "=" bwtype ":" bandwidth CRLF)
; sub-rules of 'b='
bwtype = token
token = 1*(token-char)
token-char = %x21 / %x23-27 / %x2A-2B / %x2D-2E / %x30-39
/ %x41-5A / %x5E-7E
bandwidth = 1*DIGIT
From the above:
- there is no whitespace allowed in bwtype because %x20 is not part of token-char
- there is no whitespace allowed in bandwidth because it contains only DIGIT.
- there is no whitespace on left or right of ":", otherwise, the specification would use something like bwtype SP ":" SP bandwidth
For rtpmap, in RFC4566 Section 6, the definition of rtpmap is here:
a=rtpmap:<payload type> <encoding name>/<clock rate> [/<encoding
parameters>]
This seems to introduce the requirement for a space between clock rate and encoding parameter (but it's NOT BNF format!!!). However, there is an errata here which reports that was an error.
According to my experience, it is not allowed to have space in rtpmap execpt between payload type and the payload definition.
For rtpmap, you may also check the newer ietf document rfc4566bis which provides a BNF definition for rtpmap, and this one is clearly without space:
rtpmap-value = payload-type SP encoding-name
"/" clock-rate [ "/" encoding-params ]
payload-type = zero-based-integer
encoding-name = token
clock-rate = integer
encoding-params = channels
channels = integer
fmtp is more tricky, but the definition in newer rfc4566bis is allowing spaces in byte-string BNF definition:
fmtp-value = fmt SP format-specific-params
format-specific-params = byte-string
byte-string = 1*(%x01-09/%x0B-0C/%x0E-FF)
;any byte except NUL, CR, or LF
Also, from experience, some rfc are using space around ";" and other are not. I'm not able to find the exact reason, but it may be related to the fact that spaces are allowed in Content-Type HTML header. To read more about this, you may check rfc4855 and rfc2045.
来源:https://stackoverflow.com/questions/59483948/are-the-or-in-sdp-values-for-attributes-tokens-by-themselves-with-spaces