rtp/rtpstack/inc/rtpmanager.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 #ifndef __RTPMANAGER_H
       
    22 #define __RTPMANAGER_H
       
    23 
       
    24 #include <commdbconnpref.h>
       
    25 #include <es_enum.h>
       
    26 #include <rtpdef.h>
       
    27 #include <rtpheader.h>
       
    28 #include "rtpsession.h"
       
    29 #include "rtpsdes.h"
       
    30 #include "localaddrresolver.h"
       
    31 #include "rtpmanagerdef.h"
       
    32 #include "rtpasignuniqueid.h"
       
    33 #include "srtpsession.h"
       
    34 #include "rtpsessionsrtp.h"
       
    35 
       
    36 /**
       
    37 *  Container of all rtp sessions. 
       
    38 *
       
    39 *  @lib RtpService.dll
       
    40 */
       
    41 class CRtpManager : public CBase,
       
    42     				public MRtpAsignUniqueID
       
    43     {
       
    44     #if defined( _DEBUG ) && defined( RTP_UNIT_TEST )
       
    45     // Friend class used for testing
       
    46         friend class CRtpUtRtpManager;
       
    47     #endif
       
    48     public: // Data types
       
    49         enum TCreateStreamType
       
    50             {
       
    51             ECreateRecvStream = 0,
       
    52             ECreateTranStream,
       
    53             ECreateTranStreamExt
       
    54             };
       
    55 
       
    56     public:
       
    57         static CRtpManager* NewL( MRtpErrNotify& aErrNotify );
       
    58         ~CRtpManager();
       
    59 
       
    60         TInt OpenL( const TRtpSdesParams& aSdesInfo, 
       
    61                     const TDesC* aRtpPacketDll, 
       
    62                     RSocketServ* aSocketServPtr,
       
    63                     RConnection* aRConnPtr );
       
    64 
       
    65         /**
       
    66         * Open and initialize the CRtpAPI object synchronously.
       
    67         * @param TInt aIapId - [input] IAP ID. If -1, no IAP selection dialog
       
    68         *   will pop up. Instead, the default IAP will be used.
       
    69         * @return TInt - KErrNone if successful; system wide error code
       
    70         *   otherwise
       
    71         */
       
    72         TInt StartConnection( TInt aIapId );
       
    73 
       
    74         /**
       
    75         * Open and initialize the CRtpAPI object in asynchronous mode
       
    76         * @param TRequestStatus& aStatus - [output] On completion, will contain
       
    77         *   a status code: KErrNone if successful; system wide error code
       
    78         *   otherwise.
       
    79         * @param TInt aIapId - [input] IAP ID. If -1, no IAP selection dialog
       
    80         *   will pop up. Instead, the default IAP will be used.
       
    81         * @return TInt - KErrNone if successful; system wide error code
       
    82         *   otherwise
       
    83         */
       
    84         TInt StartConnection( TRequestStatus& aStatus, TInt aIapId );
       
    85 
       
    86         /**
       
    87         * Cancels asynchoronous start of connection
       
    88         * Any open requests will be completed with KErrCancel.
       
    89         * @return None
       
    90         */
       
    91         void CancelStart(); 
       
    92 
       
    93         void Close( void );
       
    94 
       
    95         void SetLocalSdes( const TRtpSdesParams& aSdesInfo );
       
    96 
       
    97         TInetAddr& GetLocalIPAddressL();
       
    98 
       
    99         TRtpId CreateSessionL( const TCreateSessionParams& aSessionParams,
       
   100                                TUint& aPort,
       
   101                                TBool aEnableRtcp,
       
   102                                const TRtcpParams* aRtcpParams );
       
   103                                
       
   104 		TRtpId CreateSessionL( const TCreateSessionParams& aSessionParams,
       
   105                                TUint& aPort,
       
   106                                TBool aEnableRtcp,
       
   107                                const TRtcpParams* aRtcpParams,
       
   108                                CSRTPSession& aSRTPSession );
       
   109         TInt StartSession( TRtpId aSessionId );
       
   110 
       
   111         void CloseSession( TRtpId aSessionId );
       
   112 
       
   113         TInt SetRemoteAddress( TRtpId aSessionId, TInetAddr& aRemoteAddr );
       
   114         TInt SetRemoteRtcpAddress( TRtpId aSessionId, TInetAddr& aRemoteAddr );
       
   115 
       
   116         /**
       
   117         * Does the actual work of creating a stream. Used by the other
       
   118         * stream creation methods.
       
   119         * @return ID of the created stream, or KNullId if not successful
       
   120         */
       
   121         TRtpId CreateStreamL( TRtpId aSessionId,
       
   122                               const TCreateStreamType aStreamType,
       
   123                               TRtpPayloadType aPayloadType,
       
   124                               TRtpSSRC& aSSRC );
       
   125 
       
   126         TRtpId CreateReceiveStreamL( TRtpId aSessionId, const TRcvStreamParams& aParams );
       
   127         TRtpId CreateTransmitStreamL( TRtpId aSessionId, const TTranStreamParams& aParams, 
       
   128                                       TRtpSSRC& aSSRC );
       
   129 
       
   130         TRtpId CreateTransmitStreamExtL( TRtpId aSessionId, const TTranStreamParams& aParams, 
       
   131                                          const TRtpSSRC aSSRC );
       
   132 
       
   133         void CloseStream( TRtpId aStreamId );
       
   134 
       
   135         TInt RegisterRtpObserver( TRtpId aSessionId, MRtpObserver& aObserver );
       
   136 
       
   137         void UnregisterRtpObserver( TRtpId aSessionId );
       
   138 
       
   139         TInt SetNonRTPDataObserver( TRtpId aSessionId, 
       
   140                                     MNonRTPDataObserver* aNonRTPDataObserver );
       
   141         
       
   142         TInt SendRtpPacket( TRtpId aTranStreamId, 
       
   143                             const TRtpSendHeader& aHeaderInfo, 
       
   144                             const TDesC8& aPayloadData );
       
   145 
       
   146         TInt SendRtpPacket( TRtpId aTranStreamId,
       
   147                             const TRtpSendHeader& aHeaderInfo,
       
   148                             const TDesC8& aPayloadData,
       
   149                             TRequestStatus& aStatus );
       
   150 
       
   151         TInt SendRtpPacket( TRtpId aTranStreamId,
       
   152                             TRtpSequence aSequenceNum,
       
   153                             const TRtpSendHeader& aHeaderInfo,
       
   154                             const TDesC8& aPayloadData,
       
   155                             TRequestStatus& aStatus );
       
   156 
       
   157         void SendDataL( TRtpId aSessionId,
       
   158                        TBool aUseRTPSocket,
       
   159                        const TDesC8& aData,
       
   160                        TRequestStatus& aStatus );
       
   161 
       
   162         void CancelSend( TRtpId aSessionId );
       
   163 
       
   164         TInt RegisterRtcpObserver( TRtpId aSessionId, MRtcpObserver& aObserver );
       
   165 
       
   166         void UnregisterRtcpObserver( TRtpId aSessionId );
       
   167 
       
   168         TInt SendRtcpByePacketL( TRtpId aTranStreamId, const TDesC8& aReason );
       
   169 
       
   170         TInt SendRtcpAppPacketL( TRtpId aTranStreamId, const TRtcpApp& aApp );
       
   171 
       
   172         /**
       
   173         * Send an RTCP RR packet for a Reception stream.
       
   174         * @param TRtpId aRcvStreamId - [input] Reception stream ID
       
   175         * @return TInt - KErrNone if successful; system wide error code otherwise
       
   176         */
       
   177         TInt SendRtcpRrPacketL( TRtpId aRcvStreamId );
       
   178         
       
   179         /**
       
   180         * Send an RTCP SR packet for a Transmit stream.
       
   181         * @param TRtpId aTranStreamId - [input] Transmit stream ID
       
   182         * @return TInt - KErrNone if successful; system wide error code otherwise
       
   183         */
       
   184         TInt SendRtcpSrPacketL( TRtpId aTranStreamId );
       
   185 
       
   186         /**
       
   187         * Suspend RTCP sending on/off, calculations will continue. 
       
   188         * @param TRtpId aSessionId - [input] RTP Session ID
       
   189         * @param TBool aAutoSending - [input] Auto sending flag. 
       
   190         *							  ETrue:  RTCP sending will be scheduled normally
       
   191         *							  EFalse: RTCP sending will be suspended
       
   192         * @return TInt - KErrNone if successful; KErrNotFound if invalid session id;
       
   193         *				 KErrNotSupported if RTCP disabled;  system wide error code otherwise				
       
   194         */
       
   195         TInt SuspendRtcpSending( TRtpId aSessionId, TBool aAutoSending );
       
   196         
       
   197 		/**
       
   198         * Gets the status of automatic RTCP sending.
       
   199         * @param TRtpId aSessionId - [input] RTP Session ID
       
   200         * @param TBool aAutoSending - [output] ETrue: RTCP atuo sending is on 
       
   201         *				  					   EFalse: RTCP auto sending is off
       
   202  		* @return TInt - KErrNone if successful; KErrNotFound if invalid session id;
       
   203         *				 KErrNotSupported if RTCP disabled;  system wide error code otherwise
       
   204         */
       
   205         TInt IsRtcpSendingSuspended( TRtpId aSessionId, TBool& aAutoSending );
       
   206 
       
   207         TRtpId GetSessionId( TRtpId aStreamId );
       
   208 
       
   209         RSocket* GetRtpSocket( TRtpId aSessionId );
       
   210 
       
   211         RSocket* GetRtcpSocket( TRtpId aSessionId );
       
   212 
       
   213         TInt GetStreamStatistics( TRtpId aStreamId, TRtpPeerStat& aStat );
       
   214 
       
   215         TUint32 GetSamplingRate( TUint8 aPayloadType );
       
   216 
       
   217         TInt SetSamplingRate( TUint8 aPayloadType, TUint32 aSampleRate );
       
   218 
       
   219         TInt SetRtcpParameters( TRtpId aSessionId, const TRtcpParams& aRtcpParams );
       
   220 
       
   221     private:
       
   222         CRtpManager( MRtpErrNotify& aErrNotify );
       
   223         void ConstructL( void );
       
   224         CRtpSession* GetSession( TRtpId aSessionId );
       
   225 
       
   226         TRtpId AssignUniqueID();
       
   227         TInt AddRtpObject( TArrayStore aArrayID );
       
   228         TInt FindRtpObject( const TRtpId aMagicKey, TUint& aSessionAddress );
       
   229         TInt RemoveRtpObject( const TRtpId aMagicKey, const TObjectType aObjectType );
       
   230         void RemoveRtpAllObjects();
       
   231     
       
   232         /*
       
   233         * Opens the socket server and the connection
       
   234         * @return KErrNone if successful, system error code otherwise
       
   235         */
       
   236         TInt PrepareConnection( TCommDbConnPref& aPrefs, TInt aIapId );
       
   237 
       
   238         /*
       
   239         * @return Internet Access Point ID of iConn
       
   240         */
       
   241         TInt GetIapId( TUint32& aIapId );
       
   242         
       
   243         TInt AddStreamToSession(TRtpId aSessionId, TRtpId aStreamId);
       
   244 
       
   245         void CheckSdesCName();
       
   246         
       
   247     private:   // data
       
   248         TBool iStandardRtp;
       
   249         TBool iEnableRtcp;
       
   250         RLibrary iLibrary;
       
   251 
       
   252         RSocketServ iSocketServ;
       
   253         RConnection iConn;
       
   254         RSocketServ* iSocketServPtr;  // Don't use until future
       
   255         RConnection* iConnPtr;    // Don't use until future
       
   256         TBool iConnected;
       
   257 		TInt iIapId;
       
   258 
       
   259         TInetAddr iLocalAddr;
       
   260 
       
   261         CRtpSDES* iDefaultSdes;
       
   262 
       
   263         TRtpId iNumOfObjects;   // count of session and participants IDs assigned
       
   264         CArrayFixFlat<TArrayStore>* iSessionArray;   //keep track of all RTP session;
       
   265 
       
   266         TUint32 iProfileRTPTimeRates[KRtpMaxPayloadTypes];
       
   267 
       
   268         MRtpErrNotify& iErrNotify;
       
   269 
       
   270         TCommDbConnPref iPrefs;
       
   271     private:    
       
   272     #ifdef EUNIT_TESTING
       
   273 	  friend class UT_CRtpAPI;
       
   274 	  friend class UT_CRtpManager;
       
   275 	#endif     	    
       
   276         
       
   277     };
       
   278 
       
   279 #endif    // __RTPMANAGER_H
       
   280 
       
   281 // End of File