添加打印rtp详情功能

This commit is contained in:
xia-chu 2021-02-02 11:54:49 +08:00
parent 1539e4ed60
commit 3298184c5c
2 changed files with 23 additions and 2 deletions

View File

@ -478,7 +478,7 @@ size_t RtpHeader::getPaddingSize(size_t rtp_size) const {
return *end;
}
size_t RtpHeader::getPayloadSize(size_t rtp_size){
size_t RtpHeader::getPayloadSize(size_t rtp_size) const{
auto invalid_size = getPayloadOffset() + getPaddingSize(rtp_size);
if (invalid_size + RtpPacket::kRtpHeaderSize >= rtp_size) {
return 0;
@ -486,6 +486,25 @@ size_t RtpHeader::getPayloadSize(size_t rtp_size){
return rtp_size - invalid_size - RtpPacket::kRtpHeaderSize;
}
string RtpHeader::dumpString(size_t rtp_size) const{
_StrPrinter printer;
printer << "version:" << (int)version << "\r\n";
printer << "padding:" << getPaddingSize(rtp_size) << "\r\n";
printer << "ext:" << getExtSize() << "\r\n";
printer << "csrc:" << getCsrcSize() << "\r\n";
printer << "mark:" << (int)mark << "\r\n";
printer << "pt:" << (int)pt << "\r\n";
printer << "seq:" << ntohs(seq) << "\r\n";
printer << "stamp:" << ntohl(stamp) << "\r\n";
printer << "ssrc:" << ntohl(ssrc) << "\r\n";
printer << "rtp size:" << rtp_size << "\r\n";
printer << "payload offset:" << getPayloadOffset() << "\r\n";
printer << "payload size:" << getPayloadSize(rtp_size) << "\r\n";
return std::move(printer);
}
///////////////////////////////////////////////////////////////////////
RtpHeader* RtpPacket::getHeader(){
//需除去rtcp over tcp 4个字节长度
return (RtpHeader*)(data() + RtpPacket::kRtpTcpHeaderSize);

View File

@ -125,7 +125,9 @@ public:
//返回有效负载指针,跳过csrc、ext
uint8_t* getPayloadData();
//返回有效负载总长度,不包括csrc、ext、padding
size_t getPayloadSize(size_t rtp_size);
size_t getPayloadSize(size_t rtp_size) const;
//打印调试信息
string dumpString(size_t rtp_size) const;
private:
//返回有效负载偏移量