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

📄 rtpsession.h

📁 symbian平台S60_2nd_FP2_SC rtp实现
💻 H
字号:
#ifndef RTPSESSION_HXX
#define RTPSESSION_HXX

#include "rtpTypes.h"
#include "RtpPacket.h"
#include "RtpReceiver.h"
#include "RtpTransmitter.h"
#include "DTMFInterface.h"
#include "RtcpReceiver.h"

#include "Socketudp.h"

class RtpSession
{
    public:
        /**@param ports All ports are optional
         * @param jitterNew = -1 to bypass jitterBuffer
         **/
        RtpSession (const char* remoteHost, int remotePort = 0, int localPort = 0,
                    int rtcpRemotePort = 0, int rtcpLocalPort = 0,
                    RtpPayloadType apiPayloadType = rtpPayloadPCMU,
                    RtpPayloadType networkPayloadType = rtpPayloadPCMU,
                    int jitterNew = 5);
        /**@param ports All ports are optional by passing 0.  Port range is
         *        availiable here.
         * @param jitterNew = -1 to bypass jitterBuffer
         **/
        RtpSession (const char* remoteHost, int remotePort, int localPort,
                    int rtcpRemotePort, int rtcpLocalPort, int portRange,
                    RtpPayloadType apiPayloadType = rtpPayloadPCMU,
                    RtpPayloadType networkPayloadType = rtpPayloadPCMU,
                    int jitterNew = 5);
        /// consturctor init (don't call this function)
        void constructRtpSession (const char* remoteHost, int remotePort,
                                  int localPort, int rtcpRemotePort, int rtcpLocalPort,
                                  int portRange, RtpPayloadType apiPayloadType,
                                  RtpPayloadType networkPayloadType, int jitterNew);
        ///
        ~RtpSession ();

        /// reserves a rtp port by instantiating a RtpReceiver object
        int reserveRtpPort(int localMin = -1, int localMax = -1);
        /// release the rtp port
        int releaseRtpPort();

        /// reserves a rtcp port by instantiating a RtcpReceiver object
        int reserveRtcpPort(int localPort, int portRange = 0);
        /// release the rtcp port
        int releaseRtcpPort();

        /**@name Session Functions
         *  Being in a particular state disables some functions.  For example,
         *  in recvonly state, the transmit function will do nothing.
         *  Availiable state are listed in rtpTyes.h
         **/
        void setSessionState (RtpSessionState state);
        ///
        RtpSessionState getSessionState ();

        /// set transmitters
        int setTransmiter ( const char* remoteHost, int remotePort,
                            int rtcpRemotePort, RtpPayloadType apiFormat,
                            RtpPayloadType networkFormat );

        ///
        void setApiFormat (RtpPayloadType type, int size, int packetSize = 0);
        void setNetworkFormat (RtpPayloadType type, int size, int packetSize = 0);

        ///
        void setCodecString (const char* codecStringInput);

        /// size is in number of samples
        void setApiPktSampleSize (int size);
        void setNetworkPktSampleSize (int size);
        void setApiPktSize (int size);
        void setNetworkPktSize (int size);

        ///
        int getNetworkPktSampleSize ();
        int getApiPktSampleSize ();

        ///
        int getPacketSent ();
        ///
        int getByteSent ();

        ///
        int getPacketReceived ();
        ///
        int getByteReceived ();

        ///
        int getPacketLost ();

        ///
        int getJitter ();

        ///
        int getLatency ();

        // not implemented
        //void setTypeOfService (int service);
        // not implemented
        //int getTypeOfService ();
        //@}


        /** Creates an RTP packet for transmitter
         *  @param no_samples number of samples for specified payload
         *  @param padbyteSize always 0, not fully implemented
         *  @param csrc_count number of contributing sources to packet
         **/
        RtpPacket* createPacket (int padbyteSize = 0, int csrcCount = 0);

        /** Gets the previous packet's RTP sequence number 
         **/
        RtpSeqNumber getPrevSequence();

        /** Gets the previous packet's RTP timestamp
         **/
        RtpTime getPrevRtpTime();

        // set marker flago next packet
        void setMarkerOnce();

        /** Transmits packet onto network
         *  @return -1 error, otherwise size sent on sucess
         **/
        int transmit (RtpPacket* packet);
        int transmitRaw (char* inbuffer, int len);

        /** Transmit DTMF event in RTP on network
         *  @return -1 error, otherwise 0
         **/
        int transmitEvent( int event );

        /** Receives RTP packet information from network
         *  fn will deallocate packet on next call
         *  @return -1 error in packet or network, 0 no packet received,
         *             otherwise bytes receeived
         **/
        RtpPacket*  receive ();
        int receive(RtpPacket** rtpPacket,RtcpPacket** rtcpPacket);
        RtpPacket* getPacket();


        /** Checks RTCP interval, transmits and receeives if neccessary
         **/
        void processRTCP();

        /** Create and transmit compound RTCP packet
         *  @return -1 failure, else number of bytes sent on success
         **/
        int transmitRTCP ();

        /** Create and transmit a SR and BYE compound packet
         *  @return -1 failure, else number of bytes sent on success
         **/
        int transmitRTCPBYE ();

        /** receive and read compound RTCP packet
         *  @eturn 0 if no packet received, else 1 on sucess
         **/
        int receiveRTCP ();

        /** Check if time to send RTCP packet
         *  return: 1 = time to send RTCP packet
         **/
        int checkIntervalRTCP ();


        /// RTP transmitter
        RtpTransmitter* getRtpTran ()
        {
            return tran;
        }
        /// RTP recevier
        RtpReceiver* getRtpRecv ()
        {
            return recv;
        }
        /// RTCP transmitter
        RtcpTransmitter* getRtcpTran ()
        {
            return rtcpTran;
        }
        /// RTCP receiver
        RtcpReceiver* getRtcpRecv ()
        {
            return rtcpRecv;
        }


        /// DTMF callback function
        void setDTMFInterface ( DTMFInterface* t );
        void unsetDTMFInterface ( DTMFInterface* t );
        
        bool isEvent;
        DTMFEvent event;

		int setDTMFType(RtpPayloadType dtmfType);
		RtpPayloadType m_dtmfType;

    private:
        /// Internal pointer to RTP transmitter
        RtpTransmitter* tran;
        /// Internal pointer to RTP receiver
        RtpReceiver* recv;
        /// Internal pointer to RTCP transmitter
        RtcpTransmitter* rtcpTran;
        /// Internal pointer to RTCP receiver
        RtcpReceiver* rtcpRecv;

        /// session state
        RtpSessionState sessionState;

        /// session error code;
        RtpSessionError sessionError;

		CSocketUdp * iSocketEngineRtp;

		CSocketUdp * iSocketEngineRtcp;
};



#endif // RTPSESSION_HXX

⌨️ 快捷键说明

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