natfw/tsrc/natfwtestconsoles/natfwtestconsole/src/mcclink.cpp
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 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:    
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #include "mcclink.h"
       
    22 
       
    23 #include <mmccinterface.h>
       
    24 //#include <mmccnetworksettings.h>
       
    25 #include "natfwtestconsolelogs.h"
       
    26 #include "mccsession.h"
       
    27 
       
    28 // ---------------------------------------------------------------------------
       
    29 // CMccLink::ConstructL
       
    30 // ---------------------------------------------------------------------------
       
    31 // 
       
    32 void CMccLink::ConstructL()
       
    33     {
       
    34     }
       
    35 
       
    36 // ---------------------------------------------------------------------------
       
    37 // CMccLink::NewL
       
    38 // ---------------------------------------------------------------------------
       
    39 //     
       
    40 CMccLink* CMccLink::NewL( TInt aLinkType, TUint aIapId,
       
    41     CMccSession* aSession )
       
    42     {
       
    43     CMccLink* self = new( ELeave ) CMccLink( aLinkType, aIapId, aSession );
       
    44     CleanupStack::PushL( self );
       
    45     self->ConstructL();
       
    46     CleanupStack::Pop( self );
       
    47     return self;
       
    48     }
       
    49 
       
    50 // ---------------------------------------------------------------------------
       
    51 // CMccLink::CMccLink
       
    52 // ---------------------------------------------------------------------------
       
    53 // 
       
    54 CMccLink::CMccLink( TInt aLinkType, TUint aIapId, CMccSession* aSession ) :
       
    55     iLinkType( aLinkType ), iIapId( aIapId ), iSession( aSession )
       
    56     {
       
    57     }
       
    58 
       
    59 // ---------------------------------------------------------------------------
       
    60 // CMccLink::~CMccLink
       
    61 // ---------------------------------------------------------------------------
       
    62 // 
       
    63 CMccLink::~CMccLink()
       
    64     {
       
    65     Close();
       
    66     }
       
    67 
       
    68 // ---------------------------------------------------------------------------
       
    69 // CMccLink::CreateLink
       
    70 // ---------------------------------------------------------------------------
       
    71 //     
       
    72 void CMccLink::CreateLinkL( TInt32& aLinkId, TInetAddr& aDestAddr,
       
    73     TRequestStatus& aStatus )
       
    74     {
       
    75     __NATFWTESTCONSOLE( "CMccLink::CreateLinkL" )
       
    76     
       
    77     // NET settings value
       
    78     TMccNetSettings netsettings;
       
    79     netsettings.iRemoteAddress.SetAddress( aDestAddr.Address() );
       
    80     netsettings.iRemoteAddress.SetPort( aDestAddr.Port() );
       
    81     netsettings.iRemoteRtcpPort = KDefaultRtcpPort;
       
    82 
       
    83     netsettings.iLocalAddress.SetAddress( KInetAddrAny );
       
    84     netsettings.iLocalAddress.SetPort( KDefaultRtpPort );
       
    85 
       
    86     netsettings.iLocalPublicAddress.SetAddress( KInetAddrAny );
       
    87     netsettings.iLocalRtcpPort = KDefaultRtcpPort;
       
    88     netsettings.iLocalPublicRtcpPort = KDefaultRtcpPort;
       
    89     netsettings.iMediaQosValue = KDefaultMediaQos;
       
    90     netsettings.iIapId = iIapId;
       
    91     
       
    92     // create Mcc link
       
    93     User::LeaveIfError( iSession->MccInterface()->CreateLink(
       
    94         iSession->MccSessionId(), iLinkType, iLinkId, netsettings ) ); 
       
    95     
       
    96     aLinkId = iLinkId;
       
    97     aStatus = KRequestPending;
       
    98     }
       
    99 
       
   100 // ---------------------------------------------------------------------------
       
   101 // CMccLink::CreateLink
       
   102 // ---------------------------------------------------------------------------
       
   103 //     
       
   104 void CMccLink::CreateLinkL( TInt32& aLinkId, TInetAddr& aDestAddr,
       
   105     TUint aRtcpPort, TRequestStatus& aStatus )
       
   106     {
       
   107     __NATFWTESTCONSOLE( "CMccLink::CreateLinkL" )
       
   108     
       
   109     // NET settings value
       
   110     TMccNetSettings netsettings;
       
   111     netsettings.iRemoteAddress.SetAddress( aDestAddr.Address() );
       
   112     netsettings.iRemoteAddress.SetPort( aDestAddr.Port() );
       
   113     netsettings.iRemoteRtcpPort = aRtcpPort;
       
   114 
       
   115     netsettings.iLocalAddress.SetAddress( KInetAddrAny );
       
   116     netsettings.iLocalAddress.SetPort( KDefaultRtpPort );
       
   117 
       
   118     netsettings.iLocalPublicAddress.SetAddress( KInetAddrAny );
       
   119     netsettings.iLocalRtcpPort = KDefaultRtcpPort;
       
   120     netsettings.iLocalPublicRtcpPort = KDefaultRtcpPort;
       
   121     netsettings.iMediaQosValue = KDefaultMediaQos;
       
   122     netsettings.iIapId = iIapId;
       
   123     
       
   124     // create Mcc link
       
   125     User::LeaveIfError( iSession->MccInterface()->CreateLink(
       
   126         iSession->MccSessionId(), iLinkType, iLinkId, netsettings ) ); 
       
   127     
       
   128     aLinkId = iLinkId;
       
   129     aStatus = KRequestPending;
       
   130     }
       
   131     
       
   132 // ---------------------------------------------------------------------------
       
   133 // CMccLink::SetRemoteAddressL
       
   134 // ---------------------------------------------------------------------------
       
   135 // 
       
   136 void CMccLink::SetRemoteAddressL( TInetAddr& aDestAddr )
       
   137     {
       
   138     __NATFWTESTCONSOLE( "CMccLink::SetRemoteAddressL" )
       
   139     // TODO: is using TMccNetSettings unnecessary 
       
   140     /*
       
   141     TMccNetSettings netsettings;
       
   142     netsettings.iRemoteAddress.SetAddress( aDestAddr.Address() );
       
   143     netsettings.iRemoteAddress.SetPort( aDestAddr.Port() );
       
   144     */
       
   145     User::LeaveIfError( iSession->MccInterface()->SetRemoteAddress(
       
   146         iSession->MccSessionId(), iLinkId, aDestAddr ) );
       
   147     }
       
   148 
       
   149 // ---------------------------------------------------------------------------
       
   150 // CMccLink::SetRemoteAddressL
       
   151 // ---------------------------------------------------------------------------
       
   152 // 
       
   153 void CMccLink::SetRemoteAddressL( TInetAddr& aDestAddr, TUint aRtcpPort )
       
   154     {
       
   155     __NATFWTESTCONSOLE( "CMccLink::SetRemoteAddressL + rtcp" )
       
   156     
       
   157     // TODO: is using TMccNetSettings unnecessary
       
   158     /*
       
   159     TMccNetSettings netsettings;
       
   160     netsettings.iRemoteAddress.SetAddress( aDestAddr.Address() );
       
   161     netsettings.iRemoteAddress.SetPort( aDestAddr.Port() );
       
   162     netsettings.iRemoteRtcpPort = aRtcpPort;
       
   163     */
       
   164     
       
   165     User::LeaveIfError( iSession->MccInterface()->SetRemoteAddress(
       
   166         iSession->MccSessionId(), iLinkId, aDestAddr, 
       
   167         aRtcpPort ) );
       
   168     }
       
   169 
       
   170 // ---------------------------------------------------------------------------
       
   171 // CMccLink::Close
       
   172 // ---------------------------------------------------------------------------
       
   173 // 
       
   174 TInt CMccLink::Close()
       
   175     {
       
   176     return iSession->MccInterface()->CloseLink( iSession->MccSessionId(),
       
   177         iLinkId );
       
   178     }
       
   179 
       
   180 // ---------------------------------------------------------------------------
       
   181 // CMccLink::LinkId
       
   182 // ---------------------------------------------------------------------------
       
   183 //     
       
   184 TUint32 CMccLink::LinkId()
       
   185     {
       
   186     return iLinkId;
       
   187     }