natfw/natfwstunplugin/inc/natfwstunplugin.h
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2006 - 2007 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:    Implements NAT Plug-in interface, which client uses to send
       
    15 *                STUN requests. Forwards client requests to Stun Connection
       
    16 *                Handler.
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 #ifndef C_NATFWSTUNPLUGIN_H
       
    24 #define C_NATFWSTUNPLUGIN_H
       
    25 
       
    26 #include <e32base.h>
       
    27 #include "natfwpluginapi.h"
       
    28 
       
    29 class CNATFWStunConnectionHandler;
       
    30 
       
    31 
       
    32 /**
       
    33  *  Implements NAT Plug-in interface
       
    34  *
       
    35  *  The client uses this interface to send STUN requests. Forwards
       
    36  *  client requests to STUN Connection Handler.
       
    37  *
       
    38  *  @lib stunplugin.lib
       
    39  *  @since S60 v3.2
       
    40  */
       
    41 class CNATFWStunPlugin : public CNATFWPluginApi
       
    42     {
       
    43 
       
    44 public:
       
    45 
       
    46     /**
       
    47      * Creates a new instance of NAT FW STUN Plug-in class.
       
    48      *
       
    49      * @since S60 v3.2
       
    50      * @param aInitParams Initial parameters that will be given to
       
    51      *                    STUN Connection Handler class.
       
    52      * @return A new instance, ownership is transferred.
       
    53      */
       
    54     static CNATFWStunPlugin* NewL( TAny* aInitParams );
       
    55 
       
    56     ~CNATFWStunPlugin();
       
    57 
       
    58     /**
       
    59      * From CNATFWPluginApi.
       
    60      * 
       
    61      * Finds out a STUN Server and establishes a connection to it.
       
    62      * 
       
    63      * MNATFWPluginObserver::Notify is called with event code EServerConnected
       
    64      * when connecting has completed.
       
    65      *
       
    66      * FetchCandidateL can be called after successful connecting.
       
    67      *
       
    68      * @since   S60 v3.2
       
    69      * @param   aSocketServ         The handle to socket server session
       
    70      * @param   aConnectionName     The unique name of the RConnection
       
    71      */
       
    72     void ConnectServerL( const RSocketServ& aSocketServ,
       
    73         const TName& aConnectionName );
       
    74 
       
    75     /**
       
    76      * From CNATFWPluginApi.
       
    77      *
       
    78      * Fetches available candidates for a specified stream using given
       
    79      * retransmission timeout for STUN transactions. 
       
    80      * 
       
    81      * RTO value 0 indicates default retransmission timeout as specified
       
    82      * in STUN specification.
       
    83      * 
       
    84      * @since   S60 v3.2
       
    85      * @param   aStreamId           Stream identifier
       
    86      * @param   aRtoValue           Retransmission timeout in milliseconds
       
    87      * @param   aAddrFamily         KAFUnspec / KAfInet / KAfInet6
       
    88      * @leave   KErrNotSupported NAT Protocol plugin does not support
       
    89      * operation.
       
    90      */
       
    91     void FetchCandidateL( TUint aStreamId, TUint aRtoValue,
       
    92         TUint aAddrFamily );
       
    93 
       
    94     /**
       
    95      * From CNATFWPluginApi.
       
    96      *
       
    97      * Fetches available candidates for a specified stream using given
       
    98      * retransmission timeout for STUN transactions. 
       
    99      * 
       
   100      * RTO value 0 indicates default retransmission timeout as specified
       
   101      * in STUN specification.
       
   102      * 
       
   103      * Candidate is fetched using given base address as a local endpoint for
       
   104      * a multiplexer connection.
       
   105      * 
       
   106      * @since   S60 v3.2
       
   107      * @param   aStreamId           Stream identifier
       
   108      * @param   aRtoValue           Retransmission timeout in milliseconds
       
   109      * @param   aBaseAddr           Address from which to create connection
       
   110      */
       
   111     void FetchCandidateL( TUint aStreamId, TUint aRtoValue,
       
   112         const TInetAddr& aBaseAddr );
       
   113 
       
   114     /**
       
   115      * From CNATFWPluginApi.
       
   116      *
       
   117      * Enables/disables media receiving for the specified local candidate.
       
   118      * 
       
   119      * Only those candidates given with MNATFWPluginObserver callbacks
       
   120      * can be controlled. NATFW stream can have only one active candidate
       
   121      * at a time. In other words, exactly one local candidate can be used
       
   122      * for media delivery in receiving, sending or both directions.
       
   123      * 
       
   124      * MNATFWPluginObserver::Notify is called with event code
       
   125      * EReceivingActivated/EReceivingDeactivated when status change has 
       
   126      * completed. While activated incoming data is delivered to the media
       
   127      * engine.
       
   128      * 
       
   129      * Receiving must be disabled prior to deleting plugin so that all
       
   130      * resources can be freed.
       
   131      * 
       
   132      * Note: If TURN is used media cannot be delivered until remote address
       
   133      * is known.
       
   134      * 
       
   135      * @since   S60 v3.2
       
   136      * @pre     FetchCandidate(/s) and possible ICE processing have completed
       
   137      * @param   aLocalCandidate The local end point for a media
       
   138      * @param   aState          The receiving state
       
   139      */
       
   140     void SetReceivingStateL( const CNATFWCandidate& aLocalCandidate,
       
   141         TNATFWStreamingState aState );
       
   142     
       
   143     /**
       
   144      * From CNATFWPluginApi.
       
   145      *
       
   146      * Enables/disables media sending from the specified local candidate.
       
   147      * 
       
   148      * Only those candidates given with MNATFWPluginObserver callbacks
       
   149      * can be controlled. NATFW stream can have only one active candidate
       
   150      * at a time. In other words, exactly one local candidate can be used
       
   151      * for media delivery in receiving, sending or both directions.
       
   152      * 
       
   153      * Sending must be disabled prior to deleting plugin so that all
       
   154      * resources can be freed.
       
   155      * 
       
   156      * MNATFWPluginObserver::Notify is called with event code
       
   157      * ESendingActivated/ESendingDeactivated when status change has 
       
   158      * completed. While activated outgoing data from media engine is delivered
       
   159      * to the specified remote address.
       
   160      * 
       
   161      * @since   S60 v3.2
       
   162      * @pre     FetchCandidate(/s) and possible ICE processing have completed
       
   163      * @param   aLocalCandidate The local end point for a media
       
   164      * @param   aState          The sending state
       
   165      * @param   aDestAddr       The remote end point for a media
       
   166      */
       
   167     void SetSendingStateL( const CNATFWCandidate& aLocalCandidate, 
       
   168         TNATFWStreamingState aState, const TInetAddr& aDestAddr );
       
   169 
       
   170     /**
       
   171      * From CNATFWPluginApi.
       
   172      *
       
   173      * Gets identifier for a connection that is associated with the
       
   174      * given local end point.
       
   175      *
       
   176      * @since   S60 v3.2
       
   177      * @param   aLocalCandidate     The local end point for a media
       
   178      * @param   aConnectionId       Reference to found id
       
   179      */
       
   180     void GetConnectionIdL( const CNATFWCandidate& aLocalCandidate,
       
   181         TUint& aConnectionId );
       
   182     
       
   183     /**
       
   184      * From CNATFWPluginApi.
       
   185      * Get identifier of the plugin.
       
   186      * 
       
   187      * @since   S60 3.2
       
   188      * @return  Identifier of the plugin
       
   189      */
       
   190     const TDesC8& PluginIdentifier() const;
       
   191     
       
   192 private:
       
   193 
       
   194     CNATFWStunPlugin();
       
   195 
       
   196     void ConstructL( TAny* aInitParams );
       
   197 
       
   198 private: // data
       
   199 
       
   200     /**
       
   201      * Plugin identifier.
       
   202      * Own.
       
   203      */
       
   204     HBufC8* iPluginId;
       
   205     
       
   206     /**
       
   207      * Handles connection related actions.
       
   208      * Own.
       
   209      */
       
   210     CNATFWStunConnectionHandler* iStunConnectionHandler;
       
   211 
       
   212     };
       
   213 
       
   214 #endif // C_NATFWSTUNPLUGIN_H