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

📄 rtp.h

📁 mgcp协议源代码。支持多种编码:g711
💻 H
📖 第 1 页 / 共 2 页
字号:
      */    virtual void Close(      BOOL reading    /// Closing the read side of the session    ) = 0;    /**Get the local host name as used in SDES packes.      */    virtual PString GetLocalHostName() = 0;  //@}  /**@name Call back frunctions */  //@{    enum SendReceiveStatus {      e_ProcessPacket,      e_IgnorePacket,      e_AbortTransport    };    virtual SendReceiveStatus OnSendData(RTP_DataFrame & frame);    virtual SendReceiveStatus OnReceiveData(const RTP_DataFrame & frame);    virtual SendReceiveStatus OnReceiveControl(const RTP_ControlFrame & frame);    class ReceiverReport : public PObject  {        PCLASSINFO(ReceiverReport, PObject);      public:        void PrintOn(ostream &) const;        DWORD sourceIdentifier;        DWORD fractionLost;         /* fraction lost since last SR/RR */        DWORD totalLost;	    /* cumulative number of packets lost (signed!) */        DWORD lastSequenceNumber;   /* extended last sequence number received */        DWORD jitter;               /* interarrival jitter */        PTimeInterval lastTimestamp;/* last SR packet from this source */        PTimeInterval delay;        /* delay since last SR packet */    };    PARRAY(ReceiverReportArray, ReceiverReport);    class SenderReport : public PObject  {        PCLASSINFO(SenderReport, PObject);      public:        void PrintOn(ostream &) const;        DWORD sourceIdentifier;        PTime realTimestamp;        DWORD rtpTimestamp;        DWORD packetsSent;        DWORD octetsSent;    };    virtual void OnRxSenderReport(const SenderReport & sender,                                  const ReceiverReportArray & reports);    virtual void OnRxReceiverReport(DWORD src,                                    const ReceiverReportArray & reports);    class SourceDescription : public PObject  {        PCLASSINFO(SourceDescription, PObject);      public:        SourceDescription(DWORD src) { sourceIdentifier = src; }        void PrintOn(ostream &) const;        DWORD            sourceIdentifier;        POrdinalToString items;    };    PARRAY(SourceDescriptionArray, SourceDescription);    virtual void OnRxSourceDescription(const SourceDescriptionArray & descriptions);    virtual void OnRxGoodbye(const PDWORDArray & sources,                             const PString & reason);    virtual void OnRxApplDefined(const PString & type, unsigned subtype, DWORD src,                                 const BYTE * data, PINDEX size);  //@}  /**@name Member variable access */  //@{    /**Get the ID for the RTP session.      */    unsigned GetSessionID() const { return sessionID; }    /**Get the user data for the session.      */    RTP_UserData * GetUserData() const { return userData; }    /**Set the user data for the session.      */    void SetUserData(      RTP_UserData * data   // New user data to be used    );    /**Get the source output identifier.      */    DWORD GetSyncSourceOut() const { return syncSourceOut; }    /**Increment reference count for RTP session.      */    void IncrementReference() { referenceCount++; }    /**Decrement reference count for RTP session.      */    BOOL DecrementReference() { return --referenceCount == 0; }    /**Indicate if will ignore out of order packets.      */    BOOL WillIgnoreOutOfOrderPackets() const { return ignoreOutOfOrderPackets; }    /**Indicate if will ignore out of order packets.      */    void SetIgnoreOutOfOrderPackets(      BOOL ignore   /// Flag for ignore out of order packets    ) { ignoreOutOfOrderPackets = ignore; }    /**Get the interval for transmitter reports in the session.      */    unsigned GetSenderReportInterval() { return senderReportInterval; }    /**Set the interval for transmitter reports in the session.      */    void SetSenderReportInterval(      unsigned packets   // Number of packets between reports    );    /**Get the interval for receiver reports in the session.      */    unsigned GetReceiverReportInterval() { return receiverReportInterval; }    /**Set the interval for receiver reports in the session.      */    void SetReceiverReportInterval(      unsigned packets   // Number of packets between reports    );    /**Get total number of packets sent in session.      */    DWORD GetPacketsSent() const { return packetsSent; }    /**Get total number of octets sent in session.      */    DWORD GetOctetsSent() const { return octetsSent; }    /**Get total number of packets received in session.      */    DWORD GetPacketsReceived() const { return packetsReceived; }    /**Get total number of octets received in session.      */    DWORD GetOctetsReceived() const { return octetsReceived; }    /**Get total number received packets lost in session.      */    DWORD GetPacketsLost() const { return packetsLost; }    /**Get total number of packets received out of order in session.      */    DWORD GetPacketsOutOfOrder() const { return packetsOutOfOrder; }    /**Get total number received packets too late to go into jitter buffer.      */    DWORD GetPacketsTooLate() const;    /**Get average time between sent packets.       This is averaged over the last senderReportInterval packets and is in       milliseconds.      */    DWORD GetAverageSendTime() const { return averageSendTime; }    /**Get maximum time between sent packets.       This is over the last senderReportInterval packets and is in       milliseconds.      */    DWORD GetMaximumSendTime() const { return maximumSendTime; }    /**Get minimum time between sent packets.       This is over the last senderReportInterval packets and is in       milliseconds.      */    DWORD GetMinimumSendTime() const { return minimumSendTime; }    /**Get average time between received packets.       This is averaged over the last receiverReportInterval packets and is in       milliseconds.      */    DWORD GetAverageReceiveTime() const { return averageReceiveTime; }    /**Get maximum time between received packets.       This is over the last receiverReportInterval packets and is in       milliseconds.      */    DWORD GetMaximumReceiveTime() const { return maximumReceiveTime; }    /**Get minimum time between received packets.       This is over the last receiverReportInterval packets and is in       milliseconds.      */    DWORD GetMinimumReceiveTime() const { return minimumReceiveTime; }  //@}  protected:    void SetReceiverReport(RTP_ControlFrame::ReceiverReport & receiver);    unsigned           sessionID;    unsigned           referenceCount;    RTP_UserData     * userData;    RTP_JitterBuffer * jitter;    BOOL          ignoreOutOfOrderPackets;    DWORD         syncSourceOut;    DWORD         syncSourceIn;    unsigned      senderReportInterval;    unsigned      receiverReportInterval;    WORD          lastSentSequenceNumber;    WORD          expectedSequenceNumber;    PTimeInterval lastSentPacketTime;    PTimeInterval lastReceivedPacketTime;    WORD          lastRRSequenceNumber;    // Statistics    DWORD packetsSent;    DWORD octetsSent;    DWORD packetsReceived;    DWORD octetsReceived;    DWORD packetsLost;    DWORD packetsOutOfOrder;    DWORD averageSendTime;    DWORD maximumSendTime;    DWORD minimumSendTime;    DWORD averageReceiveTime;    DWORD maximumReceiveTime;    DWORD minimumReceiveTime;    DWORD jitterLevel;    unsigned senderReportCount;    unsigned receiverReportCount;    DWORD    averageSendTimeAccum;    DWORD    maximumSendTimeAccum;    DWORD    minimumSendTimeAccum;    DWORD    averageReceiveTimeAccum;    DWORD    maximumReceiveTimeAccum;    DWORD    minimumReceiveTimeAccum;};/**This class is for encpsulating the IETF Real Time Protocol interface. */class RTP_SessionManager : public PObject{  PCLASSINFO(RTP_SessionManager, PObject);  public:  /**@name Operations */  //@{    /**Use an RTP session for the specified ID.       If this function returns a non-null value, then the ReleaseSession()       function MUST be called or the session is never deleted for the       lifetime of the session manager.       If there is no session of the specified ID, then you MUST call the       AddSession() function with a new RTP_Session. The mutex flag is left       locked in this case. The AddSession() expects the mutex to be locked       and unlocks it automatically.      */    RTP_Session * UseSession(      unsigned sessionID    /// Session ID to use.    );    /**Add an RTP session for the specified ID.       This function MUST be called only after the UseSession() function has       returned NULL. The mutex flag is left locked in that case. This       function expects the mutex to be locked and unlocks it automatically.      */    void AddSession(      RTP_Session * session    /// Session to add.    );    /**Release the session. If the session ID is not being used any more any       clients via the UseSession() function, then the session is deleted.     */    void ReleaseSession(      unsigned sessionID    /// Session ID to release.    );    /**Get a session for the specified ID.       Unlike UseSession, this does not increment the usage count on the       session so may be used to just gain a pointer to an RTP session.     */    RTP_Session * GetSession(      unsigned sessionID    /// Session ID to get.    ) const;  //@}  protected:    PDICTIONARY(SessionDict, POrdinalKey, RTP_Session);    SessionDict sessions;    PMutex      mutex;};/**This class is for the IETF Real Time Protocol interface on UDP/IP. */class RTP_UDP : public RTP_Session{  PCLASSINFO(RTP_UDP, RTP_Session);  public:  /**@name Construction */  //@{    /**Create a new RTP channel.     */    RTP_UDP(      unsigned id  /// Session ID for RTP channel    );    /// Destroy the RTP    ~RTP_UDP();  //@}  /**@name Overrides from class RTP_Session */  //@{    /**Read a data frame from the RTP channel.       Any control frames received are dispatched to callbacks and are not       returned by this function. It will block until a data frame is       available or an error occurs.      */    virtual BOOL ReadData(RTP_DataFrame & frame);    /**Write a data frame from the RTP channel.      */    virtual BOOL WriteData(RTP_DataFrame & frame);    /**Write a control frame from the RTP channel.      */    virtual BOOL WriteControl(RTP_ControlFrame & frame);    /**Close down the RTP session.      */    virtual void Close(      BOOL reading    /// Closing the read side of the session    );    /**Get the session description name.      */    virtual PString GetLocalHostName();  //@}  /**@name New functions for class */  //@{    /**Open the UDP ports for the RTP session.      */    BOOL Open(      PIPSocket::Address localAddress,  /// Local interface to bind to      WORD portBase,                    /// Base of ports to search      BYTE ipTypeOfService              /// Type of Service byte    );    WORD GetLocalDataPort() const { return dataSocket.GetPort(); }    WORD GetLocalControlPort() const { return controlSocket.GetPort(); }    WORD GetRemoteDataPort() const { return remoteDataPort; }    WORD GetRemoteControlPort() const { return remoteControlPort; }    PIPSocket::Address GetRemoteAddress() const { return remoteAddress; }    BOOL SetRemoteSocketInfo(PIPSocket::Address address, WORD port, BOOL isDataPort);  //@}  protected:    SendReceiveStatus ReadDataPDU(RTP_DataFrame & frame);    SendReceiveStatus ReadControlPDU();    PIPSocket::Address remoteAddress;    WORD               remoteDataPort;    WORD               remoteControlPort;    BOOL shutdownRead;    BOOL shutdownWrite;    PUDPSocket dataSocket;    PUDPSocket controlSocket;};#endif // __RTP_H/////////////////////////////////////////////////////////////////////////////

⌨️ 快捷键说明

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