#include <RTCP.hh>
Inheritance diagram for RTCPInstance:


Public Member Functions | |
| unsigned | numMembers () const |
| void | setByeHandler (TaskFunc *handlerTask, void *clientData, Boolean handleActiveParticipantsOnly=True) |
| void | setSRHandler (TaskFunc *handlerTask, void *clientData) |
| void | setRRHandler (TaskFunc *handlerTask, void *clientData) |
| void | setSpecificRRHandler (netAddressBits fromAddress, Port fromPort, TaskFunc *handlerTask, void *clientData) |
| Groupsock * | RTCPgs () const |
| void | setStreamSocket (int sockNum, unsigned char streamChannelId) |
| void | addStreamSocket (int sockNum, unsigned char streamChannelId) |
| void | removeStreamSocket (int sockNum, unsigned char streamChannelId) |
| void | setAuxilliaryReadHandler (AuxHandlerFunc *handlerFunc, void *handlerClientData) |
| void | schedule (double nextTime) |
| void | reschedule (double nextTime) |
| void | sendReport () |
| void | sendBYE () |
| int | typeOfEvent () |
| int | sentPacketSize () |
| int | packetType () |
| int | receivedPacketSize () |
| int | checkNewSSRC () |
| void | removeLastReceivedSSRC () |
| void | removeSSRC (u_int32_t ssrc, Boolean alsoRemoveStats) |
| UsageEnvironment & | envir () const |
| char const * | name () const |
| virtual Boolean | isSource () const |
| virtual Boolean | isSink () const |
| virtual Boolean | isRTSPClient () const |
| virtual Boolean | isRTSPServer () const |
| virtual Boolean | isMediaSession () const |
| virtual Boolean | isServerMediaSession () const |
| virtual Boolean | isDarwinInjector () const |
Static Public Member Functions | |
| static RTCPInstance * | createNew (UsageEnvironment &env, Groupsock *RTCPgs, unsigned totSessionBW, unsigned char const *cname, RTPSink *sink, RTPSource const *source, Boolean isSSMSource=False) |
| static Boolean | lookupByName (UsageEnvironment &env, char const *instanceName, RTCPInstance *&resultInstance) |
| static Boolean | lookupByName (UsageEnvironment &env, char const *mediumName, Medium *&resultMedium) |
| static void | close (UsageEnvironment &env, char const *mediumName) |
| static void | close (Medium *medium) |
Protected Member Functions | |
| RTCPInstance (UsageEnvironment &env, Groupsock *RTPgs, unsigned totSessionBW, unsigned char const *cname, RTPSink *sink, RTPSource const *source, Boolean isSSMSource) | |
| virtual | ~RTCPInstance () |
| TaskToken & | nextTask () |
Private Member Functions | |
| virtual Boolean | isRTCPInstance () const |
| void | addReport () |
| void | addSR () |
| void | addRR () |
| void | enqueueCommonReportPrefix (unsigned char packetType, u_int32_t SSRC, unsigned numExtraWords=0) |
| void | enqueueCommonReportSuffix () |
| void | enqueueReportBlock (RTPReceptionStats *receptionStats) |
| void | addSDES () |
| void | addBYE () |
| void | sendBuiltPacket () |
| void | onExpire1 () |
| void | incomingReportHandler1 () |
| void | onReceive (int typeOfPacket, int totPacketSize, u_int32_t ssrc) |
| void | unsetSpecificRRHandler (netAddressBits fromAddress, Port fromPort) |
Static Private Member Functions | |
| static void | onExpire (RTCPInstance *instance) |
| static void | incomingReportHandler (RTCPInstance *instance, int) |
Private Attributes | |
| unsigned char * | fInBuf |
| OutPacketBuffer * | fOutBuf |
| RTPInterface | fRTCPInterface |
| unsigned | fTotSessionBW |
| RTPSink * | fSink |
| RTPSource const * | fSource |
| Boolean | fIsSSMSource |
| SDESItem | fCNAME |
| RTCPMemberDatabase * | fKnownMembers |
| unsigned | fOutgoingReportCount |
| double | fAveRTCPSize |
| int | fIsInitial |
| double | fPrevReportTime |
| double | fNextReportTime |
| int | fPrevNumMembers |
| int | fLastSentSize |
| int | fLastReceivedSize |
| u_int32_t | fLastReceivedSSRC |
| int | fTypeOfEvent |
| int | fTypeOfPacket |
| Boolean | fHaveJustSentPacket |
| unsigned | fLastPacketSentSize |
| TaskFunc * | fByeHandlerTask |
| void * | fByeHandlerClientData |
| Boolean | fByeHandleActiveParticipantsOnly |
| TaskFunc * | fSRHandlerTask |
| void * | fSRHandlerClientData |
| TaskFunc * | fRRHandlerTask |
| void * | fRRHandlerClientData |
| AddressPortLookupTable * | fSpecificRRHandlerTable |
Definition at line 44 of file RTCP.hh.
| RTCPInstance::RTCPInstance | ( | UsageEnvironment & | env, | |
| Groupsock * | RTPgs, | |||
| unsigned | totSessionBW, | |||
| unsigned char const * | cname, | |||
| RTPSink * | sink, | |||
| RTPSource const * | source, | |||
| Boolean | isSSMSource | |||
| ) | [protected] |
Definition at line 120 of file RTCP.cpp.
References dTimeNow(), env, EVENT_REPORT, fInBuf, fKnownMembers, fNextReportTime, fOutBuf, fPrevReportTime, fRTCPInterface, fTotSessionBW, fTypeOfEvent, incomingReportHandler(), maxPacketSize, OutPacketBuffer::maxSize, Groupsock::multicastSendOnly(), NULL, onExpire(), preferredPacketSize, RTCPgs(), and RTPInterface::startNetworkReading().
Referenced by createNew().
00125 : Medium(env), fRTCPInterface(this, RTCPgs), fTotSessionBW(totSessionBW), 00126 fSink(sink), fSource(source), fIsSSMSource(isSSMSource), 00127 fCNAME(RTCP_SDES_CNAME, cname), fOutgoingReportCount(1), 00128 fAveRTCPSize(0), fIsInitial(1), fPrevNumMembers(0), 00129 fLastSentSize(0), fLastReceivedSize(0), fLastReceivedSSRC(0), 00130 fTypeOfEvent(EVENT_UNKNOWN), fTypeOfPacket(PACKET_UNKNOWN_TYPE), 00131 fHaveJustSentPacket(False), fLastPacketSentSize(0), 00132 fByeHandlerTask(NULL), fByeHandlerClientData(NULL), 00133 fSRHandlerTask(NULL), fSRHandlerClientData(NULL), 00134 fRRHandlerTask(NULL), fRRHandlerClientData(NULL), 00135 fSpecificRRHandlerTable(NULL) { 00136 #ifdef DEBUG 00137 fprintf(stderr, "RTCPInstance[%p]::RTCPInstance()\n", this); 00138 #endif 00139 if (fTotSessionBW == 0) { // not allowed! 00140 env << "RTCPInstance::RTCPInstance error: totSessionBW parameter should not be zero!\n"; 00141 fTotSessionBW = 1; 00142 } 00143 00144 if (isSSMSource) RTCPgs->multicastSendOnly(); // don't receive multicast 00145 00146 double timeNow = dTimeNow(); 00147 fPrevReportTime = fNextReportTime = timeNow; 00148 00149 fKnownMembers = new RTCPMemberDatabase(*this); 00150 fInBuf = new unsigned char[maxPacketSize]; 00151 if (fKnownMembers == NULL || fInBuf == NULL) return; 00152 00153 // A hack to save buffer space, because RTCP packets are always small: 00154 unsigned savedMaxSize = OutPacketBuffer::maxSize; 00155 OutPacketBuffer::maxSize = maxPacketSize; 00156 fOutBuf = new OutPacketBuffer(preferredPacketSize, maxPacketSize); 00157 OutPacketBuffer::maxSize = savedMaxSize; 00158 if (fOutBuf == NULL) return; 00159 00160 // Arrange to handle incoming reports from others: 00161 TaskScheduler::BackgroundHandlerProc* handler 00162 = (TaskScheduler::BackgroundHandlerProc*)&incomingReportHandler; 00163 fRTCPInterface.startNetworkReading(handler); 00164 00165 // Send our first report. 00166 fTypeOfEvent = EVENT_REPORT; 00167 onExpire(this); 00168 }
| RTCPInstance::~RTCPInstance | ( | ) | [protected, virtual] |
Definition at line 175 of file RTCP.cpp.
References EVENT_BYE, fInBuf, fKnownMembers, fOutBuf, fRTCPInterface, fSpecificRRHandlerTable, fTypeOfEvent, iter, MediaSubsessionIterator::next(), NULL, sendBYE(), and RTPInterface::stopNetworkReading().
00175 { 00176 #ifdef DEBUG 00177 fprintf(stderr, "RTCPInstance[%p]::~RTCPInstance()\n", this); 00178 #endif 00179 // Turn off background read handling: 00180 fRTCPInterface.stopNetworkReading(); 00181 00182 // Begin by sending a BYE. We have to do this immediately, without 00183 // 'reconsideration', because "this" is going away. 00184 fTypeOfEvent = EVENT_BYE; // not used, but... 00185 sendBYE(); 00186 00187 if (fSpecificRRHandlerTable != NULL) { 00188 AddressPortLookupTable::Iterator iter(*fSpecificRRHandlerTable); 00189 RRHandlerRecord* rrHandler; 00190 while ((rrHandler = (RRHandlerRecord*)iter.next()) != NULL) { 00191 delete rrHandler; 00192 } 00193 delete fSpecificRRHandlerTable; 00194 } 00195 00196 delete fKnownMembers; 00197 delete fOutBuf; 00198 delete[] fInBuf; 00199 }
| RTCPInstance * RTCPInstance::createNew | ( | UsageEnvironment & | env, | |
| Groupsock * | RTCPgs, | |||
| unsigned | totSessionBW, | |||
| unsigned char const * | cname, | |||
| RTPSink * | sink, | |||
| RTPSource const * | source, | |||
| Boolean | isSSMSource = False | |||
| ) | [static] |
Definition at line 201 of file RTCP.cpp.
References env, RTCPgs(), and RTCPInstance().
Referenced by MediaSubsession::initiate(), main(), and StreamState::startPlaying().
00205 { 00206 return new RTCPInstance(env, RTCPgs, totSessionBW, cname, sink, source, 00207 isSSMSource); 00208 }
| Boolean RTCPInstance::lookupByName | ( | UsageEnvironment & | env, | |
| char const * | instanceName, | |||
| RTCPInstance *& | resultInstance | |||
| ) | [static] |
Definition at line 210 of file RTCP.cpp.
References env, False, Medium::isRTCPInstance(), Medium::lookupByName(), NULL, and True.
00212 { 00213 resultInstance = NULL; // unless we succeed 00214 00215 Medium* medium; 00216 if (!Medium::lookupByName(env, instanceName, medium)) return False; 00217 00218 if (!medium->isRTCPInstance()) { 00219 env.setResultMsg(instanceName, " is not a RTCP instance"); 00220 return False; 00221 } 00222 00223 resultInstance = (RTCPInstance*)medium; 00224 return True; 00225 }
| unsigned RTCPInstance::numMembers | ( | ) | const |
Definition at line 231 of file RTCP.cpp.
References fKnownMembers, NULL, and RTCPMemberDatabase::numMembers().
Referenced by onExpire1().
00231 { 00232 if (fKnownMembers == NULL) return 0; 00233 00234 return fKnownMembers->numMembers(); 00235 }
| void RTCPInstance::setByeHandler | ( | TaskFunc * | handlerTask, | |
| void * | clientData, | |||
| Boolean | handleActiveParticipantsOnly = True | |||
| ) |
Definition at line 237 of file RTCP.cpp.
References fByeHandleActiveParticipantsOnly, fByeHandlerClientData, and fByeHandlerTask.
Referenced by AVIFileSink::AVIFileSink(), main(), and QuickTimeFileSink::QuickTimeFileSink().
00238 { 00239 fByeHandlerTask = handlerTask; 00240 fByeHandlerClientData = clientData; 00241 fByeHandleActiveParticipantsOnly = handleActiveParticipantsOnly; 00242 }
| void RTCPInstance::setSRHandler | ( | TaskFunc * | handlerTask, | |
| void * | clientData | |||
| ) |
Definition at line 244 of file RTCP.cpp.
References fSRHandlerClientData, and fSRHandlerTask.
00244 { 00245 fSRHandlerTask = handlerTask; 00246 fSRHandlerClientData = clientData; 00247 }
| void RTCPInstance::setRRHandler | ( | TaskFunc * | handlerTask, | |
| void * | clientData | |||
| ) |
Definition at line 249 of file RTCP.cpp.
References fRRHandlerClientData, and fRRHandlerTask.
00249 { 00250 fRRHandlerTask = handlerTask; 00251 fRRHandlerClientData = clientData; 00252 }
| void RTCPInstance::setSpecificRRHandler | ( | netAddressBits | fromAddress, | |
| Port | fromPort, | |||
| TaskFunc * | handlerTask, | |||
| void * | clientData | |||
| ) |
Definition at line 255 of file RTCP.cpp.
References AddressPortLookupTable::Add(), fSpecificRRHandlerTable, NULL, RRHandlerRecord::rrHandlerClientData, RRHandlerRecord::rrHandlerTask, and unsetSpecificRRHandler().
Referenced by StreamState::endPlaying(), and StreamState::startPlaying().
00256 { 00257 if (handlerTask == NULL && clientData == NULL) { 00258 unsetSpecificRRHandler(fromAddress, fromPort); 00259 return; 00260 } 00261 00262 RRHandlerRecord* rrHandler = new RRHandlerRecord; 00263 rrHandler->rrHandlerTask = handlerTask; 00264 rrHandler->rrHandlerClientData = clientData; 00265 if (fSpecificRRHandlerTable == NULL) { 00266 fSpecificRRHandlerTable = new AddressPortLookupTable; 00267 } 00268 fSpecificRRHandlerTable->Add(fromAddress, (~0), fromPort, rrHandler); 00269 }
| Groupsock* RTCPInstance::RTCPgs | ( | ) | const [inline] |
Definition at line 82 of file RTCP.hh.
References fRTCPInterface, and RTPInterface::gs().
Referenced by createNew(), PassiveServerMediaSubsession::getStreamParameters(), incomingReportHandler1(), and RTCPInstance().
00082 { return fRTCPInterface.gs(); }
| void RTCPInstance::setStreamSocket | ( | int | sockNum, | |
| unsigned char | streamChannelId | |||
| ) |
Definition at line 283 of file RTCP.cpp.
References fRTCPInterface, incomingReportHandler(), RTPInterface::setStreamSocket(), RTPInterface::startNetworkReading(), and RTPInterface::stopNetworkReading().
Referenced by DarwinInjector::setDestination(), and RTSPClient::setupMediaSubsession().
00284 { 00285 // Turn off background read handling: 00286 fRTCPInterface.stopNetworkReading(); 00287 00288 // Switch to RTCP-over-TCP: 00289 fRTCPInterface.setStreamSocket(sockNum, streamChannelId); 00290 00291 // Turn background reading back on: 00292 TaskScheduler::BackgroundHandlerProc* handler 00293 = (TaskScheduler::BackgroundHandlerProc*)&incomingReportHandler; 00294 fRTCPInterface.startNetworkReading(handler); 00295 }
| void RTCPInstance::addStreamSocket | ( | int | sockNum, | |
| unsigned char | streamChannelId | |||
| ) |
Definition at line 297 of file RTCP.cpp.
References fRTCPInterface, incomingReportHandler(), RTPInterface::setStreamSocket(), RTPInterface::startNetworkReading(), and RTPInterface::stopNetworkReading().
Referenced by StreamState::startPlaying().
00298 { 00299 // First, turn off background read handling for the default (UDP) socket: 00300 fRTCPInterface.stopNetworkReading(); 00301 00302 // Add the RTCP-over-TCP interface: 00303 fRTCPInterface.setStreamSocket(sockNum, streamChannelId); 00304 00305 // Turn on background reading for this socket (in case it's not on already): 00306 TaskScheduler::BackgroundHandlerProc* handler 00307 = (TaskScheduler::BackgroundHandlerProc*)&incomingReportHandler; 00308 fRTCPInterface.startNetworkReading(handler); 00309 }
| void RTCPInstance::removeStreamSocket | ( | int | sockNum, | |
| unsigned char | streamChannelId | |||
| ) | [inline] |
Definition at line 86 of file RTCP.hh.
References fRTCPInterface, and RTPInterface::removeStreamSocket().
Referenced by StreamState::endPlaying().
00086 { 00087 fRTCPInterface.removeStreamSocket(sockNum, streamChannelId); 00088 }
| void RTCPInstance::setAuxilliaryReadHandler | ( | AuxHandlerFunc * | handlerFunc, | |
| void * | handlerClientData | |||
| ) | [inline] |
Definition at line 91 of file RTCP.hh.
References fRTCPInterface, and RTPInterface::setAuxilliaryReadHandler().
00092 { 00093 fRTCPInterface.setAuxilliaryReadHandler(handlerFunc, 00094 handlerClientData); 00095 }
| Boolean RTCPInstance::isRTCPInstance | ( | ) | const [private, virtual] |
| void RTCPInstance::addReport | ( | ) | [private] |
Definition at line 669 of file RTCP.cpp.
References addRR(), addSR(), fSink, fSource, and NULL.
Referenced by sendBYE(), and sendReport().
00669 { 00670 // Include a SR or a RR, depending on whether we 00671 // have an associated sink or source: 00672 if (fSink != NULL) { 00673 addSR(); 00674 } else if (fSource != NULL) { 00675 addRR(); 00676 } 00677 }
| void RTCPInstance::addSR | ( | ) | [private] |
Definition at line 679 of file RTCP.cpp.
References RTPSink::convertToRTPTimestamp(), enqueueCommonReportPrefix(), enqueueCommonReportSuffix(), OutPacketBuffer::enqueueWord(), fOutBuf, fSink, NULL, RTPSink::octetCount(), RTPSink::packetCount(), RTCP_PT_SR, and RTPSink::SSRC().
Referenced by addReport().
00679 { 00680 // ASSERT: fSink != NULL 00681 00682 enqueueCommonReportPrefix(RTCP_PT_SR, fSink->SSRC(), 00683 5 /* extra words in a SR */); 00684 00685 // Now, add the 'sender info' for our sink 00686 00687 // Insert the NTP and RTP timestamps for the 'wallclock time': 00688 struct timeval timeNow; 00689 gettimeofday(&timeNow, NULL); 00690 fOutBuf->enqueueWord(timeNow.tv_sec + 0x83AA7E80); 00691 // NTP timestamp most-significant word (1970 epoch -> 1900 epoch) 00692 double fractionalPart = (timeNow.tv_usec/15625.0)*0x04000000; // 2^32/10^6 00693 fOutBuf->enqueueWord((unsigned)(fractionalPart+0.5)); 00694 // NTP timestamp least-significant word 00695 unsigned rtpTimestamp = fSink->convertToRTPTimestamp(timeNow); 00696 fOutBuf->enqueueWord(rtpTimestamp); // RTP ts 00697 00698 // Insert the packet and byte counts: 00699 fOutBuf->enqueueWord(fSink->packetCount()); 00700 fOutBuf->enqueueWord(fSink->octetCount()); 00701 00702 enqueueCommonReportSuffix(); 00703 }
| void RTCPInstance::addRR | ( | ) | [private] |
Definition at line 705 of file RTCP.cpp.
References enqueueCommonReportPrefix(), enqueueCommonReportSuffix(), fSource, RTCP_PT_RR, and RTPSource::SSRC().
Referenced by addReport().
00705 { 00706 // ASSERT: fSource != NULL 00707 00708 enqueueCommonReportPrefix(RTCP_PT_RR, fSource->SSRC()); 00709 enqueueCommonReportSuffix(); 00710 }
| void RTCPInstance::enqueueCommonReportPrefix | ( | unsigned char | packetType, | |
| u_int32_t | SSRC, | |||
| unsigned | numExtraWords = 0 | |||
| ) | [private] |
| void RTCPInstance::enqueueCommonReportSuffix | ( | ) | [private] |
Definition at line 737 of file RTCP.cpp.
References enqueueReportBlock(), fSource, RTPReceptionStatsDB::Iterator::next(), NULL, RTPSource::receptionStatsDB(), and RTPReceptionStatsDB::reset().
Referenced by addRR(), and addSR().
00737 { 00738 // Output the report blocks for each source: 00739 if (fSource != NULL) { 00740 RTPReceptionStatsDB& allReceptionStats 00741 = fSource->receptionStatsDB(); 00742 00743 RTPReceptionStatsDB::Iterator iterator(allReceptionStats); 00744 while (1) { 00745 RTPReceptionStats* receptionStats = iterator.next(); 00746 if (receptionStats == NULL) break; 00747 enqueueReportBlock(receptionStats); 00748 } 00749 00750 allReceptionStats.reset(); // because we have just generated a report 00751 } 00752 }
| void RTCPInstance::enqueueReportBlock | ( | RTPReceptionStats * | receptionStats | ) | [private] |
Definition at line 755 of file RTCP.cpp.
References RTPReceptionStats::baseExtSeqNumReceived(), OutPacketBuffer::enqueueWord(), fOutBuf, RTPReceptionStats::highestExtSeqNumReceived(), RTPReceptionStats::jitter(), RTPReceptionStats::lastReceivedSR_NTPlsw(), RTPReceptionStats::lastReceivedSR_NTPmsw(), RTPReceptionStats::lastReceivedSR_time(), RTPReceptionStats::lastResetExtSeqNumReceived(), NULL, RTPReceptionStats::numPacketsReceivedSinceLastReset(), RTPReceptionStats::SSRC(), and RTPReceptionStats::totNumPacketsReceived().
Referenced by enqueueCommonReportSuffix().
00755 { 00756 fOutBuf->enqueueWord(stats->SSRC()); 00757 00758 unsigned highestExtSeqNumReceived = stats->highestExtSeqNumReceived(); 00759 00760 unsigned totNumExpected 00761 = highestExtSeqNumReceived - stats->baseExtSeqNumReceived(); 00762 int totNumLost = totNumExpected - stats->totNumPacketsReceived(); 00763 // 'Clamp' this loss number to a 24-bit signed value: 00764 if (totNumLost > 0x007FFFFF) { 00765 totNumLost = 0x007FFFFF; 00766 } else if (totNumLost < 0) { 00767 if (totNumLost < -0x00800000) totNumLost = 0x00800000; // unlikely, but... 00768 totNumLost &= 0x00FFFFFF; 00769 } 00770 00771 unsigned numExpectedSinceLastReset 00772 = highestExtSeqNumReceived - stats->lastResetExtSeqNumReceived(); 00773 int numLostSinceLastReset 00774 = numExpectedSinceLastReset - stats->numPacketsReceivedSinceLastReset(); 00775 unsigned char lossFraction; 00776 if (numExpectedSinceLastReset == 0 || numLostSinceLastReset < 0) { 00777 lossFraction = 0; 00778 } else { 00779 lossFraction = (unsigned char) 00780 ((numLostSinceLastReset << 8) / numExpectedSinceLastReset); 00781 } 00782 00783 fOutBuf->enqueueWord((lossFraction<<24) | totNumLost); 00784 fOutBuf->enqueueWord(highestExtSeqNumReceived); 00785 00786 fOutBuf->enqueueWord(stats->jitter()); 00787 00788 unsigned NTPmsw = stats->lastReceivedSR_NTPmsw(); 00789 unsigned NTPlsw = stats->lastReceivedSR_NTPlsw(); 00790 unsigned LSR = ((NTPmsw&0xFFFF)<<16)|(NTPlsw>>16); // middle 32 bits 00791 fOutBuf->enqueueWord(LSR); 00792 00793 // Figure out how long has elapsed since the last SR rcvd from this src: 00794 struct timeval const& LSRtime = stats->lastReceivedSR_time(); // "last SR" 00795 struct timeval timeNow, timeSinceLSR; 00796 gettimeofday(&timeNow, NULL); 00797 if (timeNow.tv_usec < LSRtime.tv_usec) { 00798 timeNow.tv_usec += 1000000; 00799 timeNow.tv_sec -= 1; 00800 } 00801 timeSinceLSR.tv_sec = timeNow.tv_sec - LSRtime.tv_sec; 00802 timeSinceLSR.tv_usec = timeNow.tv_usec - LSRtime.tv_usec; 00803 // The enqueued time is in units of 1/65536 seconds. 00804 // (Note that 65536/1000000 == 1024/15625) 00805 unsigned DLSR; 00806 if (LSR == 0) { 00807 DLSR = 0; 00808 } else { 00809 DLSR = (timeSinceLSR.tv_sec<<16) 00810 | ( (((timeSinceLSR.tv_usec<<11)+15625)/31250) & 0xFFFF); 00811 } 00812 fOutBuf->enqueueWord(DLSR); 00813 }
| void RTCPInstance::addSDES | ( | ) | [private] |
Definition at line 815 of file RTCP.cpp.
References OutPacketBuffer::curPacketSize(), SDESItem::data(), OutPacketBuffer::enqueue(), OutPacketBuffer::enqueueWord(), fCNAME, fOutBuf, fSink, fSource, NULL, RTCP_PT_SDES, RTPSink::SSRC(), RTPSource::SSRC(), and SDESItem::totalSize().
Referenced by sendReport().
00815 { 00816 // For now we support only the CNAME item; later support more ##### 00817 00818 // Begin by figuring out the size of the entire SDES report: 00819 unsigned numBytes = 4; 00820 // counts the SSRC, but not the header; it'll get subtracted out 00821 numBytes += fCNAME.totalSize(); // includes id and length 00822 numBytes += 1; // the special END item 00823 00824 unsigned num4ByteWords = (numBytes + 3)/4; 00825 00826 unsigned rtcpHdr = 0x81000000; // version 2, no padding, 1 SSRC chunk 00827 rtcpHdr |= (RTCP_PT_SDES<<16); 00828 rtcpHdr |= num4ByteWords; 00829 fOutBuf->enqueueWord(rtcpHdr); 00830 00831 if (fSource != NULL) { 00832 fOutBuf->enqueueWord(fSource->SSRC()); 00833 } else if (fSink != NULL) { 00834 fOutBuf->enqueueWord(fSink->SSRC()); 00835 } 00836 00837 // Add the CNAME: 00838 fOutBuf->enqueue(fCNAME.data(), fCNAME.totalSize()); 00839 00840 // Add the 'END' item (i.e., a zero byte), plus any more needed to pad: 00841 unsigned numPaddingBytesNeeded = 4 - (fOutBuf->curPacketSize() % 4); 00842 unsigned char const zero = '\0'; 00843 while (numPaddingBytesNeeded-- > 0) fOutBuf->enqueue(&zero, 1); 00844 }
| void RTCPInstance::addBYE | ( | ) | [private] |
Definition at line 846 of file RTCP.cpp.
References OutPacketBuffer::enqueueWord(), fOutBuf, fSink, fSource, NULL, RTCP_PT_BYE, RTPSink::SSRC(), and RTPSource::SSRC().
Referenced by sendBYE().
00846 { 00847 unsigned rtcpHdr = 0x81000000; // version 2, no padding, 1 SSRC 00848 rtcpHdr |= (RTCP_PT_BYE<<16); 00849 rtcpHdr |= 1; // 2 32-bit words total (i.e., with 1 SSRC) 00850 fOutBuf->enqueueWord(rtcpHdr); 00851 00852 if (fSource != NULL) { 00853 fOutBuf->enqueueWord(fSource->SSRC()); 00854 } else if (fSink != NULL) { 00855 fOutBuf->enqueueWord(fSink->SSRC()); 00856 } 00857 }
| void RTCPInstance::sendBuiltPacket | ( | ) | [private] |
Definition at line 625 of file RTCP.cpp.
References OutPacketBuffer::curPacketSize(), fHaveJustSentPacket, fLastPacketSentSize, fLastSentSize, fOutBuf, fRTCPInterface, IP_UDP_HDR_SIZE, OutPacketBuffer::packet(), OutPacketBuffer::resetOffset(), RTPInterface::sendPacket(), and True.
Referenced by sendBYE(), and sendReport().
00625 { 00626 #ifdef DEBUG 00627 fprintf(stderr, "sending RTCP packet\n"); 00628 unsigned char* p = fOutBuf->packet(); 00629 for (unsigned i = 0; i < fOutBuf->curPacketSize(); ++i) { 00630 if (i%4 == 0) fprintf(stderr," "); 00631 fprintf(stderr, "%02x", p[i]); 00632 } 00633 fprintf(stderr, "\n"); 00634 #endif 00635 unsigned reportSize = fOutBuf->curPacketSize(); 00636 fRTCPInterface.sendPacket(fOutBuf->packet(), reportSize); 00637 fOutBuf->resetOffset(); 00638 00639 fLastSentSize = IP_UDP_HDR_SIZE + reportSize; 00640 fHaveJustSentPacket = True; 00641 fLastPacketSentSize = reportSize; 00642 }
| void RTCPInstance::onExpire | ( | RTCPInstance * | instance | ) | [static, private] |
Definition at line 663 of file RTCP.cpp.
References onExpire1().
Referenced by RTCPInstance(), and schedule().
00663 { 00664 instance->onExpire1(); 00665 }
| void RTCPInstance::onExpire1 | ( | ) | [private] |
Definition at line 876 of file RTCP.cpp.
References dTimeNow(), fAveRTCPSize, fIsInitial, fPrevNumMembers, fPrevReportTime, fSink, fTotSessionBW, NULL, numMembers(), and OnExpire().
Referenced by onExpire().
00876 { 00877 // Note: fTotSessionBW is kbits per second 00878 double rtcpBW = 0.05*fTotSessionBW*1024/8; // -> bytes per second 00879 00880 OnExpire(this, // event 00881 numMembers(), // members 00882 (fSink != NULL) ? 1 : 0, // senders 00883 rtcpBW, // rtcp_bw 00884 (fSink != NULL) ? 1 : 0, // we_sent 00885 &