multimediacommscontroller/mmccrtpwrapper/inc/rtpmanager.h
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // This file provides the information required for building the whole of a rtpwrapper.
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file
       
    20 */
       
    21 
       
    22 #ifndef __RTP_MNGER_H__
       
    23 #define __RTP_MNGER_H__
       
    24 
       
    25 #include <e32std.h>
       
    26 #include <in_sock.h>
       
    27 #include <es_sock.h>
       
    28 
       
    29 #include "rtpapi.h"
       
    30 #include <rtp.h>
       
    31 
       
    32 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    33 #include <rtpsession_internal.h>
       
    34 #endif
       
    35 
       
    36 #include <srtpsession.h>
       
    37 #include <rtpprepostprocessingcallback.h>
       
    38 
       
    39 
       
    40 const TInt KDefaultStartRtpAddress  = 8000;
       
    41 const TInt KDefaultMaxRxSz          = 1250;
       
    42 const TUint KRtpDefaultBandWidth    = 64000;
       
    43  
       
    44 // Minimum bandwidth in bps
       
    45 const TUint KRtpMinimumBandWidth    = 8000;
       
    46  
       
    47 // RTCP minimum interval (ms) (default is 5 seconds)
       
    48 const TUint KRtpDefaultRtcpInterval = 5000;
       
    49 //Unspecified PayloadType
       
    50 const TInt KRtpPayloadTypeUnspecified = -1;
       
    51 
       
    52 const TInt KSrtpMaxAuthTagLength = 20;
       
    53 const TInt KSrtpMaxMKILen = 10;
       
    54 
       
    55 class CRtpManager;
       
    56 
       
    57 /* Node representing a pending RTP request.
       
    58  * When an Asynchronous send is requested the details are stored in this node
       
    59  * and then put in to a list. The head is scheduled for transmission 
       
    60  */
       
    61 class TRtpSendReqNode
       
    62 	{
       
    63 	public:
       
    64 	TSglQueLink iLink;
       
    65 	RRtpSendPacket iPktToSend;
       
    66 	TRequestStatus* iStatus;
       
    67 	};
       
    68 
       
    69 /* Note this 'T' Class. It donot own the Resources.
       
    70  * It is the responsibility of the creator to make sure
       
    71  * the resources are properly freed. By putting the resources
       
    72  * in this class the ownership is not transfered */
       
    73 NONSHARABLE_CLASS(CRtpSessionInfo) : public CBase, public MPrePostProcessingCallback
       
    74 	{
       
    75 	public:
       
    76 	TUint32 iKey; 
       
    77 	TInt iPortNumber; /* The RTP Port number used by this Session */
       
    78 	
       
    79 	#ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
       
    80 	RRtpSession iRtpSession; /* Session */
       
    81 	#else
       
    82 	RRtpSession_Internal iRtpSession; /* Session */
       
    83 	#endif	
       
    84 	
       
    85 	CSRTPSession* iSRTPSession;
       
    86 	TInt    iPayloadType; /* The Payload type for this SendStream */
       
    87 	RRtpSendSource iRtpSendSource;
       
    88 	CRtpManager* iRtpManager; /* To find our way back from callbacks */
       
    89 	MRtpObserver *iRtpObserver;
       
    90 	TBool         iRtcpEnabled;
       
    91 	MRtcpObserver *iRtcpObserver;
       
    92 	TBool iFirstPacketSent;
       
    93 
       
    94 	/* A session can have only one Payload type */
       
    95 	TUint32 iSamplingRate;
       
    96 	MNonRTPDataObserver *iNonRtpDataObserver;
       
    97 	TInetAddr iRemoteAddress;
       
    98 	TInetAddr iRemoteRTCPAddress;
       
    99 	/* TODO CleanThisUp!!! List of pending requests */
       
   100 	TSglQue<TRtpSendReqNode> *iPendingReqQue;
       
   101 	
       
   102 	TInt PreRtpProcessing(TDes8& aRTPPacket);
       
   103 	void PostRtpProcessing(TDes8& aRTPPacket);
       
   104 	TInt PreRtcpProcessing(TDes8& aRTPPacket);
       
   105 	void PostRtcpProcessing(TDes8& aRTPPacket);
       
   106 	
       
   107 	static CRtpSessionInfo* NewL();
       
   108 	void ConstructL();
       
   109 	
       
   110 	private:
       
   111 	CRtpSessionInfo():iFirstPacketSent(EFalse),iPayloadType(KRtpPayloadTypeUnspecified)
       
   112 		{
       
   113 		}
       
   114 
       
   115 	};
       
   116 
       
   117 /* Stores the Information regarding a Particular RTP recv Stream
       
   118  * belonging to a session */
       
   119 class TRtpStreamInfo
       
   120 	{
       
   121 public:
       
   122 	enum TStreamInfoState
       
   123 		{
       
   124 		/* Pre-Created->created before any new source was
       
   125 		 * detected. When a new Source is finally detected
       
   126 		 * this ID will be used. The state will change to
       
   127 		 * eStreamReadyToUse */
       
   128 		eStreamPreCreated,
       
   129 		/* Post Created stream: A new source was detected
       
   130 		 * but there were no pre created stream to assign this
       
   131 		 * stream to. When the appilcation calls CreateReceiveStream
       
   132 		 * then this stream will be picked up and its ID will be
       
   133 		 * returned( if the payload type matches). */
       
   134 		eStreamPostCreated,
       
   135 		/* ID is given to the Application and the RRtpReceiveSource
       
   136 		 * is valid */
       
   137 		eStreamReadyToUse
       
   138 		};
       
   139 
       
   140 	TUint32 iKey;
       
   141 	TUint32 iSessionKey; /* The Session to which this Stream belongs to */
       
   142 	TInt    iPayloadType;
       
   143 	TBool   iIsRecvStream;
       
   144 	TStreamInfoState  iState; 
       
   145 	RRtpReceiveSource iRecvSource; 
       
   146 	CRtpManager* iRtpManager; /* To find our way back from callbacks */
       
   147 	};
       
   148 
       
   149 /* This class ByPasses all the function calls to Symbian RTP Stack */
       
   150 class CRtpManager: public CBase
       
   151 	    {
       
   152     public:  // Constructors and destructor
       
   153 
       
   154         /**
       
   155         * Two-phased constructor.
       
   156         */
       
   157          static CRtpManager* NewL( MRtpErrNotify& aErrNotify );
       
   158 
       
   159         /**
       
   160         * Destructor.
       
   161         */
       
   162         virtual ~CRtpManager();
       
   163 
       
   164     public: 
       
   165 
       
   166         /**
       
   167         * Open and initialize the CRtpAPI object.
       
   168         * @param aSdesInfo - [input] SDES (Source Description)
       
   169         *   of the local participant (CName, Username, etc.)
       
   170         * @param aRtpPacketDll - [input] Path+file name of RTP packet
       
   171         *   formatting DLL to use; NULL to use standard RTP packet format
       
   172         * @param aRConnPtr - [input] Network connection to use;
       
   173         *   NULL to use default network connection.
       
   174         * @return KErrNone if successful; system wide error code otherwise
       
   175         */
       
   176          TInt OpenL( const TRtpSdesParams& aSdesInfo,
       
   177                              const TDesC* aRtpPacketDll,
       
   178                              const RSocketServ* aSocketServPtr,
       
   179                              const RConnection* aConnPtr );
       
   180 
       
   181         /**
       
   182         * Open and initialize the CRtpAPI object.
       
   183         * @param aIapId - [input] IAP ID. If -1, no IAP selection dialog
       
   184         *   will pop up. Instead, the default IAP will be used.
       
   185         * @return KErrNone if successful; system wide error code otherwise
       
   186         */
       
   187          TInt StartConnection( TInt aIapId = -1 );
       
   188 
       
   189         /**
       
   190         * Open and initialize the CRtpAPI object in asynchronous mode
       
   191         * @param aStatus - [output] On completion, will contain a status code:
       
   192         *   KErrNone if successful; system wide error code otherwise.
       
   193         * @param aIapId - [input] IAP ID. If -1, no IAP selection dialog
       
   194         *   will pop up. Instead, the default IAP will be used.
       
   195         * @return KErrNone if successful; system wide error code otherwise
       
   196         */
       
   197          TInt StartConnection( TRequestStatus& aStatus,
       
   198                                        TInt aIapId = -1 );
       
   199 
       
   200         /**
       
   201         * Cancels asynchoronous start of connection.
       
   202         * Any open requests will be completed with KErrCancel.
       
   203         * @return None
       
   204         */
       
   205          void CancelStart(); 
       
   206 
       
   207         /**
       
   208         * Close the CRtpAPI object.
       
   209         * @param None
       
   210         * @return None
       
   211         */
       
   212          void Close();
       
   213 
       
   214         /**
       
   215         * Set SDES (Source Description) information of the local participant.
       
   216         * Participant is defined as an application program and
       
   217         * only one local participant is allowed.
       
   218         * @param aSdesInfo - [input] SDES of the local participant
       
   219         *   (CName, Username, etc.).
       
   220         * @return None
       
   221         */
       
   222          void SetLocalSdes( const TRtpSdesParams& aSdesInfo );
       
   223 
       
   224         /**
       
   225         * Get the local IP address
       
   226         * @param None
       
   227         * @return local ip address.
       
   228         */
       
   229          TInetAddr& GetLocalIPAddressL();
       
   230 
       
   231         /**
       
   232         * Create a new RTP Session and return the Session ID as well as the
       
   233         * local port number assigned for RTP. RTP uses an even port number and
       
   234         * RTCP, if enabled, uses the next higher (odd) port number.
       
   235         * @param aSessionParams - [input] Session parameters
       
   236         * @param aPort - [input] Local port number to use for RTP;
       
   237         *                               0 to use default port number
       
   238         *                     - [output] port number assigned for RTP
       
   239         * @param aEnableRtcp - [input] ETrue to enable RTCP; EFalse to disable
       
   240         * @param aRtcpParams - [input] RTCP parameters to use;
       
   241         *    NULL to use default RTCP parameters
       
   242         * @return Identifier (ID) of RTP Session created if successful;
       
   243         *    KNullId otherwise
       
   244         */
       
   245          TRtpId CreateSessionL(
       
   246                             const TCreateSessionParams& aSessionParams,
       
   247                             TUint& aPort,
       
   248                             TBool aEnableRtcp,
       
   249                             const TRtcpParams* aRtcpParams );
       
   250         /**
       
   251         * Create a new, secure RTP Session and return the Session ID as well as the
       
   252         * local port number assigned for RTP. RTP uses an even port number and
       
   253         * RTCP, if enabled, uses the next higher (odd) port number.
       
   254         * User is expected to create corresponding SRTP session prior to calling this
       
   255         * function. 
       
   256         * @param aSessionParams - [input] Session parameters
       
   257         * @param aPort - [input] Local port number to use for RTP;
       
   258         *                               0 to use default port number
       
   259         *                     - [output] port number assigned for RTP
       
   260         * @param aEnableRtcp - [input] ETrue to enable RTCP; EFalse to disable
       
   261         * @param aRtcpParams - [input] RTCP parameters to use;
       
   262         *    NULL to use default RTCP parameters
       
   263         * @param aSession - [input] SRTP session to be used by this RTP session.
       
   264         * @return Identifier (ID) of RTP Session created if successful;
       
   265         *    KNullId otherwise
       
   266         */
       
   267 
       
   268          TRtpId CreateSessionL( 
       
   269 	                const TCreateSessionParams& aSessionParams, 
       
   270 	                TUint& aPort, 
       
   271 	                TBool aEnableRtcp, 
       
   272 	                const TRtcpParams* aRtcpParams, 
       
   273 	                CSRTPSession& aSession); 
       
   274                             
       
   275 
       
   276         /**
       
   277         * Start an RTP Session. If enabled, RTCP associated with the given
       
   278         * session is also started.
       
   279         * @param aSessionId - [input] Session ID
       
   280         * @return KErrNone if successful; system wide error code otherwise
       
   281         */
       
   282          TInt StartSession( TRtpId aSessionId );
       
   283 
       
   284         /**
       
   285         * Close an RTP Session.
       
   286         * @param aSessionId - [input] Session ID
       
   287         * @return None
       
   288         */
       
   289          void CloseSession( TRtpId aSessionId );
       
   290 
       
   291         /**
       
   292         * Set remote IP address and port number to RTP Session.
       
   293         * Port number for RTP must be an even number and the corresponding
       
   294         * RTCP, if enabled, will be set to use the next higher (odd) port.
       
   295         * @param aSessionId - [input] RTP Session ID
       
   296         * @param aRemoteAddr - [input] Remote IP address & port number for RTP
       
   297         * @return KErrNone if successful; system wide error code otherwise
       
   298         */
       
   299          TInt SetRemoteAddress( TRtpId aSessionId,
       
   300                                         const TInetAddr& aRemoteAddr );
       
   301 
       
   302         /**
       
   303         * Set remote RTCP IP address and port number to RTP Session accoring to RFC 3605
       
   304         * i.e. this should be used if RTCP port is different than RTP port + 1
       
   305         * @param TRtpId aSessionId - [input] RTP Session ID
       
   306         * @param TInetAddr& aRemoteAddr - [input] Remote IP address & port
       
   307         *                                 number for RTP
       
   308         * @return TInt - KErrNone if successful; KErrNotFound if invalid session id;
       
   309         *				 KErrNotSupported if RTCP disabled; system wide error code otherwise
       
   310         */
       
   311          TInt SetRemoteRtcpAddress( TRtpId aSessionId, const TInetAddr& aRemoteRtcpAddr );
       
   312         
       
   313         /**
       
   314         * Create a Receive stream for an RTP Session and return the stream
       
   315         * ID which is unique for all RTP Sessions.
       
   316         * @param aSessionId - [input] RTP Session ID
       
   317         * @param aParams - [input] Receive stream parameters
       
   318         * @return Stream ID if successful; KNullId otherwise
       
   319         */
       
   320          TRtpId CreateReceiveStreamL( TRtpId aSessionId,
       
   321                             const TRcvStreamParams& aParams );
       
   322 
       
   323         /**
       
   324         * Create a Transmit stream for an RTP Session and return the stream
       
   325         * ID which is unique for all RTP Sessions. SSRC value assigned for the
       
   326         * very first Transmit stream will be the same as the default SSRC
       
   327         * value reserved internally by CreateSession function. This function
       
   328         * is normally used to create a transmit stream where SSRC value is
       
   329         * randomly generated.
       
   330         * @param aSessionId - [input] RTP Session ID
       
   331         * @param aParams - [input] Transmit stream parameters
       
   332         * @param aSSRC - [output] SSRC value assigned
       
   333         * @return Stream ID if successful; KNullId otherwise
       
   334         */
       
   335          TRtpId CreateTransmitStreamL( TRtpId aSessionId,
       
   336                             const TTranStreamParams& aParams,
       
   337                             TRtpSSRC& aSSRC );
       
   338 
       
   339         /**
       
   340         * Create a Transmit stream, with a given SSRC value, for an RTP Session
       
   341         * and return the stream ID which is unique for all RTP Sessions. This
       
   342         * extended function is used for a special case where a specific SSRC
       
   343         * value needs to be associated with the transmit stream being created,
       
   344         * e.g. for retransmission purpose.
       
   345         * @param aSessionId - [input] RTP Session ID
       
   346         * @param aParams - [input] Transmit stream parameters
       
   347         * @param aSsrc - [input] SSRC value to use
       
   348         * @return Stream ID if successful; KNullId otherwise
       
   349         */
       
   350          TRtpId CreateTransmitStreamExtL( TRtpId aSessionId,
       
   351                             const TTranStreamParams& aParams,
       
   352                             const TRtpSSRC aSSRC );
       
   353 
       
   354         /**
       
   355         * Close a Transmit or Receive stream.
       
   356         * @param TRtpId aStreamId - [input] ID of stream to close
       
   357         * @return None
       
   358         */
       
   359          void CloseStream( TRtpId aStreamId );
       
   360 
       
   361         /**
       
   362         * Register a callback object for receiving RTP data packets from an RTP
       
   363         * Session. Only one receiver callback object is allowed to be
       
   364         * registered for one Session.
       
   365         * MRtpObserver::RtpPacketReceived function from aRtpObserver object is
       
   366         * called when an RTP data packet is received.
       
   367         * @param aSessionId - [input] RTP Session ID
       
   368         * @param aRtpObserver - [input] Callback object to receive RTP packets
       
   369         * @return KErrNone if successful; system wide error code otherwise
       
   370         */
       
   371          TInt RegisterRtpObserver( TRtpId aSessionId,
       
   372                                            MRtpObserver& aRtpObserver );
       
   373 
       
   374         /**
       
   375         * Unregister RTP observer callback object associated with an RTP
       
   376         * session.
       
   377         * @param aSessionId - [input] RTP Session ID
       
   378         * @return None
       
   379         */
       
   380          void UnregisterRtpObserver( TRtpId aSessionId );
       
   381 
       
   382         /**
       
   383         * Sets/resets the observer for the non-RTP data.
       
   384         * Only one receiver callback object is allowed to be
       
   385         * registered for one Session.
       
   386         * MNonRTPDataObserver::NonRTPDataReceived or
       
   387         * MNonRTPDataObserver::NonRTCPDataReceived from 
       
   388         * aNonRTPDataObserver object is
       
   389         * called when a non-RTP data packet is received.
       
   390         * @param aNonRTPDataObserver an observer, 0-pointer resets the observer
       
   391         * @return KErrNotFound if non-existing session-ID provided, system-wide error code otherwise. KErrNone if successfull.
       
   392         */
       
   393          TInt SetNonRTPDataObserver( TRtpId aSessionId, 
       
   394                                     MNonRTPDataObserver* aNonRTPDataObserver );
       
   395 
       
   396         /**
       
   397         * Send an RTP data packet in a Transmit stream synchronously.
       
   398         * @param aTranStreamId - [input] ID of Transmit stream
       
   399         * @param aHeaderInfo - [input] Header information of RTP data packet
       
   400         * @param aPayloadData - [input] Payload data of RTP data packet
       
   401         * @return KErrNone if successful; system wide error code otherwise
       
   402         */
       
   403          TInt SendRtpPacket( TRtpId aTranStreamId,
       
   404                                      const TRtpSendHeader& aHeaderInfo,
       
   405                                      const TDesC8& aPayloadData );
       
   406 
       
   407         /**
       
   408         * Send an RTP data packet in a Transmit stream asynchronously.
       
   409         * @param TRtpId aTranStreamId - [input] ID of Transmit stream
       
   410         * @param aHeaderInfo - [input] Header information
       
   411         *                                      of RTP data packet to send
       
   412         * @param aPayloadData - [input] Payload data of RTP data packet to send
       
   413         * @param aStatus - [output] On completion, will contain a status code:
       
   414         *    KErrNone if successful; system wide error code otherwise
       
   415         * @return KErrNone if successful; system wide error code otherwise
       
   416         */
       
   417          TInt SendRtpPacket( TRtpId aTranStreamId,
       
   418                                      const TRtpSendHeader& aHeaderInfo,
       
   419                                      const TDesC8& aPayloadData,
       
   420                                      TRequestStatus& aStatus );
       
   421 
       
   422         /**
       
   423         * Send an RTP data packet asynchronously, with a given sequence number,
       
   424         * in a Transmit stream mainly for retransmission purpose.
       
   425         * @param aTranStreamId - [input] ID of Transmit stream
       
   426         * @param aSequenceNum - [input] Sequence number to use
       
   427         * @param aHeaderInfo - [input] Header information of RTP data packet
       
   428         * @param aPayloadData - [input] Payload data of RTP data packet to send
       
   429         * @param aStatus - [output] On completion, will contain a status code:
       
   430         *    KErrNone if successful; system wide error code otherwise
       
   431         * @return KErrNone if successful; system wide error code otherwise
       
   432         */
       
   433          TInt SendRtpPacket( TRtpId aTranStreamId,
       
   434                                      TRtpSequence aSequenceNum,
       
   435                                      const TRtpSendHeader& aHeaderInfo,
       
   436                                      const TDesC8& aPayloadData,
       
   437                                      TRequestStatus& aStatus );
       
   438 
       
   439 
       
   440         /**
       
   441         * Send a non-RTP (control) data packet asynchronously
       
   442         * @param aSessionId - [input] RTP Session ID
       
   443         * @param aUseRTPSocket - [input] use RTP/RTCP socket
       
   444         * @param aData - [input] non-RTP data packet to send
       
   445         * @param aStatus - [output] On completion, will contain a status code:
       
   446         *    KErrNone if successful; system wide error code otherwise
       
   447         * @return KErrNone if successful; system wide error code otherwise
       
   448         */
       
   449          void SendDataL( TRtpId aSessionId,
       
   450                                 TBool aUseRTPSocket,
       
   451                                 const TDesC8& aData,
       
   452                                 TRequestStatus& aStatus );
       
   453 
       
   454         /**
       
   455         * Cancel an outstanding SendRtpPacket() operation.
       
   456         * @param TRtpId aSessionId - [input] RTP Session ID
       
   457         * @return None
       
   458         */
       
   459          void CancelSend( TRtpId aSessionId );
       
   460 
       
   461         /**
       
   462         * Register a callback object for receiving RTCP packets associated with
       
   463         * a given RTP Session. Only one observer callback object is allowed to
       
   464         * be registered. One of aRtcpObserver object's callback functions is
       
   465         * called when an RTCP packet of that type is received.
       
   466         * @param aSessionId - [input] RTP Session ID
       
   467         * @param aObserver - [input] Callback object to receive RTCP packets
       
   468         * @return KErrNone if successful; system wide error code otherwise.
       
   469         */
       
   470          TInt RegisterRtcpObserver( TRtpId aSessionId,
       
   471                                             MRtcpObserver& aRtcpObserver );
       
   472 
       
   473         /**
       
   474         * Unregister RTCP observer callback object associated with an RTP
       
   475         * session.
       
   476         * @param aSessionId - [input] RTP Session ID
       
   477         * @return None
       
   478         */
       
   479          void UnregisterRtcpObserver( TRtpId aSessionId );
       
   480 
       
   481         /**
       
   482         * Send an RTCP BYE packet for a Transmit stream.
       
   483         * @param aTranStreamId - [input] Transmit stream ID
       
   484         * @param aReason - [input] Reason for leaving
       
   485         * @return KErrNone if successful; system wide error code otherwise
       
   486         */
       
   487          TInt SendRtcpByePacket( TRtpId aTranStreamId,
       
   488                                          const TDesC8& aReason );
       
   489 
       
   490         /**
       
   491         * Send an RTCP APP packet for a Transmit stream.
       
   492         * @param TRtpId aTranStreamId - [input] Transmit stream ID
       
   493         * @param TRtcpApp aApp - [input] APP packet to send
       
   494         * @return KErrNone if successful; system wide error code otherwise
       
   495         */
       
   496          TInt SendRtcpAppPacket( TRtpId aTranStreamId,
       
   497                                          const TRtcpApp& aApp );
       
   498 
       
   499         /** 
       
   500         * Send an RTCP RR packet for a Reception stream.
       
   501         * @param TRtpId aRcvStreamId - [input] Reception stream ID
       
   502         * @return TInt - KErrNone if successful; system wide error code otherwise
       
   503         */
       
   504          TInt SendRtcpRrPacket( TRtpId aRcvStreamId );
       
   505         
       
   506         /** 
       
   507         * Send an RTCP SR packet for a Transmit stream.
       
   508         * @param TRtpId aTranStreamId - [input] Transmit stream ID
       
   509         * @return TInt - KErrNone if successful; system wide error code otherwise
       
   510         */
       
   511          TInt SendRtcpSrPacket( TRtpId aTranStreamId );
       
   512 
       
   513 		/** 
       
   514         * Suspend RTCP sending on/off, calculations will continue. 
       
   515         * @param TRtpId aSessionId - [input] RTP Session ID
       
   516         * @param TBool aAutoSending - [input] Auto sending flag. 
       
   517         *							  ETrue:  RTCP sending will be scheduled normally
       
   518         *							  EFalse: RTCP sending will be suspended
       
   519         * @return TInt - KErrNone if successful; KErrNotFound if invalid session id;
       
   520         *				 KErrNotSupported if RTCP disabled;  system wide error code otherwise				
       
   521         */
       
   522          TInt SuspendRtcpSending( TRtpId aSessionId, TBool aAutoSending );
       
   523         
       
   524 		/** 
       
   525         * Gets the status of automatic RTCP sending.
       
   526         * @param TRtpId aSessionId - [input] RTP Session ID
       
   527         * @param TBool aAutoSending - [output] ETrue: RTCP auto sending is on 
       
   528         *				  					   EFalse: RTCP auto sending is off
       
   529  		* @return TInt - KErrNone if successful; KErrNotFound if invalid session id;
       
   530         *				 KErrNotSupported if RTCP disabled;  system wide error code otherwise
       
   531         */
       
   532          TInt IsRtcpSendingSuspended( TRtpId aSessionId, TBool& aAutoSending );
       
   533 
       
   534         /**
       
   535         * Get the session ID of a stream, which belongs to that session.
       
   536         * @param aStreamId - [input] ID of a stream
       
   537         * @return Identifier (ID) of RTP Session if found; KNullId otherwise
       
   538         */
       
   539          TRtpId GetSessionId( TRtpId aStreamId );
       
   540 
       
   541         /**
       
   542         * Get address of Socket object used by a given RTP Session
       
   543         * to send/receive RTP data packets.
       
   544         * @param aSessionId - [input] RTP Session ID
       
   545         * @return Address of Socket object used if successful; NULL otherwise
       
   546         */
       
   547          RSocket* GetRtpSocket( TRtpId aSessionId );
       
   548 
       
   549         /**
       
   550         * Get address of Socket object used by a given RTP Session
       
   551         * to send/receive RTCP control packets.
       
   552         * @param aSessionId - [input] RTP Session ID
       
   553         * @return Address of Socket object used if successful; NULL otherwise
       
   554         */
       
   555          RSocket* GetRtcpSocket( TRtpId aSessionId );
       
   556 
       
   557         /**
       
   558         * Retrieve statistical information for a stream
       
   559         * based on the reports from RTCP SR & RR packets.
       
   560         * @param aStreamId - [input] ID of stream
       
   561         * @param aStat - [output] Statistical information
       
   562         * @return KErrNone if successful; system wide error code otherwise
       
   563         */
       
   564          TInt GetStreamStatistics( TRtpId aStreamId,
       
   565                                            TRtpPeerStat& aStat );
       
   566 
       
   567         /**
       
   568         * Get sampling rate setting for a payload type.
       
   569         * @param aPayloadType - [input] Payload type
       
   570         * @return Sampling rate in Hz; 0 if payload type setting not found
       
   571         */
       
   572          TUint32 GetSamplingRate( TUint8 aPayloadType );
       
   573 
       
   574         /**
       
   575         * Set sampling rate for a payload type.
       
   576         * @param aPayloadType - [input] Payload type
       
   577         * @param aSamplingRate - [input] Sampling rate in Hz
       
   578         * @return KErrNone if successful; system wide error code otherwise
       
   579         */
       
   580          TInt SetSamplingRate( TUint8 aPayloadType,
       
   581                                        TUint32 aSamplingRate );
       
   582 
       
   583         /**
       
   584         * Set RTCP parameters for a given RTP Session.
       
   585         * This function does nothing if RTCP was not enabled previously.
       
   586         * @param aSessionId - [input] RTP Session ID
       
   587         * @param aRtcpParams - [input]  RTCP parameters to use
       
   588         * @return KErrNone if successful; system wide error code otherwise
       
   589         */
       
   590          TInt SetRtcpParameters( TRtpId aSessionId,
       
   591                                          const TRtcpParams& aRtcpParams );
       
   592 
       
   593         /**
       
   594         * Synchronous custom command interface for future extensions.
       
   595         * Input/output data and return value are defined by each custom command
       
   596         * @param aFunction - [input] Function ID
       
   597         * @param aInputData1 - [input] Input data #1; NULL if not used
       
   598         * @param aInputData2 - [input] Input data #2; NULL if not used
       
   599         * @param aOutputData - [output] Output data; NULL if not used
       
   600         * @return Defined by the function
       
   601         */
       
   602          TInt CustomCommandSync( TInt aFunction,
       
   603                                          const TDesC8& aInputData1,
       
   604                                          const TDesC8& aInputData2,
       
   605                                          TDes8& aOutputData );
       
   606 
       
   607         /**
       
   608         * ASynchronous custom command interface for future extensions.
       
   609         * Input/output data and return value are defined by each custom command
       
   610         * @param aFunction - [input] Function ID
       
   611         * @param aInputData1 - [input] Input data #1; NULL if not used
       
   612         * @param aInputData2 - [input] Input data #2; NULL if not used
       
   613         * @param aOutputData - [output] Output data; NULL if not used
       
   614         * @param aStatus - [output] On completion, will contain a status code:
       
   615         *    KErrNone if successful; system wide error code otherwise
       
   616         * @return Defined by the function
       
   617         */
       
   618          TInt CustomCommandAsync( TInt aFunction,
       
   619                                           const TDesC8& aInputData1,
       
   620                                           const TDesC8& aInputData2,
       
   621                                           TDes8& aOutputData,
       
   622                                           TRequestStatus& aStatus );
       
   623     private:
       
   624         /**
       
   625         * C++ default constructor.
       
   626         */
       
   627         CRtpManager();
       
   628 
       
   629         /**
       
   630         * By default Symbian 2nd phase constructor is private.
       
   631         */
       
   632         void ConstructL( MRtpErrNotify& aErrNotify );
       
   633 
       
   634         /* Returns the Session Index or KErrnotFound if Session cannot be found */
       
   635         TInt FindSession(TRtpId aSessionId);
       
   636 		
       
   637         /* Returns the session Index or leaves if not found */
       
   638         TInt FindSessionL(TRtpId aSessionId);
       
   639         
       
   640         /* Returns the stream Index or KErrnotFound if stream cannot be found */
       
   641         TInt FindStream(TRtpId aStreamId);
       
   642         
       
   643         /* Returns the stream Index or leaves if not found */
       
   644         TInt FindStreamL(TRtpId aStreamId);
       
   645 		
       
   646 		void RegisterEventsOnSessionL(CRtpSessionInfo *aSessionInfo);
       
   647 		void RegisterEventsOnRtpRcvSourceL(RRtpReceiveSource &aRcvSrc, TRtpStreamInfo *apStrmInfo);
       
   648 		void HandleNonRtpDataL(CRtpSessionInfo *apSessionInfo);
       
   649 		void HandleNonRtcpDataL(CRtpSessionInfo *apSessionInfo);
       
   650 		
       
   651 		TInt GetDefaultIapIdL();
       
   652 		
       
   653 		void MakeACnameL(TDes8 &aCname);
       
   654 		
       
   655 		TInt SendRtpDataFromPendingQueue(CRtpSessionInfo *aSessInfo);
       
   656 		/* Callback Handlers */
       
   657 		static void RtpSessionLevelCB(CRtpSessionInfo* apSessionInfo, const TRtpEvent& aEvent);
       
   658 		static void RtpStreamLevelCB(TRtpStreamInfo* apSessionInfo, const TRtpEvent& aEvent);
       
   659 		
       
   660     private:    // Data
       
   661        TBool     iOwnsSocketServer;
       
   662        TBool     iOwnsConnection;
       
   663        TInetAddr iSockAddr;
       
   664        MRtpErrNotify *iRtpErrNotify; 
       
   665 	   RSocketServ   *iSocketServ;
       
   666 	   RConnection   *iConnection;
       
   667 	   TRtpSdesParams iSdesInfo;   //This needs to be looked into.
       
   668 	   RPointerArray<CRtpSessionInfo> iRtpSessionArr;
       
   669 	   RArray<TRtpStreamInfo> iRtpStreamsArr;
       
   670 	   TInt   iIapId;
       
   671     private:
       
   672     #ifdef __RTPWRAPPER_UNITTEST__
       
   673         friend class CRtpManager_GetLocalIPAddress;
       
   674         friend class CRtpManager_CreateTransmitStream;
       
   675         friend class CRtpManager_CreateReceiveStream;
       
   676         friend class CRtpManager_SendData;
       
   677         friend class CRtpManager_CancelSend;
       
   678         friend class CRtpManager_SendRtcpByePacket;
       
   679         friend class CRtpManager_SendRtcpSrPacket;
       
   680     #endif
       
   681     #ifdef EUNIT_TESTING
       
   682 	  friend class UT_CRtpAPI;
       
   683 	#endif     	    
       
   684 };
       
   685 
       
   686 /* Loging Macros */
       
   687 // Logging
       
   688 
       
   689 // Logging
       
   690 #ifdef _DEBUG
       
   691 
       
   692     #ifdef LOG_TO_DEBUGOUT
       
   693     #include <e32debug.h>
       
   694         #define __RTP_LOG_STMT(stmt)    stmt
       
   695         #define LOG_FUNC_ENTRY(text) RDebug::Print(_L("-->>"L##text));
       
   696         #define LOG_FUNC_EXIT(text) RDebug::Print(_L("<<--"L##text));
       
   697         #define __RTP_LOG(text) RDebug::Print(_L(text));
       
   698         #define __RTP_LOG1(text, a) RDebug::Print(_L(text), a);
       
   699         #define __RTP_LOG2(text, a, b) RDebug::Print(_L(text), a, b);
       
   700 
       
   701     #else
       
   702     #include <flogger.h>
       
   703         #define __RTP_LOG_STMT(stmt)    stmt
       
   704         #define KRtpWrapperLogDir   _L("rtp")
       
   705         #define KRtpWrapperLogFileName _L("rtpcorelog.txt")
       
   706         #define LOG_FUNC_ENTRY(text) RFileLogger::WriteFormat(KRtpWrapperLogDir, KRtpWrapperLogFileName, EFileLoggingModeAppend,_L("-->>"L##text));
       
   707         #define LOG_FUNC_EXIT(text) RFileLogger::WriteFormat(KRtpWrapperLogDir, KRtpWrapperLogFileName, EFileLoggingModeAppend,_L("<<--"L##text));
       
   708         #define __RTP_LOG(text) RFileLogger::WriteFormat(KRtpWrapperLogDir, KRtpWrapperLogFileName, EFileLoggingModeAppend, _L(text));
       
   709         #define __RTP_LOG1(text, a) RFileLogger::WriteFormat(KRtpWrapperLogDir, KRtpWrapperLogFileName, EFileLoggingModeAppend, _L(text), a);
       
   710         #define __RTP_LOG2(text, a, b) RFileLogger::WriteFormat(KRtpWrapperLogDir, KRtpWrapperLogFileName, EFileLoggingModeAppend, _L(text), a, b);
       
   711     #endif
       
   712     
       
   713 #else
       
   714     #ifndef __RTP_LOG_LOG
       
   715     #include <flogger.h>
       
   716         #define LOG_FUNC_ENTRY(text) 
       
   717         #define LOG_FUNC_EXIT(text) 
       
   718         #define __RTP_LOG_STMT(stmt)
       
   719         #define __RTP_LOGNoInd(text)
       
   720         #define __RTP_LOG(text)
       
   721         #define __RTP_LOG1(text, a)
       
   722         #define __RTP_LOG2(text, a, b)
       
   723     #endif
       
   724     
       
   725 #endif
       
   726 
       
   727 
       
   728 #endif