From fb4d07c275362d4f7b6eda5a3700c7fe4d49b567 Mon Sep 17 00:00:00 2001 From: f4exb Date: Tue, 27 Feb 2018 23:13:12 +0100 Subject: [PATCH] qrtplib: removed unknown packet support --- qrtplib/rtcpcompoundpacketbuilder.cpp | 133 -------------------------- qrtplib/rtcpcompoundpacketbuilder.h | 11 --- qrtplib/rtpsession.cpp | 117 ---------------------- qrtplib/rtpsession.h | 9 -- 4 files changed, 270 deletions(-) diff --git a/qrtplib/rtcpcompoundpacketbuilder.cpp b/qrtplib/rtcpcompoundpacketbuilder.cpp index 13434293f..b571254ac 100644 --- a/qrtplib/rtcpcompoundpacketbuilder.cpp +++ b/qrtplib/rtcpcompoundpacketbuilder.cpp @@ -36,9 +36,6 @@ #include "rtcpsdespacket.h" #include "rtcpbyepacket.h" #include "rtcpapppacket.h" -#ifdef RTP_SUPPORT_RTCPUNKNOWN -#include "rtcpunknownpacket.h" -#endif // RTP_SUPPORT_RTCPUNKNOWN #include namespace qrtplib @@ -48,9 +45,6 @@ RTCPCompoundPacketBuilder::RTCPCompoundPacketBuilder() { byesize = 0; appsize = 0; -#ifdef RTP_SUPPORT_RTCPUNKNOWN - unknownsize = 0; -#endif // RTP_SUPPORT_RTCPUNKNOWN maximumpacketsize = 0; buffer = 0; external = false; @@ -80,24 +74,10 @@ void RTCPCompoundPacketBuilder::ClearBuildBuffers() if ((*it).packetdata) delete[] (*it).packetdata; } -#ifdef RTP_SUPPORT_RTCPUNKNOWN - for (it = unknownpackets.begin(); it != unknownpackets.end(); it++) - { - if ((*it).packetdata) - delete[] (*it).packetdata; - } -#endif // RTP_SUPPORT_RTCPUNKNOWN - byepackets.clear(); apppackets.clear(); -#ifdef RTP_SUPPORT_RTCPUNKNOWN - unknownpackets.clear(); -#endif // RTP_SUPPORT_RTCPUNKNOWN byesize = 0; appsize = 0; -#ifdef RTP_SUPPORT_RTCPUNKNOWN - unknownsize = 0; -#endif // RTP_SUPPORT_RTCPUNKNOWN } int RTCPCompoundPacketBuilder::InitBuild(size_t maxpacketsize) @@ -115,9 +95,6 @@ int RTCPCompoundPacketBuilder::InitBuild(size_t maxpacketsize) external = false; byesize = 0; appsize = 0; -#ifdef RTP_SUPPORT_RTCPUNKNOWN - unknownsize = 0; -#endif // RTP_SUPPORT_RTCPUNKNOWN arebuilding = true; return 0; @@ -138,9 +115,6 @@ int RTCPCompoundPacketBuilder::InitBuild(void *externalbuffer, size_t buffersize external = true; byesize = 0; appsize = 0; -#ifdef RTP_SUPPORT_RTCPUNKNOWN - unknownsize = 0; -#endif // RTP_SUPPORT_RTCPUNKNOWN arebuilding = true; return 0; @@ -154,11 +128,7 @@ int RTCPCompoundPacketBuilder::StartSenderReport(uint32_t senderssrc, const RTPN if (report.headerlength != 0) return ERR_RTP_RTCPCOMPPACKBUILDER_ALREADYGOTREPORT; -#ifndef RTP_SUPPORT_RTCPUNKNOWN size_t totalsize = byesize + appsize + sdes.NeededBytes(); -#else - size_t totalsize = byesize+appsize+unknownsize+sdes.NeededBytes(); -#endif // RTP_SUPPORT_RTCPUNKNOWN size_t sizeleft = maximumpacketsize - totalsize; size_t neededsize = sizeof(RTCPCommonHeader) + sizeof(uint32_t) + sizeof(RTCPSenderReport); @@ -190,11 +160,7 @@ int RTCPCompoundPacketBuilder::StartReceiverReport(uint32_t senderssrc) if (report.headerlength != 0) return ERR_RTP_RTCPCOMPPACKBUILDER_ALREADYGOTREPORT; -#ifndef RTP_SUPPORT_RTCPUNKNOWN size_t totalsize = byesize + appsize + sdes.NeededBytes(); -#else - size_t totalsize = byesize+appsize+unknownsize+sdes.NeededBytes(); -#endif // RTP_SUPPORT_RTCPUNKNOWN size_t sizeleft = maximumpacketsize - totalsize; size_t neededsize = sizeof(RTCPCommonHeader) + sizeof(uint32_t); @@ -219,11 +185,7 @@ int RTCPCompoundPacketBuilder::AddReportBlock(uint32_t ssrc, uint8_t fractionlos if (report.headerlength == 0) return ERR_RTP_RTCPCOMPPACKBUILDER_REPORTNOTSTARTED; -#ifndef RTP_SUPPORT_RTCPUNKNOWN size_t totalothersize = byesize + appsize + sdes.NeededBytes(); -#else - size_t totalothersize = byesize+appsize+unknownsize+sdes.NeededBytes(); -#endif // RTP_SUPPORT_RTCPUNKNOWN size_t reportsizewithextrablock = report.NeededBytesWithExtraReportBlock(); if ((totalothersize + reportsizewithextrablock) > maximumpacketsize) @@ -256,11 +218,7 @@ int RTCPCompoundPacketBuilder::AddSDESSource(uint32_t ssrc) if (!arebuilding) return ERR_RTP_RTCPCOMPPACKBUILDER_NOTBUILDING; -#ifndef RTP_SUPPORT_RTCPUNKNOWN size_t totalotherbytes = byesize + appsize + report.NeededBytes(); -#else - size_t totalotherbytes = byesize+appsize+unknownsize+report.NeededBytes(); -#endif // RTP_SUPPORT_RTCPUNKNOWN size_t sdessizewithextrasource = sdes.NeededBytesWithExtraSource(); if ((totalotherbytes + sdessizewithextrasource) > maximumpacketsize) @@ -309,11 +267,7 @@ int RTCPCompoundPacketBuilder::AddSDESNormalItem(RTCPSDESPacket::ItemType t, con return ERR_RTP_RTCPCOMPPACKBUILDER_INVALIDITEMTYPE; } -#ifndef RTP_SUPPORT_RTCPUNKNOWN size_t totalotherbytes = byesize + appsize + report.NeededBytes(); -#else - size_t totalotherbytes = byesize+appsize+unknownsize+report.NeededBytes(); -#endif // RTP_SUPPORT_RTCPUNKNOWN size_t sdessizewithextraitem = sdes.NeededBytesWithExtraItem(itemlength); if ((sdessizewithextraitem + totalotherbytes) > maximumpacketsize) @@ -350,11 +304,7 @@ int RTCPCompoundPacketBuilder::AddSDESPrivateItem(const void *prefixdata, uint8_ if (itemlength > 255) return ERR_RTP_RTCPCOMPPACKBUILDER_TOTALITEMLENGTHTOOBIG; -#ifndef RTP_SUPPORT_RTCPUNKNOWN size_t totalotherbytes = byesize + appsize + report.NeededBytes(); -#else - size_t totalotherbytes = byesize+appsize+unknownsize+report.NeededBytes(); -#endif // RTP_SUPPORT_RTCPUNKNOWN size_t sdessizewithextraitem = sdes.NeededBytesWithExtraItem(itemlength); if ((sdessizewithextraitem + totalotherbytes) > maximumpacketsize) @@ -408,11 +358,7 @@ int RTCPCompoundPacketBuilder::AddBYEPacket(uint32_t *ssrcs, uint8_t numssrcs, c } } -#ifndef RTP_SUPPORT_RTCPUNKNOWN size_t totalotherbytes = appsize + byesize + sdes.NeededBytes() + report.NeededBytes(); -#else - size_t totalotherbytes = appsize+unknownsize+byesize+sdes.NeededBytes()+report.NeededBytes(); -#endif // RTP_SUPPORT_RTCPUNKNOWN if ((totalotherbytes + packsize) > maximumpacketsize) return ERR_RTP_RTCPCOMPPACKBUILDER_NOTENOUGHBYTESLEFT; @@ -471,11 +417,7 @@ int RTCPCompoundPacketBuilder::AddAPPPacket(uint8_t subtype, uint32_t ssrc, cons return ERR_RTP_RTCPCOMPPACKBUILDER_APPDATALENTOOBIG; size_t packsize = sizeof(RTCPCommonHeader) + sizeof(uint32_t) * 2 + appdatalen; -#ifndef RTP_SUPPORT_RTCPUNKNOWN size_t totalotherbytes = appsize + byesize + sdes.NeededBytes() + report.NeededBytes(); -#else - size_t totalotherbytes = appsize+unknownsize+byesize+sdes.NeededBytes()+report.NeededBytes(); -#endif // RTP_SUPPORT_RTCPUNKNOWN if ((totalotherbytes + packsize) > maximumpacketsize) return ERR_RTP_RTCPCOMPPACKBUILDER_NOTENOUGHBYTESLEFT; @@ -512,50 +454,6 @@ int RTCPCompoundPacketBuilder::AddAPPPacket(uint8_t subtype, uint32_t ssrc, cons return 0; } -#ifdef RTP_SUPPORT_RTCPUNKNOWN - -int RTCPCompoundPacketBuilder::AddUnknownPacket(uint8_t payload_type, uint8_t subtype, uint32_t ssrc, const void *data, size_t len) -{ - if (!arebuilding) - return ERR_RTP_RTCPCOMPPACKBUILDER_NOTBUILDING; - - size_t datawords = len/4; - - if ((datawords+2) > 65535) - return ERR_RTP_RTCPCOMPPACKBUILDER_APPDATALENTOOBIG; - - size_t packsize = sizeof(RTCPCommonHeader)+sizeof(uint32_t)+len; - size_t totalotherbytes = appsize+unknownsize+byesize+sdes.NeededBytes()+report.NeededBytes(); - - if ((totalotherbytes + packsize) > maximumpacketsize) - return ERR_RTP_RTCPCOMPPACKBUILDER_NOTENOUGHBYTESLEFT; - - uint8_t *buf = new uint8_t[packsize]; - if (buf == 0) - return ERR_RTP_OUTOFMEM; - - RTCPCommonHeader *hdr = (RTCPCommonHeader *)buf; - - hdr->version = 2; - hdr->padding = 0; - hdr->count = subtype; - hdr->length = qToBigEndian((uint16_t)(datawords+1)); - hdr->packettype = payload_type; - - uint32_t *source = (uint32_t *)(buf+sizeof(RTCPCommonHeader)); - *source = qToBigEndian(ssrc); - - if (len > 0) - memcpy((buf+sizeof(RTCPCommonHeader)+sizeof(uint32_t)),data,len); - - unknownpackets.push_back(Buffer(buf,packsize)); - unknownsize += packsize; - - return 0; -} - -#endif // RTP_SUPPORT_RTCPUNKNOWN - int RTCPCompoundPacketBuilder::EndBuild() { if (!arebuilding) @@ -566,11 +464,7 @@ int RTCPCompoundPacketBuilder::EndBuild() uint8_t *buf; size_t len; -#ifndef RTP_SUPPORT_RTCPUNKNOWN len = appsize + byesize + report.NeededBytes() + sdes.NeededBytes(); -#else - len = appsize+unknownsize+byesize+report.NeededBytes()+sdes.NeededBytes(); -#endif // RTP_SUPPORT_RTCPUNKNOWN if (!external) { @@ -744,33 +638,6 @@ int RTCPCompoundPacketBuilder::EndBuild() } } -#ifdef RTP_SUPPORT_RTCPUNKNOWN - - // adding the unknown data - - { - std::list::const_iterator it; - - for (it = unknownpackets.begin(); it != unknownpackets.end(); it++) - { - memcpy(curbuf,(*it).packetdata,(*it).packetlength); - - p = new RTCPUnknownPacket(curbuf,(*it).packetlength); - if (p == 0) - { - if (!external) - delete[] buf; - ClearPacketList(); - return ERR_RTP_OUTOFMEM; - } - rtcppacklist.push_back(p); - - curbuf += (*it).packetlength; - } - } - -#endif // RTP_SUPPORT_RTCPUNKNOWN - // adding bye packets { diff --git a/qrtplib/rtcpcompoundpacketbuilder.h b/qrtplib/rtcpcompoundpacketbuilder.h index ae0859dee..b2be64658 100644 --- a/qrtplib/rtcpcompoundpacketbuilder.h +++ b/qrtplib/rtcpcompoundpacketbuilder.h @@ -128,12 +128,6 @@ public: */ int EndBuild(); -#ifdef RTP_SUPPORT_RTCPUNKNOWN - /** Adds the RTCP packet specified by the arguments to the compound packet. - * Adds the RTCP packet specified by the arguments to the compound packet. - */ - int AddUnknownPacket(uint8_t payload_type, uint8_t subtype, uint32_t ssrc, const void *data, size_t len); -#endif // RTP_SUPPORT_RTCPUNKNOWN private: class Buffer { @@ -403,11 +397,6 @@ private: std::list apppackets; size_t appsize; -#ifdef RTP_SUPPORT_RTCPUNKNOWN - std::list unknownpackets; - size_t unknownsize; -#endif // RTP_SUPPORT_RTCPUNKNOWN - void ClearBuildBuffers(); }; diff --git a/qrtplib/rtpsession.cpp b/qrtplib/rtpsession.cpp index e6385e314..485c1db2c 100644 --- a/qrtplib/rtpsession.cpp +++ b/qrtplib/rtpsession.cpp @@ -655,123 +655,6 @@ int RTPSession::SendRTCPAPPPacket(uint8_t subtype, const uint8_t name[4], const #endif // RTP_SUPPORT_SENDAPP -#ifdef RTP_SUPPORT_RTCPUNKNOWN - -int RTPSession::SendUnknownPacket(bool sr, uint8_t payload_type, uint8_t subtype, const void *data, size_t len) -{ - int status; - - if (!created) - return ERR_RTP_SESSION_NOTCREATED; - - BUILDER_LOCK - uint32_t ssrc = packetbuilder.GetSSRC(); - BUILDER_UNLOCK - - RTCPCompoundPacketBuilder* rtcpcomppack = new RTCPCompoundPacketBuilder(GetMemoryManager()); - if (rtcpcomppack == 0) - { - delete rtcpcomppack; - return ERR_RTP_OUTOFMEM; - } - - status = rtcpcomppack->InitBuild(maxpacksize); - if(status < 0) - { - delete rtcpcomppack; - return status; - } - - if (sr) - { - // setup for the rtcp - RTPTime rtppacktime = packetbuilder.GetPacketTime(); - uint32_t rtppacktimestamp = packetbuilder.GetPacketTimestamp(); - uint32_t packcount = packetbuilder.GetPacketCount(); - uint32_t octetcount = packetbuilder.GetPayloadOctetCount(); - RTPTime curtime = RTPTime::CurrentTime(); - RTPTime diff = curtime; - diff -= rtppacktime; - diff += 1;// add transmission delay or RTPTime(0,0); - - double timestampunit = 90000; - - uint32_t tsdiff = (uint32_t)((diff.GetDouble()/timestampunit)+0.5); - uint32_t rtptimestamp = rtppacktimestamp+tsdiff; - RTPNTPTime ntptimestamp = curtime.GetNTPTime(); - - //first packet in an rtcp compound packet should always be SR or RR - if((status = rtcpcomppack->StartSenderReport(ssrc,ntptimestamp,rtptimestamp,packcount,octetcount)) < 0) - { - delete rtcpcomppack; - return status; - } - } - else - { - //first packet in an rtcp compound packet should always be SR or RR - if((status = rtcpcomppack->StartReceiverReport(ssrc)) < 0) - { - delete rtcpcomppack; - return status; - } - - } - - //add SDES packet with CNAME item - if ((status = rtcpcomppack->AddSDESSource(ssrc)) < 0) - { - delete rtcpcomppack; - return status; - } - - BUILDER_LOCK - size_t owncnamelen = 0; - uint8_t *owncname = rtcpbuilder.GetLocalCNAME(&owncnamelen); - - if ((status = rtcpcomppack->AddSDESNormalItem(RTCPSDESPacket::CNAME,owncname,owncnamelen)) < 0) - { - BUILDER_UNLOCK - delete rtcpcomppack; - return status; - } - BUILDER_UNLOCK - - //add our packet - if((status = rtcpcomppack->AddUnknownPacket(payload_type, subtype, ssrc, data, len)) < 0) - { - delete rtcpcomppack; - return status; - } - - if((status = rtcpcomppack->EndBuild()) < 0) - { - delete rtcpcomppack; - return status; - } - - //send packet - status = SendRTCPData(rtcpcomppack->GetCompoundPacketData(), rtcpcomppack->GetCompoundPacketLength()); - if(status < 0) - { - delete rtcpcomppack; - return status; - } - - PACKSENT_LOCK - sentpackets = true; - PACKSENT_UNLOCK - - OnSendRTCPCompoundPacket(rtcpcomppack); // we'll place this after the actual send to avoid tampering - - int retlen = rtcpcomppack->GetCompoundPacketLength(); - - delete rtcpcomppack; - return retlen; -} - -#endif // RTP_SUPPORT_RTCPUNKNOWN - int RTPSession::SendRawData(const void *data, size_t len, bool usertpchannel) { if (!created) diff --git a/qrtplib/rtpsession.h b/qrtplib/rtpsession.h index 918ac2b00..cc12084b5 100644 --- a/qrtplib/rtpsession.h +++ b/qrtplib/rtpsession.h @@ -180,15 +180,6 @@ public: int SendRTCPAPPPacket(uint8_t subtype, const uint8_t name[4], const void *appdata, size_t appdatalen); #endif // RTP_SUPPORT_SENDAPP -#ifdef RTP_SUPPORT_RTCPUNKNOWN - /** Tries to send an Unknown packet immediately. - * Tries to send an Unknown packet immediately. If successful, the function returns the number - * of bytes in the RTCP compound packet. Note that this immediate sending is not compliant with the RTP - * specification, so use with care. Can send message along with a receiver report or a sender report - */ - int SendUnknownPacket(bool sr, uint8_t payload_type, uint8_t subtype, const void *data, size_t len); -#endif // RTP_SUPPORT_RTCPUNKNOWN - /** With this function raw data can be sent directly over the RTP or * RTCP channel (if they are different); the data is **not** passed through the * RTPSession::OnChangeRTPOrRTCPData function. */