属性标记的 SDP 值中的“:”或“/”是否单独允许在它们周围有空格?

Are the ":" or "/" in SDP values for attributes tokens by themselves with spaces optionally allowed around them?

在 SDP 中,冒号 (':') 和斜杠 ('/') 用于许多属性值(标准和 a= 扩展)。这里只是其中的一部分:

  b=AS:41
  a=rtpmap:96 AMR-WB/16000/1
  a=fmtp:96 mode-change-capability=2; max-red=80

我想知道(对于解析和生成 SDP),是否允许在它们周围使用 space。所有示例都指向周围没有 space。我认为给出 SDP 语法的 RFC 4566 第 9 节对此并不清楚。

我会说,通常,SDP 不喜欢白色space。 rfc4566 的第一条规则没有回答你的问题,但它是一个开始:

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.

先从rfc4566中定义的bandwidth参数说起

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

从上面:

  • bwtype 中不允许有白色space 因为 %x20 不是 [ 的一部分=63=]
  • 带宽中不允许有白色space,因为它只包含DIGIT.
  • ":"左右两边没有白色space,否则规范会使用类似bwtype SP ":" SP bandwidth

对于rtpmap,在RFC4566 Section 6中,rtpmap的定义在这里:

a=rtpmap:<payload type> <encoding name>/<clock rate> [/<encoding
  parameters>]

这似乎引入了对时钟速率和编码参数之间 space 的要求(但它不是 BNF 格式!!!)。但是,有一个 errata here 报告这是一个错误。

根据我的经验,在有效载荷类型和有效载荷定义之间的rtpmap execpt中不允许有space。

关于rtpmap,你也可以查看较新的ietf文档rfc4566bis,其中提供了rtpmap的BNF定义,而这个显然没有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 更棘手,但较新的 rfc4566bis 中的定义允许 byte-string 中的 space BNF 定义:

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

此外,根据经验,一些 rfc 在 ";" 周围使用 space,而其他则不是。我找不到确切的原因,但这可能与 Content-Type HTML header 中允许 space 的事实有关。要了解更多相关信息,您可以查看 rfc4855 and rfc2045.