/// <summary> /// A ByePacket can contain multiple SSRCs so we need to process them in a loop /// </summary> /// <param name="packet">ByePacket</param> /// <param name="ipAddress">IPAddress packet was received from</param> private void ProcessBYEPacket(ByePacket packet, IPAddress ipAddress) { // Remove stream does a special form of AddSsrcToIp // to try and prevent mischievous programming foreach(uint ssrc in packet.SSRCs) { RemoveSSRC(ssrc, ipAddress); } }
private void AddByeReports(CompoundPacket cp) { while(!cpComplete && byeReports.Count > 0) { bool byepComplete = false; bool addedReport = false; ByePacket byep = new ByePacket(); // Remove the size of the header + ssrc if(space >= byep.Size) { space -= byep.Size; // Add the rest while(space >= Rtp.SSRC_SIZE && byeReports.Count > 0) { try { uint ssrc = (uint)byeReports.Peek(); byep.AddSSRC(ssrc); byeReports.Dequeue(); space -= Rtp.SSRC_SIZE; addedReport = true; } catch(RtcpPacket.InsufficientItemSpaceException) { // No more room in bp for reports byepComplete = true; break; } } } // We broke out of the loop for one of 3 reasons // 1. There were no more byeReports // 2. There was no more room in bp // 3. There was no more room in cp (cpComplete) // If we added a report to bp, add bp to cp if(addedReport) { int start = cp.Buffer.Length; cp.AddPacket(byep); int end = cp.Buffer.Length; Debug.Assert( (end-start) == byep.Size ); // math check } // Figure out if we exited because cp is complete if(byeReports.Count > 0 && byepComplete == false) { cpComplete = true; } } }