⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 iqueue.h

📁 ccrtp, ccrtp-1.5.0.tar.gz
💻 H
📖 第 1 页 / 共 3 页
字号:
// Copyright (C) 2001,2002,2004 Federico Montesino Pouzols <fedemp@altern.org>.//// This program is free software; you can redistribute it and/or modify// it under the terms of the GNU General Public License as published by// the Free Software Foundation; either version 2 of the License, or// (at your option) any later version.//// This program is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the// GNU General Public License for more details.//// You should have received a copy of the GNU General Public License// along with this program; if not, write to the Free Software// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.//// As a special exception, you may use this file as part of a free software// library without restriction.  Specifically, if other files instantiate// templates or use macros or inline functions from this file, or you compile// this file and link it with other files to produce an executable, this// file does not by itself cause the resulting executable to be covered by// the GNU General Public License.  This exception does not however// invalidate any other reasons why the executable file might be covered by// the GNU General Public License.//// This exception applies only to the code released under the name GNU// ccRTP.  If you copy code from other releases into a copy of GNU// ccRTP, as the General Public License permits, the exception does// not apply to the code that you add in this way.  To avoid misleading// anyone as to the status of such modified files, you must delete// this exception notice from them.//// If you write modifications of your own for GNU ccRTP, it is your choice// whether to permit this exception to apply to your modifications.// If you do not wish that, delete this exception notice.///** * @file iqueue.h * * @short Generic RTP input queues. **/#ifndef	CCXX_RTP_IQUEUE_H_#define CCXX_RTP_IQUEUE_H_#include <ccrtp/queuebase.h>#include <ccrtp/CryptoContext.h>#include <list>#ifdef	CCXX_NAMESPACESnamespace ost {#endif/** * @defgroup iqueue Generic RTP input queues. * @{ **//** * @class Members rtp.h * @short members and senders accounting * * Records the number of members as well as active senders. For now, * it is too simple. * * @author Federico Montesino Pouzols <fedemp@altern.org> **/class __EXPORT Members{public:	inline void	setMembersCount(uint32 n)	{ members = n; }	inline void	increaseMembersCount()	{ members++; }	inline void	decreaseMembersCount()	{ members--; }	inline uint32	getMembersCount() const	{ return members; }	inline void	setSendersCount(uint32 n)	{ activeSenders = n; }	inline void	increaseSendersCount()	{ activeSenders++; }	inline void	decreaseSendersCount()	{ activeSenders--; }	inline uint32	getSendersCount() const	{ return activeSenders; }protected:	Members() :		members(0),		activeSenders(0)	{ }	inline virtual ~Members()	{ }private:	/// number of identified members	uint32 members;	/// number of identified members that currently are active senders	uint32 activeSenders;};/** * @class SyncSourceHandler * @short SyncSource objects modification methods. * * @author Federico Montesino Pouzols <fedemp@altern.org> **/class __EXPORT SyncSourceHandler{public:	/**	 * This requires SyncSource - SyncSourceHandler friendship.	 *	 * Get the SyncSourceLink corresponding to a SyncSource	 * object.	 **/	inline void*	getLink(const SyncSource& source) const	{ return source.getLink(); }	inline void	setLink(SyncSource& source, void* link)	{ source.setLink(link); }	inline void	setParticipant(SyncSource& source, Participant& p)	{ source.setParticipant(p); }	inline void	setState(SyncSource& source, SyncSource::State ns)	{ source.setState(ns); }	inline void	setSender(SyncSource& source, bool active)	{ source.setSender(active); }	inline void	setDataTransportPort(SyncSource& source, tpport_t p)	{ source.setDataTransportPort(p); }	inline void	setControlTransportPort(SyncSource& source, tpport_t p)	{ source.setControlTransportPort(p); }	inline void	setNetworkAddress(SyncSource& source, InetAddress addr)	{ source.setNetworkAddress(addr); }protected:	SyncSourceHandler()	{ }	inline virtual ~SyncSourceHandler()	{ }};/** * @class ParticipantHandler * @short Participant objects modification methods. * * @author Federico Montesino Pouzols <fedemp@altern.org> **/class __EXPORT ParticipantHandler{public:	inline void	setSDESItem(Participant* part, SDESItemType item,		    const std::string& val)	{ part->setSDESItem(item,val); }	inline void	setPRIVPrefix(Participant* part, const std::string val)	{ part->setPRIVPrefix(val); }protected:	ParticipantHandler()	{ }	inline virtual ~ParticipantHandler()	{ }};/** * @class ApplicationHandler * @short Application objects modification methods. * * @author Federico Montesino Pouzols <fedemp@altern.org> **/class __EXPORT ApplicationHandler{public:	inline void	addParticipant(RTPApplication& app, Participant& part)	{ app.addParticipant(part); }	inline void	removeParticipant(RTPApplication& app,			  RTPApplication::ParticipantLink* pl)	{ app.removeParticipant(pl); }protected:	ApplicationHandler()	{ }	inline virtual ~ApplicationHandler()	{ }};/** * @class ConflictHandler * @short To track addresses of sources conflicting with the local * one. * * @author Federico Montesino Pouzols <fedemp@altern.org> **/class __EXPORT ConflictHandler{public:	struct ConflictingTransportAddress	{		ConflictingTransportAddress(InetAddress na,					    tpport_t dtp, tpport_t ctp);		void setNext(ConflictingTransportAddress* nc)		{ next = nc; }		inline const InetAddress& getNetworkAddress( ) const		{ return networkAddress; }		inline tpport_t getDataTransportPort() const		{ return dataTransportPort; }		inline tpport_t getControlTransportPort() const		{ return controlTransportPort; }		InetAddress networkAddress;		tpport_t dataTransportPort;		tpport_t controlTransportPort;		ConflictingTransportAddress* next;		// arrival time of last data or control packet.		timeval lastPacketTime;	};	/**	 * @param na Inet network address.	 * @param dtp Data transport port.	 **/	ConflictingTransportAddress* searchDataConflict(InetAddress na,							tpport_t dtp);	/**	 * @param na Inet network address.	 * @param ctp Data transport port.	 **/	ConflictingTransportAddress* searchControlConflict(InetAddress na,							   tpport_t ctp);	void updateConflict(ConflictingTransportAddress& ca)	{ gettimeofday(&(ca.lastPacketTime),NULL); }	void addConflict(const InetAddress& na, tpport_t dtp, tpport_t ctp);protected:	ConflictHandler()	{ firstConflict = lastConflict = NULL; }	inline virtual ~ConflictHandler()	{ }	ConflictingTransportAddress* firstConflict, * lastConflict;};/** * @class MembershipBookkeeping * @short Controls the group membership in the current session. * * For now, this class implements only a hash table of members, but * its design and relation with other classes is intented to support * group membership sampling in case scalability problems arise. * * @author Federico Montesino Pouzols <fedemp@altern.org> */class __EXPORT MembershipBookkeeping :	public SyncSourceHandler,	public ParticipantHandler,	public ApplicationHandler,	public ConflictHandler,	private Members{public:	inline size_t getDefaultMembersHashSize()	{ return defaultMembersHashSize; }protected:	/**	 * @short The initial size is a hint to allocate the resources	 * needed in order to keep the members' identifiers and	 * associated information.	 *	 * Although ccRTP will reallocate resources when it becomes	 * necessary, a good hint may save a lot of unpredictable time	 * penalties.	 *	 * @param initialSize an estimation of how many participants	 * the session will consist of.	 *	 */	MembershipBookkeeping(uint32 initialSize = defaultMembersHashSize);	/**	 * Purges all RTPSource structures created during the session,	 * as well as the hash table and the list of sources.	 **/	inline virtual	~MembershipBookkeeping()	{ endMembers(); }	struct SyncSourceLink;	inline SyncSourceLink* getLink(const SyncSource& source) const	{ return static_cast<SyncSourceLink*>(SyncSourceHandler::getLink(source)); }	/**	 * Get whether a synchronization source is recorded in this	 * membership controller.	 **/	inline bool isMine(const SyncSource& source) const	{ return getLink(source)->getMembership() == this; }	/**	 * @struct IncomingRTPPktLink	 *	 * @short Incoming RTP data packets control structure within	 * the incoming packet queue class.	 **/	struct IncomingRTPPktLink	{		IncomingRTPPktLink(IncomingRTPPkt* pkt, SyncSourceLink* sLink,				   struct timeval& recv_ts,				   uint32 shifted_ts,				   IncomingRTPPktLink* sp,				   IncomingRTPPktLink* sn,				   IncomingRTPPktLink* p,				   IncomingRTPPktLink* n) :			packet(pkt),			sourceLink(sLink),			prev(p), next(n),			srcPrev(sp), srcNext(sn),			receptionTime(recv_ts),			shiftedTimestamp(shifted_ts)		{ }		~IncomingRTPPktLink()		{ }		inline SyncSourceLink* getSourceLink() const		{ return sourceLink; }		inline void setSourceLink(SyncSourceLink* src)		{ sourceLink = src; }		inline IncomingRTPPktLink* getNext() const		{ return next; }		inline void setNext(IncomingRTPPktLink* nl)		{ next = nl; }		inline IncomingRTPPktLink* getPrev() const		{ return prev; }		inline void setPrev(IncomingRTPPktLink* pl)		{ prev = pl; }		inline IncomingRTPPktLink* getSrcNext() const		{ return srcNext; }		inline void setSrcNext(IncomingRTPPktLink* sn)		{ srcNext = sn; }		inline IncomingRTPPktLink* getSrcPrev() const		{ return srcPrev; }		inline void setSrcPrev(IncomingRTPPktLink* sp)		{ srcPrev = sp; }		inline IncomingRTPPkt* getPacket() const		{ return packet; }		inline void setPacket(IncomingRTPPkt* pkt)		{ packet = pkt; }		/**		 * Set the time this packet was received at.		 *		 * @param t time of reception.		 * @note this has almost nothing to do with the 32-bit		 * timestamp contained in the packet header.		 **/		inline void setRecvTime(const timeval &t)		{ receptionTime = t; }		/**		 * Get the time this packet was received at.		 **/		inline timeval getRecvTime() const		{ return receptionTime; }		/**		 * Get timestamp of this packet. The timestamp of		 * incoming packets is filtered so that the timestamp		 * this method provides for the first packet received		 * from every source starts from 0.		 *		 * @return 32 bit timestamp starting from 0 for each source.		 */		inline uint32 getTimestamp() const		{ return shiftedTimestamp; };

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -