endpoint.h
资源名称:h323.zip [点击查看]
上传用户:hnnddl
上传日期:2007-01-06
资源大小:3580k
文件大小:8k
源码类别:
IP电话/视频会议
开发平台:
WINDOWS
- /*
- * $Revision: 1.1.1.1 $
- * $Date: 1997/06/27 20:21:10 $
- */
- ////////////////////////////////////////////////////////////////
- // Copyright (c) 1996,97 Lucent Technologies //
- // All Rights Reserved //
- // //
- // THIS IS UNPUBLISHED //
- // PROPRIETARY SOURCE //
- // CODE OF Lucent Technologies //
- // AND elemedia //
- // //
- // The copyright notice above does not evidence any //
- // actual or intended publication of such source code//
- ////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////
- // File : endpoint.h //
- // //
- // This file declares RTPEndpointInfo //
- // //
- // //
- // History: //
- // 20_Jan_1997 Created //
- // //
- ////////////////////////////////////////////////////////////////
- #if (!defined(__ENDPOINT_H__))
- #define __ENDPOINT_H__
- #include "rtp/rtperr.h"
- #include "util/listifc.h"
- #define RTP_SEQ_MOD (1 << 16)
- #define RTP_TS_MOD (0xFFFFFFFF)
- struct RTCPReceptionReport;
- struct RTCPSenderInfo;
- class RTPSession;
- class RTCPPacket;
- class CBuffer;
- class RTPEndpointInfo;
- class Logger;
- struct EndpointStats;
- // The RTP Endpoint Information class. This class abstracts
- // the functions and information maintained by and for an
- // RTP endpoint. For the local endpoint all information
- // that would be needed to send a sender report is maintained.
- // For remote endpoints all information that is required for
- // sending reception reports would be maintained.
- //
- // Can be instantiated only by using the Factory method.
- class DLLEXPORT RTPEndpointInfo : public ListElementInterface
- {
- public: // Friendship associations..
- friend class RTPPacket;
- friend class RTCPPacket;
- friend class RTPSession;
- public: // methods.
- virtual ~RTPEndpointInfo ();
- // Various routines that return the SDES names for this endpoint.
- void GetCName(char *&buf, int& length);
- void GetRealName(char *&buf, int& length);
- void GetEMail(char *&buf, int& length);
- void GetPhone(char *&buf, int& length);
- void GetLoc(char *&buf, int& length);
- void GetTool(char *&buf, int& length);
- void GetNote(char *&buf, int& length);
- void GetPriv(char *&buf, int& length);
- // Return this endpoints ssrc.
- unsigned int GetSSRC();
- // Retrive some statistics regarding this endpoint.
- // Information returned in host byte order.
- void GetStatistics(struct RTPEndpointStats &endpoint_stats);
- protected: // Types
- // Various schemes using which the endpoints list can be looked up
- // The endpoints list contains information regarding all remote
- // endpoints that participate with this local endpoint for this
- // session. This information consists of statistics needed for sending
- // reception reports.
- enum LookupSchemes
- {
- LOOKUP_ON_SSRC
- };
- protected: // Member functions.
- // Constructor. Creates an endpointinfo class for the given ssrc and
- // session.
- // The constructor is protected so that this class cannot be instantiated
- // directly.
- RTPEndpointInfo (unsigned int ssrc, RTPSession *session,
- unsigned short sequence_no = 0);
- int Match(void *key, unsigned long key_type);
- // the pointer to the current session.
- RTPSession *session;
- // The ssrc of the endpoint.
- unsigned int ssrc;
- // for sequence number checks in incoming rtp packets.
- // needed to send reception reports too.
- int probation; // is the source valid ?
- unsigned int cycles; // number of sequence number wraparounds.
- unsigned short max_seq; // max sequence number expected.
- unsigned short base_seq; // first sequence number recd.
- unsigned int bad_seq; // last bad sequence number received
- unsigned int max_misorder; // tolerance on the lower side of max_seq
- unsigned int max_dropout; // tolarance on the upper side of max_seq
- int min_sequential; // no of consecutive ordered pkts to
- // go out of probation(1 for no probation)
- // NTP time in the last sender report packet that was received.
- unsigned int sr_ntp_secs;
- unsigned int sr_ntp_fraction;
- // NTP time when the last sender report packet arrived.
- unsigned int sr_arrival_ntp_secs;
- unsigned int sr_arrival_ntp_fraction;
- // for loss stats. needed to generate reception reports.
- unsigned int expected_prior;// saved expected value during last rr.
- unsigned int received_prior;// saved received value during last rr.
- // incoming packet statistics .
- unsigned int misorder; // no of misordered packets.
- unsigned int received; // total number of packets from this source.
- unsigned int transit_time; // rel transit time for previous packet
- unsigned int delay_variance;// cumulative interarrival jitter.
- // outgoing packet statistics. needed for generating sender reports.
- unsigned int packets_sent;
- unsigned int octets_sent;
- // The receiver report for the (remote) endpoint.
- RTCPReceptionReport *rr;
- // sender(local endpoint) only. The sender report for the (local) endpoint.
- RTCPSenderInfo *sr;
- // SDES items.
- CBuffer *cname;
- CBuffer *real_name;
- CBuffer *email;
- CBuffer *phone;
- CBuffer *note;
- CBuffer *tool;
- CBuffer *loc;
- CBuffer *priv;
- // Mutex object for this endpoint.
- void* mutex;
- // marks if there was any activity in this endpoint since the
- // last call to GetSenderInfo or GetReceptionReport.
- int activity_flag;
- // Set the SSRC for this endpoint.
- void SetSSRC(unsigned int ssrc);
- // Routines to set the various SDES ids for this endpoint.
- void SetCName(char *buf, int length);
- void SetRealName(char *buf, int length);
- void SetEMail(char *buf, int length);
- void SetPhone(char *buf, int length);
- void SetLoc(char *buf, int length);
- void SetTool(char *buf, int length);
- void SetNote(char *buf, int length);
- void SetPriv(char *buf, int length);
- // indicate that a sender report was got from this endpoint at the
- // specified time.
- // Used to maintain some stats required for sending reception reports.
- void SenderReportArrived(struct RTCPSenderInfo& sr,
- unsigned int now_ntp_secs, unsigned int now_ntp_fraction);
- // Routines for getting the sender and receiver reports.
- // Calling GetReceptionReport for the local endpoint or
- // GetSenderInfo for a remote endpoint is an error which is
- // not notified.
- RTCPSenderInfo * GetSenderInfo();
- RTCPReceptionReport * GetReceptionReport(unsigned int now_ntp_sec,
- unsigned int now_ntp_frac);
- // Was there any activity since the last time
- // (probationary period indicates inactivity).
- int CheckActivity();
- // Called whenever a packet is received from this endpoint.
- // Update statistics for sending reception reports.
- ProtReturnCode PacketReceived(RTPPacket &packet, unsigned int rtp_time);
- // Called whenever a packet is sent out from this endpoint.
- // Update local endpoints statistics.
- ProtReturnCode PacketSent(RTPPacket &packet, int payload_length);
- // initialize the packet sequence check variables.
- void init_seq(unsigned short seq);
- private:
- Logger *_logger;
- };
- // The statistics collected for this endpoint.
- struct RTPEndpointStats
- {
- unsigned int es_ssrc;
- // incoming packet stats from this endpoint.
- // Does not make any sense for the local endpoint.
- int es_probation; // is the source valid ?
- unsigned int es_misorder; // no of misordered packets.
- unsigned int es_received; // total number of packets from this source.
- unsigned int es_delay_variance;// cumulative interarrival jitter.
- // outgoing packet statistics for this endpoint.
- // For local endpoints counted as and when packets are sent,
- // and for remote endpoints collected from the most recent SenderReport.
- unsigned int es_packets_sent;
- unsigned int es_octets_sent;
- };
- #endif // __ENDPOINT_H__