Zum Hauptinhalt springen

9. SDP Grammar (SDP语法)

本节提供SDP的增强巴科斯-诺尔范式 (Augmented BNF, ABNF) 语法。ABNF在[RFC 5234]中定义。

SDP语法定义

; SDP Syntax
session-description = proto-version
origin-field
session-name-field
information-field
uri-field
email-fields
phone-fields
connection-field
bandwidth-fields
time-fields
key-field
attribute-fields
media-descriptions

proto-version = %x76 "=" 1*DIGIT CRLF
;this memo describes version 0

origin-field = %x6f "=" username SP sess-id SP sess-version SP
nettype SP addrtype SP unicast-address CRLF

session-name-field = %x73 "=" text CRLF

information-field = [%x69 "=" text CRLF]

uri-field = [%x75 "=" uri CRLF]

email-fields = *(%x65 "=" email-address CRLF)

phone-fields = *(%x70 "=" phone-number CRLF)

connection-field = [%x63 "=" nettype SP addrtype SP
connection-address CRLF]

bandwidth-fields = *(%x62 "=" bwtype ":" bandwidth CRLF)

time-fields = 1*( %x74 "=" start-time SP stop-time
*(CRLF repeat-fields) CRLF)
[zone-adjustments CRLF]

repeat-fields = %x72 "=" repeat-interval SP typed-time
1*(SP typed-time)

zone-adjustments = %x7a "=" time SP ["-"] typed-time
*(SP time SP ["-"] typed-time)

key-field = [%x6b "=" key-type CRLF]

attribute-fields = *(%x61 "=" attribute CRLF)

media-descriptions = *( media-field
information-field
*connection-field
bandwidth-fields
key-field
attribute-fields )

media-field = %x6d "=" media SP port ["/" integer]
SP proto 1*(SP fmt) CRLF

; Sub-rules
username = non-ws-string
sess-id = 1*DIGIT
sess-version = 1*DIGIT
nettype = token
addrtype = token
media = token
port = 1*DIGIT
proto = token *("/" token)
fmt = token

注意: 完整的ABNF语法定义非常详细,包括所有字段的详细规则和终端符号定义。完整语法请参考 RFC 4566官方文档 第9节。