"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/rtp.cxx" between
h323plus-1_26_9.tar.gz and h323plus-1_27_0.tar.gz

About: H.323 Plus offers libraries for voice (VoIP) and videoconferencing using H.323.

rtp.cxx  (h323plus-1_26_9):rtp.cxx  (h323plus-1_27_0)
skipping to change at line 391 skipping to change at line 391
SetCount(index+1); SetCount(index+1);
PINDEX originalPayloadSize = index != 0 ? GetPayloadSize() : 0; PINDEX originalPayloadSize = index != 0 ? GetPayloadSize() : 0;
SetPayloadSize(originalPayloadSize+sizeof(SourceDescription)); SetPayloadSize(originalPayloadSize+sizeof(SourceDescription));
SourceDescription & sdes = *(SourceDescription *)(GetPayloadPtr()+originalPayl oadSize); SourceDescription & sdes = *(SourceDescription *)(GetPayloadPtr()+originalPayl oadSize);
sdes.src = src; sdes.src = src;
sdes.item[0].type = e_END; sdes.item[0].type = e_END;
return sdes; return sdes;
} }
// TODO: this method produces invalid packets, if the data size needs padding // TODO: this method produces invalid packets, if the data size needs packet pad
ding
// thus data currently gets padded
RTP_ControlFrame::SourceDescription::Item & RTP_ControlFrame::SourceDescription::Item &
RTP_ControlFrame::AddSourceDescriptionItem(SourceDescription & sdes, RTP_ControlFrame::AddSourceDescriptionItem(SourceDescription & sdes,
unsigned type, unsigned type,
const PString & data) const PString & data)
{ {
PINDEX dataLength = data.GetLength(); // pad data string to avoid need for broken packet padding
PString sizedData = data;
while (sizedData.GetLength() < 2 || ((sizedData.GetLength() - 2) % 4 != 0))
sizedData += ' ';
PINDEX dataLength = sizedData.GetLength();
SetPayloadSize(GetPayloadSize()+sizeof(SourceDescription::Item)+dataLength-1); SetPayloadSize(GetPayloadSize()+sizeof(SourceDescription::Item)+dataLength-1);
SourceDescription::Item * item = sdes.item; SourceDescription::Item * item = sdes.item;
while (item->type != e_END) while (item->type != e_END)
item = item->GetNextItem(); item = item->GetNextItem();
item->type = (BYTE)type; item->type = (BYTE)type;
item->length = (BYTE)dataLength; item->length = (BYTE)dataLength;
memcpy(item->data, (const char *)data, item->length); memcpy(item->data, (const char *)sizedData, item->length);
item->GetNextItem()->type = e_END; item->GetNextItem()->type = e_END;
return *item; return *item;
} }
void RTP_ControlFrame::ReceiverReport::SetLostPackets(unsigned packets) void RTP_ControlFrame::ReceiverReport::SetLostPackets(unsigned packets)
{ {
lost[0] = (BYTE)(packets >> 16); lost[0] = (BYTE)(packets >> 16);
lost[1] = (BYTE)(packets >> 8); lost[1] = (BYTE)(packets >> 8);
lost[2] = (BYTE)packets; lost[2] = (BYTE)packets;
skipping to change at line 967 skipping to change at line 973
report.SetCount(1); report.SetCount(1);
AddReceiverReport(*(RTP_ControlFrame::ReceiverReport *)&sender[1]); AddReceiverReport(*(RTP_ControlFrame::ReceiverReport *)&sender[1]);
} }
} }
// Add the SDES part to compound RTCP packet // Add the SDES part to compound RTCP packet
PTRACE(2, "RTP\tSending SDES: " << canonicalName); PTRACE(2, "RTP\tSending SDES: " << canonicalName);
report.WriteNextCompound(); report.WriteNextCompound();
RTP_ControlFrame::SourceDescription & sdes = report.AddSourceDescription(syncS ourceOut); RTP_ControlFrame::SourceDescription & sdes = report.AddSourceDescription(syncS ourceOut);
// TODO: adding variable length names disabled until we handle padding correct report.AddSourceDescriptionItem(sdes, RTP_ControlFrame::e_CNAME, canonicalName
ly );
//report.AddSourceDescriptionItem(sdes, RTP_ControlFrame::e_CNAME, canonicalNa report.AddSourceDescriptionItem(sdes, RTP_ControlFrame::e_TOOL, toolName);
me);
//report.AddSourceDescriptionItem(sdes, RTP_ControlFrame::e_TOOL, toolName);
// Wait a fuzzy amount of time so things don't get into lock step // Wait a fuzzy amount of time so things don't get into lock step
int interval = (int)reportTimeInterval.GetMilliSeconds(); int interval = (int)reportTimeInterval.GetMilliSeconds();
int third = interval/3; int third = interval/3;
interval += PRandom::Number()%(2*third); interval += PRandom::Number()%(2*third);
interval -= third; interval -= third;
reportTimer = interval; reportTimer = interval;
return WriteControl(report); return WriteControl(report);
} }
skipping to change at line 1010 skipping to change at line 1015
} }
RTP_Session::SendReceiveStatus RTP_Session::OnReceiveControl(RTP_ControlFrame & frame) RTP_Session::SendReceiveStatus RTP_Session::OnReceiveControl(RTP_ControlFrame & frame)
{ {
do { do {
BYTE * payload = frame.GetPayloadPtr(); BYTE * payload = frame.GetPayloadPtr();
unsigned size = frame.GetPayloadSize(); unsigned size = frame.GetPayloadSize();
switch (frame.GetPayloadType()) { switch (frame.GetPayloadType()) {
case RTP_ControlFrame::e_SenderReport : case RTP_ControlFrame::e_SenderReport :
if (size >= (sizeof(RTP_ControlFrame::SenderReport)+frame.GetCount()*siz eof(RTP_ControlFrame::ReceiverReport))) { if (size >= (sizeof(RTP_ControlFrame::SenderReport)+frame.GetCount() * s izeof(RTP_ControlFrame::ReceiverReport))) {
SenderReport sender; SenderReport sender;
const RTP_ControlFrame::SenderReport & sr = *(const RTP_ControlFrame:: SenderReport *)payload; const RTP_ControlFrame::SenderReport & sr = *(const RTP_ControlFrame:: SenderReport *)payload;
sender.sourceIdentifier = sr.ssrc; sender.sourceIdentifier = sr.ssrc;
sender.realTimestamp = PTime(sr.ntp_sec-SecondsFrom1900to1970, sr.ntp_ frac/4294); sender.realTimestamp = PTime(sr.ntp_sec-SecondsFrom1900to1970, sr.ntp_ frac / 4294);
sender.realTimestamp1970 = sr.ntp_sec-SecondsFrom1900to1970; sender.realTimestamp1970 = sr.ntp_sec-SecondsFrom1900to1970;
sender.rtpTimestamp = sr.rtp_ts; sender.rtpTimestamp = sr.rtp_ts;
sender.packetsSent = sr.psent; sender.packetsSent = sr.psent;
sender.octetsSent = sr.osent; sender.octetsSent = sr.osent;
rtpSync.realTimestamp = sender.realTimestamp; rtpSync.realTimestamp = sender.realTimestamp;
rtpSync.rtpTimestamp = sender.rtpTimestamp; rtpSync.rtpTimestamp = sender.rtpTimestamp;
avSyncData = true; avSyncData = true;
// trace the report // trace the report
ReceiverReportArray RRs = BuildReceiverReportArray(frame, sizeof(RTP_C ontrolFrame::SenderReport)); ReceiverReportArray RRs = BuildReceiverReportArray(frame, sizeof(RTP_C ontrolFrame::SenderReport));
OnRxSenderReport(sender, RRs); OnRxSenderReport(sender, RRs);
} }
else { else {
PTRACE(2, "RTP\tSenderReport packet truncated"); PTRACE(2, "RTP\tSenderReport packet truncated");
} }
break; break;
case RTP_ControlFrame::e_ReceiverReport : case RTP_ControlFrame::e_ReceiverReport :
if (size >= (frame.GetCount()*sizeof(RTP_ControlFrame::ReceiverReport))) if (size >= (frame.GetCount() * sizeof(RTP_ControlFrame::ReceiverReport)
OnRxReceiverReport(*(const PUInt32b *)payload, ))
BuildReceiverReportArray(frame, sizeof(PUI OnRxReceiverReport(*(const PUInt32b *)payload, BuildReceiverReportArra
nt32b))); y(frame, sizeof(PUInt32b)));
else { else {
PTRACE(2, "RTP\tReceiverReport packet truncated"); PTRACE(2, "RTP\tReceiverReport packet truncated");
} }
break; break;
case RTP_ControlFrame::e_SourceDescription : case RTP_ControlFrame::e_SourceDescription :
if (size >= frame.GetCount()*sizeof(RTP_ControlFrame::SourceDescription) if (size >= frame.GetCount() * sizeof(RTP_ControlFrame::SourceDescriptio
) { n)) {
unsigned parsedBytes = 0; // bytes parsed so far
SourceDescriptionArray descriptions; SourceDescriptionArray descriptions;
const RTP_ControlFrame::SourceDescription * sdes = (const RTP_ControlF rame::SourceDescription *)payload; const RTP_ControlFrame::SourceDescription * sdes = (const RTP_ControlF rame::SourceDescription *)payload;
for (PINDEX srcIdx = 0; srcIdx < (PINDEX)frame.GetCount(); srcIdx++) { for (PINDEX srcIdx = 0; srcIdx < (PINDEX)frame.GetCount(); srcIdx++) {
if (parsedBytes >= size) {
PTRACE(2, "RTP\tSourceDescription packet truncated");
break;
}
descriptions.SetAt(srcIdx, new SourceDescription(sdes->src)); descriptions.SetAt(srcIdx, new SourceDescription(sdes->src));
const RTP_ControlFrame::SourceDescription::Item * item = sdes->item; const RTP_ControlFrame::SourceDescription::Item * item = sdes->item;
while (item->type != RTP_ControlFrame::e_END) { while (item->type != RTP_ControlFrame::e_END) {
descriptions[srcIdx].items.SetAt(item->type, PString(item->data, i tem->length)); descriptions[srcIdx].items.SetAt(item->type, PString(item->data, i tem->length));
parsedBytes += item->length + 2;
if (parsedBytes >= size) {
PTRACE(2, "RTP\tSourceDescription packet truncated");
break;
}
item = item->GetNextItem(); item = item->GetNextItem();
} }
sdes = (const RTP_ControlFrame::SourceDescription *)item->GetNextIte m(); sdes = (const RTP_ControlFrame::SourceDescription *)item->GetNextIte m();
} }
OnRxSourceDescription(descriptions); OnRxSourceDescription(descriptions);
} }
else { else {
PTRACE(2, "RTP\tSourceDescription packet truncated"); PTRACE(2, "RTP\tSourceDescription packet truncated");
} }
break; break;
case RTP_ControlFrame::e_Goodbye : case RTP_ControlFrame::e_Goodbye :
if (size >= 4) { if (size >= 4) {
PString reason; PString reason;
unsigned count = frame.GetCount()*4; // bytes with SSRCs before option al reason unsigned count = frame.GetCount() * 4; // bytes with SSRCs before opti onal reason
if (size > count) { if (size > count) {
// verify that RTCP packed is indeed as long as length byte indicate s // verify that RTCP packed is indeed as long as length byte indicate s
if (size >= payload[count] + sizeof(DWORD) /*SSRC*/ + sizeof(unsigne d char) /* length */) { if (size >= payload[count] + sizeof(DWORD) /*SSRC*/ + sizeof(unsigne d char) /* length */) {
reason = PString((const char *)(payload+count+1), payload[count]); reason = PString((const char *)(payload+count+1), payload[count]);
} else { } else {
PTRACE(2, "RTP\tGoodbye packet invalid"); PTRACE(2, "RTP\tGoodbye packet invalid");
} }
} }
PDWORDArray sources(count); PDWORDArray sources(count);
for (PINDEX i = 0; i < (PINDEX)frame.GetCount(); i++) { for (PINDEX i = 0; i < (PINDEX)frame.GetCount(); i++) {
skipping to change at line 1088 skipping to change at line 1102
OnRxGoodbye(sources, reason); OnRxGoodbye(sources, reason);
} }
else { else {
PTRACE(2, "RTP\tGoodbye packet truncated"); PTRACE(2, "RTP\tGoodbye packet truncated");
} }
break; break;
case RTP_ControlFrame::e_ApplDefined : case RTP_ControlFrame::e_ApplDefined :
if (size >= 4) { if (size >= 4) {
PString str((const char *)(payload+4), 4); PString str((const char *)(payload+4), 4);
OnRxApplDefined(str, frame.GetCount(), *(const PUInt32b *)payload, OnRxApplDefined(str, frame.GetCount(), *(const PUInt32b *)payload, pay
payload+8, frame.GetPayloadSize()-8); load+8, frame.GetPayloadSize()-8);
} }
else { else {
PTRACE(2, "RTP\tApplDefined packet truncated"); PTRACE(2, "RTP\tApplDefined packet truncated");
} }
break; break;
default : default :
PTRACE(2, "RTP\tUnknown control payload type: " << frame.GetPayloadType( )); PTRACE(2, "RTP\tUnknown control payload type: " << frame.GetPayloadType( ));
} }
} while (frame.ReadNextCompound()); } while (frame.ReadNextCompound());
 End of changes. 12 change blocks. 
19 lines changed or deleted 34 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)