📄 rtppkt.h
字号:
} { *off++ = (UINT8) (dlsr>>24); *off++ = (UINT8) (dlsr>>16); *off++ = (UINT8) (dlsr>>8); *off++ = (UINT8) (dlsr); } len = off-buf; return off;}HX_INLINE UINT8*ReceptionReport::unpack(UINT8* buf, UINT32 len){ if (!buf || !len) return 0; UINT8* off = buf; { ssrc = GetDwordFromBufAndInc(off); } { fraction = *off++; } { lost = *off++<<16; lost |= *off++<<8; lost |= *off++; } { last_seq = GetDwordFromBufAndInc(off); } { jitter = GetDwordFromBufAndInc(off); } { lsr = GetDwordFromBufAndInc(off); } { dlsr = GetDwordFromBufAndInc(off); } return off;}HX_INLINE UINT8*SDESItem::pack(UINT8* buf, UINT32 &len){ UINT8* off = buf; *off++ = sdes_type; if ((sdes_type != 0)) { *off++ = length; {memcpy(off, data, length); off += length; } /* Flawfinder: ignore */ } len = off-buf; return off;}HX_INLINE UINT8*SDESItem::unpack(UINT8* buf, UINT32 len){ if (!buf || !len) return 0; UINT8* off = buf; sdes_type = *off++; if ((sdes_type != 0)) { length = *off++; if (off-buf+length > (int)len) return 0; {data = (UINT8 *)off; off += length;} } return off;}HX_INLINE UINT8*APPItem::pack(UINT8* buf, UINT32 &len){ UINT8* off = buf; *off++ = app_type; if ((1 == app_type)) { { *off++ = (UINT8) (packet_sent); } {*off++ = (UINT8) (seq_no>>8); *off++ = (UINT8) (seq_no);} { *off++ = (UINT8) (timestamp>>24); *off++ = (UINT8) (timestamp>>16); *off++ = (UINT8) (timestamp>>8); *off++ = (UINT8) (timestamp); } } if ((2 == app_type)) { { *off++ = (UINT8) (lowest_timestamp>>24); *off++ = (UINT8) (lowest_timestamp>>16); *off++ = (UINT8) (lowest_timestamp>>8); *off++ = (UINT8) (lowest_timestamp); } { *off++ = (UINT8) (highest_timestamp>>24); *off++ = (UINT8) (highest_timestamp>>16); *off++ = (UINT8) (highest_timestamp>>8); *off++ = (UINT8) (highest_timestamp); } { *off++ = (UINT8) (bytes_buffered>>24); *off++ = (UINT8) (bytes_buffered>>16); *off++ = (UINT8) (bytes_buffered>>8); *off++ = (UINT8) (bytes_buffered); } { *off++ = (UINT8) (padding0>>16); *off++ = (UINT8) (padding0>>8); *off++ = (UINT8) (padding0); } } len = off-buf; return off;}HX_INLINE UINT8*APPItem::unpack(UINT8* buf, UINT32 len){ if (!buf || !len) return 0; UINT8* off = buf; app_type = *off++; if ((1 == app_type)) { { packet_sent = *off++; } {seq_no = *off++<<8; seq_no |= *off++;} { timestamp = GetDwordFromBufAndInc(off); } } if ((2 == app_type)) { { lowest_timestamp = GetDwordFromBufAndInc(off); } { highest_timestamp = GetDwordFromBufAndInc(off); } { bytes_buffered = GetDwordFromBufAndInc(off); } { padding0 = *off++<<16; padding0 |= *off++<<8; padding0 |= *off++; } } return off;}HX_INLINE UINT8*RTCPPacketBase::pack(UINT8* buf, UINT32 &len){ UINT8* off = buf; { *off &= ~0xc0; *off |= (version_flag&0x3)<<6; } {*off &= ~(1<<5); *off |= (padding_flag&1)<<5;} { *off &= ~0x1f; *off++ |= count&0x1f; } { *off++ = (UINT8) (packet_type); } {*off++ = (UINT8) (length>>8); *off++ = (UINT8) (length);} if ((packet_type == 200)) { { *off++ = (UINT8) (sr_ssrc>>24); *off++ = (UINT8) (sr_ssrc>>16); *off++ = (UINT8) (sr_ssrc>>8); *off++ = (UINT8) (sr_ssrc); } { *off++ = (UINT8) (ntp_sec>>24); *off++ = (UINT8) (ntp_sec>>16); *off++ = (UINT8) (ntp_sec>>8); *off++ = (UINT8) (ntp_sec); } { *off++ = (UINT8) (ntp_frac>>24); *off++ = (UINT8) (ntp_frac>>16); *off++ = (UINT8) (ntp_frac>>8); *off++ = (UINT8) (ntp_frac); } { *off++ = (UINT8) (rtp_ts>>24); *off++ = (UINT8) (rtp_ts>>16); *off++ = (UINT8) (rtp_ts>>8); *off++ = (UINT8) (rtp_ts); } { *off++ = (UINT8) (psent>>24); *off++ = (UINT8) (psent>>16); *off++ = (UINT8) (psent>>8); *off++ = (UINT8) (psent); } { *off++ = (UINT8) (osent>>24); *off++ = (UINT8) (osent>>16); *off++ = (UINT8) (osent>>8); *off++ = (UINT8) (osent); } {for (int i = 0; i < count; i++) off = sr_data[i].pack(off, len); } } if ((packet_type == 201)) { { *off++ = (UINT8) (rr_ssrc>>24); *off++ = (UINT8) (rr_ssrc>>16); *off++ = (UINT8) (rr_ssrc>>8); *off++ = (UINT8) (rr_ssrc); } {for (int i = 0; i < count; i++) off = rr_data[i].pack(off, len); } } if ((packet_type == 202)) { {memcpy(off, sdes_data, (length * 4)); off += (length * 4); } /* Flawfinder: ignore */ } if ((packet_type == 203)) { {for (int i = 0; i < count; i++) { *off++ = (UINT8) (bye_src[i]>>24); *off++ = (UINT8) (bye_src[i]>>16); *off++ = (UINT8) (bye_src[i]>>8); *off++ = (UINT8) (bye_src[i]); } } } if ((packet_type == 204)) { { *off++ = (UINT8) (app_ssrc>>24); *off++ = (UINT8) (app_ssrc>>16); *off++ = (UINT8) (app_ssrc>>8); *off++ = (UINT8) (app_ssrc); } {memcpy(off, app_name, 4); off += 4; } /* Flawfinder: ignore */ {memcpy(off, app_data, ((length - 2) * 4)); off += ((length - 2) * 4); } /* Flawfinder: ignore */ } len = off-buf; return off;}HX_INLINE UINT8*RTCPPacketBase::unpack(UINT8* buf, UINT32 len){ if (!buf || len < 4) return 0; UINT8* off = buf; { version_flag = (*off&0xc0)>>6; } padding_flag = (*off>>5)&1; { count = *off++&0x1f; } { packet_type = *off++; } {length = *off++<<8; length |= *off++;} if (len < (UINT32)4*(length + 1)) { count = 0; return 0; } if ((packet_type == 200)) { if (length < 6) { count = 0; return buf + 4 + 4*length; } { sr_ssrc = GetDwordFromBufAndInc(off); } { ntp_sec = GetDwordFromBufAndInc(off); } { ntp_frac = GetDwordFromBufAndInc(off); } { rtp_ts = GetDwordFromBufAndInc(off); } { psent = GetDwordFromBufAndInc(off); } { osent = GetDwordFromBufAndInc(off); } if (length < 6 + count*(ReceptionReport::static_size() / 4)) { count = 0; return buf + 4 + length*4; } { sr_data = new ReceptionReport[count]; for (int i = 0; i < count; i++) off = sr_data[i].unpack(off, len); } } if ((packet_type == 201)) { if (length < 1) { count = 0; return buf + 4 + 4*length; } { rr_ssrc = GetDwordFromBufAndInc(off); } if (length < 1 + count*(ReceptionReport::static_size() / 4)) { count = 0; return buf + 4 + length*4; } { rr_data = new ReceptionReport[count]; for (int i = 0; i < count; i++) off = rr_data[i].unpack(off, len); } } if ((packet_type == 202)) { if (off-buf+(length * 4) > (int)len) return 0; {sdes_data = (UINT8 *)off; off += (length * 4);} } if ((packet_type == 203)) { if (length < count) { count = 0; return buf + 4 + length*4; } { bye_src = new UINT32[count]; for (int i = 0; i < count; i++) { bye_src[i] = GetDwordFromBufAndInc(off); } } } if ((packet_type == 204)) { { app_ssrc = GetDwordFromBufAndInc(off); } if (off-buf+4 > (int)len) return 0; {memcpy(app_name, off, 4); off += 4; } /* Flawfinder: ignore */ if (off-buf+((length - 2) * 4) > (int)len) return 0; {app_data = (UINT8 *)off; off += ((length - 2) * 4);} } return off;}#endif //_DEFINE_INLINE#endif /* _RTPPKT_H_ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -