rtp/rtpstack/inc/rtptranstream.h
changeset 0 307788aac0a8
child 29 5f12516512fa
equal deleted inserted replaced
-1:000000000000 0:307788aac0a8
       
     1 /*
       
     2 * Copyright (c) 2004-2005 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:    
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 #ifndef RtpTranStream_H
       
    23 #define RtpTranStream_H
       
    24 
       
    25 #include "rtpstream.h"
       
    26 
       
    27 
       
    28 /**
       
    29 *  Derived class for RTP transmit stream. 
       
    30 *
       
    31 *  @lib RtpService.dll
       
    32 */
       
    33 class CRtpTranStream : public CRtpStream
       
    34     {
       
    35     #if defined( _DEBUG ) && defined( RTP_UNIT_TEST )
       
    36 	    //Friend class used for testing
       
    37 	    friend class CRtpUtRtpStream; 
       
    38     #endif 
       
    39     public:
       
    40         static CRtpTranStream* NewL( const TRtpPayloadType aPayloadType,
       
    41                                      const TRtpId aSessionID,
       
    42                                      const TRtpId aTranStreamID,
       
    43                                      const TRtpSSRC aSSRC,
       
    44                                      MRtcpObserver* aObserver,
       
    45                                      const TUint32* aProfileRTPTimeRates );
       
    46         ~CRtpTranStream();
       
    47 
       
    48         TInt BuildRtpPacket( const TRtpSendHeader& aHeaderInfo,
       
    49                              const TDesC8& aPayloadData,
       
    50                              TRtpSequence aSeqNum,
       
    51                              TBool aSetSeqNum,
       
    52                              CRtpPacket* aPktSnd );
       
    53 
       
    54         TInt BuildRtcpBYEPacket( const TDesC8& aReason,
       
    55                                  CRtpPacket* aPktRtcpSnd );
       
    56 
       
    57         TInt BuildRtcpAPPPacket( const TRtcpApp& aApp,
       
    58                                  CRtpPacket* aPktRtcpSnd );
       
    59 
       
    60         inline TBool SentRTPPackets() const { return iFlagSentRTPPackets; };
       
    61         inline void SetSentRTPPackets( TBool aFlag )
       
    62             {
       
    63             iFlagSentRTPPackets = aFlag;
       
    64             };
       
    65 
       
    66         inline TBool SentRtcpReport() { return iFSentRtcpReport; };
       
    67         inline void SetRtcpReportFlag() { iFSentRtcpReport = ETrue; };
       
    68         inline void ResetRtcpReportFlag() { iFSentRtcpReport = EFalse; };
       
    69         inline void SetBandwidth( TUint32 aBandwidth ) 
       
    70             { 
       
    71             iRtcpStats.iRtcpReceiverStats.iTxBandwidth = aBandwidth;
       
    72             }; 
       
    73 
       
    74     public: // from CRtpStream
       
    75         TInt ResetStreamStat();
       
    76         TInt GetStreamStat( TRtpPeerStat& aStat );
       
    77         TRtpRtcpEnum RtpStreamProcessRtcpReportSectionL( CRtpPacket* aPkt );
       
    78         void RtpStreamCreateRtcpReportSection( CRtpPacket* aPkt );
       
    79 
       
    80     private:
       
    81         CRtpTranStream( const TRtpPayloadType aPayloadType,
       
    82                         const TRtpId aSessionId,
       
    83                         const TRtpId aStreamId,
       
    84                         const TRtpSSRC aSSRC,
       
    85                         MRtcpObserver* aRtcpObserver,
       
    86                         const TUint32* aProfileRTPTimeRates );
       
    87         void ConstructL();
       
    88 
       
    89         inline void IncCumNumOctetsSent( TUint32 aInc ) 
       
    90             {
       
    91             iCumNumOctetsSent += aInc;
       
    92             iSN_size[iSeqNum % KSNMaxArray] = iCumNumOctetsSent;
       
    93             };
       
    94 
       
    95         void RtpStreamSyncInit( TRtpTimeStamp initTimeStamp );
       
    96         TUint32 RtpStreamSyncGetRoundTripDelay( TUint32 lastSRTimeStamp,
       
    97                                                 TUint32 delaySinceLSR );
       
    98         void RtpStreamSyncCurrent( TRtpTimeSync* aSyncInfoCurrent );
       
    99 
       
   100         /**
       
   101          * Makes an estimate of the Tx and Rx bandwidths.
       
   102          * NOTE: This is just a simple estimate, which assumes the following:
       
   103          * - this is an end-to-end session
       
   104          * - the sessions and streams are set up before traffic starts
       
   105          * - the payload bitrate is constant
       
   106          * The result of this estimation should not be used in any other
       
   107          * contexts.
       
   108          */
       
   109         void EstimateBandWidths( TUint32 aCurrentTime );
       
   110 
       
   111     private:
       
   112         // flag to indicate if a packet was sent since last RTCP packet
       
   113         TBool iFlagSentRTPPackets;
       
   114 
       
   115         // time of previous RTCP packet sent
       
   116         TUint32 iPreviousTime;
       
   117 
       
   118         // remote bandwidth
       
   119         TUint32 iRemoteBandwidth;
       
   120 
       
   121         // previous remote sequence number
       
   122         TUint32 iPreviousRemoteSN;
       
   123 
       
   124         // time of previous RTCP packet received
       
   125         TUint32 iPrevRemoteTime;
       
   126 
       
   127         // number of bytes sent
       
   128         TUint32 iCumNumOctetsSent;
       
   129 
       
   130         // keeps track of how many bytes were received by the receiver
       
   131         TUint32 iCumNumOctetsReceived;
       
   132 
       
   133         // previous value of cumNumOctetsSent
       
   134         TUint32 iCumNumOctetsSent_last;
       
   135 
       
   136         // keeps track of the total bytes sent
       
   137         TUint32 iSN_size[KSNMaxArray];
       
   138 
       
   139         // if ETrue, then packet sequence number is given by application
       
   140         TBool iFSetSeqNum;
       
   141 
       
   142         // flag that indicates if an RTCP Packet has been sent
       
   143         TBool iFSentRtcpReport; 
       
   144      private:    
       
   145 	    #ifdef EUNIT_TESTING
       
   146 		  	friend class UT_CRtpSession;
       
   147 			friend class UT_CRtpStream;
       
   148 			friend class UT_CRtpSessionSrtp;
       
   149 		#endif     	    
       
   150             
       
   151     };
       
   152 
       
   153 
       
   154 #endif	// RtpTranStream_H