sipvoipprovider/inc/svputility.h
branchRCL_3
changeset 22 d38647835c2e
equal deleted inserted replaced
21:f742655b05bf 22:d38647835c2e
       
     1 /*
       
     2 * Copyright (c) 2006-2010 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 	/**
       
   222     * Adds P-Preferred-Identity to user headers.
       
   223     * @since Series 60 3.2
       
   224 	* @param aUserAgentHeaders user agent headers.
       
   225 	* @param aUri own sip uri.
       
   226     * @return void
       
   227     */
       
   228     void AddPPreferredIdentityToUserHeadersL( 
       
   229         CDesC8Array& aUserAgentHeaders, const TDesC8& aUri  );
       
   230     
       
   231     /**
       
   232      * Updates the jitterbuffer size to given RTP source. Function resets
       
   233      * the iJitterBufferSize member, which is got when finding MO/MT codecs
       
   234      * in AppendCapabilitiesDataL. If iJitterBufferSize = 0, then default
       
   235      * 10 frame jitterbuffer is used.
       
   236      * @since S60 v3.2
       
   237      * @param aRtpSource RTP source which to update.
       
   238      * @return void
       
   239      */
       
   240     void UpdateJitterBufferSizeL( CMceRtpSource& aRtpSource );
       
   241     
       
   242     
       
   243     /**
       
   244      * Gets DTMF mode, Inband mode returns EFalse and Outband mode ETrue
       
   245      * @since Series 60 3.2
       
   246      * @return TBool EFalse for Inband, ETrue for Outband
       
   247      */
       
   248     TBool GetDTMFMode();
       
   249     
       
   250     /**
       
   251      * Sets DTMF mode. This function is used when audiostreams have been
       
   252      * studied about the inband/outband DTMF status.
       
   253      * @since S60 v3.2
       
   254      * @param aOutbandEnabled. ETrue if outband DTMF is enabled.
       
   255      * @return void
       
   256      */
       
   257     void SetDtmfMode( TBool aOutbandEnabled );
       
   258     
       
   259     /**
       
   260      * Gets keep-alive timer value by IAP id
       
   261      * @since S60 v3.2
       
   262      * @param aIapId IAP id
       
   263      * @param aKeepAliveValue Keep-alive timer value
       
   264      * @return ETrue if value found, else EFalse
       
   265      */
       
   266     TBool GetKeepAliveByIapIdL( TUint32 aIapId, TInt& aKeepAliveValue ) const;
       
   267     
       
   268     /**
       
   269      * Gets keep-alive timer value by AOR
       
   270      * @since S60 v3.2
       
   271      * @param aAor AOR
       
   272      * @param aKeepAliveValue Keep-alive timer value
       
   273      * @return ETrue if value found, else EFalse
       
   274      */
       
   275     TBool GetKeepAliveByAORL( const TDesC8& aAor,
       
   276         TInt& aKeepAliveValue ) const;
       
   277 
       
   278      
       
   279 private: // new methods
       
   280 
       
   281     /**
       
   282      * Checks if outband DMTF is offerd  
       
   283      * @Since S60 3.2
       
   284      * @param aAudioStream Mce audiostream
       
   285      * @return TBool, ETrue -> OB offered
       
   286      */
       
   287     TBool DtmfOBInOffer( CMceAudioStream& aAudioStream );
       
   288     
       
   289     /**
       
   290      * Sets DTMF specific settings for audiostream
       
   291      * @Since S60 v3.2
       
   292      * @param aVoIPProfile Used VoIP profile
       
   293      * @param aAudioStream Audiostream, used here to set codec order num to tel-ev.
       
   294      * @return void
       
   295      * @leave system error if setting fails
       
   296      */ 
       
   297     void SetDtmfL( const CRCSEProfileEntry& aVoIPProfile, 
       
   298                   CMceAudioStream&  aAudioStream);
       
   299     
       
   300     /**
       
   301     * Method for matching ISO-639-1 language tags to Symbian language codes
       
   302     * @since Series 60 3.2
       
   303     * @param aLanguageCode Symbian language code
       
   304     * @param aLangMatch Language tag corresponding given Symbian language code
       
   305     */
       
   306     static void MatchLanguageTags( TInt aLanguageCode,
       
   307         TDes& aLangMatch );
       
   308  
       
   309 
       
   310     /**
       
   311     * Get audio codecs from database for certain VoIP profile.
       
   312     * @since Series60 3.2
       
   313     * @param aProfile RCSE profile where to search the codecs ID's.
       
   314     * @param aCodecIds 
       
   315     */                               
       
   316     void GetCodecIdsByVoIPProfileIdL( 
       
   317         const CRCSEProfileEntry& aProfile,
       
   318         RArray< TUint32 >& aCodecIds ) const;
       
   319     /**
       
   320      * Set audio codec values and append new codec in array.
       
   321      * @since Series60 3.2 
       
   322      * @param aAudioInStream Representation of Mce audio stream
       
   323      * @param aVoIPProfile VoIP profile entry
       
   324      * @param aCodecProfile Audio codec entry
       
   325      * @return void
       
   326      */                                                              
       
   327     void MoCallCapabilitiesL( CMceAudioStream& aAudioInStream, 
       
   328                               const CRCSEProfileEntry& aVoIPProfile,
       
   329                               const CRCSEAudioCodecEntry& aCodecProfile );
       
   330                                 
       
   331     /**
       
   332      * Set AMR related provisioned parameters.
       
   333      * @since Series60 3.2 
       
   334      * @param aAudioInStream Representation of Mce audio stream
       
   335      * @param aCodecProfile Audio codec entry
       
   336      * @param aCodecNumber AMR codec number in codec array
       
   337      * @return void
       
   338      */                                                              
       
   339     void SetAMRParameters( CMceAudioStream& aAudioInStream, 
       
   340                            const CRCSEAudioCodecEntry& aCodecProfile,
       
   341                            TInt aCodecNumber );
       
   342 
       
   343     /**
       
   344      * Set audio codec values and append new codec in array.
       
   345      * @since Series60 3.2 
       
   346      * @param aAudioInStream Representation of Mce audio stream
       
   347      * @param aVoIPProfile VoIP profile entry
       
   348      * @param aCodecProfile Audio codec entry
       
   349      * @return void
       
   350      */                            
       
   351     void MtCallCapabilitiesL( CMceAudioStream& aAudioInStream, 
       
   352                               const CRCSEProfileEntry& aVoIPProfile,
       
   353                               const CRCSEAudioCodecEntry& aCodecProfile );
       
   354                                        
       
   355     /**
       
   356     * Removes unnecessary codecs from Mce
       
   357     * Codecs that are supported by Mce, but are found from database
       
   358     * @since Series60 3.2
       
   359     * @param aAudioInStream Representation of Mce audio stream
       
   360     * @return None
       
   361     */                                  
       
   362     void RemoveUnnecessaryCodecsL( CMceAudioStream& aAudioInStream );
       
   363      
       
   364     /**
       
   365      * Method for setting codec order priority in offer.
       
   366      * @since S60 v3.2
       
   367      * @param aAudioStream Representation of Mce audio stream.
       
   368      * @return void
       
   369      */       
       
   370     void SetDtmfCodecOrderL( CMceAudioStream& aAudioStream ) const;
       
   371     
       
   372     /**
       
   373      * Method for setting CN on for PCMA, PCMU and ILBC if 
       
   374      * codecs provisioned and offered in incoming call
       
   375      * @since S60 v3.2
       
   376      * @param aAudioStream Representation of Mce audio stream.
       
   377      * @return void
       
   378      */     
       
   379     void SetComfortNoiseL( CMceAudioStream& aAudioStream );
       
   380    
       
   381     /**
       
   382      * Method for checking and setting red media attribute
       
   383      * @since S60 v3.2
       
   384      * @param aAudioStream Representation of Mce audio stream.
       
   385      * @return void
       
   386      */     
       
   387     void SetRedundancyL( CMceAudioStream& aAudioStream );
       
   388    
       
   389     /**
       
   390      * Sets Media level Quality Of Service. This is IP level type of service or
       
   391      * DSCP value.
       
   392      * @since S60 v3.2
       
   393      * @param aQosValue Media QoS value in settings.
       
   394      * @param aSession MCE session into which set the media QoS.
       
   395      * @return void
       
   396      */
       
   397     void SetMediaQoSL( TUint32 aQosValue, CMceSession* aSession ) const;
       
   398     
       
   399     /**
       
   400      * Enables or disables RTCP sending from RTP sinks in given media stream.
       
   401      *
       
   402      * @since S60 v3.2
       
   403      * @param aRtcp RTCP setting value read from RCSE
       
   404      * @param aStream Stream whose RTP sinks to update
       
   405      * @return void
       
   406      */
       
   407     void CheckRtcpSettingL( TUint32 aRtcp, CMceMediaStream& aStream,
       
   408                             TBool aSessionUpdateOngoing = EFalse ) const;
       
   409     
       
   410     /**
       
   411       * Method for setting VAD (Voice Activity Detection) for provisioned and
       
   412       * bound codecs.  
       
   413       * @since S60 v3.2
       
   414       * @param aInAudioStream Representation of Mce audio stream
       
   415       * @param aVADSetting value of VAD setting
       
   416       * @param aCodecName codec name
       
   417       */
       
   418     void SetVADL( CMceAudioStream& aInAudioStream, 
       
   419                             TBool aVADSetting,
       
   420                             const TDesC8& aCodecName );
       
   421 
       
   422      /**
       
   423      * Set AMR-WB (Adaptive Multi-Rate Wideband) related provisioned parameters.
       
   424      * @since S60 v3.2
       
   425      * @param aAudioInStream Representation of Mce audio stream.
       
   426      * @param aCodecProfile Stored audio codec entry in RCSE.
       
   427      * @param aCodecNumber Codec number in codec array.
       
   428      */                                                              
       
   429     void SetAmrWbParameters( CMceAudioStream& aAudioInStream, 
       
   430                            const CRCSEAudioCodecEntry& aCodecProfile,
       
   431                            TInt aCodecNumber );   
       
   432 
       
   433 private: // data
       
   434 
       
   435 
       
   436     /**
       
   437      * second-phase constructor
       
   438      */
       
   439     void ConstructL();
       
   440     
       
   441     /**
       
   442      * C++ default constructor.
       
   443      */
       
   444     CSVPUtility();
       
   445     
       
   446     /**
       
   447      * Flags to determine which codecs are matched
       
   448      */
       
   449     TBool iAMR;
       
   450     TBool iILBC;
       
   451     TBool iPCMU;
       
   452     TBool iPCMA;
       
   453     TBool iG729;
       
   454     TBool iCN;
       
   455     TBool iRed;
       
   456     TBool iAMRWB;
       
   457     
       
   458     /**
       
   459      * Flag which determines which DMTF mode is used
       
   460      * ETrue => Outbound, EFalse => Inbound
       
   461      */
       
   462     TBool iTelEv;
       
   463     
       
   464     /**
       
   465      * codec preference order
       
   466      */
       
   467     TInt iPreferredCodec;
       
   468     
       
   469     /**
       
   470      * Codec match flag, determines if codec matched in Mt call case
       
   471      */
       
   472     TBool iCodecMatched;
       
   473    
       
   474     /** 
       
   475      * Flag to determine whether DTMF settin is read already
       
   476      */ 
       
   477     TBool iDTMFChecked;
       
   478     
       
   479     /**
       
   480      * Jitterbuffer length found from codec settings.
       
   481      */
       
   482     TInt32 iJitterBufferSize;
       
   483     
       
   484     /**
       
   485      * Keeps track in Mt call case when matching codecs
       
   486      */
       
   487     TInt iRoundIndex;
       
   488     
       
   489     /**
       
   490      * instance of the VoIP event logger class.
       
   491      * own.
       
   492      */
       
   493     CVoipEventLog* iVoipEventLogger;
       
   494 
       
   495 private:
       
   496 
       
   497     // For testing
       
   498     SVP_UT_DEFS
       
   499    
       
   500     };
       
   501 
       
   502 #endif // SVPUTILITY_H