天天看點

webrtc 中RTP和RTCP類型判斷

在webrtc中,為了友善,RTP和RTCP都用的是同一個收發端口;

這裡如何通過同一個端口判斷,接收到的資料是RTP類型還是RTCP類型呢?

主要是三個判斷:

1:看packet的大小;

2:看是否符合kRtcpExpectedVersion的版本号;

3:看是否屬于RTCP的類型;

直接看源碼:

bool RtpHeaderParser::RTCP() const {

  // 72 to 76 is reserved for RTP

  // 77 to 79 is not reserver but  they are not assigned we will block them

  // for RTCP 200 SR  == marker bit + 72

  // for RTCP 204 APP == marker bit + 76

  /*

  *       RTCP

  *

  * FIR      full INTRA-frame request             192     [RFC2032]   supported

  * NACK     negative acknowledgement             193     [RFC2032]

  * IJ       Extended inter-arrival jitter report 195     [RFC-ietf-avt-rtp-toff

  * set-07.txt] http://tools.ietf.org/html/draft-ietf-avt-rtp-toffset-07

繼續閱讀