天天看點

RTP頭結構解析

RTP標頭前12個固定位元組機構圖:

0                   1                   2                   3

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

   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

   |V=2|P|X| CC   |M|     PT      |       sequence number         |

   |                           timestamp                           |

   |           synchronization source (SSRC) identifier            |

   +=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+

   |            contributing source (CSRC) identifiers             |

   |                             ….                              |

V – Version. Identifies the RTP version.

RTP版本号

P – Padding. When set, the packet contains one or more additional padding octets at the end which are not part of the payload.

是否填充,如果設定為允許填充的話,在包的末尾填充一個或多個位元組,這些填充的位元組不是有效負載的一部分。

X – Extension bit. When set, the fixed header is followed by exactly one header extension, with a defined format.

擴充位,如果設定為允許的話,固定頭結構後面(即包的12個位元組後面,有效負載的前面)緊跟着一個擴充頭結構,該結構是已定義的一種格式

CSRC count (CC) -Contains the number of CSRC identifiers that follow the fixed header.

資料源的個數(即源的個數),如果隻有一個源那麼此時的值為0。

M – Marker. The interpretation of the marker is defined by a profile. It is intended to allow significant events such as frame boundaries to be marked in the packet stream.

辨別,在文檔中是這樣定義的,它有意辨別重要的事物比如:在流媒體中辨別一幀資料的邊界(結束或開始)。

Payload type – Identifies the format of the RTP payload and determines its interpretation by the application. A profile specifies a default static mapping of payload type codes to payload formats. Additional payload type codes may be defined dynamically through non-RTP means.

有效負載,RTP資料的有效負載(不包括頭12個位元組),由具體的應用程式來确定負載的格式和意義。官方文檔裡有表格說明,該表格顯示了格式代碼和具體格式的對應關系,附加的格式代碼可能不在RTP協定裡定義。

Sequence number – Increments by one for each RTP data packet sent, and may be used by the receiver to detect packet loss and to restore packet sequence.

資料包序号,發送的RTP資料包序号,接收端可用它來檢查丢失的資料包和确定儲存資料包次序。

Timestamp – Reflects the sampling instant of the first octet in the RTP data packet. The sampling instant must be derived from a clock that increments monotonically and linearly in time to allow synchronization and jitter calculations.

時間戳, 紀錄了RTP資料包中第一個位元組的采樣時間,采樣時間必須源自一個時間增量且允許同步和計算。

SSRC – Synchronization source. This identifier is chosen randomly, with the intent that no two synchronization sources within the same RTP session will have the same SSRC identifier.

同步辨別, 是一個随機數,在同一個RTP會話中隻有一個同步辨別。

CSRC – Contributing source identifiers list. Identifies the contributing sources for the payload contained in this packet.