Stream Radio section updated
[platform/upstream/libvorbis.git] / doc / draft-kerr-avt-vorbis-rtp-04.xml
1 <?xml version='1.0'?>
2 <!DOCTYPE rfc SYSTEM 'rfc2629.dtd'>
3 <?rfc toc="yes" ?>
4
5 <rfc ipr="full3667" docName="RTP Payload Format for Vorbis Encoded Audio">
6
7 <front>
8 <title>draft-kerr-avt-vorbis-rtp-04</title>
9
10 <author initials="P" surname="Kerr" fullname="Phil Kerr">
11 <organization>Xiph.Org</organization>
12 <address>
13 <email>phil@plus24.com</email>
14 <uri>http://www.xiph.org/</uri>
15 </address>
16 </author>
17
18 <date day="31" month="December" year="2004" />
19
20 <area>General</area>
21 <workgroup>AVT Working Group</workgroup>
22 <keyword>I-D</keyword>
23
24 <keyword>Internet-Draft</keyword>
25 <keyword>Vorbis</keyword>
26 <keyword>RTP</keyword>
27
28 <abstract>
29 <t>This document describes a RTP payload format for transporting 
30 Vorbis encoded audio.  It details the RTP encapsulation mechanism 
31 for raw Vorbis data and details the delivery mechanisms for the 
32 decoder probability model, referred to as a codebook, metadata 
33 and other setup information.</t>
34 </abstract>
35
36 <note title="Editors Note">
37 <t>
38 All references to RFC XXXX are to be replaced by references to the RFC number of this memo, when published.
39 </t>
40 </note>
41
42 </front>
43
44 <middle>
45
46 <section anchor="Introduction" title="Introduction">
47 <t>
48 Vorbis is a general purpose perceptual audio codec intended to allow 
49 maximum encoder flexibility, thus allowing it to scale competitively 
50 over an exceptionally wide range of bitrates.   At the high 
51 quality/bitrate end of the scale (CD or DAT rate stereo, 
52 16/24 bits), it is in the same league as MPEG-2 and MPC. Similarly, 
53 the 1.0 encoder can encode high-quality CD and DAT rate stereo at 
54 below 48k bits/sec without resampling to a lower rate.   Vorbis is 
55 also intended for lower and higher sample rates (from 8kHz 
56 telephony to 192kHz digital masters) and a range of channel 
57 representations (monaural, polyphonic, stereo, quadraphonic, 5.1, 
58 ambisonic, or up to 255 discrete channels).
59
60 Vorbis encoded audio is generally encapsulated within an Ogg format 
61 bitstream <xref target="rfc3533"></xref>, which provides framing and synchronization.  For the 
62 purposes of RTP transport, this layer is unnecessary, and so raw 
63 Vorbis packets are used in the payload.
64 </t>
65
66 <section anchor="Terminology" title="Terminology">
67
68 <t>
69 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
70 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
71 document are to be interpreted as described in RFC 2119 <xref target="rfc2119"></xref>.
72 </t>
73
74 </section>
75 </section>
76
77 <section anchor="Payload Format" title="Payload Format">
78 <t>
79 For RTP based transportation of Vorbis encoded audio the standard 
80 RTP header is followed by a 5 octet payload header, then the payload 
81 data.  The payload headers are used to associate the Vorbis data with 
82 its associated decoding codebooks as well as indicating if the following packet
83 contains fragmented Vorbis data and/or the the number of whole Vorbis
84 data frames.  The payload data contains the raw Vorbis bitstream 
85 information.
86 </t>
87
88 <section anchor="RTP Header" title="RTP Header">
89
90 <artwork><![CDATA[
91     0                   1                   2                   3
92     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
93    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
94    |V=2|P|X|  CC   |M|     PT      |       sequence number         |
95    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
96    |                           timestamp                           |
97    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
98    |           synchronization source (SSRC) identifier            |
99    +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
100    |            contributing source (CSRC) identifiers             |
101    |                              ...                              |
102    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
103 ]]></artwork>
104
105 <t>
106 The RTP header begins with an octet of fields (V, P, X, and CC) to 
107 support specialized RTP uses (see <xref target="rfc3550"></xref> and <xref target="rfc3551"></xref> for details). For Vorbis RTP, the following values are used.
108 </t>
109
110 <t>
111 Version (V): 2 bits</t><t>
112 This field identifies the version of RTP. The version
113 used by this specification is two (2).
114 </t>
115
116 <t>
117 Padding (P): 1 bit</t><t>
118 Padding MAY be used with this payload format according to 
119 section 5.1 of <xref target="rfc3550"></xref>.  
120 </t>
121
122 <t>
123 Extension (X): 1 bit</t><t>
124 Always set to 0, as audio silence suppression is not used by 
125 the Vorbis codec. 
126 </t>
127
128 <t>
129 CSRC count (CC): 4 bits</t><t>
130 The CSRC count is used in accordance with <xref target="rfc3550"></xref>.
131 </t>
132
133 <t>
134 Marker (M): 1 bit</t><t>
135 Set to zero.  Audio silence suppression not used.  This conforms
136 to section 4.1 of <xref target="vorbis-spec-ref"></xref>.
137 </t>
138
139 <t>
140 Payload Type (PT): 7 bits</t><t>
141 An RTP profile for a class of applications is expected to assign 
142 a payload type for this format, or a dynamically allocated 
143 payload type SHOULD be chosen which designates the payload as 
144 Vorbis.
145 </t>
146
147 <t>
148 Sequence number: 16 bits</t><t>
149 The sequence number increments by one for each RTP data packet
150 sent, and may be used by the receiver to detect packet loss and
151 to restore packet sequence. This field is detailed further in
152 <xref target="rfc3550"></xref>.
153 </t>
154
155 <t>
156 Timestamp: 32 bits</t><t>
157 A timestamp representing the sampling time of the first sample of
158 the first Vorbis packet in the RTP packet.  The clock frequency 
159 MUST be set to the sample rate of the encoded audio data and is 
160 conveyed out-of-band as a SDP attribute.
161 </t>
162
163 <t>
164 SSRC/CSRC identifiers: </t><t>
165 These two fields, 32 bits each with one SSRC field and a maximum 
166 of 16 CSRC fields, are as defined in <xref target="rfc3550"></xref>.  
167 </t>
168
169 </section>
170
171 <section anchor="Payload Header" title="Payload Header">
172
173 <t>
174 After the RTP Header section the following five octets are the Payload Header.  
175 This header is split into a number of bitfields detailing the format
176 of the following Payload Data packets.
177 </t>
178
179 <artwork><![CDATA[
180     0                   1                   2                   3
181     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
182    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
183    |                          Codebook Ident                       |
184    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
185    |C|F| T |# pkts.|
186    +-+-+-+-+-+-+-+-+
187 ]]></artwork>
188
189 <t>
190 Codebook Ident: 32 bits</t><t>
191 This 32 bit field is used to associate the Vorbis data to a decoding Codebook.
192 It is created by making a CRC32 checksum of the codebook required to decode the 
193 particular Vorbis audio stream.
194 </t>
195
196 <t>
197 Continuation (C): 1 bit</t><t>
198 Set to one if this is a continuation of a fragmented packet.
199 </t>
200
201 <t>
202 Fragmented (F): 1 bit</t><t>
203 Set to one if the payload contains complete packets or if it
204 contains the last fragment of a fragmented packet. 
205 </t>
206
207 <t>
208 Payload Type (T): 2 bits</t><t>
209 This field sets the packet payload type.  There are currently four type of packet payloads. 
210 </t>
211
212 <vspace blankLines="1" />
213 <list style="empty">
214 <t>      0 = Raw Vorbis payload</t>
215 <t>      1 = Configuration payload</t>
216 <t>      2 = Codebook payload</t>
217 <t>      3 = Metadata payload</t>
218 </list>
219
220 <t>
221 The last 4 bits are the number of complete packets in this payload.  
222 This provides for a maximum number of 15 Vorbis packets in the 
223 payload.  If the packet contains fragmented data the number of packets MUST be set to 0.
224 </t>
225
226 </section>
227
228 <section anchor="Payload Data" title="Payload Data">
229
230 <t>
231 Raw Vorbis packets are unbounded in length currently, although at some future
232 point there will likely be a practical limit placed on them.  
233 Typical Vorbis packet sizes are from very small (2-3 bytes) to 
234 quite large (8-12 kilobytes).  The reference implementation <xref target="libvorbis"></xref>
235 typically produces packets less than ~800 bytes, except for the
236 codebook header packets which are ~4-12 kilobytes.
237 Within an RTP context the maximum Vorbis packet size, including the RTP and payload 
238 headers, SHOULD be kept below the path MTU to avoid packet fragmentation.  
239 </t>
240
241 <t>
242 Each Vorbis payload packet starts with a one octet length header, 
243 which is used to represent the size of the following data payload, followed 
244 by the raw Vorbis data.
245 </t>
246
247 <t>
248 For payloads which consist of multiple Vorbis packets the payload data 
249 consists of the packet length followed by the packet data for each of 
250 the Vorbis packets in the payload.
251 </t>
252
253 <t>
254 The Vorbis packet length header is the length of the Vorbis data 
255 block only and does not count the length octet.
256 </t>
257
258 <t>
259 The payload packing of the Vorbis data packets SHOULD follow the
260 guidelines set-out in <xref target="rfc3551"></xref> where the oldest packet
261 occurs immediately after the RTP packet header.
262 </t>
263
264 <t>
265 Channel mapping of the audio is in accordance with BS. 775-1
266 ITU-R.
267 </t>
268
269 </section>
270
271 <section anchor="Example RTP Packet" title="Example RTP Packet">
272
273 <t>
274 Here is an example RTP packet containing two Vorbis packets.
275 </t>
276 <t>
277 RTP Packet Header:
278 </t>
279
280 <artwork><![CDATA[
281     0                   1                   2                   3
282     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
283    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
284    | 2 |0|0|  0    |0|      PT     |       sequence number         |
285    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
286    |                 timestamp (in sample rate units)              |
287    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
288    |          synchronisation source (SSRC) identifier             |
289    +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
290    |            contributing source (CSRC) identifiers             |
291    |                              ...                              |
292    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
293 ]]></artwork>
294
295 <t>
296 Payload Data:
297 </t>
298
299 <artwork><![CDATA[
300     0                   1                   2                   3
301     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
302    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
303    |                          Codebook Ident                       |
304    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
305    |0|1| 0 | 2 pks |      len      |         vorbis data ...       |
306    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
307    ..                     ...vorbis data...                       ..
308    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
309    ..    data      |      len      |   next vorbis packet data...  |
310    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
311 ]]></artwork>
312
313 </section>
314
315 </section>
316
317 <section anchor="Frame Packetizing" title="Frame Packetizing">
318
319 <t>
320 Each RTP packet contains either one complete Vorbis packet, one 
321 Vorbis packet fragment, or an integer number of complete Vorbis 
322 packets (up to a max of 15 packets, since the number of packets 
323 is defined by a 4 bit value).
324 </t>
325
326 <t>
327 Any Vorbis data packet that is 256 octets or less SHOULD be bundled in the
328 RTP packet with as many Vorbis packets as will fit, up to a maximum
329 of 15.
330 </t>
331
332 <t>
333 If a Vorbis packet is larger than 256 octets it MUST be
334 fragmented.  A fragmented packet has a zero in the last four bits 
335 of the payload header.  Each fragment after the first will also set 
336 the Continued (C) bit to one in the payload header.  The RTP packet 
337 containing the last fragment of the Vorbis packet will have the 
338 Fragmented (F) bit set to one.  To maintain the correct sequence
339 for fragmented packet reception the timestamp field of fragmented 
340 packets MUST be the same as the first packet sent, with the sequence 
341 number incremented as normal for the subsequent RTP packets.  Path 
342 MTU is detailed in <xref target="rfc1063"></xref>  and <xref target="rfc1981"></xref>.
343 </t>
344
345 <section anchor="Example Fragmented Vorbis Packet" title="Example Fragmented Vorbis Packet">
346
347 <t>
348 Here is an example fragmented Vorbis packet split over three RTP
349 packets.  
350 </t>
351
352 <artwork><![CDATA[
353    Packet 1:
354
355     0                   1                   2                   3
356     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
357    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
358    |V=2|P|X|  CC   |M|     PT      |           1000                |
359    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
360    |                             xxxxx                             |
361    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
362    |           synchronization source (SSRC) identifier            |
363    +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
364    |            contributing source (CSRC) identifiers             |
365    |                              ...                              |
366    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
367    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
368    |                          Codebook Ident                       |
369    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
370    |0|0| 0 |      0|      len      |         vorbis data ..        |
371    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
372    |                       ..vorbis data..                         |
373    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
374 ]]></artwork>
375
376 <t>
377 In this packet the initial sequence number is 1000 and the 
378 timestamp is xxxxx.  The number of packets field is set to 0.
379 </t>
380
381 <artwork><![CDATA[
382    Packet 2:
383
384     0                   1                   2                   3
385     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
386    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
387    |V=2|P|X|  CC   |M|     PT      |           1001                |
388    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
389    |                             xxxxx                             |
390    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
391    |           synchronization source (SSRC) identifier            |
392    +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
393    |            contributing source (CSRC) identifiers             |
394    |                              ...                              |
395    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
396    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
397    |                          Codebook Ident                       |
398    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
399    |1|0| 0 |      0|      len      |         vorbis data ...       |
400    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
401    |                       ..vorbis data..                         |
402    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
403 ]]></artwork>
404
405 <t>
406 The C bit is set to 1 and the number of packets field is set to 0.
407 For large Vorbis fragments there can be several of these type of
408 payload packets.  The maximum packet size SHOULD be no greater
409 than the path MTU, including all RTP and payload headers.  The 
410 sequence number has been incremented by one but the timestamp field 
411 remains the same as the initial packet.
412 </t>
413
414 <artwork><![CDATA[
415    Packet 3:
416
417     0                   1                   2                   3
418     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
419    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
420    |V=2|P|X|  CC   |M|     PT      |           1002                |
421    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
422    |                             xxxxx                             |
423    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
424    |           synchronization source (SSRC) identifier            |
425    +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
426    |            contributing source (CSRC) identifiers             |
427    |                              ...                              |
428    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
429    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
430    |                          Codebook Ident                       |
431    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
432    |1|1| 0 |      0|      len      |         vorbis data ..        |
433    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
434    |                       ..vorbis data..                         |
435    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
436 ]]></artwork>
437
438 <t>
439 This is the last Vorbis fragment packet.  The C and F bits are 
440 set and the packet count remains set to 0.  As in the previous 
441 packets the timestamp remains set to the first packet in the 
442 sequence and the sequence number has been incremented.
443 </t>
444 </section>
445
446 <section anchor="Packet Loss" title="Packet Loss">
447
448 <t>
449 As there is no error correction within the Vorbis stream, packet 
450 loss will result in a loss of signal.  Packet loss is more of an 
451 issue for fragmented Vorbis packets as the client will have to 
452 cope with the handling of the C and F flags.  If we use the 
453 fragmented Vorbis packet example above and the first packet is
454 lost the client SHOULD detect that the next packet has the packet
455 count field set to 0 and the C bit is set and MUST drop it.  The
456 next packet, which is the final fragmented packet, SHOULD be dropped
457 in the same manner, or buffered.  Feedback reports on lost and 
458 dropped packets MUST be sent back via RTCP.
459 </t>
460
461 </section>
462
463 </section>
464
465 <section anchor="Configuration Headers" title="Configuration Headers">
466
467 <t>
468 Unlike other mainstream audio codecs Vorbis has no statically 
469 configured probability model, instead it packs all entropy decoding
470 configuration, VQ and Huffman models into a self-contained codebook.
471 This codebook block also requires additional identification 
472 information detailing the number of audio channels, bitrates and
473 other information used to initialise the Vorbis stream.
474 </t>
475
476 <t>
477 To decode a Vorbis stream three configuration header blocks are
478 needed.  The first header indicates the sample and bitrates, the 
479 number of channels and the version of the Vorbis encoder used.  
480 The second header contains the decoders probability model, or 
481 codebook and the third header details stream metadata.
482 </t>
483
484 <t>
485 As the RTP stream may change certain configuration data mid-session
486 there are two different methods for delivering this configuration
487 data to a client, in-band and SDP which is 
488 detailed below.  SDP delivery is used to set-up an initial
489 state for the client application and in-band is used to change state
490 during the session.  The changes may be due to different metadata
491 or codebooks as well as different bitrates of the stream.
492 </t>
493
494 <t>
495 Out of the two delivery vectors the use of an SDP attribute to indicate an URI 
496 where the configuration and codebook data can be obtained is preferred  
497 as they can be fetched reliably using TCP.  The in-band codebook delivery SHOULD 
498 only be used in situations where the link between the client is unidirectional or if 
499 the SDP-based information is not available. 
500 </t>
501
502 <t>
503 Synchronizing the configuration and codebook headers to the RTP stream is 
504 critical.  The 32 bit Codebook Ident field is used to indicate when a change in the stream has
505 taken place.  The client application MUST have in advance the correct configuration and codebook 
506 headers and if the client detects a change in the Ident value and does not have this information 
507 it MUST NOT decode the raw Vorbis data.
508 </t>
509
510 <section anchor="In-band Header Transmission" title="In-band Header Transmission">
511
512 <t>
513 The three header data blocks are sent in-band with the packet type bits set to 
514 match the payload type.  Normally the codebook and configuration 
515 headers are sent once per session if the stream is an encoding of live audio, as typically 
516 the encoder state will not change, but the encoder state can change at the boundary 
517 of chained Vorbis audio files.  Metadata can be sent at the start as well as any time during 
518 the life of the session.  Clients MUST be capable of dealing with periodic re-transmission of the 
519 configuration headers.
520 </t>
521
522 <t>
523 A Vorbis configuration header is indicated with the payload type field set to 1.
524 The Vorbis version MUST be set to zero to comply with
525 this document.  The fields Sample Rate, Bitrate Maximum/Nominal/
526 Minimum and Num Audio Channels are set in accordance with <xref target="vorbis-spec-ref"></xref> with 
527 the bsz fields above referring to the blocksize parameters.  The 
528 framing bit is not used for RTP transportation and so applications 
529 constructing Vorbis files MUST take care to set this if required.
530 </t>
531
532 <artwork><![CDATA[
533     0                   1                   2                   3
534     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
535    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
536    |V=2|P|X|  CC   |M|     PT      |             xxxx              |
537    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
538    |                             xxxxx                             |
539    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
540    |           synchronization source (SSRC) identifier            |
541    +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
542    |            contributing source (CSRC) identifiers             |
543    |                              ...                              |
544    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
545    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
546    |                          Codebook Ident                       |
547    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
548    |0|1| 2 |      1| bsz 0 | bsz 1 |       Num Audio Channels      |
549    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
550    |                        Vorbis Version                         |
551    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
552    |                       Audio Sample Rate                       |
553    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
554    |                        Bitrate Maximum                        |
555    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
556    |                        Bitrate Nominal                        |
557    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
558    |                        Bitrate Minimum                        |
559    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
560 ]]></artwork>
561
562 <t>
563 If the payload type field is set to 2, this indicates the packet contains codebook data.
564 </t>
565
566 <t>
567 The configuration information detailed below MUST be completely 
568 intact, as a client can not decode a stream with an incomplete 
569 or corrupted codebook set.
570 </t>
571
572 <t>
573 A 16 bit codebook length field precedes the codebook datablock.  The length field 
574 allows for codebooks to be up to 64K in size.  Packet fragmentation, 
575 as per the Vorbis data, MUST be performed if the codebooks size exceeds
576 path MTU.  The Codebook Ident field MUST be set to match the associated codebook 
577 needed to decode the Vorbis stream.
578 </t>
579
580 <t>
581 The Codebook Ident is the CRC32 checksum of the codebook and 
582 is used to detect a corrupted codebook as well as 
583 associating it with its Vorbis data stream.  This Ident value 
584 MUST NOT be set to the value of the current stream if this header is
585 being sent before the boundary of the chained file has been reached.
586 If a checksum failure is detected then this is considered to 
587 be a failure and MUST be reported to the client application.
588 </t>
589
590 <artwork><![CDATA[
591     0                   1                   2                   3
592     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
593    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
594    |V=2|P|X|  CC   |M|     PT      |             xxxx              |
595    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
596    |                             xxxxx                             |
597    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
598    |           synchronization source (SSRC) identifier            |
599    +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
600    |            contributing source (CSRC) identifiers             |
601    |                              ...                              |
602    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
603    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
604    |                           Codebook Ident                      |
605    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
606    |0|1| 2 |      1|           Codebook Length                     |
607    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
608    |    length     |           Codebook                           ..
609    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
610    ..                          Codebook                            |
611    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
612 ]]></artwork>
613
614
615 <t>
616 With the payload type flag set to 3, this indicates that the packet contain the 
617 comment metadata, such as artist name, track title and so on.  These
618 metadata messages are not intended to be fully descriptive but to 
619 offer basic track/song information.  This message MUST be sent at 
620 the start of the stream, together with the setup and codebook 
621 headers, even if it contains no information.  During a session the
622 metadata associated with the stream may change from that specified 
623 at the start, e.g. a live concert broadcast changing acts/scenes, so
624 clients MUST have the ability to receive header blocks.  Details
625 on the format of the comments can be found in the Vorbis 
626 documentation <xref target="v-comment"></xref>.
627 </t>
628
629
630   1) [vendor_length] = read an unsigned integer of 32 bits
631   2) [vendor_string] = read a UTF-8 vector as [vendor_length] octets
632   3) [user_comment_list_length] = read an unsigned integer of 32 bits
633   4) iterate [user_comment_list_length] times {
634
635        5) [length] = read an unsigned integer of 32 bits
636        6) this iteration's user comment = read a UTF-8 vector as [length] octets
637
638      }
639
640   7) [framing_bit] = read a single bit as boolean
641   8) if ( [framing_bit]  unset or end of packet ) then ERROR
642   9) done.
643
644
645 <t>
646 The format for the data takes the form of a 32 bit codec vendors
647 name length field followed by the name encoded in UTF-8.  The next 32 
648 bit field denotes the number of user comments. Each of the user comments 
649 is prefixed by a 32 bit length field followed by the comment text.   
650 </t>
651
652 <artwork><![CDATA[
653     0                   1                   2                   3
654     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
655    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
656    |V=2|P|X|  CC   |M|     PT      |             xxxx              |
657    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
658    |                             xxxxx                             |
659    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
660    |           synchronization source (SSRC) identifier            |
661    +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
662    |            contributing source (CSRC) identifiers             |
663    |                              ...                              |
664    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
665    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
666    |                          Codebook Ident                       |
667    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
668    |0|1| 3 |      1|          Vendor string length                 |
669    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
670    |    length     |          Vendor string                       ..
671    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
672    |                    User comments list length                  |
673    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
674    ..               User comment length / User comment             |
675    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
676 ]]></artwork>
677
678 </section>
679
680 <section anchor="Session Description for Vorbis RTP Streams" title="Session Description for Vorbis RTP Streams"> 
681 <t>
682 Session description information concerning the Vorbis stream 
683 SHOULD be provided if possible and MUST be in accordance with <xref target="rfc2327"></xref>.  
684 </t>
685
686 <t>
687 If the stream comprises chained Vorbis files the configuration and codebook headers for each
688 file SHOULD be packaged together and passed to the client using the headers attribute.
689 </t>
690
691 <t>
692 Below is an outline of the mandatory SDP attributes.
693 </t>
694
695 <vspace blankLines="1" />
696 <list style="empty">
697 <t>c=IN IP4/6 </t>
698 <t>m=audio  RTP/AVP 98</t>
699 <t>a=rtpmap:98 VORBIS/44100/2</t>
700 <t>a=fmtp:98 header=&lt;URI of configuration header&gt; </t>
701 </list>
702
703 <t>
704 The Vorbis configuration specified in the header attribute MUST contain
705 all of the configuration data and codebooks needed for the life of the session.  
706 </t>
707
708 <t>
709 The port value is specified by the server application bound to 
710 the address specified in the c attribute.  The bitrate value 
711 and channels specified in the m attribute MUST match the Vorbis 
712 sample rate value.
713 </t>
714
715 </section>
716
717 <section anchor="Codebook Caching" title="Codebook Caching"> 
718
719 <t>
720 Codebook caching allows clients that have previously connected to a 
721 stream to re-use the associated codebooks and configuration data.  
722 When a client receives a codebook it may store it locally and can 
723 compare the CRC32 key with that of the new stream and begin decoding 
724 before it has received any of the headers.
725 </t>   
726
727 </section>
728
729 </section>
730
731 <section anchor="IANA Considerations" title="IANA Considerations"> 
732
733 <t>
734 MIME media type name: audio
735 </t>
736 <t>
737 MIME subtype: vorbis
738 </t>
739
740 <t>
741 Required Parameters:</t><t>
742 header indicates the URI of the decoding configuration headers.
743 </t>
744
745 <t>
746 Optional Parameters: </t><t>
747 None.
748 </t>
749
750 <t>
751 Encoding considerations:</t><t>
752 This type is only defined for transfer via RTP as specified 
753 in RFC XXXX.
754 </t>
755
756 <t>
757 Security Considerations:</t><t>
758 See Section 6 of RFC 3047.
759 </t>
760
761 <t>
762 Interoperability considerations: none
763 </t>
764
765 <t>
766 Published specification:</t>
767 <t>See the Vorbis documentation <xref target="vorbis-spec-ref"></xref> for details.</t>
768
769 <t>
770 Applications which use this media type:</t><t>
771 Audio streaming and conferencing tools
772 </t>
773
774 <t>
775 Additional information: none
776 </t>
777
778 <t>
779 Person &amp; email address to contact for further information:</t><t>
780 Phil Kerr: &lt;phil@plus24.com&gt;
781 </t>
782
783 <t>
784 Intended usage: COMMON
785 </t>
786
787 <t>
788 Author/Change controller:</t><t>
789 Author: Phil Kerr
790 Change controller: IETF AVT Working Group
791 </t>
792
793 </section>
794
795 <section anchor="Congestion Control" title="Congestion Control"> 
796
797 <t>
798 Vorbis clients SHOULD send regular receiver reports detailing 
799 congestion.  A mechanism for dynamically downgrading the stream, 
800 known as bitrate peeling, will allow for a graceful backing off
801 of the stream bitrate.  This feature is not available at present
802 so an alternative would be to redirect the client to a lower 
803 bitrate stream if one is available.  
804 </t>
805
806 </section> 
807
808 <section anchor="Security Considerations" title="Security Considerations"> 
809 <t>
810 RTP packets using this payload format are subject to the security 
811 considerations discussed in the RTP specification <xref target="rfc3550"></xref>.  This implies 
812 that the confidentiality of the media stream is achieved by using
813 encryption.  Because the data compression used with this payload
814 format is applied end-to-end, encryption may be performed on the 
815 compressed data.  Where the size of a data block is set care MUST 
816 be taken to prevent buffer overflows in the client applications.
817 </t>
818
819 </section> 
820
821 <section anchor="Acknowledgments" title="Acknowledgments"> 
822
823 <t>
824 This document is a continuation of draft-moffitt-vorbis-rtp-00.txt.
825 The MIME type section is a continuation of draft-short-avt-rtp-
826 vorbis-mime-00.txt
827 </t>
828
829 <t>
830 Thanks to the AVT, Ogg Vorbis Communities / Xiph.org including 
831 Steve Casner, Aaron Colwell, Ross Finlayson, Ramon Garcia, Pascal Hennequin, Ralph Giles, 
832 Tor-Einar Jarnbjo, Colin Law, John Lazzaro, Jack Moffitt, Christopher Montgomery,
833 Colin Perkins, Barry Short, Mike Smith, Magnus Westerlund.
834 </t>
835
836 </section> 
837
838 </middle>
839
840 <back>
841
842 <references title="Normative References">
843
844 <reference anchor="rfc3533">
845 <front>
846 <title>The Ogg Encapsulation Format Version 0</title>
847 <author initials="S." surname="Pfeiffer" fullname="Silvia Pfeiffer"></author>
848 </front>
849 <seriesInfo name="RFC" value="3533" />
850 </reference>
851
852 <reference anchor="rfc2119">
853 <front>
854 <title>Key words for use in RFCs to Indicate Requirement Levels </title>
855 <author initials="S." surname="Bradner" fullname="Scott Bradner"></author>
856 </front>
857 <seriesInfo name="RFC" value="2119" />
858 </reference>   
859
860 <reference anchor="rfc3550">
861 <front>
862 <title>RTP: A Transport Protocol for real-time applications</title>
863 <author initials="H." surname="Schulzrinne" fullname=""></author>
864 <author initials="S." surname="Casner" fullname=""></author>
865 <author initials="R." surname="Frederick" fullname=""></author>
866 <author initials="V." surname="Jacobson" fullname=""></author>
867 </front>
868 <seriesInfo name="RFC" value="3550" />
869 </reference> 
870
871 <reference anchor="rfc3551">
872 <front>
873 <title>RTP Profile for Audio and Video Conferences with Minimal Control.</title>
874 <author initials="H." surname="Schulzrinne" fullname=""></author>
875 <author initials="S." surname="Casner" fullname=""></author>
876 </front>
877 <date month="July" year="2003" />
878 <seriesInfo name="RFC" value="3551" />
879 </reference> 
880   
881 <reference anchor="rfc2327">
882 <front>
883 <title>SDP: Session Description Protocol</title>
884 <author initials="M." surname="Handley" fullname="Mark Handley"></author>
885 <author initials="V." surname="Jacobson" fullname="Van Jacobson"></author>
886 </front>
887 <seriesInfo name="RFC" value="2327" />
888 </reference>   
889
890 <reference anchor="rfc1063">
891 <front>
892 <title>Path MTU Discovery</title>
893 <author initials="J." surname="Mogul et al." fullname="J. Mogul et al."></author>
894 </front>
895 <seriesInfo name="RFC" value="1063" />
896 </reference>   
897
898 <reference anchor="rfc1981">
899 <front>
900 <title>Path MTU Discovery for IP version 6</title>
901 <author initials="J." surname="McCann et al." fullname="J. McCann et al."></author>
902 </front>
903 <seriesInfo name="RFC" value="1981" />
904 </reference>   
905 </references>
906
907 <references title="Informative References">
908 <reference anchor="libvorbis">
909 <front>
910 <title>libvorbis: Available from the Xiph website, http://www.xiph.org</title>
911 </front>
912 </reference>   
913
914 <reference anchor="vorbis-spec-ref">
915 <front>
916 <title>Ogg Vorbis I spec:  Codec setup and packet decode.  http://www.xiph.org/ogg/vorbis/doc/vorbis-spec-ref.html</title>
917 </front>
918 </reference>   
919   
920 <reference anchor="v-comment">
921 <front>
922 <title>Ogg Vorbis I spec:  Comment field and header specification.  http://www.xiph.org/ogg/vorbis/doc/v-comment.html</title>
923 </front>
924 </reference>   
925   
926 </references>
927 </back>
928 </rfc>