1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-12-23 01:55:48 -05:00

qrtplib: removed unknown packet support

This commit is contained in:
f4exb 2018-02-27 23:13:12 +01:00
parent ff4a35b3e3
commit fb4d07c275
4 changed files with 0 additions and 270 deletions

View File

@ -36,9 +36,6 @@
#include "rtcpsdespacket.h" #include "rtcpsdespacket.h"
#include "rtcpbyepacket.h" #include "rtcpbyepacket.h"
#include "rtcpapppacket.h" #include "rtcpapppacket.h"
#ifdef RTP_SUPPORT_RTCPUNKNOWN
#include "rtcpunknownpacket.h"
#endif // RTP_SUPPORT_RTCPUNKNOWN
#include <string.h> #include <string.h>
namespace qrtplib namespace qrtplib
@ -48,9 +45,6 @@ RTCPCompoundPacketBuilder::RTCPCompoundPacketBuilder()
{ {
byesize = 0; byesize = 0;
appsize = 0; appsize = 0;
#ifdef RTP_SUPPORT_RTCPUNKNOWN
unknownsize = 0;
#endif // RTP_SUPPORT_RTCPUNKNOWN
maximumpacketsize = 0; maximumpacketsize = 0;
buffer = 0; buffer = 0;
external = false; external = false;
@ -80,24 +74,10 @@ void RTCPCompoundPacketBuilder::ClearBuildBuffers()
if ((*it).packetdata) if ((*it).packetdata)
delete[] (*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(); byepackets.clear();
apppackets.clear(); apppackets.clear();
#ifdef RTP_SUPPORT_RTCPUNKNOWN
unknownpackets.clear();
#endif // RTP_SUPPORT_RTCPUNKNOWN
byesize = 0; byesize = 0;
appsize = 0; appsize = 0;
#ifdef RTP_SUPPORT_RTCPUNKNOWN
unknownsize = 0;
#endif // RTP_SUPPORT_RTCPUNKNOWN
} }
int RTCPCompoundPacketBuilder::InitBuild(size_t maxpacketsize) int RTCPCompoundPacketBuilder::InitBuild(size_t maxpacketsize)
@ -115,9 +95,6 @@ int RTCPCompoundPacketBuilder::InitBuild(size_t maxpacketsize)
external = false; external = false;
byesize = 0; byesize = 0;
appsize = 0; appsize = 0;
#ifdef RTP_SUPPORT_RTCPUNKNOWN
unknownsize = 0;
#endif // RTP_SUPPORT_RTCPUNKNOWN
arebuilding = true; arebuilding = true;
return 0; return 0;
@ -138,9 +115,6 @@ int RTCPCompoundPacketBuilder::InitBuild(void *externalbuffer, size_t buffersize
external = true; external = true;
byesize = 0; byesize = 0;
appsize = 0; appsize = 0;
#ifdef RTP_SUPPORT_RTCPUNKNOWN
unknownsize = 0;
#endif // RTP_SUPPORT_RTCPUNKNOWN
arebuilding = true; arebuilding = true;
return 0; return 0;
@ -154,11 +128,7 @@ int RTCPCompoundPacketBuilder::StartSenderReport(uint32_t senderssrc, const RTPN
if (report.headerlength != 0) if (report.headerlength != 0)
return ERR_RTP_RTCPCOMPPACKBUILDER_ALREADYGOTREPORT; return ERR_RTP_RTCPCOMPPACKBUILDER_ALREADYGOTREPORT;
#ifndef RTP_SUPPORT_RTCPUNKNOWN
size_t totalsize = byesize + appsize + sdes.NeededBytes(); 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 sizeleft = maximumpacketsize - totalsize;
size_t neededsize = sizeof(RTCPCommonHeader) + sizeof(uint32_t) + sizeof(RTCPSenderReport); size_t neededsize = sizeof(RTCPCommonHeader) + sizeof(uint32_t) + sizeof(RTCPSenderReport);
@ -190,11 +160,7 @@ int RTCPCompoundPacketBuilder::StartReceiverReport(uint32_t senderssrc)
if (report.headerlength != 0) if (report.headerlength != 0)
return ERR_RTP_RTCPCOMPPACKBUILDER_ALREADYGOTREPORT; return ERR_RTP_RTCPCOMPPACKBUILDER_ALREADYGOTREPORT;
#ifndef RTP_SUPPORT_RTCPUNKNOWN
size_t totalsize = byesize + appsize + sdes.NeededBytes(); 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 sizeleft = maximumpacketsize - totalsize;
size_t neededsize = sizeof(RTCPCommonHeader) + sizeof(uint32_t); 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) if (report.headerlength == 0)
return ERR_RTP_RTCPCOMPPACKBUILDER_REPORTNOTSTARTED; return ERR_RTP_RTCPCOMPPACKBUILDER_REPORTNOTSTARTED;
#ifndef RTP_SUPPORT_RTCPUNKNOWN
size_t totalothersize = byesize + appsize + sdes.NeededBytes(); 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(); size_t reportsizewithextrablock = report.NeededBytesWithExtraReportBlock();
if ((totalothersize + reportsizewithextrablock) > maximumpacketsize) if ((totalothersize + reportsizewithextrablock) > maximumpacketsize)
@ -256,11 +218,7 @@ int RTCPCompoundPacketBuilder::AddSDESSource(uint32_t ssrc)
if (!arebuilding) if (!arebuilding)
return ERR_RTP_RTCPCOMPPACKBUILDER_NOTBUILDING; return ERR_RTP_RTCPCOMPPACKBUILDER_NOTBUILDING;
#ifndef RTP_SUPPORT_RTCPUNKNOWN
size_t totalotherbytes = byesize + appsize + report.NeededBytes(); 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(); size_t sdessizewithextrasource = sdes.NeededBytesWithExtraSource();
if ((totalotherbytes + sdessizewithextrasource) > maximumpacketsize) if ((totalotherbytes + sdessizewithextrasource) > maximumpacketsize)
@ -309,11 +267,7 @@ int RTCPCompoundPacketBuilder::AddSDESNormalItem(RTCPSDESPacket::ItemType t, con
return ERR_RTP_RTCPCOMPPACKBUILDER_INVALIDITEMTYPE; return ERR_RTP_RTCPCOMPPACKBUILDER_INVALIDITEMTYPE;
} }
#ifndef RTP_SUPPORT_RTCPUNKNOWN
size_t totalotherbytes = byesize + appsize + report.NeededBytes(); 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); size_t sdessizewithextraitem = sdes.NeededBytesWithExtraItem(itemlength);
if ((sdessizewithextraitem + totalotherbytes) > maximumpacketsize) if ((sdessizewithextraitem + totalotherbytes) > maximumpacketsize)
@ -350,11 +304,7 @@ int RTCPCompoundPacketBuilder::AddSDESPrivateItem(const void *prefixdata, uint8_
if (itemlength > 255) if (itemlength > 255)
return ERR_RTP_RTCPCOMPPACKBUILDER_TOTALITEMLENGTHTOOBIG; return ERR_RTP_RTCPCOMPPACKBUILDER_TOTALITEMLENGTHTOOBIG;
#ifndef RTP_SUPPORT_RTCPUNKNOWN
size_t totalotherbytes = byesize + appsize + report.NeededBytes(); 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); size_t sdessizewithextraitem = sdes.NeededBytesWithExtraItem(itemlength);
if ((sdessizewithextraitem + totalotherbytes) > maximumpacketsize) 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(); 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) if ((totalotherbytes + packsize) > maximumpacketsize)
return ERR_RTP_RTCPCOMPPACKBUILDER_NOTENOUGHBYTESLEFT; return ERR_RTP_RTCPCOMPPACKBUILDER_NOTENOUGHBYTESLEFT;
@ -471,11 +417,7 @@ int RTCPCompoundPacketBuilder::AddAPPPacket(uint8_t subtype, uint32_t ssrc, cons
return ERR_RTP_RTCPCOMPPACKBUILDER_APPDATALENTOOBIG; return ERR_RTP_RTCPCOMPPACKBUILDER_APPDATALENTOOBIG;
size_t packsize = sizeof(RTCPCommonHeader) + sizeof(uint32_t) * 2 + appdatalen; size_t packsize = sizeof(RTCPCommonHeader) + sizeof(uint32_t) * 2 + appdatalen;
#ifndef RTP_SUPPORT_RTCPUNKNOWN
size_t totalotherbytes = appsize + byesize + sdes.NeededBytes() + report.NeededBytes(); 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) if ((totalotherbytes + packsize) > maximumpacketsize)
return ERR_RTP_RTCPCOMPPACKBUILDER_NOTENOUGHBYTESLEFT; return ERR_RTP_RTCPCOMPPACKBUILDER_NOTENOUGHBYTESLEFT;
@ -512,50 +454,6 @@ int RTCPCompoundPacketBuilder::AddAPPPacket(uint8_t subtype, uint32_t ssrc, cons
return 0; 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() int RTCPCompoundPacketBuilder::EndBuild()
{ {
if (!arebuilding) if (!arebuilding)
@ -566,11 +464,7 @@ int RTCPCompoundPacketBuilder::EndBuild()
uint8_t *buf; uint8_t *buf;
size_t len; size_t len;
#ifndef RTP_SUPPORT_RTCPUNKNOWN
len = appsize + byesize + report.NeededBytes() + sdes.NeededBytes(); len = appsize + byesize + report.NeededBytes() + sdes.NeededBytes();
#else
len = appsize+unknownsize+byesize+report.NeededBytes()+sdes.NeededBytes();
#endif // RTP_SUPPORT_RTCPUNKNOWN
if (!external) if (!external)
{ {
@ -744,33 +638,6 @@ int RTCPCompoundPacketBuilder::EndBuild()
} }
} }
#ifdef RTP_SUPPORT_RTCPUNKNOWN
// adding the unknown data
{
std::list<Buffer>::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 // adding bye packets
{ {

View File

@ -128,12 +128,6 @@ public:
*/ */
int EndBuild(); 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: private:
class Buffer class Buffer
{ {
@ -403,11 +397,6 @@ private:
std::list<Buffer> apppackets; std::list<Buffer> apppackets;
size_t appsize; size_t appsize;
#ifdef RTP_SUPPORT_RTCPUNKNOWN
std::list<Buffer> unknownpackets;
size_t unknownsize;
#endif // RTP_SUPPORT_RTCPUNKNOWN
void ClearBuildBuffers(); void ClearBuildBuffers();
}; };

View File

@ -655,123 +655,6 @@ int RTPSession::SendRTCPAPPPacket(uint8_t subtype, const uint8_t name[4], const
#endif // RTP_SUPPORT_SENDAPP #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) int RTPSession::SendRawData(const void *data, size_t len, bool usertpchannel)
{ {
if (!created) if (!created)

View File

@ -180,15 +180,6 @@ public:
int SendRTCPAPPPacket(uint8_t subtype, const uint8_t name[4], const void *appdata, size_t appdatalen); int SendRTCPAPPPacket(uint8_t subtype, const uint8_t name[4], const void *appdata, size_t appdatalen);
#endif // RTP_SUPPORT_SENDAPP #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 /** 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 * RTCP channel (if they are different); the data is **not** passed through the
* RTPSession::OnChangeRTPOrRTCPData function. */ * RTPSession::OnChangeRTPOrRTCPData function. */