rtp/rtpstack/inc/rtpcommsend.h
changeset 0 307788aac0a8
equal deleted inserted replaced
-1:000000000000 0:307788aac0a8
       
     1 /*
       
     2 * Copyright (c) 2004-2008 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 RtpCommSend_H
       
    22 #define RtpCommSend_H
       
    23 
       
    24 #include <es_sock.h>
       
    25 #include <rtpdef.h>
       
    26 
       
    27 #include "rtpsenditem.h"
       
    28 #include "rtpcommdef.h"
       
    29 #include "rtputil.h"
       
    30 
       
    31 /**
       
    32 *  Class definition for sending
       
    33 *
       
    34 *  @lib RtpService.dll
       
    35 */
       
    36 class CRtpCommSend : public CActive
       
    37     {
       
    38     #if defined( _DEBUG ) && defined( RTP_UNIT_TEST )
       
    39     // Friend class used for testing
       
    40         friend class CRtpUtRtpCommSend;
       
    41     #endif 
       
    42     public:
       
    43         static CRtpCommSend* NewL( RSocket& aSocket, MRtpErrNotify& aErrNotify, 
       
    44                                    /*TInt aBufSize,*/ TInetAddr& aAddr ); 
       
    45 
       
    46         ~CRtpCommSend();
       
    47 
       
    48         TInt Send( const TDesC8& aPacket );
       
    49         void Send( const TDesC8& aPacket, TRequestStatus& aStatus );
       
    50         void CancelAsyncSend();
       
    51         void SetToAddress(TInetAddr& aAddr);
       
    52 
       
    53     protected: // from CActive
       
    54 
       
    55         /**
       
    56         * Cancel any outstanding operation
       
    57         */
       
    58         void DoCancel();
       
    59 
       
    60         /**
       
    61         * Called when operation complete
       
    62         */
       
    63         void RunL();
       
    64 
       
    65     private:
       
    66         CRtpCommSend( RSocket& aSocket, MRtpErrNotify& aErrNotify, TInetAddr& aAddr );
       
    67         void ConstructL( /*TInt aBufSize*/ );
       
    68 
       
    69         /**
       
    70         * Handle a 'write buffer empty' situation.
       
    71         */
       
    72         void SendNextPacket();
       
    73         
       
    74         /**
       
    75         * Remove Item From Queue
       
    76         */
       
    77         void RemoveFromQueue();
       
    78         
       
    79         /**
       
    80          * Complete and remove queue items.
       
    81          * @since S60 3.2.3
       
    82          * @param aError completion code
       
    83          */
       
    84         void CompleteAndRemoveRequests( TInt aError );
       
    85         
       
    86         /**
       
    87          * Complete client's request.
       
    88          * @since S60 3.2.3
       
    89          * @param aItem send item
       
    90          * @param aReason completion code
       
    91          */
       
    92         void CompleteClientRequest( CRtpSendItem& aItem, TInt aReason ) const;
       
    93 
       
    94     private: // Member data
       
    95         
       
    96         enum TWriteState 
       
    97             {
       
    98             ESending, EWaiting, ECommsFailed
       
    99             };
       
   100 
       
   101    
       
   102         RSocket&        iSocket;
       
   103         TInetAddr       iToAddr;
       
   104         TWriteState     iWriteStatus;
       
   105         TPtrC8          iBufPtr;  // As a data memeber to hold the packet point for
       
   106                                   // Asyn sending in case the sending packet is out of scope.
       
   107         MRtpErrNotify&  iRtpErrNotify; 
       
   108 	    TSglQue <CRtpSendItem> iSendQue;
       
   109         /** List iterator - needed to delete all the items */
       
   110 		TSglQueIter<CRtpSendItem> iQueueIter;
       
   111 		#ifdef EUNIT_TESTING
       
   112 	  	friend class UT_CRtpAPI;
       
   113 	  	friend class UT_CRtpSession;
       
   114 	  	friend class UT_CRtpSessionSrtp;
       
   115 	  	friend class UT_CRtpComm;
       
   116 		#endif     	    
       
   117            };
       
   118 
       
   119 #endif	// RtpCommSend_H