private void AddReceiverReports(CompoundPacket cp) { while(!cpComplete && receiverReports.Count > 0) { bool rrpComplete = false; bool addedReport = false; RrPacket rrp = new RrPacket(); rrp.SSRC = participant.SSRC; // Remove the size of the header + ssrc if(space >= rrp.Size) { space -= rrp.Size; // Add the rest while(space >= ReceiverReport.SIZE && receiverReports.Count > 0) { try { ReceiverReport rr = (ReceiverReport)receiverReports.Peek(); rrp.AddReceiverReport(rr); receiverReports.Dequeue(); space -= ReceiverReport.SIZE; addedReport = true; } catch(RtcpPacket.InsufficientItemSpaceException) { // No more room in rrp for reports rrpComplete = true; break; } } } // We broke out of the loop for one of 3 reasons // 1. There were no more ReceiverReports // 2. There was no more room in rrp // 3. There was no more room in cp (cpComplete) // If we added a report to rrp, add rrp to cp if(addedReport) { int start = cp.Buffer.Length; cp.AddPacket(rrp); int end = cp.Buffer.Length; Debug.Assert( (end - start) == rrp.Size ); // math check } // Figure out if we exited because cp is complete if(receiverReports.Count > 0 && rrpComplete == false) { cpComplete = true; } } }
private void ProcessRRPacket(RrPacket packet, IPAddress ipAddress) { AddSsrcToIp(packet.SSRC, ipAddress); RtpParticipant senderParticipant = (RtpParticipant)ssrcToParticipant[packet.SSRC]; if (senderParticipant != null) { string senderCName = senderParticipant.CName; foreach(ReceiverReport rr in packet.ReceiverReports) { RtpParticipant sourceParticipant = (RtpParticipant)ssrcToParticipant[rr.SSRC]; if (sourceParticipant != null) { string sourceCName = sourceParticipant.CName; RaiseReceiverReportEvent(senderCName, sourceCName, rr); } } } }
private void AddEmptyReceiverReportPacket(CompoundPacket cp) { RrPacket rr = new RrPacket(); rr.SSRC = participant.SSRC; int start = cp.Buffer.Length; cp.AddPacket(rr); int end = cp.Buffer.Length; space -= rr.Size; Debug.Assert( (end - start) == rr.Size ); // math check }