h.264規范中使用了在NAL層使用了RTP的包頭形式,下面對RTP的包頭做一下解釋:
首先我們來看一下H.264中對于RPT的結構封裝如下:
typedef struct
{
unsigned int v; //!< Version, 2 bits, MUST be 0x2
unsigned int p; //!< Padding bit, Padding MUST NOT be used
unsigned int x; //!< Extension, MUST be zero
unsigned int cc; /*!< CSRC count, normally 0 in the absence
of RTP mixers */
unsigned int m; //!< Marker bit
unsigned int pt; //!< 7 bits, Payload Type, dynamically established
unsigned int seq; /*!< RTP sequence number, incremented by one for
each sent packet */
unsigned int old_seq; //!< to detect wether packets were lost
unsigned int timestamp; //!< timestamp, 27 MHz for H.26L
unsigned int ssrc; //!< Synchronization Source, chosen randomly
byte * payload; //!< the payload including payload headers
unsigned int paylen; //!< length of payload in bytes
byte * packet; //!< complete packet including header and payload
unsigned int packlen; //!< length of packet, typically paylen+12
} RTPpacket_t;
對于RTP包頭格式如下:
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 |
| .... |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
前12個字節在每個RTP包中都存在,他們是:V、P、X、CC、M、PT、sequence number、timestamp、SSRC.其中V是版本號(占2個bit);P是填充位(占1個bit);X是擴展位(占1個bit);CC是CSRC的記數位(占4個bit);M是標記位(占1個bit);PT是有效載荷的類型(占7個bit);sequence number是RTP包記數位(占16個bit);timestamp是時間戳位(占4個字節);SSRC是同步標志位(占4個字節)。
CSRC不是RTP必須的(占4個字節)。
rtp包頭的意思:
CSRC記數(CC) 表示CSRC標識的數目。CSRC標識緊跟在RTP固定頭部之后,用來表示RTP數據報的來源,RTP協議允許在同一個會話中存在多個數據源,它們可以通過RTP混合器合并為一個數據源。例如,可以產生一個CSRC列表來表示一個電話會議,該會議通過一個RTP混合器將所有講話者的語音數據組合為一個RTP數據源。
負載類型(PT) 標明RTP負載的格式,包括所采用的編碼算法、采樣頻率、承載通道等。例如,類型2表明該RTP數據包中承載的是用ITU G.721算法編碼的語音數據,采樣頻率為8000Hz,并且采用單聲道。
序列號 用來為接收方提供探測數據丟失的方法,但如何處理丟失的數據則是應用程序自己的事情,RTP協議本身并不負責數據的重傳。
時間戳 記錄了負載中第一個字節的采樣時間,接收方能夠時間戳能夠確定數據的到達是否受到了延遲抖動的影響,但具體如何來補償延遲抖動則是應用程序自己的事情。
posted on 2009-07-18 19:18
Bluesea 閱讀(3205)
評論(0) 編輯 收藏 引用 所屬分類:
網絡