Commit 3298184c by xia-chu

添加打印rtp详情功能

parent 1539e4ed
......@@ -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);
......
......@@ -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:
//返回有效负载偏移量
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论