📄 iqueue.h
字号:
inline void setTimestamp(uint32 ts) { shiftedTimestamp = ts;} // the packet this link refers to. IncomingRTPPkt* packet; // the synchronization source this packet comes from. SyncSourceLink* sourceLink; // global incoming packet queue links. IncomingRTPPktLink* prev, * next; // source specific incoming packet queue links. IncomingRTPPktLink* srcPrev, * srcNext; // time this packet was received at struct timeval receptionTime; // timestamp of the packet in host order and after // substracting the initial timestamp for its source // (it is an increment from the initial timestamp). uint32 shiftedTimestamp; }; /** * @struct SyncSourceLink * * @short Synchronization Source internal handler within the * incoming packets queue. * * Incoming packets queue objects hold a hash table and a * linked list of synchronization sources. For each of these * sources, there is also a linked list of incoming rtp * packets, which are linked in an "all incoming packets" list * as well. SyncSourceLink objects hold the necessary data to * maintain these data estructures, as well as source specific * information and statistics for RTCP, * * @author Federico Montesino Pouzols <fedemp@altern.org> **/ struct SyncSourceLink { // 2^16 static const uint32 SEQNUMMOD; SyncSourceLink(MembershipBookkeeping* m, SyncSource* s, IncomingRTPPktLink* fp = NULL, IncomingRTPPktLink* lp = NULL, SyncSourceLink* ps = NULL, SyncSourceLink* ns = NULL, SyncSourceLink* ncollis = NULL) : membership(m), source(s), first(fp), last(lp), prev(ps), next(ns), nextCollis(ncollis), prevConflict(NULL) { m->setLink(*s,this); // record that the source is associated initStats(); // to this link. } /** * Note it deletes the source. **/ ~SyncSourceLink(); inline MembershipBookkeeping* getMembership() { return membership; } /** * Get the synchronization source object this link * objet holds information for. **/ inline SyncSource* getSource() { return source; } /** * Get first RTP (data) packet in the queue of packets * received from this socket. **/ inline IncomingRTPPktLink* getFirst() { return first; } inline void setFirst(IncomingRTPPktLink* fp) { first = fp; } /** * Get last RTP (data) packet in the queue of packets * received from this socket. **/ inline IncomingRTPPktLink* getLast() { return last; } inline void setLast(IncomingRTPPktLink* lp) { last = lp; } /** * Get the link object for the previous RTP source. **/ inline SyncSourceLink* getPrev() { return prev; } inline void setPrev(SyncSourceLink* ps) { prev = ps; } /** * Get the link object for the next RTP source. **/ inline SyncSourceLink* getNext() { return next; } inline void setNext(SyncSourceLink *ns) { next = ns; } /** * Get the link object for the next RTP source in the * hash table entry collision list. Note that * collision does not refer to SSRC collision, but * hash table collision. **/ inline SyncSourceLink* getNextCollis() { return nextCollis; } inline void setNextCollis(SyncSourceLink* ns) { nextCollis = ns; } inline ConflictingTransportAddress* getPrevConflict() const { return prevConflict; } /** * Get conflicting address. **/ void setPrevConflict(InetAddress& addr, tpport_t dataPort, tpport_t controlPort); unsigned char* getSenderInfo() { return senderInfo; } void setSenderInfo(unsigned char* si); unsigned char* getReceiverInfo() { return receiverInfo; } void setReceiverInfo(unsigned char* ri); inline timeval getLastPacketTime() const { return lastPacketTime; } inline timeval getLastRTCPPacketTime() const { return lastRTCPPacketTime; } inline timeval getLastRTCPSRTime() const { return lastRTCPSRTime; } /** * Get the total number of RTP packets received from this * source. */ inline uint32 getObservedPacketCount() const { return obsPacketCount; } inline void incObservedPacketCount() { obsPacketCount++; } /** * Get the total number of payload octets received from this * source. **/ inline uint32 getObservedOctetCount() const { return obsOctetCount; } inline void incObservedOctetCount(uint32 n) { obsOctetCount += n; } /** * Get the highest valid sequence number received. **/ uint16 getMaxSeqNum() const { return maxSeqNum; } /** * Set the highest valid sequence number recived. * @param max Sequence number. **/ void setMaxSeqNum(uint16 max) { maxSeqNum = max; } inline uint32 getExtendedMaxSeqNum() const { return extendedMaxSeqNum; } inline void setExtendedMaxSeqNum(uint32 seq) { extendedMaxSeqNum = seq; } inline uint32 getCumulativePacketLost() const { return cumulativePacketLost; } inline void setCumulativePacketLost(uint32 pl) { cumulativePacketLost = pl; } inline uint8 getFractionLost() const { return fractionLost; } inline void setFractionLost(uint8 fl) { fractionLost = fl; } inline uint32 getLastPacketTransitTime() { return lastPacketTransitTime; } inline void setLastPacketTransitTime(uint32 time) { lastPacketTransitTime = time; } inline float getJitter() const { return jitter; } inline void setJitter(float j) { jitter = j; } inline uint32 getInitialDataTimestamp() const { return initialDataTimestamp; } inline void setInitialDataTimestamp(uint32 ts) { initialDataTimestamp = ts; } inline timeval getInitialDataTime() const { return initialDataTime; } inline void setInitialDataTime(timeval it) { initialDataTime = it; } /** * Mark this source as having sent a BYE control packet. * * @return whether some packet from this source had * been received before (getHello() has been called at * least once) **/ bool getGoodbye() { if(!flag) return false; flag = false; return true; } /** * Mark this source as having sent some packet. * * @return whether no packet from this source had been * received before **/ bool getHello() { if(flag) return false; flag = true; return true; } inline uint32 getBadSeqNum() const { return badSeqNum; } inline void setBadSeqNum(uint32 seq) { badSeqNum = seq; } uint8 getProbation() const { return probation; } inline void setProbation(uint8 p) { probation = p; } inline void decProbation() { --probation; } bool isValid() const { return 0 == probation; } inline uint16 getBaseSeqNum() const { return baseSeqNum; } inline uint32 getSeqNumAccum() const { return seqNumAccum; } inline void incSeqNumAccum() { seqNumAccum += SEQNUMMOD; } /** * Start a new sequence of received packets. **/ inline void initSequence(uint16 seqnum) { maxSeqNum = seqNumAccum = seqnum; } /** * Record the insertion of an RTP packet from this * source into the scheduled reception queue. All * received packets should be registered with * recordReception(), but only those actually inserted * into the queue should be registered via this * method. * * @param pl Link structure for packet inserted into the queue. **/ void recordInsertion(const IncomingRTPPktLink& pl); void initStats(); /** * Compute cumulative packet lost and fraction of * packets lost during the last reporting interval. **/ void computeStats(); MembershipBookkeeping* membership; // The source this link object refers to. SyncSource* source; // first/last packets from this source in the queue. IncomingRTPPktLink* first, * last; // Links for synchronization sources located before // and after this one in the list of sources. SyncSourceLink* prev, * next; // Prev and next inside the hash table collision list. SyncSourceLink* nextCollis; ConflictingTransportAddress* prevConflict; unsigned char* senderInfo; unsigned char* receiverInfo; // time the last RTP packet from this source was // received at. timeval lastPacketTime; // time the last RTCP packet was received. timeval lastRTCPPacketTime; // time the lasrt RTCP SR was received. Required for // DLSR computation. timeval lastRTCPSRTime; // for outgoing RR reports. // number of packets received from this source. uint32 obsPacketCount; // number of octets received from this source. uint32 obsOctetCount; // the higher sequence number seen from this source uint16 maxSeqNum; uint32 extendedMaxSeqNum; uint32 cumulativePacketLost; uint8 fractionLost; // for interarrivel jitter computation uint32 lastPacketTransitTime; // interarrival jitter of packets from this source. float jitter; uint32 initialDataTimestamp; timeval initialDataTime; // this flag assures we only call one gotHello and one // gotGoodbye for this src. bool flag; // for source validation: uint32 badSeqNum; uint8 probation; // packets in sequence before valid. uint16 baseSeqNum; uint32 expectedPrior; uint32 receivedPrior; uint32 seqNumAccum; }; /** * Returns whether there is already a synchronizacion source * with "ssrc" SSRC identifier. **/ bool isRegistered(uint32 ssrc); /** * Get the description of a source by its <code>ssrc</code> identifier. * * @param ssrc SSRC identifier, in host order. * @param created whether a new source has been created. * @return Pointer to the SyncSource object identified by * <code>ssrc</code>. */ SyncSourceLink* getSourceBySSRC(uint32 ssrc, bool& created); /** * Mark the source identified by <code>ssrc</code> as having * sent a BYE packet. It is not deleted until a timeout * expires, so that in case some packets from this source * arrive a bit later the source is not inserted again in the * table of known sources. * * @return true if the source had been previously identified. * false if it was not in the table of known sources. **/ bool BYESource(uint32 ssrc); /** * Remove the description of the source identified by * <code>ssrc</code> * * @return whether the source has been actually removed or it * did not exist. */ bool removeSource(uint32 ssrc); inline SyncSourceLink* getFirst() { return first; } inline SyncSourceLink* getLast() { return last; } inline uint32 getMembersCount() { return Members::getMembersCount(); } inline void setMembersCount(uint32 n) { Members::setMembersCount(n); } inline uint32 getSendersCount() { return Members::getSendersCount(); } static const size_t defaultMembersHashSize; static const uint32 SEQNUMMOD;private: MembershipBookkeeping(const MembershipBookkeeping &o); MembershipBookkeeping& operator=(const MembershipBookkeeping &o); /** * Purge all RTPSource structures, the hash table and the list * of sources. **/ void endMembers(); // Hash table with sources of RTP and RTCP packets uint32 sourceBucketsNum; SyncSourceLink** sourceLinks;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -