sipvoipprovider/inc/svputility.h
changeset 0 a4daefaec16c
child 11 6134b5029079
equal deleted inserted replaced
-1:000000000000 0:a4daefaec16c
       
     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:  Static utility functions for SVP.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef SVPUTILITY_H
       
    21 #define SVPUTILITY_H
       
    22 
       
    23 #include <e32base.h>
       
    24 #include <mceaudiostream.h>
       
    25 #include <mcedtmfobserver.h> // dtmf
       
    26 #include <mccpcallobserver.h>
       
    27 #include <mceinsession.h> 
       
    28 #include <ccpdefs.h>    // error definitions
       
    29 #include <mccpdtmfobserver.h> // dtmf
       
    30 
       
    31 #include "cipappphoneutils.h" // CIpAppPhoneUtils, KSVPMaxTerminalTypeLength
       
    32 #include "svpconsts.h"
       
    33 #include "svputdefs.h"
       
    34 
       
    35 // FORWARD DECLARATIONS
       
    36 class CRCSEProfileEntry;
       
    37 class CRCSEAudioCodecEntry;
       
    38 class CMceRtpSource;
       
    39 class CSIPProfile;
       
    40 class CVoipEventLog;
       
    41 class CVoipErrorEntry;
       
    42 
       
    43 /**
       
    44  *  Static utility function for SVP usage.
       
    45  *
       
    46  *  @lib 
       
    47  *  @since S60 3.2
       
    48  */
       
    49 class CSVPUtility : public CBase
       
    50     {
       
    51 
       
    52 public: 
       
    53     
       
    54     /**
       
    55     * Two-phased constructor.
       
    56     */
       
    57     static CSVPUtility* NewL();
       
    58     
       
    59     /**
       
    60     * Destructor.
       
    61     */
       
    62     virtual ~CSVPUtility();
       
    63 
       
    64 
       
    65 public: // new methods
       
    66     
       
    67     /**
       
    68      * Sets keep alive payload and timer when CN is provisioned
       
    69      * @since Series 60 3.2
       
    70      * @param aAudioStream Representation of Mce audio stream
       
    71      * @param aKeepAliveValue Keep-alive timer value
       
    72      * @return None
       
    73      */
       
    74     void SetCNKeepAliveL( CMceAudioStream& aAudioStream,
       
    75                           TInt aKeepAliveValue );
       
    76     /**
       
    77      * Sets keep alive payload and timer when CN is not provisioned
       
    78      * @since Series 60 3.2
       
    79      * @param aAudioStream Representation of Mce audio stream
       
    80      * @param aKeepAliveValue Keep-alive timer value
       
    81      * @return None
       
    82      */
       
    83     void SetKeepAliveL( CMceAudioStream& aAudioStream,
       
    84                         TInt aKeepAliveValue );
       
    85     
       
    86     /**
       
    87      * Sets keep alive payload and timer when CN is not provisioned
       
    88      * @since Series 60 3.2
       
    89      * @param aStream Checks if CN codec is present in stream
       
    90      * @return None
       
    91      */
       
    92     TBool IsComfortNoise( CMceAudioStream& aStream );
       
    93     
       
    94     /**
       
    95     * Set codecs for given stream in Mo call case
       
    96     * Set codecs settings from database
       
    97     * Compares database codecs to those supported by Mce
       
    98     * Leave with value KErrNotFound if codecs not found. 
       
    99     * @since Series 60 3.2
       
   100     * @param aVoIPProfileId VoIP profile ID number 
       
   101     * @param audioInStream Representation of Mce audio stream
       
   102     * @param aKeepAliveValue Keep-alive timer value
       
   103     * @return None
       
   104     */
       
   105     void SetAudioCodecsMOL( TUint32 aVoIPProfileId, 
       
   106                             CMceAudioStream& audioInStream,
       
   107                             TInt aKeepAliveValue );
       
   108 
       
   109     /**
       
   110     * Set codecs for given stream in Mt call case
       
   111     * Compares database codecs to those supported by Mce. 
       
   112     * @since Series 60 3.2
       
   113     * @param aVoIPProfile VoIP profile entry
       
   114     * @param audioInStream Representation of Mce audio stream
       
   115     * @param aKeepAliveValue Keepalive timer value
       
   116     * @return None
       
   117     */
       
   118     void SetAudioCodecsMTL( CRCSEProfileEntry& aVoIPProfile, 
       
   119                             CMceMediaStream& aAudioStream,
       
   120                             TInt aKeepAliveValue,
       
   121                             TBool aSessionUpdateOngoing = EFalse );
       
   122 
       
   123     /**
       
   124     * Sets G711 codecs (PCMA & PCMU) for emergency call when there is no VoIP 
       
   125     * profile, i.e. calling emergency by IAP ID only. RCSE default profile 
       
   126     * values are used when needed.
       
   127     * @since Series 60 3.2
       
   128     * @param audioInStream   Audio stream
       
   129     * @param aKeepAliveValue Keep-alive value
       
   130     * @param aVoipProfileId VoIP profile ID, KErrNotFound, if no VoIP profile
       
   131     */
       
   132     void SetAudioCodecsForEmergencyL( CMceAudioStream& aAudioInStream,
       
   133                                       TInt aKeepAliveValue, 
       
   134                                       TInt32 aVoipProfileId = KErrNotFound );
       
   135 
       
   136     /**
       
   137     * Matches Mce and Ccp errors 
       
   138     * @since S60 3.2
       
   139     * @param aErrorCode Error code - may be modified
       
   140     * @param aTone Contains tone associated to possible error condition.
       
   141     * @return TCCPError CCP error
       
   142     */                             
       
   143     TCCPError GetCCPError( TInt& aErrorCode, TCCPTone& aTone ) const;
       
   144     
       
   145                                          
       
   146     /**
       
   147      * Write mce/sip errors to the voip event logger
       
   148      * @since S60 3.2
       
   149      * @param aErrorCode Error code
       
   150      * @param aSipProfileId Id of the SIP profile
       
   151      * @param aRemoteURI Address of the remote party
       
   152      * @param aMethod Failed method e.g. INVITE          
       
   153      */                             
       
   154     void LogVoipEventL( TInt aErrorCode, 
       
   155                         TUint32 aSipProfileId,
       
   156                         const TDesC& aRemoteURI,
       
   157                         const TDesC& aMethod ) const;
       
   158     
       
   159         
       
   160     /**
       
   161     * Matches Mce and CCP DTMF events 
       
   162     * @since S60 3.2
       
   163     * @param aEvent Event received from Mce DTMF observer
       
   164     * @param aDtmfStringSengin Flag needed to determine which events are 
       
   165     *                          sent to client application
       
   166     * @return TCCPDtmfEvent Matched CCP DTMF event
       
   167     */ 
       
   168     MCCPDTMFObserver::TCCPDtmfEvent GetDtmfEvent( MMceDtmfObserver::TMceDtmfEvent aEvent,
       
   169                                                   TBool aDtmfStringSending );
       
   170          
       
   171    
       
   172     /**
       
   173     * Set provisioning data for VoIP profile.
       
   174     * @param aVoIPProfile VoIP profile entry.
       
   175     * @param aUserAgentHeaders On completion, contains collected user-agent header.
       
   176     */
       
   177     void SetProvisioningDataL( CRCSEProfileEntry& aVoipProfile, 
       
   178                                CDesC8Array& aUserAgentHeaders,
       
   179                                TUint32& aSecurityStatus,
       
   180                                TBuf<KSVPMaxTerminalTypeLength>& aTerminalType,
       
   181                                TBuf<KSVPWlanMacAddressLength>& aWlanMACAddress ) const;
       
   182     /**
       
   183     * Get the terminal type at startup.
       
   184     * @since Series60 3.2
       
   185     * @param aTerminalType
       
   186     */                                                     
       
   187     void GetTerminalTypeL( TBuf< KSVPMaxTerminalTypeLength >& aTerminalType );
       
   188     
       
   189     /**
       
   190     * Get the Wlan MAC address at startup.
       
   191     * @since Series 60 3.2
       
   192     * @param aWlanMACAddress.
       
   193     */
       
   194     static void GetWlanMACAddressL( TBuf< KSVPWlanMacAddressLength >& aWlanMACAddress );
       
   195     
       
   196     /**
       
   197     * Resolves the security mechanism, checks if TLS or SIPS is used in profile
       
   198     * @since Series 60 3.2
       
   199     * @param aProfile SIP profile which is used to call
       
   200     * @param aSecureCallPreference Secure call preference of the call ( 0, 1 or 2 ) 
       
   201     */
       
   202     void ResolveSecurityMechanismL( const CSIPProfile& aProfile,
       
   203                                     TUint32& aSecureCallPreference );
       
   204 
       
   205     /**
       
   206     * Check Calling Line Identification Restriction (CLIR) value.
       
   207     * @since Series 60 3.2
       
   208     * @return ETRue if CLIR is ON, otherwise EFalse.
       
   209     */
       
   210     TBool IsCLIROnL() const;
       
   211 
       
   212     /**
       
   213     * Set fromheader.
       
   214     * If CLIR is on add anonymous info according sec status, otherwise nothing
       
   215     * @since Series 60 3.2
       
   216     * @return HBufC8* constructed fromheader.
       
   217     */
       
   218     HBufC8* SetMoFromHeaderLC( TUint aSecurityStatus );
       
   219     
       
   220     /**
       
   221      * Updates the jitterbuffer size to given RTP source. Function resets
       
   222      * the iJitterBufferSize member, which is got when finding MO/MT codecs
       
   223      * in AppendCapabilitiesDataL. If iJitterBufferSize = 0, then default
       
   224      * 10 frame jitterbuffer is used.
       
   225      * @since S60 v3.2
       
   226      * @param aRtpSource RTP source which to update.
       
   227      * @return void
       
   228      */
       
   229     void UpdateJitterBufferSizeL( CMceRtpSource& aRtpSource );
       
   230     
       
   231     
       
   232     /**
       
   233      * Gets DTMF mode, Inband mode returns EFalse and Outband mode ETrue
       
   234      * @since Series 60 3.2
       
   235      * @return TBool EFalse for Inband, ETrue for Outband
       
   236      */
       
   237     TBool GetDTMFMode();
       
   238     
       
   239     /**
       
   240      * Sets DTMF mode. This function is used when audiostreams have been
       
   241      * studied about the inband/outband DTMF status.
       
   242      * @since S60 v3.2
       
   243      * @param aOutbandEnabled. ETrue if outband DTMF is enabled.
       
   244      * @return void
       
   245      */
       
   246     void SetDtmfMode( TBool aOutbandEnabled );
       
   247     
       
   248     /**
       
   249      * Gets keep-alive timer value by IAP id
       
   250      * @since S60 v3.2
       
   251      * @param aIapId IAP id
       
   252      * @param aKeepAliveValue Keep-alive timer value
       
   253      * @return ETrue if value found, else EFalse
       
   254      */
       
   255     TBool GetKeepAliveByIapIdL( TUint32 aIapId, TInt& aKeepAliveValue ) const;
       
   256     
       
   257     /**
       
   258      * Gets keep-alive timer value by AOR
       
   259      * @since S60 v3.2
       
   260      * @param aAor AOR
       
   261      * @param aKeepAliveValue Keep-alive timer value
       
   262      * @return ETrue if value found, else EFalse
       
   263      */
       
   264     TBool GetKeepAliveByAORL( const TDesC8& aAor,
       
   265         TInt& aKeepAliveValue ) const;
       
   266 
       
   267      
       
   268 private: // new methods
       
   269 
       
   270     /**
       
   271      * Checks if outband DMTF is offerd  
       
   272      * @Since S60 3.2
       
   273      * @param aAudioStream Mce audiostream
       
   274      * @return TBool, ETrue -> OB offered
       
   275      */
       
   276     TBool DtmfOBInOffer( CMceAudioStream& aAudioStream );
       
   277     
       
   278     /**
       
   279      * Sets DTMF specific settings for audiostream
       
   280      * @Since S60 v3.2
       
   281      * @param aVoIPProfile Used VoIP profile
       
   282      * @param aAudioStream Audiostream, used here to set codec order num to tel-ev.
       
   283      * @return void
       
   284      * @leave system error if setting fails
       
   285      */ 
       
   286     void SetDtmfL( const CRCSEProfileEntry& aVoIPProfile, 
       
   287                   CMceAudioStream&  aAudioStream);
       
   288     
       
   289     /**
       
   290     * Method for matching ISO-639-1 language tags to Symbian language codes
       
   291     * @since Series 60 3.2
       
   292     * @param aLanguageCode Symbian language code
       
   293     * @param aLangMatch Language tag corresponding given Symbian language code
       
   294     */
       
   295     static void MatchLanguageTags( TInt aLanguageCode,
       
   296         TDes& aLangMatch );
       
   297  
       
   298 
       
   299     /**
       
   300     * Get audio codecs from database for certain VoIP profile.
       
   301     * @since Series60 3.2
       
   302     * @param aProfile RCSE profile where to search the codecs ID's.
       
   303     * @param aCodecIds 
       
   304     */                               
       
   305     void GetCodecIdsByVoIPProfileIdL( 
       
   306         const CRCSEProfileEntry& aProfile,
       
   307         RArray< TUint32 >& aCodecIds ) const;
       
   308     /**
       
   309      * Set audio codec values and append new codec in array.
       
   310      * @since Series60 3.2 
       
   311      * @param aAudioInStream Representation of Mce audio stream
       
   312      * @param aVoIPProfile VoIP profile entry
       
   313      * @param aCodecProfile Audio codec entry
       
   314      * @return void
       
   315      */                                                              
       
   316     void MoCallCapabilitiesL( CMceAudioStream& aAudioInStream, 
       
   317                               const CRCSEProfileEntry& aVoIPProfile,
       
   318                               const CRCSEAudioCodecEntry& aCodecProfile );
       
   319                                 
       
   320     /**
       
   321      * Set AMR related provisioned parameters.
       
   322      * @since Series60 3.2 
       
   323      * @param aAudioInStream Representation of Mce audio stream
       
   324      * @param aCodecProfile Audio codec entry
       
   325      * @param aCodecNumber AMR codec number in codec array
       
   326      * @return void
       
   327      */                                                              
       
   328     void SetAMRParameters( CMceAudioStream& aAudioInStream, 
       
   329                            const CRCSEAudioCodecEntry& aCodecProfile,
       
   330                            TInt aCodecNumber );
       
   331 
       
   332     /**
       
   333      * Set audio codec values and append new codec in array.
       
   334      * @since Series60 3.2 
       
   335      * @param aAudioInStream Representation of Mce audio stream
       
   336      * @param aVoIPProfile VoIP profile entry
       
   337      * @param aCodecProfile Audio codec entry
       
   338      * @return void
       
   339      */                            
       
   340     void MtCallCapabilitiesL( CMceAudioStream& aAudioInStream, 
       
   341                               const CRCSEProfileEntry& aVoIPProfile,
       
   342                               const CRCSEAudioCodecEntry& aCodecProfile );
       
   343                                        
       
   344     /**
       
   345     * Removes unnecessary codecs from Mce
       
   346     * Codecs that are supported by Mce, but are found from database
       
   347     * @since Series60 3.2
       
   348     * @param aAudioInStream Representation of Mce audio stream
       
   349     * @return None
       
   350     */                                  
       
   351     void RemoveUnnecessaryCodecsL( CMceAudioStream& aAudioInStream );
       
   352      
       
   353     /**
       
   354      * Method for setting codec order priority in offer.
       
   355      * @since S60 v3.2
       
   356      * @param aAudioStream Representation of Mce audio stream.
       
   357      * @return void
       
   358      */       
       
   359     void SetDtmfCodecOrderL( CMceAudioStream& aAudioStream ) const;
       
   360     
       
   361     /**
       
   362      * Method for setting CN on for PCMA, PCMU and ILBC if 
       
   363      * codecs provisioned and offered in incoming call
       
   364      * @since S60 v3.2
       
   365      * @param aAudioStream Representation of Mce audio stream.
       
   366      * @return void
       
   367      */     
       
   368     void SetComfortNoiseL( CMceAudioStream& aAudioStream );
       
   369    
       
   370     /**
       
   371      * Method for checking and setting red media attribute
       
   372      * @since S60 v3.2
       
   373      * @param aAudioStream Representation of Mce audio stream.
       
   374      * @return void
       
   375      */     
       
   376     void SetRedundancyL( CMceAudioStream& aAudioStream );
       
   377    
       
   378     /**
       
   379      * Sets Media level Quality Of Service. This is IP level type of service or
       
   380      * DSCP value.
       
   381      * @since S60 v3.2
       
   382      * @param aQosValue Media QoS value in settings.
       
   383      * @param aSession MCE session into which set the media QoS.
       
   384      * @return void
       
   385      */
       
   386     void SetMediaQoSL( TUint32 aQosValue, CMceSession* aSession ) const;
       
   387     
       
   388     /**
       
   389      * Enables or disables RTCP sending from RTP sinks in given media stream.
       
   390      *
       
   391      * @since S60 v3.2
       
   392      * @param aRtcp RTCP setting value read from RCSE
       
   393      * @param aStream Stream whose RTP sinks to update
       
   394      * @return void
       
   395      */
       
   396     void CheckRtcpSettingL( TUint32 aRtcp, CMceMediaStream& aStream,
       
   397                             TBool aSessionUpdateOngoing = EFalse ) const;
       
   398     
       
   399     /**
       
   400       * Method for setting VAD (Voice Activity Detection) for provisioned and
       
   401       * bound codecs.  
       
   402       * @since S60 v3.2
       
   403       * @param aInAudioStream Representation of Mce audio stream
       
   404       * @param aVADSetting value of VAD setting
       
   405       * @param aCodecName codec name
       
   406       */
       
   407     void SetVADL( CMceAudioStream& aInAudioStream, 
       
   408                             TBool aVADSetting,
       
   409                             const TDesC8& aCodecName );
       
   410 
       
   411      /**
       
   412      * Set AMR-WB (Adaptive Multi-Rate Wideband) related provisioned parameters.
       
   413      * @since S60 v3.2
       
   414      * @param aAudioInStream Representation of Mce audio stream.
       
   415      * @param aCodecProfile Stored audio codec entry in RCSE.
       
   416      * @param aCodecNumber Codec number in codec array.
       
   417      */                                                              
       
   418     void SetAmrWbParameters( CMceAudioStream& aAudioInStream, 
       
   419                            const CRCSEAudioCodecEntry& aCodecProfile,
       
   420                            TInt aCodecNumber );   
       
   421 
       
   422 private: // data
       
   423 
       
   424 
       
   425     /**
       
   426      * second-phase constructor
       
   427      */
       
   428     void ConstructL();
       
   429     
       
   430     /**
       
   431      * C++ default constructor.
       
   432      */
       
   433     CSVPUtility();
       
   434     
       
   435     /**
       
   436      * Flags to determine which codecs are matched
       
   437      */
       
   438     TBool iAMR;
       
   439     TBool iILBC;
       
   440     TBool iPCMU;
       
   441     TBool iPCMA;
       
   442     TBool iG729;
       
   443     TBool iCN;
       
   444     TBool iRed;
       
   445     TBool iAMRWB;
       
   446     
       
   447     /**
       
   448      * Flag which determines which DMTF mode is used
       
   449      * ETrue => Outbound, EFalse => Inbound
       
   450      */
       
   451     TBool iTelEv;
       
   452     
       
   453     /**
       
   454      * codec preference order
       
   455      */
       
   456     TInt iPreferredCodec;
       
   457     
       
   458     /**
       
   459      * Codec match flag, determines if codec matched in Mt call case
       
   460      */
       
   461     TBool iCodecMatched;
       
   462    
       
   463     /** 
       
   464      * Flag to determine whether DTMF settin is read already
       
   465      */ 
       
   466     TBool iDTMFChecked;
       
   467     
       
   468     /**
       
   469      * Jitterbuffer length found from codec settings.
       
   470      */
       
   471     TInt32 iJitterBufferSize;
       
   472     
       
   473     /**
       
   474      * Keeps track in Mt call case when matching codecs
       
   475      */
       
   476     TInt iRoundIndex;
       
   477     
       
   478     /**
       
   479      * instance of the VoIP event logger class.
       
   480      * own.
       
   481      */
       
   482     CVoipEventLog* iVoipEventLogger;
       
   483 
       
   484 private:
       
   485 
       
   486     // For testing
       
   487     SVP_UT_DEFS
       
   488    
       
   489     };
       
   490 
       
   491 #endif // SVPUTILITY_H