sipvoipprovider/src/svpaudioutility.cpp
changeset 0 a4daefaec16c
equal deleted inserted replaced
-1:000000000000 0:a4daefaec16c
       
     1 /*
       
     2 * Copyright (c) 2006-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:  Provides static utility functions for SVP
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <mceaudiostream.h>
       
    20 #include <mcertpsource.h>
       
    21 #include <mceaudiocodec.h>
       
    22 #include <mcespeakersink.h>
       
    23 #include <mcemicsource.h>
       
    24 #include <AudioPreference.h>
       
    25 #include "svpaudioutility.h"
       
    26 #include "svplogger.h"
       
    27 #include "svpconsts.h"
       
    28 #include "svpsessionbase.h"
       
    29 #include "svpemergencysession.h"
       
    30 #include "svpholdcontext.h"
       
    31 #include "svpholdcontroller.h"
       
    32 
       
    33 // LOCAL CONSTANTS
       
    34 // Constants for VoIP uplink audio preferences, renamed for better
       
    35 // readability and to clarify between IB/OB DTMF's. 
       
    36 // See <audiopreference.h> for more information.
       
    37 // Inband signalling uplink preference (i.e inband DTMF)
       
    38 const TUint KSVPAudioPrefUplinkIbDtmf = KAudioPrefVoipAudioUplinkNonSignal;
       
    39 // Outband signalling uplink preference (i.e outband DTMF)
       
    40 const TUint KSVPAudioPrefUplinkOobDtmf = KAudioPrefVoipAudioUplink;
       
    41 
       
    42 
       
    43 // ---------------------------------------------------------------------------
       
    44 // SVPAudioUtility::IsDownlinkStream
       
    45 // ---------------------------------------------------------------------------
       
    46 //
       
    47 TBool SVPAudioUtility::IsDownlinkStream( CMceAudioStream& aStream )
       
    48     {
       
    49     SVPDEBUG2( "SVPAudioUtility::IsDownlinkStream source: 0x%x", aStream.Source() );
       
    50     
       
    51     if ( aStream.Source() && KMceRTPSource == aStream.Source()->Type() )
       
    52         {
       
    53         SVPDEBUG1( "SVPAudioUtility::IsDownlinkStream RTP SOURCE => DOWNLINK" );
       
    54         return ETrue;
       
    55         }
       
    56     else
       
    57         {
       
    58         SVPDEBUG1( "SVPAudioUtility::IsDownlinkStream EFalse" );
       
    59         
       
    60         return EFalse;
       
    61         }
       
    62     }
       
    63 
       
    64 // ---------------------------------------------------------------------------
       
    65 // SVPAudioUtility::SetPriorityCodecValuesL
       
    66 // ---------------------------------------------------------------------------
       
    67 //
       
    68 TBool SVPAudioUtility::SetPriorityCodecValuesL(
       
    69     CMceAudioStream& aAudioInStream,
       
    70     CMceAudioStream& aAudioOutStream )
       
    71     {
       
    72     SVPDEBUG1("SVPAudioUtility::SetPriorityCodecValuesL In");
       
    73     
       
    74     // set MMF codec priorities  for all codecs in both streams
       
    75     const TInt inCodecCount = aAudioInStream.Codecs().Count();
       
    76     SVPDEBUG2(
       
    77         "SVPAudioUtility::SetPriorityCodecValuesL codeccount IN: %d",
       
    78             inCodecCount )
       
    79      
       
    80     const TInt outCodecCount = aAudioOutStream.Codecs().Count();
       
    81     SVPDEBUG2(
       
    82         "SVPAudioUtility::SetPriorityCodecValuesL codeccount OUT: %d",
       
    83             outCodecCount )
       
    84     
       
    85     const TBool inDtmf = SVPAudioUtility::SetDtmfPriorityL( aAudioInStream );
       
    86     const TBool outDtmf = SVPAudioUtility::SetDtmfPriorityL( aAudioOutStream );
       
    87     
       
    88     // inDtmf and outDtmf _must_ match. Either inband (both EFalse) or outband
       
    89     // (both ETrue).
       
    90     if ( inDtmf != outDtmf )
       
    91         {
       
    92         SVPDEBUG1("SVPAudioUtility::SetPriorityCodecValuesL KErrNotFound");
       
    93         User::Leave( KErrNotFound );
       
    94         }
       
    95     
       
    96     SVPDEBUG1( "SVPAudioUtility::SetPriorityCodecValuesL set IN priorities" );
       
    97     
       
    98     SetAudioCodecPrioritiesL( aAudioInStream, KAudioPrefVoipAudioDownlink );
       
    99     
       
   100     // Check which version of DTMF's are we using, inband or outband.
       
   101     TBool outband( EFalse );
       
   102     TUint uplinkPreference = KSVPAudioPrefUplinkIbDtmf;
       
   103     if ( inDtmf && outDtmf )
       
   104         {
       
   105         SVPDEBUG1(
       
   106             "SVPAudioUtility::SetPriorityCodecValuesL change to OOB DTMF" );
       
   107         
       
   108         uplinkPreference = KSVPAudioPrefUplinkOobDtmf;
       
   109         outband = ETrue;
       
   110         }
       
   111     // else inband used.
       
   112     
       
   113     SVPDEBUG1( "SVPAudioUtility::SetPriorityCodecValuesL set OUT priorities" );
       
   114     
       
   115     SetAudioCodecPrioritiesL( aAudioOutStream, uplinkPreference );
       
   116     
       
   117     SVPDEBUG1( "SVPAudioUtility::SetPriorityCodecValuesL Out" );
       
   118     
       
   119     return outband;
       
   120     }
       
   121 
       
   122 // ---------------------------------------------------------------------------
       
   123 // SVPAudioUtility::SetDtmfPriorityL
       
   124 // ---------------------------------------------------------------------------
       
   125 //
       
   126 TBool SVPAudioUtility::SetDtmfPriorityL( CMceAudioStream& aAudioStream )
       
   127     {
       
   128     SVPDEBUG1( "SVPAudioUtility::SetDtmfPriorityL In" );
       
   129     
       
   130     const RPointerArray<CMceAudioCodec>& codecs = aAudioStream.Codecs();
       
   131     TInt codCount( codecs.Count() );
       
   132     
       
   133     // loop through codecs in in stream
       
   134     while ( codCount )
       
   135         {
       
   136         codCount--;
       
   137         
       
   138         SVPDEBUG2( "SVPAudioUtility::SetDtmfPriorityL, round: %d", codCount );
       
   139         
       
   140         // Check if codec is DTMF, note the return values of CompareF
       
   141         if( !codecs[ codCount ]->SdpName().CompareF( KTELEVENT ) )
       
   142             {
       
   143             SVPDEBUG1( "SVPAudioUtility::SetDtmfPriorityL ETrue" );
       
   144             
       
   145             SVPDEBUG2( "SVPAudioUtility::SetDtmfPriorityL curr.prio: %d",
       
   146                 codecs[codCount]->MMFPriority() )
       
   147             SVPDEBUG2( "SVPAudioUtility::SetDtmfPriorityL curr.pref: 0x%x",
       
   148                 codecs[codCount]->MMFPriorityPreference() )
       
   149             
       
   150             // Set the priorities.
       
   151             codecs[ codCount ]->SetMMFPriorityL( KAudioPriorityDTMFString );
       
   152             codecs[ codCount ]->SetMMFPriorityPreferenceL( KAudioDTMFString );
       
   153             return ETrue;
       
   154             }
       
   155         }
       
   156     
       
   157     SVPDEBUG1( "SVPAudioUtility::SetDtmfPriorityL EFalse" );
       
   158     return EFalse;
       
   159     }
       
   160 
       
   161 // ---------------------------------------------------------------------------
       
   162 // SVPAudioUtility::SetAudioCodecPrioritiesL
       
   163 // ---------------------------------------------------------------------------
       
   164 //
       
   165 void SVPAudioUtility::SetAudioCodecPrioritiesL(
       
   166     CMceAudioStream& aAudioStream,
       
   167     TUint aAudioPref )
       
   168     {
       
   169     SVPDEBUG2( "SVPAudioUtility::SetAudioCodecPrioritiesL aAudioPref: 0x%x",
       
   170         aAudioPref );
       
   171     
       
   172     const RPointerArray<CMceAudioCodec>& codecs = aAudioStream.Codecs();
       
   173     TInt codCount( codecs.Count() );
       
   174     
       
   175     // loop through codecs in in stream
       
   176     while ( codCount )
       
   177         {
       
   178         codCount--;
       
   179         
       
   180         SVPDEBUG2( "SVPAudioUtility::SetAudioCodecPrioritiesL, round: %d",
       
   181             codCount );
       
   182         
       
   183         // Handle only real audio codecs.
       
   184         if( codecs[ codCount ]->SdpName().CompareF( KTELEVENT ) )
       
   185             {
       
   186             SVPDEBUG2( "SVPAudioUtility::SetAudioCodecPrioritiesL curr.prio: %d",
       
   187                 codecs[codCount]->MMFPriority() )
       
   188             SVPDEBUG2( "SVPAudioUtility::SetAudioCodecPrioritiesL curr.pref: 0x%x",
       
   189                 codecs[codCount]->MMFPriorityPreference() )
       
   190                 
       
   191             // Priority is always the same for VoIP.
       
   192             codecs[ codCount ]->SetMMFPriorityL( KAudioPriorityPhoneCall );
       
   193             codecs[ codCount ]->SetMMFPriorityPreferenceL( aAudioPref );
       
   194             }
       
   195         } 
       
   196     }
       
   197 
       
   198 // ---------------------------------------------------------------------------
       
   199 // SVPAudioUtility::SetAudioCodecPrioritiesL
       
   200 // ---------------------------------------------------------------------------
       
   201 //
       
   202 void SVPAudioUtility::SetAudioStreamPrioritiesL(
       
   203     CMceMediaStream& aMediaStream,
       
   204     CMceMediaStream& aBoundStream )
       
   205     {
       
   206     SVPDEBUG1( "SVPAudioUtility::SetAudioStreamPrioritiesL In" );
       
   207     
       
   208     if ( KMceAudio != aMediaStream.Type() ||
       
   209          KMceAudio != aBoundStream.Type() )
       
   210         {
       
   211         SVPDEBUG1( "SVPAudioUtility::SetAudioStreamPrioritiesL KErrArgument" );
       
   212         SVPDEBUG2( "SVPAudioUtility::SetAudioStreamPrioritiesL media.Type: %u",
       
   213             aMediaStream.Type() );
       
   214         SVPDEBUG2( "SVPAudioUtility::SetAudioStreamPrioritiesL bound.Type: %u",
       
   215             aBoundStream.Type() );
       
   216         
       
   217         User::Leave( KErrArgument );
       
   218         }
       
   219     // else stream types are OK, thus we proceed.
       
   220     
       
   221     // Set the codec MMF priorities here, first get the audiostreams.
       
   222     CMceAudioStream& stream = static_cast<CMceAudioStream&>( aMediaStream );
       
   223     CMceAudioStream& bound = static_cast<CMceAudioStream&>( aBoundStream );
       
   224     
       
   225     if ( SVPAudioUtility::IsDownlinkStream( stream ) )
       
   226         {
       
   227         SVPAudioUtility::SetPriorityCodecValuesL( stream, bound );
       
   228         }
       
   229     else
       
   230         {
       
   231         SVPAudioUtility::SetPriorityCodecValuesL( bound, stream );
       
   232         }
       
   233     
       
   234     SVPDEBUG1( "SVPAudioUtility::SetAudioStreamPrioritiesL Out" );
       
   235     }
       
   236 
       
   237 // ---------------------------------------------------------------------------
       
   238 // SVPAudioUtility::EnableSpeakerSinkL
       
   239 // ---------------------------------------------------------------------------
       
   240 //
       
   241 void SVPAudioUtility::EnableSpeakerSinkL( 
       
   242     const RPointerArray< CMceMediaSink >& aSink )
       
   243     {
       
   244     TInt snkCount( aSink.Count() );
       
   245     while ( snkCount )
       
   246         {
       
   247         snkCount--;
       
   248         if ( KMceSpeakerSink == aSink[ snkCount ]->Type() && 
       
   249              !aSink[ snkCount ]->IsEnabled() )
       
   250             {
       
   251             SVPDEBUG1( "SVPAudioUtility::EnableSpeakerSinkL Speaker found" );
       
   252             
       
   253             aSink[ snkCount ]->EnableL();
       
   254             
       
   255             SVPDEBUG1( "SVPAudioUtility::EnableSpeakerSinkL Speaker ENABLED" );
       
   256             }
       
   257         } 
       
   258     }
       
   259     
       
   260 // ---------------------------------------------------------------------------
       
   261 // SVPAudioUtility::DisableSpeakerSinkL
       
   262 // ---------------------------------------------------------------------------
       
   263 //
       
   264 void SVPAudioUtility::DisableSpeakerSinkL( 
       
   265     const RPointerArray< CMceMediaSink >& aSink )
       
   266     {
       
   267     TInt snkCount( aSink.Count() );
       
   268     while ( snkCount )
       
   269         {
       
   270         snkCount--;
       
   271         if ( KMceSpeakerSink == aSink[ snkCount ]->Type() &&
       
   272              aSink[ snkCount ]->IsEnabled() )
       
   273             {
       
   274             SVPDEBUG1( "SVPAudioUtility::DisableSpeakerSinkL Speaker found" );
       
   275             
       
   276             aSink[ snkCount ]->DisableL();
       
   277             
       
   278             SVPDEBUG1( "SVPAudioUtility::DisableSpeakerSinkL Speaker DISABLED" );
       
   279             }
       
   280         } 
       
   281     }
       
   282 
       
   283 // ---------------------------------------------------------------------------
       
   284 // SVPAudioUtility::EnableMicSourceL
       
   285 // ---------------------------------------------------------------------------
       
   286 //
       
   287 void SVPAudioUtility::EnableMicSourceL( CMceMediaSource& aMicSource )
       
   288     {            
       
   289     if ( KMceMicSource == aMicSource.Type() && !aMicSource.IsEnabled() )
       
   290         {
       
   291         SVPDEBUG1("SVPAudioUtility::EnableMicSourceL Mic found");
       
   292         
       
   293         aMicSource.EnableL();
       
   294         
       
   295         SVPDEBUG1("SVPAudioUtility::EnableMicSourceL Mic ENABLED");
       
   296         }
       
   297     }
       
   298 
       
   299 // ---------------------------------------------------------------------------
       
   300 // SVPAudioUtility::DisableMicSourceL
       
   301 // ---------------------------------------------------------------------------
       
   302 //
       
   303 void SVPAudioUtility::DisableMicSourceL( CMceMediaSource& aMicSource )
       
   304     {
       
   305     if ( KMceMicSource == aMicSource.Type() && aMicSource.IsEnabled() )
       
   306         {
       
   307         SVPDEBUG1( "SVPAudioUtility::DisableMicSourceL Mic found" );
       
   308         
       
   309         aMicSource.DisableL();
       
   310         
       
   311         SVPDEBUG1( "SVPAudioUtility::DisableMicSourceL Mic DISABLED" );
       
   312         }
       
   313     }
       
   314     
       
   315 // ---------------------------------------------------------------------------
       
   316 // SVPAudioUtility::EnableSpeakerSinksL
       
   317 // ---------------------------------------------------------------------------
       
   318 //
       
   319 void SVPAudioUtility::EnableSpeakerSinksL(
       
   320     const RPointerArray< CMceMediaStream >& aStreams )
       
   321     {
       
   322     SVPDEBUG1("SVPAudioUtility::EnableSpeakerSinksL In");
       
   323     
       
   324     TInt index( aStreams.Count() );
       
   325     while( index-- )
       
   326         {
       
   327         if ( KMceAudio == aStreams[ index ]->Type() )
       
   328             {
       
   329             EnableSpeakerSinkL( aStreams[ index ]->Sinks() );
       
   330             }
       
   331         
       
   332         if ( KMceAudio == aStreams[ index ]->BoundStreamL().Type() )
       
   333             {
       
   334             EnableSpeakerSinkL( aStreams[ index ]->BoundStreamL().Sinks() );
       
   335             }
       
   336         }
       
   337     
       
   338     SVPDEBUG1("SVPAudioUtility::EnableSpeakerSinksL Out");
       
   339     }
       
   340 
       
   341 // ---------------------------------------------------------------------------
       
   342 // SVPAudioUtility::DisableMicSourceL
       
   343 // ---------------------------------------------------------------------------
       
   344 //
       
   345 void SVPAudioUtility::DisableMicSourceL( CMceMediaStream& aStream )
       
   346     {
       
   347     SVPDEBUG1("SVPAudioUtility::DisableMicSourceL CMceMediaStream In");
       
   348     
       
   349     CMceMediaSource* source = NULL;
       
   350     source = aStream.Source();
       
   351     if ( source )
       
   352         {
       
   353         SVPDEBUG1("SVPAudioUtility::DisableMicSourceL aStream");
       
   354         
       
   355         DisableMicSourceL( *source );
       
   356         }
       
   357     
       
   358     if ( aStream.BoundStream() )
       
   359         {
       
   360         source = aStream.BoundStreamL().Source();
       
   361         if ( source )
       
   362             {
       
   363             SVPDEBUG1("SVPAudioUtility::DisableMicSourceL BoundStream");
       
   364             
       
   365             DisableMicSourceL( *source );
       
   366             }
       
   367         }
       
   368         
       
   369     SVPDEBUG1("SVPAudioUtility::DisableMicSourceL CMceMediaStream Out");
       
   370     }
       
   371 
       
   372 // ---------------------------------------------------------------------------
       
   373 // SVPAudioUtility::FindCodec
       
   374 // ---------------------------------------------------------------------------
       
   375 //
       
   376 CMceAudioCodec* SVPAudioUtility::FindCodec( CMceAudioStream& aAudiostream,
       
   377     const TDesC8& aCodecname )
       
   378     {
       
   379     SVPDEBUG1("SVPAudioUtility::FindCodec In");
       
   380     
       
   381     const RPointerArray<CMceAudioCodec>& codecs = aAudiostream.Codecs();
       
   382     TInt codecCount = codecs.Count();
       
   383     while ( codecCount )
       
   384         {
       
   385         codecCount--;
       
   386         if ( !codecs[codecCount]->SdpName().CompareF( aCodecname ) )
       
   387             {
       
   388             SVPDEBUG1("SVPAudioUtility::SVPAudioUtility Codec found");
       
   389             
       
   390             return codecs[codecCount];
       
   391             }
       
   392         }
       
   393     
       
   394     SVPDEBUG1("SVPAudioUtility::FindCodec Out NULL");
       
   395     return NULL;
       
   396     }
       
   397 
       
   398 // ---------------------------------------------------------------------------
       
   399 // SVPAudioUtility::RemoveCodecL
       
   400 // ---------------------------------------------------------------------------
       
   401 //
       
   402 void SVPAudioUtility::RemoveCodecL( CMceAudioStream& aAudiostream,
       
   403     const TDesC8& aCodecname )
       
   404     {
       
   405     SVPDEBUG1("SVPAudioUtility::RemoveCodecL In");
       
   406     
       
   407     CMceAudioCodec* codec = SVPAudioUtility::FindCodec( aAudiostream,
       
   408         aCodecname );
       
   409     
       
   410     while ( codec )
       
   411         {
       
   412         SVPDEBUG1("SVPAudioUtility::RemoveCodecL Removing");
       
   413         
       
   414         aAudiostream.RemoveCodecL( *codec );
       
   415         codec = SVPAudioUtility::FindCodec( aAudiostream, aCodecname );
       
   416         }
       
   417     
       
   418     SVPDEBUG1("SVPAudioUtility::RemoveCodecL Out");
       
   419     }
       
   420 
       
   421 // ---------------------------------------------------------------------------
       
   422 // SVPAudioUtility::MmfPriorityUpdateNeededL
       
   423 // ---------------------------------------------------------------------------
       
   424 //
       
   425 TBool SVPAudioUtility::MmfPriorityUpdateNeededL(
       
   426     const RPointerArray<CMceMediaStream>& aStreams )
       
   427     {
       
   428     SVPDEBUG1( "SVPAudioUtility::MmfPriorityUpdateNeededL In" )
       
   429     
       
   430     // We need to check if DTMF codec is found and then check uplink stream
       
   431     // MMF priorities.
       
   432     // 1) If DTMF codec is found and uplink stream codecs have preference
       
   433     //    KSVPAudioPrefAudioUplinkOobDtmf no update is needed.
       
   434     // 2) If DTMF codec is not found and uplink stream codecs have preference
       
   435     //    KSVPAudioPrefAudioUplinkIbDtmf no update is needed.
       
   436     // 3) In other cases we need to do MMF preference/priority update.
       
   437     
       
   438     // In order to do this we need to find uplink audio streams, check whether
       
   439     // the stream has DTMF codec and then check which MMF preference the codec
       
   440     // codec has. We may have multiple streams, but for simplicity sake if
       
   441     // we find just one stream needing priority/preference update, we return
       
   442     // ETrue as update need.
       
   443     TInt strmCount( aStreams.Count() );
       
   444     
       
   445     SVPDEBUG2( "SVPAudioUtility::MmfPriorityUpdateNeededL strmCount: %d",
       
   446         strmCount )
       
   447     
       
   448     while ( strmCount )
       
   449         {
       
   450         SVPDEBUG2( "SVPAudioUtility::MmfPriorityUpdateNeededL tb checked",
       
   451             strmCount )
       
   452         
       
   453         strmCount--;
       
   454         
       
   455         // Basic assertions. Streams have to be KMceAudio and 'main' stream
       
   456         // must have a bound stream.
       
   457         __ASSERT_ALWAYS( KMceAudio == aStreams[strmCount]->Type(),
       
   458             User::Leave( KErrArgument ) );
       
   459         __ASSERT_ALWAYS( aStreams[strmCount]->BoundStream(),
       
   460             User::Leave( KErrArgument ) );
       
   461         __ASSERT_ALWAYS( KMceAudio == aStreams[strmCount]->BoundStreamL().Type(),
       
   462             User::Leave( KErrArgument ) );
       
   463         
       
   464         // Now that we are clear from the asserts, we can safely do the casts
       
   465         // and find the uplink stream for priority/preference checking.
       
   466         CMceAudioStream* audioStream =
       
   467             static_cast<CMceAudioStream*>( aStreams[strmCount] );
       
   468         CMceAudioStream& boundStream =
       
   469             static_cast<CMceAudioStream&>( audioStream->BoundStreamL() );
       
   470         
       
   471         CMceAudioStream* uplinkStream = NULL;
       
   472         
       
   473         if ( !IsDownlinkStream( *audioStream ) )
       
   474             {
       
   475             SVPDEBUG1( "SVPAudioUtility::MmfPriorityUpdateNeededL main is uplink" )
       
   476             
       
   477             uplinkStream = audioStream;
       
   478             }
       
   479         else if ( !IsDownlinkStream( boundStream ) )
       
   480             {
       
   481             SVPDEBUG1( "SVPAudioUtility::MmfPriorityUpdateNeededL bound is uplink" )
       
   482             
       
   483             uplinkStream = &boundStream;
       
   484             }
       
   485         
       
   486         // Next assert handles the missing else branch.
       
   487         __ASSERT_ALWAYS( uplinkStream, User::Leave( KErrNotFound ) );
       
   488         
       
   489         TBool res = MmfPriorityUpdateNeededL( *uplinkStream );
       
   490         if ( res )
       
   491             {
       
   492             SVPDEBUG1( "SVPAudioUtility::MmfPriorityUpdateNeededL ETrue" )
       
   493             return ETrue;
       
   494             }
       
   495         }
       
   496     
       
   497     SVPDEBUG1( "SVPAudioUtility::MmfPriorityUpdateNeededL EFalse" )
       
   498     return EFalse;
       
   499     }
       
   500 
       
   501 // ---------------------------------------------------------------------------
       
   502 // SVPAudioUtility::MmfPriorityUpdateNeededL
       
   503 // ---------------------------------------------------------------------------
       
   504 //
       
   505 TBool SVPAudioUtility::MmfPriorityUpdateNeededL(
       
   506     CMceAudioStream& aUplinkStream )
       
   507     {
       
   508     SVPDEBUG1( "SVPAudioUtility::MmfPriorityUpdateNeededL (stream) In" )
       
   509     
       
   510     // Check which uplink preference we need to have based whether DTMF codec
       
   511     // is part of the codec list.
       
   512     TUint uplinkPreference = 0;
       
   513     if ( FindCodec( aUplinkStream, KTELEVENT ) )
       
   514         {
       
   515         SVPDEBUG1( "SVPAudioUtility::MmfPriorityUpdateNeededL (stream) DTMF OB" )
       
   516         
       
   517         uplinkPreference = KSVPAudioPrefUplinkOobDtmf;
       
   518         }
       
   519     else
       
   520         {
       
   521         SVPDEBUG1( "SVPAudioUtility::MmfPriorityUpdateNeededL (stream) DTMF IB" )
       
   522         
       
   523         uplinkPreference = KSVPAudioPrefUplinkIbDtmf;
       
   524         }
       
   525     
       
   526     // Given stream must have at least one codec in order to do the priority /
       
   527     // preference check. This function is private and called inside, thus this
       
   528     // assertion just adds to the checks done in caller.
       
   529     const RPointerArray<CMceAudioCodec>& codecs = aUplinkStream.Codecs();
       
   530     TInt codecCount = codecs.Count();
       
   531     
       
   532     SVPDEBUG2( "SVPAudioUtility::MmfPriorityUpdateNeededL (stream) codecCount: %d",
       
   533         codecCount )
       
   534     
       
   535     __ASSERT_ALWAYS( codecCount, User::Leave( KErrArgument ) );
       
   536     
       
   537     while( codecCount )
       
   538         {
       
   539         SVPDEBUG2( "SVPAudioUtility::MmfPriorityUpdateNeededL (stream) tb checked: %d",
       
   540             codecCount )
       
   541         
       
   542         codecCount--;
       
   543         
       
   544         SVPDEBUG2( "SVPAudioUtility::MmfPriorityUpdateNeededL curr.prio: %d",
       
   545                 codecs[codecCount]->MMFPriority() )
       
   546         SVPDEBUG2( "SVPAudioUtility::MmfPriorityUpdateNeededL curr.pref: 0x%x",
       
   547                 codecs[codecCount]->MMFPriorityPreference() )
       
   548         
       
   549         // Do not include DTMF codec into the preference check. Note CompareF
       
   550         // return value also, 0 means match.
       
   551         if ( codecs[codecCount]->SdpName().CompareF( KTELEVENT ) &&
       
   552             uplinkPreference != codecs[codecCount]->MMFPriorityPreference() )
       
   553             {
       
   554             SVPDEBUG1( "SVPAudioUtility::MmfPriorityUpdateNeededL (stream) ETrue" )
       
   555             
       
   556             return ETrue;
       
   557             }
       
   558         
       
   559         // else preferences match, ne-ext please!!!
       
   560         }
       
   561     
       
   562     SVPDEBUG1( "SVPAudioUtility::MmfPriorityUpdateNeededL (stream) EFalse" )
       
   563     return EFalse;
       
   564     }
       
   565 
       
   566 // ---------------------------------------------------------------------------
       
   567 // SVPAudioUtility::DtmfActionCapableSession
       
   568 // ---------------------------------------------------------------------------
       
   569 //
       
   570 TBool SVPAudioUtility::DtmfActionCapableSession(
       
   571     const CSVPSessionBase& aSession )
       
   572     {
       
   573     if ( aSession.HasHoldController() &&
       
   574          ESVPConnected == aSession.HoldController().HoldState() )
       
   575         {
       
   576         SVPDEBUG1( "SVPAudioUtility::DtmfActionCapableSession ETrue 1" )
       
   577         
       
   578         return ETrue;
       
   579         }
       
   580     else if ( !aSession.HasHoldController() )
       
   581         {
       
   582         SVPDEBUG1( "SVPAudioUtility::DtmfActionCapableSession ETrue 2" )
       
   583         
       
   584         return ETrue;
       
   585         }
       
   586     else
       
   587         {
       
   588         SVPDEBUG1( "SVPAudioUtility::DtmfActionCapableSession EFalse" )
       
   589         
       
   590         return EFalse;
       
   591         }
       
   592     }
       
   593 
       
   594 // ---------------------------------------------------------------------------
       
   595 // Check DTMF capability of emergency session
       
   596 // ---------------------------------------------------------------------------
       
   597 //
       
   598 TBool SVPAudioUtility::DtmfActionCapableSession(
       
   599     const CSVPEmergencySession& aSession )
       
   600     {
       
   601     if ( aSession.HasHoldController() &&
       
   602          ESVPConnected == aSession.HoldController().HoldState() )
       
   603         {
       
   604         SVPDEBUG1( "SVPAudioUtility::DtmfActionCapableSession ETrue 1" )
       
   605         
       
   606         return ETrue;
       
   607         }
       
   608     else if ( !aSession.HasHoldController() )
       
   609         {
       
   610         SVPDEBUG1( "SVPAudioUtility::DtmfActionCapableSession ETrue 2" )
       
   611         
       
   612         return ETrue;
       
   613         }
       
   614     else
       
   615         {
       
   616         SVPDEBUG1( "SVPAudioUtility::DtmfActionCapableSession EFalse" )
       
   617         
       
   618         return EFalse;
       
   619         }
       
   620     }
       
   621 
       
   622 // ---------------------------------------------------------------------------
       
   623 // SVPAudioUtility::DtmfActionCapableStream
       
   624 // ---------------------------------------------------------------------------
       
   625 //
       
   626 TBool SVPAudioUtility::DtmfActionCapableStream(
       
   627     const CMceMediaStream& aStream )
       
   628     {
       
   629     // We used to check for source's DtmfAvailable and DtmfActive attributes,
       
   630     // but those are IPC calls which are not preferred for DTMF's real-time
       
   631     // nature. Thus leaving those out and letting the server return us a
       
   632     // error code if those attributes are not correct for DTMF sending
       
   633     // actually does the same thing but improves performance.
       
   634     // Thus what once was three IPC calls is now just one.
       
   635     TBool ret = EFalse;
       
   636     CMceMediaSource* source = aStream.Source();
       
   637     
       
   638 #ifdef _DEBUG
       
   639     SVPDEBUG2( "SVPAudioUtility::DtmfActionCapableStream type: %d", aStream.Type() )
       
   640     SVPDEBUG2( "SVPAudioUtility::DtmfActionCapableStream source: 0x%x", source )
       
   641     if ( source )
       
   642         {
       
   643         SVPDEBUG2( "SVPAudioUtility::DtmfActionCapableStream enabled: %d", source->IsEnabled() )
       
   644         }
       
   645 #endif
       
   646     
       
   647     if ( KMceAudio == aStream.Type() && source && source->IsEnabled() )
       
   648         {
       
   649         ret = ETrue;
       
   650         }
       
   651     
       
   652     SVPDEBUG2( "SVPAudioUtility::DtmfActionCapableStream ret: %d", ret )
       
   653     
       
   654     return ret;
       
   655     }
       
   656