vtuis/lcvtplugin/src/common/lcvtutility.cpp
branchRCL_3
changeset 25 779871d1e4f4
parent 24 f15ac8e65a02
child 26 590f6f022902
equal deleted inserted replaced
24:f15ac8e65a02 25:779871d1e4f4
     1 /*
       
     2 * Copyright (c) 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:  Implementation of the VtUiUtility class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include    "lcvtutility.h"
       
    22 #include    <featmgr.h>
       
    23 #include    <mvtengmedia.h>
       
    24 #include    <cvtlogger.h>
       
    25 
       
    26 // Characters to open number entry.
       
    27 //_LIT( KVtUiDTMFCharacters, "0123456789*#" );
       
    28 
       
    29 // ============================ MEMBER FUNCTIONS ===============================
       
    30 
       
    31 // -----------------------------------------------------------------------------
       
    32 // LcVtUtility::GetAudioRoutingAvailability
       
    33 // -----------------------------------------------------------------------------
       
    34 //
       
    35 void LcVtUtility::GetAudioRoutingAvailability(
       
    36         MVtEngAudio& aAudio,
       
    37         TInt& aAvailable )
       
    38     {
       
    39     aAvailable = 0;    
       
    40     //const TBool bluetoothAudioSupported = ETrue;        
       
    41 
       
    42     MVtEngAudio::TAudioRoutingState routingState;
       
    43     if ( aAudio.GetRoutingState( routingState ) == KErrNone )
       
    44         {
       
    45         // Deactivate BT handsfree.
       
    46         if ( /*bluetoothAudioSupported &&*/
       
    47              IsAudioRoutingAvailable(
       
    48                 aAudio,
       
    49                 routingState,
       
    50                 MVtEngAudio::EAudioBT,
       
    51                 MVtEngAudio::EAudioHandset ) )
       
    52             {
       
    53             aAvailable |= EDeactivateBtHandsfree;
       
    54             }
       
    55 
       
    56         // Activate BT handsfree.
       
    57         if ( /*bluetoothAudioSupported &&*/
       
    58              ( IsAudioRoutingAvailable(
       
    59                  aAudio,
       
    60                  routingState,
       
    61                  MVtEngAudio::EAudioHandset,
       
    62                  MVtEngAudio::EAudioBT ) ||
       
    63                IsAudioRoutingAvailable(
       
    64                 aAudio,
       
    65                 routingState,
       
    66                 MVtEngAudio::EAudioLoudspeaker,
       
    67                 MVtEngAudio::EAudioBT ) ) )
       
    68             {
       
    69             aAvailable |= EActivateBtHandsfree;
       
    70             }
       
    71 
       
    72         // Deactivate loudspeaker
       
    73         if ( IsAudioRoutingAvailable(
       
    74                 aAudio,
       
    75                 routingState,
       
    76                 MVtEngAudio::EAudioLoudspeaker,
       
    77                 MVtEngAudio::EAudioHandset ) )
       
    78             {
       
    79             aAvailable |= EDeactivateLoudspeaker;
       
    80             }
       
    81 
       
    82         // Activate loudspeaker
       
    83         if ( IsAudioRoutingAvailable(
       
    84                 aAudio,
       
    85                 routingState,
       
    86                 MVtEngAudio::EAudioHandset,
       
    87                 MVtEngAudio::EAudioLoudspeaker ) ||
       
    88              ( /*bluetoothAudioSupported &&*/ 
       
    89                IsAudioRoutingAvailable( 
       
    90                    aAudio,
       
    91                    routingState, 
       
    92                    MVtEngAudio::EAudioBT, 
       
    93                    MVtEngAudio::EAudioLoudspeaker ) ) )
       
    94             {
       
    95             aAvailable |= EActivateLoudspeaker;
       
    96             }
       
    97         }
       
    98     }
       
    99 
       
   100 // -----------------------------------------------------------------------------
       
   101 // LcVtUtility::GetOutgoingMediaState
       
   102 // -----------------------------------------------------------------------------
       
   103 //
       
   104 void LcVtUtility::GetOutgoingMediaState(
       
   105         MVtEngMedia& aMedia,
       
   106         TInt& aAvailable )
       
   107     {
       
   108     TInt outgoingMediaState;
       
   109     const TInt err =
       
   110         aMedia.GetMediaState(
       
   111             MVtEngMedia::EMediaOutgoing,
       
   112             outgoingMediaState );
       
   113     if ( err == KErrNone )
       
   114         {
       
   115         // If source is still image, then video sending is off.
       
   116         MVtEngMedia::TMediaSource source;
       
   117         if ( aMedia.GetSource( source ) == KErrNone )
       
   118             {
       
   119             if ( source == MVtEngMedia::EMediaStillImage )
       
   120                 {
       
   121                 outgoingMediaState &= ~MVtEngMedia::EMediaVideo;
       
   122                 }
       
   123             }
       
   124         TBool freezeSupported;
       
   125         if( aMedia.GetFreezeSupported( freezeSupported ) == KErrNone )
       
   126             {
       
   127             TBool isFrozen;
       
   128             if( freezeSupported && aMedia.GetFreezeState( isFrozen ) == KErrNone )
       
   129                 {
       
   130                 if( isFrozen )
       
   131                     {
       
   132                     outgoingMediaState &= ~MVtEngMedia::EMediaVideo;
       
   133                     }
       
   134                 }
       
   135             }
       
   136         }
       
   137     else
       
   138         {
       
   139         outgoingMediaState =
       
   140             ( MVtEngMedia::EMediaAudio | MVtEngMedia::EMediaVideo );
       
   141         }
       
   142     aAvailable = outgoingMediaState;
       
   143     }
       
   144 
       
   145 // -----------------------------------------------------------------------------
       
   146 // LcVtUtility::GetIncomingMediaState
       
   147 // -----------------------------------------------------------------------------
       
   148 //
       
   149 void LcVtUtility::GetIncomingMediaState(
       
   150         MVtEngMedia& aMedia,
       
   151         TInt& aAvailable )
       
   152     {
       
   153     TInt mediaState;
       
   154     const TInt err =
       
   155         aMedia.GetMediaState(
       
   156             MVtEngMedia::EMediaIncoming,
       
   157             mediaState );
       
   158     if ( err != KErrNone )
       
   159         {
       
   160         mediaState =
       
   161             ( MVtEngMedia::EMediaAudio | MVtEngMedia::EMediaVideo );
       
   162         }
       
   163 
       
   164     aAvailable = mediaState;
       
   165     }
       
   166 
       
   167 // -----------------------------------------------------------------------------
       
   168 // LcVtUtility::HasStillImage
       
   169 // -----------------------------------------------------------------------------
       
   170 //
       
   171 TBool LcVtUtility::HasStillImage(
       
   172         MVtEngMedia& aMedia )
       
   173     {
       
   174     TInt caps;
       
   175     const TInt capsErr = aMedia.GetSourcesCaps( caps );
       
   176     return ( capsErr == KErrNone ) &&
       
   177            ( caps & MVtEngMedia::ESourceCapsStillImage );
       
   178     }
       
   179 
       
   180 // -----------------------------------------------------------------------------
       
   181 // LcVtUtility::GetFreezeState
       
   182 // -----------------------------------------------------------------------------
       
   183 //
       
   184 TBool LcVtUtility::GetFreezeState(
       
   185         MVtEngMedia& aMedia )
       
   186     {
       
   187     TBool isFrozen;
       
   188     const TInt err = aMedia.GetFreezeState( isFrozen );
       
   189     if ( err == KErrNone )
       
   190         {
       
   191         return isFrozen;
       
   192         }
       
   193     else //provider was not ready
       
   194         {
       
   195         return EFalse;
       
   196         }
       
   197     }
       
   198 
       
   199 // -----------------------------------------------------------------------------
       
   200 // LcVtUtility::IsFreezeSupported
       
   201 // -----------------------------------------------------------------------------
       
   202 //
       
   203 TBool LcVtUtility::IsFreezeSupported(
       
   204         MVtEngMedia& aMedia )
       
   205     {
       
   206     TBool isFreezeSupported;
       
   207     const TInt err = aMedia.GetFreezeSupported( isFreezeSupported );
       
   208     if ( err == KErrNone )
       
   209         {
       
   210         return isFreezeSupported;
       
   211         }
       
   212     else //provider was not ready
       
   213         {
       
   214         return EFalse;
       
   215         }
       
   216     }
       
   217 
       
   218 // -----------------------------------------------------------------------------
       
   219 // LcVtUtility::GetVideoQuality
       
   220 // -----------------------------------------------------------------------------
       
   221 //
       
   222 void LcVtUtility::GetVideoQuality(
       
   223             MVtEngMedia& aMedia,
       
   224             MVtEngMedia::TVideoQuality& aVideoQuality )
       
   225     {
       
   226     aMedia.GetVideoQuality( aVideoQuality );
       
   227     }
       
   228 
       
   229 // -----------------------------------------------------------------------------
       
   230 // LcVtUtility::GetObjectSharingState
       
   231 // -----------------------------------------------------------------------------
       
   232 //
       
   233 void LcVtUtility::GetObjectSharingState(
       
   234     MVtEngMedia& aMedia,
       
   235     MVtEngMedia::TShareObjectState& aShareObjectState )
       
   236     {
       
   237     aMedia.GetObjectSharingState( aShareObjectState );
       
   238     }
       
   239 
       
   240 
       
   241 // -----------------------------------------------------------------------------
       
   242 // LcVtUtility::IsZoomAllowed
       
   243 // -----------------------------------------------------------------------------
       
   244 //
       
   245 TBool LcVtUtility::IsZoomAllowed(
       
   246         MVtEngMedia& aMedia )
       
   247     {
       
   248     TBool result = EFalse;
       
   249 
       
   250     TInt currentStep;
       
   251     if ( aMedia.GetCurrentZoomStep( currentStep ) == KErrNone )
       
   252         {
       
   253         TInt max;
       
   254         if ( aMedia.GetMaxZoomStep( max ) == KErrNone )
       
   255             {
       
   256             // Zooming is allowed if maximum zoom step is greater than
       
   257             // zero and camera is in use (and not still image / none).
       
   258             TInt avail;
       
   259             GetOutgoingMediaState( aMedia, avail );
       
   260 
       
   261             result = ( max > 0 ) && ( avail & MVtEngMedia::EMediaVideo );
       
   262             }
       
   263         }
       
   264 
       
   265     __VTPRINT2( DEBUG_GEN, "Ui.AllowZoom.%d", result )
       
   266     return result;
       
   267     }
       
   268 
       
   269 // -----------------------------------------------------------------------------
       
   270 // LcVtUtility::HasCameras
       
   271 // -----------------------------------------------------------------------------
       
   272 //
       
   273 TBool LcVtUtility::HasCameras( MVtEngMedia& aMedia )
       
   274     {
       
   275     TInt sourceCaps;
       
   276     if ( aMedia.GetSourcesCaps( sourceCaps ) != KErrNone )
       
   277         {
       
   278         sourceCaps = 0;
       
   279         }
       
   280     return ( sourceCaps & MVtEngMedia::ESourceCapsPrimaryCamera ) ||
       
   281            ( sourceCaps & MVtEngMedia::ESourceCapsSecondaryCamera );
       
   282     }
       
   283 
       
   284 // -----------------------------------------------------------------------------
       
   285 // LcVtUtility::IsAudioRoutingAvailable
       
   286 // -----------------------------------------------------------------------------
       
   287 //
       
   288 TBool LcVtUtility::IsAudioRoutingAvailable(
       
   289         MVtEngAudio& aAudio,
       
   290         const MVtEngAudio::TAudioRoutingState aCurrent,
       
   291         const MVtEngAudio::TAudioRoutingState aSource,
       
   292         const MVtEngAudio::TAudioRoutingState aTarget )
       
   293     {
       
   294     TBool result = EFalse;
       
   295     if ( aCurrent == aSource )
       
   296         {
       
   297         TBool available = EFalse;
       
   298         TInt err = aAudio.GetRoutingAvailability( aTarget, available );
       
   299 
       
   300         result = ( ( err == KErrNone ) && ( available ) );
       
   301         }
       
   302 
       
   303     return result;
       
   304     }
       
   305 
       
   306 // -----------------------------------------------------------------------------
       
   307 // LcVtUtility::IsDTMFCharacter
       
   308 // -----------------------------------------------------------------------------
       
   309 //
       
   310 TBool LcVtUtility::IsDTMFCharacter( const TChar aChar )
       
   311     {
       
   312     return EFalse;
       
   313     /*
       
   314     return
       
   315         ( KVtUiDTMFCharacters().Locate( aChar ) != KErrNotFound );
       
   316         */
       
   317     }
       
   318 
       
   319 //  End of File