diff --git a/src/Rtsp/Rtsp.cpp b/src/Rtsp/Rtsp.cpp index 97bf27e1..41f9aae5 100644 --- a/src/Rtsp/Rtsp.cpp +++ b/src/Rtsp/Rtsp.cpp @@ -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); diff --git a/src/Rtsp/Rtsp.h b/src/Rtsp/Rtsp.h index d9ba975d..75dc7141 100644 --- a/src/Rtsp/Rtsp.h +++ b/src/Rtsp/Rtsp.h @@ -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: //返回有效负载偏移量