void RTCPScheduler::AnalyseIncoming(RTCPCompoundPacket &rtcpcomppack) { bool isbye = false; RTCPPacket *p; rtcpcomppack.GotoFirstPacket(); while (!isbye && ((p = rtcpcomppack.GetNextPacket()) != 0)) { if (p->GetPacketType() == RTCPPacket::BYE) isbye = true; } if (!isbye) { size_t packsize = headeroverhead+rtcpcomppack.GetCompoundPacketLength(); avgrtcppacksize = (size_t)((1.0/16.0)*((double)packsize)+(15.0/16.0)*((double)avgrtcppacksize)); } else { if (byescheduled) { size_t packsize = headeroverhead+rtcpcomppack.GetCompoundPacketLength(); avgbyepacketsize = (size_t)((1.0/16.0)*((double)packsize)+(15.0/16.0)*((double)avgbyepacketsize)); byemembers++; } } }
void RTPSession::BYEDestroy(const RTPTime &maxwaittime,const void *reason,size_t reasonlength) { if (!created) return; // first, stop the thread so we have full control over all components #ifdef RTP_SUPPORT_THREAD if (pollthread) RTPDelete(pollthread,GetMemoryManager()); #endif // RTP_SUPPORT_THREAD RTPTime stoptime = RTPTime::CurrentTime(); stoptime += maxwaittime; // add bye packet to the list if we've sent data RTCPCompoundPacket *pack; if (sentpackets) { int status; reasonlength = (reasonlength>RTCP_BYE_MAXREASONLENGTH)?RTCP_BYE_MAXREASONLENGTH:reasonlength; status = rtcpbuilder.BuildBYEPacket(&pack,reason,reasonlength,useSR_BYEifpossible); if (status >= 0) { byepackets.push_back(pack); if (byepackets.size() == 1) rtcpsched.ScheduleBYEPacket(pack->GetCompoundPacketLength()); } } if (!byepackets.empty()) { bool done = false; while (!done) { RTPTime curtime = RTPTime::CurrentTime(); if (curtime >= stoptime) done = true; if (rtcpsched.IsTime()) { pack = *(byepackets.begin()); byepackets.pop_front(); rtptrans->SendRTCPData(pack->GetCompoundPacketData(),pack->GetCompoundPacketLength()); OnSendRTCPCompoundPacket(pack); // we'll place this after the actual send to avoid tampering RTPDelete(pack,GetMemoryManager()); if (!byepackets.empty()) // more bye packets to send, schedule them rtcpsched.ScheduleBYEPacket((*(byepackets.begin()))->GetCompoundPacketLength()); else done = true; } if (!done) RTPTime::Wait(RTPTime(0,100000)); } } if (deletetransmitter) RTPDelete(rtptrans,GetMemoryManager()); packetbuilder.Destroy(); rtcpbuilder.Destroy(); rtcpsched.Reset(); collisionlist.Clear(); sources.Clear(); // clear rest of bye packets std::list<RTCPCompoundPacket *>::const_iterator it; for (it = byepackets.begin() ; it != byepackets.end() ; it++) RTPDelete(*it,GetMemoryManager()); byepackets.clear(); created = false; }